| 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 <GraphicPropertyItemConverter.hxx> |
| 21 |
#include "SchWhichPairs.hxx" |
| 22 |
#include <ChartModel.hxx> |
| 23 |
#include <ItemPropertyMap.hxx> |
| 24 |
#include <PropertyHelper.hxx> |
| 25 |
#include <CommonConverters.hxx> |
| 26 |
#include <editeng/memberids.h> |
| 27 |
#include <svx/chrtitem.hxx> |
| 28 |
#include <svx/unomid.hxx> |
| 29 |
#include <svx/xflbmtit.hxx> |
| 30 |
#include <svx/xflbstit.hxx> |
| 31 |
#include <svx/xbtmpit.hxx> |
| 32 |
#include <svx/xflftrit.hxx> |
| 33 |
#include <svx/xlndsit.hxx> |
| 34 |
#include <svx/xflhtit.hxx> |
| 35 |
#include <svx/xflgrit.hxx> |
| 36 |
#include <svx/xfltrit.hxx> |
| 37 |
#include <svx/xlntrit.hxx> |
| 38 |
#include <svx/xgrscit.hxx> |
| 39 |
#include <com/sun/star/beans/XPropertyState.hpp> |
| 40 |
#include <com/sun/star/beans/XPropertySet.hpp> |
| 41 |
#include <com/sun/star/drawing/BitmapMode.hpp> |
| 42 |
#include <com/sun/star/container/XNameAccess.hpp> |
| 43 |
#include <com/sun/star/lang/XMultiServiceFactory.hpp> |
| 44 |
#include <utility> |
| 45 |
#include <comphelper/diagnose_ex.hxx> |
| 46 |
|
| 47 |
using namespace ::com::sun::star; |
| 48 |
|
| 49 |
namespace chart::wrapper { |
| 50 |
|
| 51 |
namespace { |
| 52 |
|
| 53 |
ItemPropertyMapType & lcl_GetDataPointFilledPropertyMap() |
| 54 |
{ |
| 55 |
static ItemPropertyMapType aDataPointPropertyFilledMap{ |
| 56 |
{XATTR_FILLSTYLE, {"FillStyle", 0}}, |
| 57 |
{XATTR_FILLCOLOR, {"Color", 0}}, |
| 58 |
{XATTR_LINECOLOR, {"BorderColor", 0}}, |
| 59 |
{XATTR_LINESTYLE, {"BorderStyle", 0}}, |
| 60 |
{XATTR_LINEWIDTH, {"BorderWidth", 0}}, |
| 61 |
{XATTR_FILLBACKGROUND, {"FillBackground", 0}}, |
| 62 |
{XATTR_FILLBMP_POS, {"FillBitmapRectanglePoint", 0}}, |
| 63 |
{XATTR_FILLBMP_SIZEX, {"FillBitmapSizeX", 0}}, |
| 64 |
{XATTR_FILLBMP_SIZEY, {"FillBitmapSizeY", 0}}, |
| 65 |
{XATTR_FILLBMP_SIZELOG, {"FillBitmapLogicalSize", 0}}, |
| 66 |
{XATTR_FILLBMP_TILEOFFSETX, {"FillBitmapOffsetX", 0}}, |
| 67 |
{XATTR_FILLBMP_TILEOFFSETY, {"FillBitmapOffsetY", 0}}, |
| 68 |
{XATTR_FILLBMP_POSOFFSETX, {"FillBitmapPositionOffsetX", 0}}, |
| 69 |
{XATTR_FILLBMP_POSOFFSETY, {"FillBitmapPositionOffsetY", 0}}}; |
| 70 |
return aDataPointPropertyFilledMap; |
| 71 |
} |
| 72 |
ItemPropertyMapType & lcl_GetDataPointLinePropertyMap() |
| 73 |
{ |
| 74 |
static ItemPropertyMapType aDataPointPropertyLineMap{ |
| 75 |
{XATTR_LINECOLOR, {"Color", 0}}, |
| 76 |
{XATTR_LINESTYLE, {"LineStyle", 0}}, |
| 77 |
{XATTR_LINEWIDTH, {"LineWidth", 0}}, |
| 78 |
{XATTR_LINECAP, {"LineCap", 0}}}; |
| 79 |
return aDataPointPropertyLineMap; |
| 80 |
} |
| 81 |
ItemPropertyMapType & lcl_GetLinePropertyMap() |
| 82 |
{ |
| 83 |
static ItemPropertyMapType aLinePropertyMap{ |
| 84 |
{XATTR_LINESTYLE, {"LineStyle", 0}}, |
| 85 |
{XATTR_LINEWIDTH, {"LineWidth", 0}}, |
| 86 |
{XATTR_LINECOLOR, {"LineColor", 0}}, |
| 87 |
{XATTR_LINEJOINT, {"LineJoint", 0}}, |
| 88 |
{XATTR_LINECAP, {"LineCap", 0}}}; |
| 89 |
return aLinePropertyMap; |
| 90 |
} |
| 91 |
ItemPropertyMapType & lcl_GetFillPropertyMap() |
| 92 |
{ |
| 93 |
static ItemPropertyMapType aFillPropertyMap{ |
| 94 |
{XATTR_FILLSTYLE, {"FillStyle", 0}}, |
| 95 |
{XATTR_FILLCOLOR, {"FillColor", 0}}, |
| 96 |
{XATTR_FILLBACKGROUND, {"FillBackground", 0}}, |
| 97 |
{XATTR_FILLBMP_POS, {"FillBitmapRectanglePoint", 0}}, |
| 98 |
{XATTR_FILLBMP_SIZEX, {"FillBitmapSizeX", 0}}, |
| 99 |
{XATTR_FILLBMP_SIZEY, {"FillBitmapSizeY", 0}}, |
| 100 |
{XATTR_FILLBMP_SIZELOG, {"FillBitmapLogicalSize", 0}}, |
| 101 |
{XATTR_FILLBMP_TILEOFFSETX, {"FillBitmapOffsetX", 0}}, |
| 102 |
{XATTR_FILLBMP_TILEOFFSETY, {"FillBitmapOffsetY", 0}}, |
| 103 |
{XATTR_FILLBMP_POSOFFSETX, {"FillBitmapPositionOffsetX", 0}}, |
| 104 |
{XATTR_FILLBMP_POSOFFSETY, {"FillBitmapPositionOffsetY", 0}}}; |
| 105 |
return aFillPropertyMap; |
| 106 |
} |
| 107 |
|
| 108 |
bool lcl_supportsFillProperties( ::chart::wrapper::GraphicObjectType eType ) |
| 109 |
{ |
| 110 |
return ( eType == ::chart::wrapper::GraphicObjectType::FilledDataPoint || |
| 111 |
eType == ::chart::wrapper::GraphicObjectType::LineAndFillProperties ); |
| 112 |
} |
| 113 |
|
| 114 |
bool lcl_SetContentForNamedProperty( |
| 115 |
const uno::Reference< lang::XMultiServiceFactory > & xFactory, |
| 116 |
const OUString & rTableName, |
| 117 |
NameOrIndex & rItem, sal_uInt8 nMemberId ) |
| 118 |
{ |
| 119 |
bool bResult = false; |
| 120 |
if( xFactory.is()) |
| 121 |
{ |
| 122 |
OUString aPropertyValue( rItem.GetName()); |
| 123 |
uno::Reference< container::XNameAccess > xNameAcc( |
| 124 |
xFactory->createInstance( rTableName ), |
| 125 |
uno::UNO_QUERY ); |
| 126 |
if( xNameAcc.is() && |
| 127 |
xNameAcc->hasByName( aPropertyValue )) |
| 128 |
{ |
| 129 |
rItem.PutValue( xNameAcc->getByName( aPropertyValue ), nMemberId ); |
| 130 |
bResult = true; |
| 131 |
} |
| 132 |
} |
| 133 |
return bResult; |
| 134 |
} |
| 135 |
|
| 136 |
} // anonymous namespace |
| 137 |
|
| 138 |
GraphicPropertyItemConverter::GraphicPropertyItemConverter( |
| 139 |
const uno::Reference< |
| 140 |
beans::XPropertySet > & rPropertySet, |
| 141 |
SfxItemPool& rItemPool, |
| 142 |
SdrModel& rDrawModel, |
| 143 |
rtl::Reference< ChartModel > xChartModel, |
| 144 |
GraphicObjectType eObjectType /* = FILL_PROPERTIES */ ) : |
| 145 |
ItemConverter( rPropertySet, rItemPool ), |
| 146 |
m_GraphicObjectType( eObjectType ), |
| 147 |
m_rDrawModel( rDrawModel ), |
| 148 |
m_xChartModel(std::move( xChartModel )) |
| 149 |
{ |
| 150 |
} |
| 151 |
|
| 152 |
GraphicPropertyItemConverter::~GraphicPropertyItemConverter() |
| 153 |
{} |
| 154 |
|
| 155 |
const WhichRangesContainer& GraphicPropertyItemConverter::GetWhichPairs() const |
| 156 |
{ |
| 157 |
switch( m_GraphicObjectType ) |
| 158 |
{ |
| 159 |
case GraphicObjectType::LineDataPoint: |
| 160 |
case GraphicObjectType::FilledDataPoint: |
| 161 |
return nRowWhichPairs; |
| 162 |
case GraphicObjectType::LineProperties: |
| 163 |
return nLinePropertyWhichPairs; |
| 164 |
case GraphicObjectType::LineAndFillProperties: |
| 165 |
return nLineAndFillPropertyWhichPairs; |
| 166 |
} |
| 167 |
|
| 168 |
static const WhichRangesContainer empty; |
| 169 |
return empty; |
| 170 |
} |
| 171 |
|
| 172 |
bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const |
| 173 |
{ |
| 174 |
if (nWhichId == SCHATTR_COLOR_PALETTE) |
| 175 |
{ |
| 176 |
return false; |
| 177 |
} |
| 178 |
|
| 179 |
ItemPropertyMapType::const_iterator aEndIt; |
| 180 |
ItemPropertyMapType::const_iterator aIt; |
| 181 |
|
| 182 |
switch( m_GraphicObjectType ) |
| 183 |
{ |
| 184 |
case GraphicObjectType::LineDataPoint: |
| 185 |
aEndIt = lcl_GetDataPointLinePropertyMap().end(); |
| 186 |
aIt = lcl_GetDataPointLinePropertyMap().find( nWhichId ); |
| 187 |
break; |
| 188 |
case GraphicObjectType::FilledDataPoint: |
| 189 |
aEndIt = lcl_GetDataPointFilledPropertyMap().end(); |
| 190 |
aIt = lcl_GetDataPointFilledPropertyMap().find( nWhichId ); |
| 191 |
break; |
| 192 |
case GraphicObjectType::LineProperties: |
| 193 |
aEndIt = lcl_GetLinePropertyMap().end(); |
| 194 |
aIt = lcl_GetLinePropertyMap().find( nWhichId ); |
| 195 |
break; |
| 196 |
|
| 197 |
case GraphicObjectType::LineAndFillProperties: |
| 198 |
// line |
| 199 |
aEndIt = lcl_GetLinePropertyMap().end(); |
| 200 |
aIt = lcl_GetLinePropertyMap().find( nWhichId ); |
| 201 |
|
| 202 |
// not found => try fill |
| 203 |
if( aIt == aEndIt ) |
| 204 |
{ |
| 205 |
aEndIt = lcl_GetFillPropertyMap().end(); |
| 206 |
aIt = lcl_GetFillPropertyMap().find( nWhichId ); |
| 207 |
} |
| 208 |
break; |
| 209 |
} |
| 210 |
|
| 211 |
if( aIt == aEndIt ) |
| 212 |
return false; |
| 213 |
|
| 214 |
rOutProperty =(*aIt).second; |
| 215 |
return true; |
| 216 |
} |
| 217 |
|
| 218 |
void GraphicPropertyItemConverter::FillSpecialItem( |
| 219 |
sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const |
| 220 |
{ |
| 221 |
switch( nWhichId ) |
| 222 |
{ |
| 223 |
// bitmap property |
| 224 |
case XATTR_FILLBMP_TILE: |
| 225 |
case XATTR_FILLBMP_STRETCH: |
| 226 |
{ |
| 227 |
drawing::BitmapMode aMode = drawing::BitmapMode_REPEAT; |
| 228 |
if( GetPropertySet()->getPropertyValue( u"FillBitmapMode"_ustr ) >>= aMode ) |
| 229 |
{ |
| 230 |
rOutItemSet.Put( XFillBmpTileItem( aMode == drawing::BitmapMode_REPEAT )); |
| 231 |
rOutItemSet.Put( XFillBmpStretchItem( aMode == drawing::BitmapMode_STRETCH )); |
| 232 |
} |
| 233 |
} |
| 234 |
break; |
| 235 |
|
| 236 |
case XATTR_FILLFLOATTRANSPARENCE: |
| 237 |
try |
| 238 |
{ |
| 239 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 240 |
{ |
| 241 |
OUString aPropName = |
| 242 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 243 |
? u"TransparencyGradientName"_ustr |
| 244 |
: u"FillTransparenceGradientName"_ustr; |
| 245 |
|
| 246 |
uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName )); |
| 247 |
if( aValue.hasValue()) |
| 248 |
{ |
| 249 |
XFillFloatTransparenceItem aItem; |
| 250 |
aItem.PutValue( aValue, MID_NAME ); |
| 251 |
|
| 252 |
lcl_SetContentForNamedProperty( |
| 253 |
m_xChartModel, u"com.sun.star.drawing.TransparencyGradientTable"_ustr , |
| 254 |
aItem, MID_FILLGRADIENT ); |
| 255 |
|
| 256 |
// this is important to enable the item |
| 257 |
OUString aName; |
| 258 |
if( (aValue >>= aName) && |
| 259 |
!aName.isEmpty()) |
| 260 |
{ |
| 261 |
aItem.SetEnabled( true ); |
| 262 |
rOutItemSet.Put( aItem ); |
| 263 |
} |
| 264 |
} |
| 265 |
} |
| 266 |
} |
| 267 |
catch( const beans::UnknownPropertyException & ) |
| 268 |
{ |
| 269 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 270 |
} |
| 271 |
break; |
| 272 |
|
| 273 |
case XATTR_GRADIENTSTEPCOUNT: |
| 274 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 275 |
{ |
| 276 |
OUString aPropName = |
| 277 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 278 |
? u"GradientStepCount"_ustr |
| 279 |
: u"FillGradientStepCount"_ustr; |
| 280 |
|
| 281 |
uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ) ); |
| 282 |
if( hasLongOrShortValue(aValue) ) |
| 283 |
{ |
| 284 |
sal_Int16 nStepCount = getShortForLongAlso(aValue); |
| 285 |
rOutItemSet.Put( XGradientStepCountItem( nStepCount )); |
| 286 |
} |
| 287 |
} |
| 288 |
break; |
| 289 |
|
| 290 |
case XATTR_LINEDASH: |
| 291 |
{ |
| 292 |
OUString aPropName = |
| 293 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 294 |
? u"BorderDashName"_ustr |
| 295 |
: u"LineDashName"_ustr; |
| 296 |
|
| 297 |
XLineDashItem aItem; |
| 298 |
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); |
| 299 |
|
| 300 |
lcl_SetContentForNamedProperty( |
| 301 |
m_xChartModel, u"com.sun.star.drawing.DashTable"_ustr , |
| 302 |
aItem, MID_LINEDASH ); |
| 303 |
|
| 304 |
// translate model name to UI-name for predefined entries, so |
| 305 |
// that the correct entry is chosen in the list of UI-names |
| 306 |
std::unique_ptr<XLineDashItem> pItemToPut = aItem.checkForUniqueItem( m_rDrawModel ); |
| 307 |
|
| 308 |
if(pItemToPut) |
| 309 |
rOutItemSet.Put( std::move(pItemToPut) ); |
| 310 |
else |
| 311 |
rOutItemSet.Put(aItem); |
| 312 |
} |
| 313 |
break; |
| 314 |
|
| 315 |
case XATTR_FILLGRADIENT: |
| 316 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 317 |
{ |
| 318 |
OUString aPropName = |
| 319 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 320 |
? u"GradientName"_ustr |
| 321 |
: u"FillGradientName"_ustr; |
| 322 |
|
| 323 |
XFillGradientItem aItem; |
| 324 |
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); |
| 325 |
|
| 326 |
lcl_SetContentForNamedProperty( |
| 327 |
m_xChartModel, u"com.sun.star.drawing.GradientTable"_ustr , |
| 328 |
aItem, MID_FILLGRADIENT ); |
| 329 |
|
| 330 |
// translate model name to UI-name for predefined entries, so |
| 331 |
// that the correct entry is chosen in the list of UI-names |
| 332 |
std::unique_ptr<XFillGradientItem> pItemToPut = aItem.checkForUniqueItem( m_rDrawModel ); |
| 333 |
|
| 334 |
if(pItemToPut) |
| 335 |
rOutItemSet.Put(std::move(pItemToPut) ); |
| 336 |
else |
| 337 |
rOutItemSet.Put(aItem); |
| 338 |
} |
| 339 |
break; |
| 340 |
|
| 341 |
case XATTR_FILLHATCH: |
| 342 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 343 |
{ |
| 344 |
OUString aPropName = |
| 345 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 346 |
? u"HatchName"_ustr |
| 347 |
: u"FillHatchName"_ustr; |
| 348 |
|
| 349 |
XFillHatchItem aItem; |
| 350 |
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); |
| 351 |
|
| 352 |
lcl_SetContentForNamedProperty( |
| 353 |
m_xChartModel, u"com.sun.star.drawing.HatchTable"_ustr , |
| 354 |
aItem, MID_FILLHATCH ); |
| 355 |
|
| 356 |
// translate model name to UI-name for predefined entries, so |
| 357 |
// that the correct entry is chosen in the list of UI-names |
| 358 |
std::unique_ptr<XFillHatchItem> pItemToPut = aItem.checkForUniqueItem( m_rDrawModel ); |
| 359 |
|
| 360 |
if(pItemToPut) |
| 361 |
rOutItemSet.Put( std::move(pItemToPut) ); |
| 362 |
else |
| 363 |
rOutItemSet.Put(aItem); |
| 364 |
} |
| 365 |
break; |
| 366 |
|
| 367 |
case XATTR_FILLBITMAP: |
| 368 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 369 |
{ |
| 370 |
XFillBitmapItem aItem; |
| 371 |
aItem.PutValue( GetPropertySet()->getPropertyValue( u"FillBitmapName"_ustr ), MID_NAME ); |
| 372 |
|
| 373 |
lcl_SetContentForNamedProperty( |
| 374 |
m_xChartModel, u"com.sun.star.drawing.BitmapTable"_ustr , |
| 375 |
aItem, MID_BITMAP ); |
| 376 |
|
| 377 |
// translate model name to UI-name for predefined entries, so |
| 378 |
// that the correct entry is chosen in the list of UI-names |
| 379 |
std::unique_ptr<XFillBitmapItem> pItemToPut = aItem.checkForUniqueItem( m_rDrawModel ); |
| 380 |
|
| 381 |
if(pItemToPut) |
| 382 |
rOutItemSet.Put( std::move(pItemToPut) ); |
| 383 |
else |
| 384 |
rOutItemSet.Put(aItem); |
| 385 |
} |
| 386 |
break; |
| 387 |
|
| 388 |
// hack, because QueryValue of XLineTransparenceItem returns sal_Int32 |
| 389 |
// instead of sal_Int16 |
| 390 |
case XATTR_LINETRANSPARENCE: |
| 391 |
{ |
| 392 |
OUString aPropName = |
| 393 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 394 |
? u"BorderTransparency"_ustr |
| 395 |
: (m_GraphicObjectType == GraphicObjectType::LineDataPoint) |
| 396 |
? u"Transparency"_ustr |
| 397 |
: u"LineTransparence"_ustr; |
| 398 |
|
| 399 |
XLineTransparenceItem aItem; |
| 400 |
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), 0 ); |
| 401 |
|
| 402 |
rOutItemSet.Put( aItem ); |
| 403 |
} |
| 404 |
break; |
| 405 |
|
| 406 |
// hack, because QueryValue of XFillTransparenceItem returns sal_Int32 |
| 407 |
// instead of sal_Int16 |
| 408 |
case XATTR_FILLTRANSPARENCE: |
| 409 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 410 |
{ |
| 411 |
OUString aPropName = |
| 412 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 413 |
? u"Transparency"_ustr |
| 414 |
: u"FillTransparence"_ustr; |
| 415 |
|
| 416 |
XFillTransparenceItem aItem; |
| 417 |
aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), 0 ); |
| 418 |
|
| 419 |
rOutItemSet.Put( aItem ); |
| 420 |
} |
| 421 |
break; |
| 422 |
} |
| 423 |
} |
| 424 |
|
| 425 |
bool GraphicPropertyItemConverter::ApplySpecialItem( |
| 426 |
sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) |
| 427 |
{ |
| 428 |
bool bChanged = false; |
| 429 |
uno::Any aValue; |
| 430 |
|
| 431 |
switch( nWhichId ) |
| 432 |
{ |
| 433 |
// bitmap property |
| 434 |
case XATTR_FILLBMP_STRETCH: |
| 435 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 436 |
{ |
| 437 |
static constexpr OUString aModePropName(u"FillBitmapMode"_ustr); |
| 438 |
bool bStretched = rItemSet.Get( XATTR_FILLBMP_STRETCH ).GetValue(); |
| 439 |
drawing::BitmapMode aMode = |
| 440 |
(bStretched ? drawing::BitmapMode_STRETCH : drawing::BitmapMode_NO_REPEAT); |
| 441 |
drawing::BitmapMode aOtherMode = drawing::BitmapMode_NO_REPEAT; |
| 442 |
|
| 443 |
aValue <<= aMode; |
| 444 |
GetPropertySet()->getPropertyValue( aModePropName ) >>= aOtherMode; |
| 445 |
|
| 446 |
// don't overwrite if it has been set to BitmapMode_REPEAT (= tiled) already |
| 447 |
// XATTR_FILLBMP_STRETCH and XATTR_FILLBMP_TILE often come in pairs, tdf#104658 |
| 448 |
if( aMode != aOtherMode && aOtherMode != drawing::BitmapMode_REPEAT ) |
| 449 |
{ |
| 450 |
GetPropertySet()->setPropertyValue( aModePropName, aValue ); |
| 451 |
bChanged = true; |
| 452 |
} |
| 453 |
} |
| 454 |
break; |
| 455 |
|
| 456 |
case XATTR_FILLBMP_TILE: |
| 457 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 458 |
{ |
| 459 |
static constexpr OUString aModePropName(u"FillBitmapMode"_ustr); |
| 460 |
bool bTiled = rItemSet.Get( XATTR_FILLBMP_TILE ).GetValue(); |
| 461 |
drawing::BitmapMode aMode = |
| 462 |
(bTiled ? drawing::BitmapMode_REPEAT : drawing::BitmapMode_NO_REPEAT); |
| 463 |
|
| 464 |
aValue <<= aMode; |
| 465 |
if( aValue != GetPropertySet()->getPropertyValue( aModePropName )) |
| 466 |
{ |
| 467 |
GetPropertySet()->setPropertyValue( aModePropName, aValue ); |
| 468 |
bChanged = true; |
| 469 |
} |
| 470 |
} |
| 471 |
break; |
| 472 |
|
| 473 |
case XATTR_FILLFLOATTRANSPARENCE: |
| 474 |
try |
| 475 |
{ |
| 476 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 477 |
{ |
| 478 |
OUString aPropName = |
| 479 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 480 |
? u"TransparencyGradientName"_ustr |
| 481 |
: u"FillTransparenceGradientName"_ustr; |
| 482 |
|
| 483 |
const XFillFloatTransparenceItem & rItem = |
| 484 |
static_cast< const XFillFloatTransparenceItem & >( |
| 485 |
rItemSet.Get( nWhichId )); |
| 486 |
|
| 487 |
if( rItem.IsEnabled() && |
| 488 |
rItem.QueryValue( aValue, MID_NAME )) |
| 489 |
{ |
| 490 |
uno::Any aGradient; |
| 491 |
rItem.QueryValue( aGradient, MID_FILLGRADIENT ); |
| 492 |
|
| 493 |
// add TransparencyGradient to list if it does not already exist |
| 494 |
OUString aPreferredName; |
| 495 |
aValue >>= aPreferredName; |
| 496 |
aValue <<= PropertyHelper::addTransparencyGradientUniqueNameToTable( |
| 497 |
aGradient, m_xChartModel, aPreferredName ); |
| 498 |
|
| 499 |
if( aValue != GetPropertySet()->getPropertyValue( aPropName )) |
| 500 |
{ |
| 501 |
GetPropertySet()->setPropertyValue( aPropName, aValue ); |
| 502 |
bChanged = true; |
| 503 |
} |
| 504 |
} |
| 505 |
else |
| 506 |
{ |
| 507 |
OUString aName; |
| 508 |
if( ( GetPropertySet()->getPropertyValue( aPropName ) >>= aName ) |
| 509 |
&& !aName.isEmpty() ) |
| 510 |
{ |
| 511 |
uno::Reference< beans::XPropertyState > xState( GetPropertySet(), uno::UNO_QUERY ); |
| 512 |
if( xState.is()) |
| 513 |
xState->setPropertyToDefault( aPropName ); |
| 514 |
bChanged = true; |
| 515 |
} |
| 516 |
} |
| 517 |
} |
| 518 |
} |
| 519 |
catch( const beans::UnknownPropertyException & ) |
| 520 |
{ |
| 521 |
DBG_UNHANDLED_EXCEPTION("chart2"); |
| 522 |
} |
| 523 |
break; |
| 524 |
|
| 525 |
case XATTR_GRADIENTSTEPCOUNT: |
| 526 |
{ |
| 527 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 528 |
{ |
| 529 |
OUString aPropName = |
| 530 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 531 |
? u"GradientStepCount"_ustr |
| 532 |
: u"FillGradientStepCount"_ustr; |
| 533 |
|
| 534 |
sal_Int16 nStepCount = static_cast< const XGradientStepCountItem & >( |
| 535 |
rItemSet.Get( nWhichId )).GetValue(); |
| 536 |
|
| 537 |
aValue <<= nStepCount; |
| 538 |
if( aValue != GetPropertySet()->getPropertyValue( aPropName )) |
| 539 |
{ |
| 540 |
GetPropertySet()->setPropertyValue( aPropName, aValue ); |
| 541 |
bChanged = true; |
| 542 |
} |
| 543 |
} |
| 544 |
} |
| 545 |
break; |
| 546 |
|
| 547 |
case XATTR_LINEDASH: |
| 548 |
{ |
| 549 |
OUString aPropName = |
| 550 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 551 |
? u"BorderDashName"_ustr |
| 552 |
: u"LineDashName"_ustr; |
| 553 |
|
| 554 |
const XLineDashItem & rItem = |
| 555 |
static_cast< const XLineDashItem & >( |
| 556 |
rItemSet.Get( nWhichId )); |
| 557 |
|
| 558 |
if( rItem.QueryValue( aValue, MID_NAME )) |
| 559 |
{ |
| 560 |
if( aValue != GetPropertySet()->getPropertyValue( aPropName )) |
| 561 |
{ |
| 562 |
// add LineDash to list |
| 563 |
uno::Any aLineDash; |
| 564 |
rItem.QueryValue( aLineDash, MID_LINEDASH ); |
| 565 |
OUString aPreferredName; |
| 566 |
aValue >>= aPreferredName; |
| 567 |
aValue <<= PropertyHelper::addLineDashUniqueNameToTable( |
| 568 |
aLineDash, m_xChartModel, aPreferredName ); |
| 569 |
|
| 570 |
GetPropertySet()->setPropertyValue( aPropName, aValue ); |
| 571 |
bChanged = true; |
| 572 |
} |
| 573 |
} |
| 574 |
} |
| 575 |
break; |
| 576 |
|
| 577 |
case XATTR_FILLGRADIENT: |
| 578 |
{ |
| 579 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 580 |
{ |
| 581 |
OUString aPropName = |
| 582 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 583 |
? u"GradientName"_ustr |
| 584 |
: u"FillGradientName"_ustr; |
| 585 |
|
| 586 |
const XFillGradientItem & rItem = |
| 587 |
static_cast< const XFillGradientItem & >( |
| 588 |
rItemSet.Get( nWhichId )); |
| 589 |
|
| 590 |
if( rItem.QueryValue( aValue, MID_NAME )) |
| 591 |
{ |
| 592 |
if( aValue != GetPropertySet()->getPropertyValue( aPropName )) |
| 593 |
{ |
| 594 |
// add Gradient to list |
| 595 |
uno::Any aGradient; |
| 596 |
rItem.QueryValue( aGradient, MID_FILLGRADIENT ); |
| 597 |
OUString aPreferredName; |
| 598 |
aValue >>= aPreferredName; |
| 599 |
aValue <<= PropertyHelper::addGradientUniqueNameToTable( |
| 600 |
aGradient, m_xChartModel, aPreferredName ); |
| 601 |
|
| 602 |
GetPropertySet()->setPropertyValue( aPropName, aValue ); |
| 603 |
bChanged = true; |
| 604 |
} |
| 605 |
} |
| 606 |
} |
| 607 |
} |
| 608 |
break; |
| 609 |
|
| 610 |
case XATTR_FILLHATCH: |
| 611 |
{ |
| 612 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 613 |
{ |
| 614 |
OUString aPropName = |
| 615 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 616 |
? u"HatchName"_ustr |
| 617 |
: u"FillHatchName"_ustr; |
| 618 |
|
| 619 |
const XFillHatchItem & rItem = |
| 620 |
static_cast< const XFillHatchItem & >( |
| 621 |
rItemSet.Get( nWhichId )); |
| 622 |
|
| 623 |
if( rItem.QueryValue( aValue, MID_NAME )) |
| 624 |
{ |
| 625 |
if( aValue != GetPropertySet()->getPropertyValue( aPropName )) |
| 626 |
{ |
| 627 |
// add Hatch to list |
| 628 |
uno::Any aHatch; |
| 629 |
rItem.QueryValue( aHatch, MID_FILLHATCH ); |
| 630 |
OUString aPreferredName; |
| 631 |
aValue >>= aPreferredName; |
| 632 |
aValue <<= PropertyHelper::addHatchUniqueNameToTable( |
| 633 |
aHatch, m_xChartModel, aPreferredName ); |
| 634 |
|
| 635 |
GetPropertySet()->setPropertyValue( aPropName, aValue ); |
| 636 |
bChanged = true; |
| 637 |
} |
| 638 |
} |
| 639 |
} |
| 640 |
} |
| 641 |
break; |
| 642 |
|
| 643 |
case XATTR_FILLBITMAP: |
| 644 |
{ |
| 645 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 646 |
{ |
| 647 |
const XFillBitmapItem & rItem = |
| 648 |
static_cast< const XFillBitmapItem & >( |
| 649 |
rItemSet.Get( nWhichId )); |
| 650 |
|
| 651 |
if( rItem.QueryValue( aValue, MID_NAME )) |
| 652 |
{ |
| 653 |
if( aValue != GetPropertySet()->getPropertyValue( u"FillBitmapName"_ustr )) |
| 654 |
{ |
| 655 |
// add Bitmap to list |
| 656 |
uno::Any aBitmap; |
| 657 |
rItem.QueryValue(aBitmap, MID_BITMAP); |
| 658 |
OUString aPreferredName; |
| 659 |
aValue >>= aPreferredName; |
| 660 |
aValue <<= PropertyHelper::addBitmapUniqueNameToTable( |
| 661 |
aBitmap, m_xChartModel, aPreferredName ); |
| 662 |
|
| 663 |
GetPropertySet()->setPropertyValue( u"FillBitmapName"_ustr , aValue ); |
| 664 |
bChanged = true; |
| 665 |
} |
| 666 |
} |
| 667 |
} |
| 668 |
} |
| 669 |
break; |
| 670 |
|
| 671 |
// hack, because QueryValue of XLineTransparenceItem returns sal_Int32 |
| 672 |
// instead of sal_Int16 |
| 673 |
case XATTR_LINETRANSPARENCE: |
| 674 |
{ |
| 675 |
OUString aPropName = |
| 676 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 677 |
? u"BorderTransparency"_ustr |
| 678 |
: (m_GraphicObjectType == GraphicObjectType::LineDataPoint) |
| 679 |
? u"Transparency"_ustr |
| 680 |
: u"LineTransparence"_ustr; |
| 681 |
|
| 682 |
const XLineTransparenceItem & rItem = |
| 683 |
static_cast< const XLineTransparenceItem & >( |
| 684 |
rItemSet.Get( nWhichId )); |
| 685 |
|
| 686 |
if( rItem.QueryValue( aValue )) |
| 687 |
{ |
| 688 |
OSL_ENSURE( ! aValue.isExtractableTo( |
| 689 |
cppu::UnoType<sal_Int16>::get()), |
| 690 |
"TransparenceItem QueryValue bug is fixed. Remove hack." ); |
| 691 |
sal_Int32 nValue = 0; |
| 692 |
if( aValue >>= nValue ) |
| 693 |
{ |
| 694 |
OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" ); |
| 695 |
sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue )); |
| 696 |
aValue <<= nValueToSet; |
| 697 |
|
| 698 |
GetPropertySet()->setPropertyValue( aPropName, aValue ); |
| 699 |
bChanged = true; |
| 700 |
} |
| 701 |
else |
| 702 |
{ |
| 703 |
OSL_FAIL( "Wrong type in Transparency Any" ); |
| 704 |
} |
| 705 |
} |
| 706 |
} |
| 707 |
break; |
| 708 |
|
| 709 |
// hack, because QueryValue of XFillTransparenceItem returns sal_Int32 |
| 710 |
// instead of sal_Int16 |
| 711 |
case XATTR_FILLTRANSPARENCE: |
| 712 |
if( lcl_supportsFillProperties( m_GraphicObjectType )) |
| 713 |
{ |
| 714 |
OUString aPropName = |
| 715 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 716 |
? u"Transparency"_ustr |
| 717 |
: u"FillTransparence"_ustr; |
| 718 |
|
| 719 |
const XFillTransparenceItem & rItem = |
| 720 |
static_cast< const XFillTransparenceItem & >( |
| 721 |
rItemSet.Get( nWhichId )); |
| 722 |
|
| 723 |
if( rItem.QueryValue( aValue )) |
| 724 |
{ |
| 725 |
OSL_ENSURE( ! aValue.isExtractableTo( |
| 726 |
cppu::UnoType<sal_Int16>::get()), |
| 727 |
"TransparenceItem QueryValue bug is fixed. Remove hack." ); |
| 728 |
sal_Int32 nValue = 0; |
| 729 |
if( aValue >>= nValue ) |
| 730 |
{ |
| 731 |
OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" ); |
| 732 |
sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue )); |
| 733 |
aValue <<= nValueToSet; |
| 734 |
|
| 735 |
GetPropertySet()->setPropertyValue( aPropName, aValue ); |
| 736 |
// if linear or no transparence is set, delete the gradient |
| 737 |
OUString aTransGradPropName = |
| 738 |
(m_GraphicObjectType == GraphicObjectType::FilledDataPoint) |
| 739 |
? u"TransparencyGradientName"_ustr |
| 740 |
: u"FillTransparenceGradientName"_ustr; |
| 741 |
GetPropertySet()->setPropertyValue( |
| 742 |
aTransGradPropName, uno::Any( OUString() )); |
| 743 |
|
| 744 |
bChanged = true; |
| 745 |
} |
| 746 |
else |
| 747 |
{ |
| 748 |
OSL_FAIL( "Wrong type in Transparency Any" ); |
| 749 |
} |
| 750 |
} |
| 751 |
} |
| 752 |
break; |
| 753 |
case SCHATTR_COLOR_PALETTE: |
| 754 |
{ |
| 755 |
const auto& rItem = static_cast<const SvxChartColorPaletteItem&>(rItemSet.Get(nWhichId)); |
| 756 |
m_xChartModel->setColorPalette(rItem.GetType(), rItem.GetIndex()); |
| 757 |
const auto oColorPalette = m_xChartModel->getCurrentColorPalette(); |
| 758 |
if (oColorPalette) |
| 759 |
m_xChartModel->applyColorPaletteToDataSeries(*oColorPalette); |
| 760 |
} |
| 761 |
break; |
| 762 |
} |
| 763 |
|
| 764 |
return bChanged; |
| 765 |
} |
| 766 |
|
| 767 |
} // namespace chart |
| 768 |
|
| 769 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |