Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / oox / source / drawingml / fillproperties.cxx
blob314ff58226954435e00faf41dabe01732840309b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "drawingml/fillproperties.hxx"
22 #include <iterator>
24 #include <drawingml/graphicproperties.hxx>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/beans/XPropertySet.hpp>
28 #include <com/sun/star/awt/Gradient.hpp>
29 #include <com/sun/star/text/GraphicCrop.hpp>
30 #include <com/sun/star/awt/Size.hpp>
31 #include <com/sun/star/drawing/BitmapMode.hpp>
32 #include <com/sun/star/drawing/ColorMode.hpp>
33 #include <com/sun/star/drawing/FillStyle.hpp>
34 #include <com/sun/star/drawing/Hatch.hpp>
35 #include <com/sun/star/drawing/RectanglePoint.hpp>
36 #include <com/sun/star/graphic/XGraphicTransformer.hpp>
37 #include <oox/core/fragmenthandler.hxx>
38 #include "oox/helper/graphichelper.hxx"
39 #include "oox/drawingml/drawingmltypes.hxx"
40 #include "oox/drawingml/shapepropertymap.hxx"
41 #include <oox/token/namespaces.hxx>
42 #include <oox/token/properties.hxx>
43 #include <oox/token/tokens.hxx>
44 #include <rtl/math.hxx>
45 #include <osl/diagnose.h>
47 using namespace ::com::sun::star;
48 using namespace ::com::sun::star::drawing;
49 using namespace ::com::sun::star::graphic;
51 using ::com::sun::star::uno::Reference;
52 using ::com::sun::star::uno::Exception;
53 using ::com::sun::star::uno::UNO_QUERY_THROW;
54 using ::com::sun::star::geometry::IntegerRectangle2D;
56 namespace oox {
57 namespace drawingml {
59 namespace {
61 Reference< XGraphic > lclCheckAndApplyDuotoneTransform( const BlipFillProperties& aBlipProps, Reference< XGraphic > const & xGraphic,
62 const GraphicHelper& rGraphicHelper, const sal_Int32 nPhClr )
64 if( aBlipProps.maDuotoneColors[0].isUsed() && aBlipProps.maDuotoneColors[1].isUsed() )
66 sal_Int32 nColor1 = aBlipProps.maDuotoneColors[0].getColor( rGraphicHelper, nPhClr );
67 sal_Int32 nColor2 = aBlipProps.maDuotoneColors[1].getColor( rGraphicHelper, nPhClr );
68 try
70 Reference< XGraphicTransformer > xTransformer( aBlipProps.mxGraphic, UNO_QUERY_THROW );
71 return xTransformer->applyDuotone( xGraphic, nColor1, nColor2 );
73 catch( Exception& )
77 return xGraphic;
80 Reference< XGraphic > lclCheckAndApplyChangeColorTransform( const BlipFillProperties &aBlipProps, Reference< XGraphic > const & xGraphic,
81 const GraphicHelper& rGraphicHelper, const sal_Int32 nPhClr )
83 if( aBlipProps.maColorChangeFrom.isUsed() && aBlipProps.maColorChangeTo.isUsed() )
85 sal_Int32 nFromColor = aBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr );
86 sal_Int32 nToColor = aBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr );
87 if ( (nFromColor != nToColor) || aBlipProps.maColorChangeTo.hasTransparency() ) try
89 sal_Int16 nToTransparence = aBlipProps.maColorChangeTo.getTransparency();
90 sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) * 2.55 );
91 Reference< XGraphicTransformer > xTransformer( aBlipProps.mxGraphic, UNO_QUERY_THROW );
92 return xTransformer->colorChange( xGraphic, nFromColor, 9, nToColor, nToAlpha );
94 catch( Exception& )
98 return xGraphic;
101 Reference< XGraphic > applyBrightnessContrast( Reference< XGraphic > const & xGraphic, sal_Int32 brightness, sal_Int32 contrast )
105 Reference< XGraphicTransformer > xTransformer( xGraphic, UNO_QUERY_THROW );
106 return xTransformer->applyBrightnessContrast( xGraphic, brightness, contrast, true );
108 catch( Exception& )
111 return xGraphic;
114 BitmapMode lclGetBitmapMode( sal_Int32 nToken )
116 OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
117 switch( nToken )
119 case XML_tile: return BitmapMode_REPEAT;
120 case XML_stretch: return BitmapMode_STRETCH;
122 return BitmapMode_NO_REPEAT;
125 RectanglePoint lclGetRectanglePoint( sal_Int32 nToken )
127 OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
128 switch( nToken )
130 case XML_tl: return RectanglePoint_LEFT_TOP;
131 case XML_t: return RectanglePoint_MIDDLE_TOP;
132 case XML_tr: return RectanglePoint_RIGHT_TOP;
133 case XML_l: return RectanglePoint_LEFT_MIDDLE;
134 case XML_ctr: return RectanglePoint_MIDDLE_MIDDLE;
135 case XML_r: return RectanglePoint_RIGHT_MIDDLE;
136 case XML_bl: return RectanglePoint_LEFT_BOTTOM;
137 case XML_b: return RectanglePoint_MIDDLE_BOTTOM;
138 case XML_br: return RectanglePoint_RIGHT_BOTTOM;
140 return RectanglePoint_LEFT_TOP;
143 const awt::Size lclGetOriginalSize( const GraphicHelper& rGraphicHelper, const Reference< XGraphic >& rxGraphic )
145 awt::Size aSizeHmm( 0, 0 );
148 Reference< beans::XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW );
149 if( xGraphicPropertySet->getPropertyValue( "Size100thMM" ) >>= aSizeHmm )
151 if( !aSizeHmm.Width && !aSizeHmm.Height )
152 { // MAPMODE_PIXEL USED :-(
153 awt::Size aSourceSizePixel( 0, 0 );
154 if( xGraphicPropertySet->getPropertyValue( "SizePixel" ) >>= aSourceSizePixel )
155 aSizeHmm = rGraphicHelper.convertScreenPixelToHmm( aSourceSizePixel );
159 catch( Exception& )
162 return aSizeHmm;
165 } // namespace
167 void GradientFillProperties::assignUsed( const GradientFillProperties& rSourceProps )
169 if( !rSourceProps.maGradientStops.empty() )
170 maGradientStops = rSourceProps.maGradientStops;
171 moFillToRect.assignIfUsed( rSourceProps.moFillToRect );
172 moTileRect.assignIfUsed( rSourceProps.moTileRect );
173 moGradientPath.assignIfUsed( rSourceProps.moGradientPath );
174 moShadeAngle.assignIfUsed( rSourceProps.moShadeAngle );
175 moShadeFlip.assignIfUsed( rSourceProps.moShadeFlip );
176 moShadeScaled.assignIfUsed( rSourceProps.moShadeScaled );
177 moRotateWithShape.assignIfUsed( rSourceProps.moRotateWithShape );
180 void PatternFillProperties::assignUsed( const PatternFillProperties& rSourceProps )
182 maPattFgColor.assignIfUsed( rSourceProps.maPattFgColor );
183 maPattBgColor.assignIfUsed( rSourceProps.maPattBgColor );
184 moPattPreset.assignIfUsed( rSourceProps.moPattPreset );
187 void BlipFillProperties::assignUsed( const BlipFillProperties& rSourceProps )
189 if( rSourceProps.mxGraphic.is() )
190 mxGraphic = rSourceProps.mxGraphic;
191 moBitmapMode.assignIfUsed( rSourceProps.moBitmapMode );
192 moFillRect.assignIfUsed( rSourceProps.moFillRect );
193 moTileOffsetX.assignIfUsed( rSourceProps.moTileOffsetX );
194 moTileOffsetY.assignIfUsed( rSourceProps.moTileOffsetY );
195 moTileScaleX.assignIfUsed( rSourceProps.moTileScaleX );
196 moTileScaleY.assignIfUsed( rSourceProps.moTileScaleY );
197 moTileAlign.assignIfUsed( rSourceProps.moTileAlign );
198 moTileFlip.assignIfUsed( rSourceProps.moTileFlip );
199 moRotateWithShape.assignIfUsed( rSourceProps.moRotateWithShape );
200 moColorEffect.assignIfUsed( rSourceProps.moColorEffect );
201 moBrightness.assignIfUsed( rSourceProps.moBrightness );
202 moContrast.assignIfUsed( rSourceProps.moContrast );
203 maColorChangeFrom.assignIfUsed( rSourceProps.maColorChangeFrom );
204 maColorChangeTo.assignIfUsed( rSourceProps.maColorChangeTo );
205 maDuotoneColors[0].assignIfUsed( rSourceProps.maDuotoneColors[0] );
206 maDuotoneColors[1].assignIfUsed( rSourceProps.maDuotoneColors[1] );
207 maEffect.assignUsed( rSourceProps.maEffect );
208 moAlphaModFix.assignIfUsed(rSourceProps.moAlphaModFix);
211 void FillProperties::assignUsed( const FillProperties& rSourceProps )
213 moFillType.assignIfUsed( rSourceProps.moFillType );
214 maFillColor.assignIfUsed( rSourceProps.maFillColor );
215 maGradientProps.assignUsed( rSourceProps.maGradientProps );
216 maPatternProps.assignUsed( rSourceProps.maPatternProps );
217 maBlipProps.assignUsed( rSourceProps.maBlipProps );
220 Color FillProperties::getBestSolidColor() const
222 Color aSolidColor;
223 if( moFillType.has() ) switch( moFillType.get() )
225 case XML_solidFill:
226 aSolidColor = maFillColor;
227 break;
228 case XML_gradFill:
229 if( !maGradientProps.maGradientStops.empty() )
231 GradientFillProperties::GradientStopMap::const_iterator aGradientStop =
232 maGradientProps.maGradientStops.begin();
233 if (maGradientProps.maGradientStops.size() > 2)
234 ++aGradientStop;
235 aSolidColor = aGradientStop->second;
237 break;
238 case XML_pattFill:
239 aSolidColor = maPatternProps.maPattBgColor.isUsed() ? maPatternProps.maPattBgColor : maPatternProps.maPattFgColor;
240 break;
242 return aSolidColor;
245 /// Maps the hatch token to drawing::Hatch.
246 static drawing::Hatch createHatch( sal_Int32 nHatchToken, sal_Int32 nColor )
248 drawing::Hatch aHatch;
249 aHatch.Color = nColor;
251 // best-effort mapping; we do not support all the styles in core
252 switch ( nHatchToken )
254 case XML_pct5: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 250; aHatch.Angle = 450; break;
255 case XML_pct10: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 450; break;
256 case XML_pct20: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
257 case XML_pct25: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 200; aHatch.Angle = 450; break;
258 case XML_pct30: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 175; aHatch.Angle = 450; break;
259 case XML_pct40: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
260 case XML_pct50: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 125; aHatch.Angle = 450; break;
261 case XML_pct60: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
262 case XML_pct70: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 125; aHatch.Angle = 450; break;
263 case XML_pct75: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
264 case XML_pct80: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 75; aHatch.Angle = 450; break;
265 case XML_pct90: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 50; aHatch.Angle = 450; break;
266 case XML_horz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
267 case XML_vert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 900; break;
268 case XML_ltHorz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 0; break;
269 case XML_ltVert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 900; break;
270 case XML_dkHorz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 25; aHatch.Angle = 0; break;
271 case XML_dkVert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 25; aHatch.Angle = 900; break;
272 case XML_narHorz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 0; break;
273 case XML_narVert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 900; break;
274 case XML_dashHorz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 0; break;
275 case XML_dashVert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 900; break;
276 case XML_cross: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
277 case XML_dnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 1350; break;
278 case XML_upDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
279 case XML_ltDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 1350; break;
280 case XML_ltUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 450; break;
281 case XML_dkDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 1350; break;
282 case XML_dkUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 450; break;
283 case XML_wdDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 1350; break;
284 case XML_wdUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
285 case XML_dashDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 1350; break;
286 case XML_dashUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
287 case XML_diagCross: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
288 case XML_smCheck: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 50; aHatch.Angle = 450; break;
289 case XML_lgCheck: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
290 case XML_smGrid: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 50; aHatch.Angle = 0; break;
291 case XML_lgGrid: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
292 case XML_dotGrid: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 400; aHatch.Angle = 0; break;
293 case XML_smConfetti: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 600; break;
294 case XML_lgConfetti: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 600; break;
295 case XML_horzBrick: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 0; break;
296 case XML_diagBrick: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 450; break;
297 case XML_solidDmnd: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
298 case XML_openDmnd: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
299 case XML_dotDmnd: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 450; break;
300 case XML_plaid: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 200; aHatch.Angle = 900; break;
301 case XML_sphere: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
302 case XML_weave: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
303 case XML_divot: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 400; aHatch.Angle = 450; break;
304 case XML_shingle: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 1350; break;
305 case XML_wave: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
306 case XML_trellis: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 75; aHatch.Angle = 450; break;
307 case XML_zigZag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 75; aHatch.Angle = 0; break;
310 return aHatch;
313 void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
314 const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, sal_Int32 nPhClr,
315 bool bFlipH, bool bFlipV ) const
317 if( moFillType.has() )
319 FillStyle eFillStyle = FillStyle_NONE;
320 OSL_ASSERT((moFillType.get() & sal_Int32(0xFFFF0000))==0);
321 switch( moFillType.get() )
323 case XML_noFill:
324 eFillStyle = FillStyle_NONE;
325 break;
327 case XML_solidFill:
328 if( maFillColor.isUsed() )
330 rPropMap.setProperty( ShapeProperty::FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) );
331 if( maFillColor.hasTransparency() )
332 rPropMap.setProperty( ShapeProperty::FillTransparency, maFillColor.getTransparency() );
333 eFillStyle = FillStyle_SOLID;
335 break;
337 case XML_gradFill:
338 // do not create gradient struct if property is not supported...
339 if( rPropMap.supportsProperty( ShapeProperty::FillGradient ) )
341 sal_Int32 nEndTrans = 0;
342 sal_Int32 nStartTrans = 0;
343 awt::Gradient aGradient;
344 aGradient.Angle = 900;
345 aGradient.StartIntensity = 100;
346 aGradient.EndIntensity = 100;
348 // Old code, values in aGradient overwritten in many cases by newer code below
349 if( maGradientProps.maGradientStops.size() > 1 )
351 aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr );
352 aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr );
353 if( maGradientProps.maGradientStops.rbegin()->second.hasTransparency() )
354 nEndTrans = maGradientProps.maGradientStops.rbegin()->second.getTransparency()*255/100;
355 if( maGradientProps.maGradientStops.begin()->second.hasTransparency() )
356 nStartTrans = maGradientProps.maGradientStops.begin()->second.getTransparency()*255/100;
359 // Adjust for flips
360 if ( bFlipH )
361 nShapeRotation = 180*60000 - nShapeRotation;
362 if ( bFlipV )
363 nShapeRotation = -nShapeRotation;
365 // "rotate with shape" not set, or set to false -> do not rotate
366 if ( !maGradientProps.moRotateWithShape.get( false ) )
367 nShapeRotation = 0;
369 if( maGradientProps.moGradientPath.has() )
371 aGradient.Style = (maGradientProps.moGradientPath.get() == XML_circle) ? awt::GradientStyle_ELLIPTICAL : awt::GradientStyle_RECT;
372 // position of gradient center (limited to [30%;70%], otherwise gradient is too hidden)
373 IntegerRectangle2D aFillToRect = maGradientProps.moFillToRect.get( IntegerRectangle2D( 0, 0, MAX_PERCENT, MAX_PERCENT ) );
374 sal_Int32 nCenterX = (MAX_PERCENT + aFillToRect.X1 - aFillToRect.X2) / 2;
375 aGradient.XOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterX / PER_PERCENT, 30, 70 );
376 sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
377 aGradient.YOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterY / PER_PERCENT, 30, 70 );
378 ::std::swap( aGradient.StartColor, aGradient.EndColor );
379 ::std::swap( nStartTrans, nEndTrans );
381 else
383 // A copy of the gradient stops for local modification
384 GradientFillProperties::GradientStopMap aGradientStops(maGradientProps.maGradientStops);
386 // Add a fake gradient stop at 0% and 100% if necessary, so that the gradient always starts
387 // at 0% and ends at 100%, to make following logic clearer (?).
388 if( aGradientStops.find(0.0) == aGradientStops.end() )
390 // temp variable required
391 Color aFirstColor(aGradientStops.begin()->second);
392 aGradientStops[0.0] = aFirstColor;
395 if( aGradientStops.find(1.0) == aGradientStops.end() )
397 // ditto
398 Color aLastColor(aGradientStops.rbegin()->second);
399 aGradientStops[1.0] = aLastColor;
402 // Check if the gradient is symmetric, which we will emulate with an "axial" gradient.
403 bool bSymmetric(true);
405 GradientFillProperties::GradientStopMap::const_iterator aItA( aGradientStops.begin() );
406 GradientFillProperties::GradientStopMap::const_iterator aItZ(std::prev(aGradientStops.end()));
407 while( bSymmetric && aItA->first < aItZ->first )
409 if( aItA->second.getColor( rGraphicHelper, nPhClr ) != aItZ->second.getColor( rGraphicHelper, nPhClr ) ||
410 aItA->second.getTransparency() != aItZ->second.getTransparency() )
411 bSymmetric = false;
412 else
414 ++aItA;
415 aItZ = std::prev(aItZ);
418 // Don't be fooled if the middlemost stop isn't at 0.5.
419 if( bSymmetric && aItA == aItZ && aItA->first != 0.5 )
420 bSymmetric = false;
422 // If symmetric, do the rest of the logic for just a half.
423 if( bSymmetric )
425 // aItZ already points to the colour for the middle, but insert a fake stop at the
426 // exact middle if necessary.
427 if( aItA->first != aItZ->first )
429 Color aMiddleColor = aItZ->second;
430 aGradientStops[0.5] = aMiddleColor;
432 // Drop the rest of the stops
433 while( aGradientStops.rbegin()->first > 0.5 )
434 aGradientStops.erase( aGradientStops.rbegin()->first );
438 SAL_INFO("oox.drawingml.gradient", "symmetric: " << (bSymmetric ? "YES" : "NO") <<
439 ", number of stops: " << aGradientStops.size());
440 for (GradientFillProperties::GradientStopMap::iterator p(aGradientStops.begin());
441 p != aGradientStops.end();
442 ++p)
443 SAL_INFO("oox.drawingml.gradient", " " << std::distance(aGradientStops.begin(), p) << ": " <<
444 p->first << ": " <<
445 std::hex << p->second.getColor( rGraphicHelper, nPhClr ) << std::dec <<
446 "@" << (100-p->second.getTransparency()) << "%");
448 // Now estimate the simple LO style gradient (only two stops, at n% and 100%, where n ==
449 // the "border") that best emulates the gradient between begin() and prior(end()).
451 // First look for the largest segment in the gradient.
452 GradientFillProperties::GradientStopMap::iterator aIt(aGradientStops.begin());
453 double nWidestWidth = -1;
454 GradientFillProperties::GradientStopMap::iterator aWidestSegmentStart;
455 ++aIt;
456 while( aIt != aGradientStops.end() )
458 if (aIt->first - std::prev(aIt)->first > nWidestWidth)
460 nWidestWidth = aIt->first - std::prev(aIt)->first;
461 aWidestSegmentStart = std::prev(aIt);
463 ++aIt;
465 assert( nWidestWidth > 0 );
467 double nBorder = 0;
468 bool bSwap(false);
470 // Do we have just two segments, and either one is of uniform colour, or three or more
471 // segments, and the widest one is the first or last one, and is it of uniform colour? If
472 // so, deduce the border from it, and drop that segment.
473 if( aGradientStops.size() == 3 &&
474 aGradientStops.begin()->second.getColor(rGraphicHelper, nPhClr) == std::next(aGradientStops.begin())->second.getColor(rGraphicHelper, nPhClr) &&
475 aGradientStops.begin()->second.getTransparency() == std::next(aGradientStops.begin())->second.getTransparency())
477 // Two segments, first is uniformly coloured
478 SAL_INFO("oox.drawingml.gradient", "two segments, first is uniformly coloured");
479 nBorder = std::next(aGradientStops.begin())->first - aGradientStops.begin()->first;
480 aGradientStops.erase(aGradientStops.begin());
481 aWidestSegmentStart = aGradientStops.begin();
483 else if( !bSymmetric &&
484 aGradientStops.size() == 3 &&
485 std::next(aGradientStops.begin())->second.getColor(rGraphicHelper, nPhClr) == std::prev(aGradientStops.end())->second.getColor(rGraphicHelper, nPhClr) &&
486 std::next(aGradientStops.begin())->second.getTransparency() == std::prev(aGradientStops.end())->second.getTransparency())
488 // Two segments, second is uniformly coloured
489 SAL_INFO("oox.drawingml.gradient", "two segments, second is uniformly coloured");
490 nBorder = std::prev(aGradientStops.end())->first - std::next(aGradientStops.begin())->first;
491 aGradientStops.erase(std::next(aGradientStops.begin()));
492 aWidestSegmentStart = aGradientStops.begin();
493 bSwap = true;
494 nShapeRotation = 180*60000 - nShapeRotation;
496 else if( !bSymmetric &&
497 aGradientStops.size() >= 4 &&
498 aWidestSegmentStart->second.getColor( rGraphicHelper, nPhClr ) == std::next(aWidestSegmentStart)->second.getColor(rGraphicHelper, nPhClr) &&
499 aWidestSegmentStart->second.getTransparency() == std::next(aWidestSegmentStart)->second.getTransparency() &&
500 ( aWidestSegmentStart == aGradientStops.begin() ||
501 std::next(aWidestSegmentStart) == std::prev(aGradientStops.end())))
503 // Not symmetric, three or more segments, the widest is first or last and is uniformly coloured
504 SAL_INFO("oox.drawingml.gradient", "first or last segment is widest and is uniformly coloured");
505 nBorder = std::next(aWidestSegmentStart)->first - aWidestSegmentStart->first;
507 // If it's the last segment that is uniformly coloured, rotate the gradient 180
508 // degrees and swap start and end colours
509 if (std::next(aWidestSegmentStart) == std::prev(aGradientStops.end()))
511 bSwap = true;
512 nShapeRotation = 180*60000 - nShapeRotation;
515 aGradientStops.erase( aWidestSegmentStart++ );
517 // Look for which is widest now
518 aIt = std::next(aGradientStops.begin());
519 nWidestWidth = -1;
520 while( aIt != aGradientStops.end() )
522 if (aIt->first - std::prev(aIt)->first > nWidestWidth)
524 nWidestWidth = aIt->first - std::prev(aIt)->first;
525 aWidestSegmentStart = std::prev(aIt);
527 ++aIt;
530 SAL_INFO("oox.drawingml.gradient", "widest segment start: " << aWidestSegmentStart->first << ", border: " << nBorder);
531 assert( (!bSymmetric && !bSwap) || !(bSymmetric && bSwap) );
533 // Now we have a potential border and a largest segment. Use those.
535 aGradient.Style = bSymmetric ? awt::GradientStyle_AXIAL : awt::GradientStyle_LINEAR;
536 sal_Int32 nDmlAngle = maGradientProps.moShadeAngle.get( 0 ) - nShapeRotation;
537 // convert DrawingML angle (in 1/60000 degrees) to API angle (in 1/10 degrees)
538 aGradient.Angle = static_cast< sal_Int16 >( (4500 - (nDmlAngle / (PER_DEGREE / 10))) % 3600 );
539 Color aStartColor, aEndColor;
540 if( bSymmetric )
542 aStartColor = std::next(aWidestSegmentStart)->second;
543 aEndColor = aWidestSegmentStart->second;
544 nBorder *= 2;
546 else if( bSwap )
548 aStartColor = std::next(aWidestSegmentStart)->second;
549 aEndColor = aWidestSegmentStart->second;
551 else
553 aStartColor = aWidestSegmentStart->second;
554 aEndColor = std::next(aWidestSegmentStart)->second;
557 SAL_INFO("oox.drawingml.gradient", "start color: " << std::hex << aStartColor.getColor( rGraphicHelper, nPhClr ) << std::dec <<
558 "@" << (100-aStartColor.getTransparency()) << "%"
559 ", end color: " << std::hex << aEndColor.getColor( rGraphicHelper, nPhClr ) << std::dec <<
560 "@" << (100-aEndColor.getTransparency()) << "%");
562 aGradient.StartColor = aStartColor.getColor( rGraphicHelper, nPhClr );
563 aGradient.EndColor = aEndColor.getColor( rGraphicHelper, nPhClr );
565 if( aStartColor.hasTransparency() )
566 nStartTrans = aStartColor.getTransparency()*255/100;
567 if( aEndColor.hasTransparency() )
568 nEndTrans = aEndColor.getTransparency()*255/100;
570 aGradient.Border = rtl::math::round(100*nBorder);
573 // push gradient or named gradient to property map
574 if( rPropMap.setProperty( ShapeProperty::FillGradient, aGradient ) )
575 eFillStyle = FillStyle_GRADIENT;
577 // push gradient transparency to property map
578 if( nStartTrans != 0 || nEndTrans != 0 )
580 awt::Gradient aGrad(aGradient);
581 uno::Any aVal;
582 aGrad.EndColor = (sal_Int32)( nEndTrans | nEndTrans << 8 | nEndTrans << 16 );
583 aGrad.StartColor = (sal_Int32)( nStartTrans | nStartTrans << 8 | nStartTrans << 16 );
584 aVal <<= aGrad;
585 rPropMap.setProperty( ShapeProperty::GradientTransparency, aGrad );
589 break;
591 case XML_blipFill:
592 // do not start complex graphic transformation if property is not supported...
593 if( maBlipProps.mxGraphic.is() && rPropMap.supportsProperty( ShapeProperty::FillBitmapUrl ) )
595 Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
596 // TODO: "rotate with shape" is not possible with our current core
598 OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
599 // push bitmap or named bitmap to property map
600 if( !aGraphicUrl.isEmpty() && rPropMap.supportsProperty( ShapeProperty::FillBitmapNameFromUrl ) && rPropMap.setProperty( ShapeProperty::FillBitmapNameFromUrl, aGraphicUrl ) )
601 eFillStyle = FillStyle_BITMAP;
602 else if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( ShapeProperty::FillBitmapUrl, aGraphicUrl ) )
603 eFillStyle = FillStyle_BITMAP;
605 // set other bitmap properties, if bitmap has been inserted into the map
606 if( eFillStyle == FillStyle_BITMAP )
608 // bitmap mode (single, repeat, stretch)
609 BitmapMode eBitmapMode = lclGetBitmapMode( maBlipProps.moBitmapMode.get( XML_TOKEN_INVALID ) );
610 rPropMap.setProperty( ShapeProperty::FillBitmapMode, eBitmapMode );
612 // additional settings for repeated bitmap
613 if( eBitmapMode == BitmapMode_REPEAT )
615 // anchor position inside bitmap
616 RectanglePoint eRectPoint = lclGetRectanglePoint( maBlipProps.moTileAlign.get( XML_tl ) );
617 rPropMap.setProperty( ShapeProperty::FillBitmapRectanglePoint, eRectPoint );
619 awt::Size aOriginalSize = lclGetOriginalSize( rGraphicHelper, maBlipProps.mxGraphic );
620 if( (aOriginalSize.Width > 0) && (aOriginalSize.Height > 0) )
622 // size of one bitmap tile (given as 1/1000 percent of bitmap size), convert to 1/100 mm
623 double fScaleX = maBlipProps.moTileScaleX.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
624 sal_Int32 nFillBmpSizeX = getLimitedValue< sal_Int32, double >( aOriginalSize.Width * fScaleX, 1, SAL_MAX_INT32 );
625 rPropMap.setProperty( ShapeProperty::FillBitmapSizeX, nFillBmpSizeX );
626 double fScaleY = maBlipProps.moTileScaleY.get( MAX_PERCENT ) / static_cast< double >( MAX_PERCENT );
627 sal_Int32 nFillBmpSizeY = getLimitedValue< sal_Int32, double >( aOriginalSize.Height * fScaleY, 1, SAL_MAX_INT32 );
628 rPropMap.setProperty( ShapeProperty::FillBitmapSizeY, nFillBmpSizeY );
630 // offset of the first bitmap tile (given as EMUs), convert to percent
631 sal_Int16 nTileOffsetX = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetX.get( 0 ) / 3.6 / aOriginalSize.Width, 0, 100 );
632 rPropMap.setProperty( ShapeProperty::FillBitmapOffsetX, nTileOffsetX );
633 sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 );
634 rPropMap.setProperty( ShapeProperty::FillBitmapOffsetY, nTileOffsetY );
637 else if ( eBitmapMode == BitmapMode_STRETCH && maBlipProps.moFillRect.has() )
639 geometry::IntegerRectangle2D aFillRect( maBlipProps.moFillRect.get() );
640 awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
641 if ( aOriginalSize.Width && aOriginalSize.Height )
643 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
644 if ( aFillRect.X1 )
645 aGraphCrop.Left = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X1 ) / 100000 );
646 if ( aFillRect.Y1 )
647 aGraphCrop.Top = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y1 ) / 100000 );
648 if ( aFillRect.X2 )
649 aGraphCrop.Right = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Width ) * aFillRect.X2 ) / 100000 );
650 if ( aFillRect.Y2 )
651 aGraphCrop.Bottom = static_cast< sal_Int32 >( ( static_cast< double >( aOriginalSize.Height ) * aFillRect.Y2 ) / 100000 );
652 rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
657 if (maBlipProps.moAlphaModFix.has())
658 rPropMap.setProperty(ShapeProperty::FillTransparency, static_cast<sal_Int16>(100 - (maBlipProps.moAlphaModFix.get() / PER_PERCENT)));
660 break;
662 case XML_pattFill:
664 if( rPropMap.supportsProperty( ShapeProperty::FillHatch ) )
666 Color aColor( maPatternProps.maPattFgColor );
667 if( aColor.isUsed() && maPatternProps.moPattPreset.has() )
669 // we do not support hatches that have background
670 // color too, so all this is some best-effort approach
671 eFillStyle = FillStyle_HATCH;
672 rPropMap.setProperty( ShapeProperty::FillHatch, createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( rGraphicHelper, nPhClr ) ) );
674 else if ( maPatternProps.maPattBgColor.isUsed() )
676 aColor = maPatternProps.maPattBgColor;
677 rPropMap.setProperty( ShapeProperty::FillColor, aColor.getColor( rGraphicHelper, nPhClr ) );
678 if( aColor.hasTransparency() )
679 rPropMap.setProperty( ShapeProperty::FillTransparency, aColor.getTransparency() );
680 eFillStyle = FillStyle_SOLID;
684 break;
686 case XML_grpFill:
687 // todo
688 eFillStyle = FillStyle_NONE;
689 break;
692 // set final fill style property
693 rPropMap.setProperty( ShapeProperty::FillStyle, eFillStyle );
697 void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper ) const
699 sal_Int16 nBrightness = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
700 sal_Int16 nContrast = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
701 ColorMode eColorMode = ColorMode_STANDARD;
703 switch( maBlipProps.moColorEffect.get( XML_TOKEN_INVALID ) )
705 case XML_biLevel: eColorMode = ColorMode_MONO; break;
706 case XML_grayscl: eColorMode = ColorMode_GREYS; break;
709 if( maBlipProps.mxGraphic.is() )
711 // created transformed graphic
712 Reference< XGraphic > xGraphic = lclCheckAndApplyChangeColorTransform(maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, API_RGB_TRANSPARENT);
713 xGraphic = lclCheckAndApplyDuotoneTransform(maBlipProps, xGraphic, rGraphicHelper, API_RGB_TRANSPARENT);
715 if (eColorMode == ColorMode_STANDARD && nBrightness == 70 && nContrast == -70)
716 // map MSO 'washout' to our Watermark colormode
717 eColorMode = ColorMode_WATERMARK;
718 else if( nBrightness != 0 && nContrast != 0 )
720 // MSO uses a different algorithm for contrast+brightness, LO applies contrast before brightness,
721 // while MSO apparently applies half of brightness before contrast and half after. So if only
722 // contrast or brightness need to be altered, the result is the same, but if both are involved,
723 // there's no way to map that, so just force a conversion of the image.
724 xGraphic = applyBrightnessContrast( xGraphic, nBrightness, nContrast );
725 nBrightness = 0;
726 nContrast = 0;
728 rPropMap.setProperty(PROP_Graphic, xGraphic);
730 // do we still need to set GraphicURL as well? (TODO)
731 OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
732 if( !aGraphicUrl.isEmpty() )
733 rPropMap.setProperty(PROP_GraphicURL, aGraphicUrl);
735 // cropping
736 if ( maBlipProps.moClipRect.has() )
738 geometry::IntegerRectangle2D oClipRect( maBlipProps.moClipRect.get() );
739 awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
740 if ( aOriginalSize.Width && aOriginalSize.Height )
742 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
743 if ( oClipRect.X1 )
744 aGraphCrop.Left = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 );
745 if ( oClipRect.Y1 )
746 aGraphCrop.Top = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 );
747 if ( oClipRect.X2 )
748 aGraphCrop.Right = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 );
749 if ( oClipRect.Y2 )
750 aGraphCrop.Bottom = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 );
751 rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
755 rPropMap.setProperty(PROP_GraphicColorMode, eColorMode);
757 // brightness and contrast
758 if( nBrightness != 0 )
759 rPropMap.setProperty(PROP_AdjustLuminance, nBrightness);
760 if( nContrast != 0 )
761 rPropMap.setProperty(PROP_AdjustContrast, nContrast);
763 // Media content
764 assert(m_xMediaStream.is() != m_sMediaPackageURL.isEmpty());
765 if (m_xMediaStream.is() && !m_sMediaPackageURL.isEmpty())
767 rPropMap.setProperty(PROP_PrivateStream, m_xMediaStream);
768 rPropMap.setProperty(PROP_MediaURL, m_sMediaPackageURL);
772 bool ArtisticEffectProperties::isEmpty() const
774 return msName.isEmpty();
777 css::beans::PropertyValue ArtisticEffectProperties::getEffect()
779 css::beans::PropertyValue aRet;
780 if( msName.isEmpty() )
781 return aRet;
783 css::uno::Sequence< css::beans::PropertyValue > aSeq( maAttribs.size() + 1 );
784 sal_uInt32 i = 0;
785 for( std::map< OUString, css::uno::Any >::iterator it = maAttribs.begin(); it != maAttribs.end(); ++it )
787 aSeq[i].Name = it->first;
788 aSeq[i].Value = it->second;
789 i++;
792 if( mrOleObjectInfo.maEmbeddedData.hasElements() )
794 css::uno::Sequence< css::beans::PropertyValue > aGraphicSeq( 2 );
795 aGraphicSeq[0].Name = "Id";
796 aGraphicSeq[0].Value <<= mrOleObjectInfo.maProgId;
797 aGraphicSeq[1].Name = "Data";
798 aGraphicSeq[1].Value <<= mrOleObjectInfo.maEmbeddedData;
800 aSeq[i].Name = "OriginalGraphic";
801 aSeq[i].Value <<= aGraphicSeq;
804 aRet.Name = msName;
805 aRet.Value <<= aSeq;
807 return aRet;
810 void ArtisticEffectProperties::assignUsed( const ArtisticEffectProperties& rSourceProps )
812 if( !rSourceProps.isEmpty() )
814 msName = rSourceProps.msName;
815 maAttribs = rSourceProps.maAttribs;
819 OUString ArtisticEffectProperties::getEffectString( sal_Int32 nToken )
821 switch( nToken )
823 // effects
824 case OOX_TOKEN( a14, artisticBlur ): return OUString( "artisticBlur" );
825 case OOX_TOKEN( a14, artisticCement ): return OUString( "artisticCement" );
826 case OOX_TOKEN( a14, artisticChalkSketch ): return OUString( "artisticChalkSketch" );
827 case OOX_TOKEN( a14, artisticCrisscrossEtching ): return OUString( "artisticCrisscrossEtching" );
828 case OOX_TOKEN( a14, artisticCutout ): return OUString( "artisticCutout" );
829 case OOX_TOKEN( a14, artisticFilmGrain ): return OUString( "artisticFilmGrain" );
830 case OOX_TOKEN( a14, artisticGlass ): return OUString( "artisticGlass" );
831 case OOX_TOKEN( a14, artisticGlowDiffused ): return OUString( "artisticGlowDiffused" );
832 case OOX_TOKEN( a14, artisticGlowEdges ): return OUString( "artisticGlowEdges" );
833 case OOX_TOKEN( a14, artisticLightScreen ): return OUString( "artisticLightScreen" );
834 case OOX_TOKEN( a14, artisticLineDrawing ): return OUString( "artisticLineDrawing" );
835 case OOX_TOKEN( a14, artisticMarker ): return OUString( "artisticMarker" );
836 case OOX_TOKEN( a14, artisticMosiaicBubbles ): return OUString( "artisticMosiaicBubbles" );
837 case OOX_TOKEN( a14, artisticPaintStrokes ): return OUString( "artisticPaintStrokes" );
838 case OOX_TOKEN( a14, artisticPaintBrush ): return OUString( "artisticPaintBrush" );
839 case OOX_TOKEN( a14, artisticPastelsSmooth ): return OUString( "artisticPastelsSmooth" );
840 case OOX_TOKEN( a14, artisticPencilGrayscale ): return OUString( "artisticPencilGrayscale" );
841 case OOX_TOKEN( a14, artisticPencilSketch ): return OUString( "artisticPencilSketch" );
842 case OOX_TOKEN( a14, artisticPhotocopy ): return OUString( "artisticPhotocopy" );
843 case OOX_TOKEN( a14, artisticPlasticWrap ): return OUString( "artisticPlasticWrap" );
844 case OOX_TOKEN( a14, artisticTexturizer ): return OUString( "artisticTexturizer" );
845 case OOX_TOKEN( a14, artisticWatercolorSponge ): return OUString( "artisticWatercolorSponge" );
846 case OOX_TOKEN( a14, brightnessContrast ): return OUString( "brightnessContrast" );
847 case OOX_TOKEN( a14, colorTemperature ): return OUString( "colorTemperature" );
848 case OOX_TOKEN( a14, saturation ): return OUString( "saturation" );
849 case OOX_TOKEN( a14, sharpenSoften ): return OUString( "sharpenSoften" );
851 // attributes
852 case XML_visible: return OUString( "visible" );
853 case XML_trans: return OUString( "trans" );
854 case XML_crackSpacing: return OUString( "crackSpacing" );
855 case XML_pressure: return OUString( "pressure" );
856 case XML_numberOfShades: return OUString( "numberOfShades" );
857 case XML_grainSize: return OUString( "grainSize" );
858 case XML_intensity: return OUString( "intensity" );
859 case XML_smoothness: return OUString( "smoothness" );
860 case XML_gridSize: return OUString( "gridSize" );
861 case XML_pencilSize: return OUString( "pencilSize" );
862 case XML_size: return OUString( "size" );
863 case XML_brushSize: return OUString( "brushSize" );
864 case XML_scaling: return OUString( "scaling" );
865 case XML_detail: return OUString( "detail" );
866 case XML_bright: return OUString( "bright" );
867 case XML_contrast: return OUString( "contrast" );
868 case XML_colorTemp: return OUString( "colorTemp" );
869 case XML_sat: return OUString( "sat" );
870 case XML_amount: return OUString( "amount" );
872 SAL_WARN( "oox.drawingml", "ArtisticEffectProperties::getEffectString: unexpected token " << nToken );
873 return OUString();
876 sal_Int32 ArtisticEffectProperties::getEffectToken( const OUString& sName )
878 // effects
879 if( sName == "artisticBlur" )
880 return XML_artisticBlur;
881 else if( sName == "artisticCement" )
882 return XML_artisticCement;
883 else if( sName == "artisticChalkSketch" )
884 return XML_artisticChalkSketch;
885 else if( sName == "artisticCrisscrossEtching" )
886 return XML_artisticCrisscrossEtching;
887 else if( sName == "artisticCutout" )
888 return XML_artisticCutout;
889 else if( sName == "artisticFilmGrain" )
890 return XML_artisticFilmGrain;
891 else if( sName == "artisticGlass" )
892 return XML_artisticGlass;
893 else if( sName == "artisticGlowDiffused" )
894 return XML_artisticGlowDiffused;
895 else if( sName == "artisticGlowEdges" )
896 return XML_artisticGlowEdges;
897 else if( sName == "artisticLightScreen" )
898 return XML_artisticLightScreen;
899 else if( sName == "artisticLineDrawing" )
900 return XML_artisticLineDrawing;
901 else if( sName == "artisticMarker" )
902 return XML_artisticMarker;
903 else if( sName == "artisticMosiaicBubbles" )
904 return XML_artisticMosiaicBubbles;
905 else if( sName == "artisticPaintStrokes" )
906 return XML_artisticPaintStrokes;
907 else if( sName == "artisticPaintBrush" )
908 return XML_artisticPaintBrush;
909 else if( sName == "artisticPastelsSmooth" )
910 return XML_artisticPastelsSmooth;
911 else if( sName == "artisticPencilGrayscale" )
912 return XML_artisticPencilGrayscale;
913 else if( sName == "artisticPencilSketch" )
914 return XML_artisticPencilSketch;
915 else if( sName == "artisticPhotocopy" )
916 return XML_artisticPhotocopy;
917 else if( sName == "artisticPlasticWrap" )
918 return XML_artisticPlasticWrap;
919 else if( sName == "artisticTexturizer" )
920 return XML_artisticTexturizer;
921 else if( sName == "artisticWatercolorSponge" )
922 return XML_artisticWatercolorSponge;
923 else if( sName == "brightnessContrast" )
924 return XML_brightnessContrast;
925 else if( sName == "colorTemperature" )
926 return XML_colorTemperature;
927 else if( sName == "saturation" )
928 return XML_saturation;
929 else if( sName == "sharpenSoften" )
930 return XML_sharpenSoften;
932 // attributes
933 else if( sName == "visible" )
934 return XML_visible;
935 else if( sName == "trans" )
936 return XML_trans;
937 else if( sName == "crackSpacing" )
938 return XML_crackSpacing;
939 else if( sName == "pressure" )
940 return XML_pressure;
941 else if( sName == "numberOfShades" )
942 return XML_numberOfShades;
943 else if( sName == "grainSize" )
944 return XML_grainSize;
945 else if( sName == "intensity" )
946 return XML_intensity;
947 else if( sName == "smoothness" )
948 return XML_smoothness;
949 else if( sName == "gridSize" )
950 return XML_gridSize;
951 else if( sName == "pencilSize" )
952 return XML_pencilSize;
953 else if( sName == "size" )
954 return XML_size;
955 else if( sName == "brushSize" )
956 return XML_brushSize;
957 else if( sName == "scaling" )
958 return XML_scaling;
959 else if( sName == "detail" )
960 return XML_detail;
961 else if( sName == "bright" )
962 return XML_bright;
963 else if( sName == "contrast" )
964 return XML_contrast;
965 else if( sName == "colorTemp" )
966 return XML_colorTemp;
967 else if( sName == "sat" )
968 return XML_sat;
969 else if( sName == "amount" )
970 return XML_amount;
972 SAL_WARN( "oox.drawingml", "ArtisticEffectProperties::getEffectToken - unexpected token name" );
973 return XML_none;
976 } // namespace drawingml
977 } // namespace oox
979 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */