fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / oox / source / drawingml / fillproperties.cxx
blob2c0d40f0ccd97fcbe959bb480e4764dc12469c31
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 <iterator>
21 #include <boost/utility.hpp>
23 #include <oox/drawingml/fillproperties.hxx>
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/tokens.hxx"
42 #include <rtl/math.hxx>
43 #include <osl/diagnose.h>
45 using namespace ::com::sun::star;
46 using namespace ::com::sun::star::drawing;
47 using namespace ::com::sun::star::graphic;
49 using ::com::sun::star::uno::Reference;
50 using ::com::sun::star::uno::Exception;
51 using ::com::sun::star::uno::UNO_QUERY;
52 using ::com::sun::star::uno::UNO_QUERY_THROW;
53 using ::com::sun::star::geometry::IntegerRectangle2D;
55 namespace oox {
56 namespace drawingml {
58 namespace {
60 Reference< XGraphic > lclCheckAndApplyDuotoneTransform( const BlipFillProperties& aBlipProps, Reference< XGraphic > xGraphic,
61 const GraphicHelper& rGraphicHelper, const sal_Int32 nPhClr )
63 if( aBlipProps.maDuotoneColors[0].isUsed() && aBlipProps.maDuotoneColors[1].isUsed() )
65 sal_Int32 nColor1 = aBlipProps.maDuotoneColors[0].getColor( rGraphicHelper, nPhClr );
66 sal_Int32 nColor2 = aBlipProps.maDuotoneColors[1].getColor( rGraphicHelper, nPhClr );
67 try
69 Reference< XGraphicTransformer > xTransformer( aBlipProps.mxGraphic, UNO_QUERY_THROW );
70 xGraphic = xTransformer->applyDuotone( xGraphic, nColor1, nColor2 );
72 catch( Exception& )
76 return xGraphic;
79 Reference< XGraphic > lclCheckAndApplyChangeColorTransform( const BlipFillProperties &aBlipProps, Reference< XGraphic > xGraphic,
80 const GraphicHelper& rGraphicHelper, const sal_Int32 nPhClr )
82 if( aBlipProps.maColorChangeFrom.isUsed() && aBlipProps.maColorChangeTo.isUsed() )
84 sal_Int32 nFromColor = aBlipProps.maColorChangeFrom.getColor( rGraphicHelper, nPhClr );
85 sal_Int32 nToColor = aBlipProps.maColorChangeTo.getColor( rGraphicHelper, nPhClr );
86 if ( (nFromColor != nToColor) || aBlipProps.maColorChangeTo.hasTransparency() ) try
88 sal_Int16 nToTransparence = aBlipProps.maColorChangeTo.getTransparency();
89 sal_Int8 nToAlpha = static_cast< sal_Int8 >( (100 - nToTransparence) * 2.55 );
90 Reference< XGraphicTransformer > xTransformer( aBlipProps.mxGraphic, UNO_QUERY_THROW );
91 xGraphic = xTransformer->colorChange( xGraphic, nFromColor, 9, nToColor, nToAlpha );
93 catch( Exception& )
97 return xGraphic;
100 Reference< XGraphic > applyBrightnessContrast( Reference< XGraphic > xGraphic, sal_Int32 brightness, sal_Int32 contrast )
104 Reference< XGraphicTransformer > xTransformer( xGraphic, UNO_QUERY_THROW );
105 xGraphic = xTransformer->applyBrightnessContrast( xGraphic, brightness, contrast, true );
107 catch( Exception& )
110 return xGraphic;
113 BitmapMode lclGetBitmapMode( sal_Int32 nToken )
115 OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
116 switch( nToken )
118 case XML_tile: return BitmapMode_REPEAT;
119 case XML_stretch: return BitmapMode_STRETCH;
121 return BitmapMode_NO_REPEAT;
124 RectanglePoint lclGetRectanglePoint( sal_Int32 nToken )
126 OSL_ASSERT((nToken & sal_Int32(0xFFFF0000))==0);
127 switch( nToken )
129 case XML_tl: return RectanglePoint_LEFT_TOP;
130 case XML_t: return RectanglePoint_MIDDLE_TOP;
131 case XML_tr: return RectanglePoint_RIGHT_TOP;
132 case XML_l: return RectanglePoint_LEFT_MIDDLE;
133 case XML_ctr: return RectanglePoint_MIDDLE_MIDDLE;
134 case XML_r: return RectanglePoint_RIGHT_MIDDLE;
135 case XML_bl: return RectanglePoint_LEFT_BOTTOM;
136 case XML_b: return RectanglePoint_MIDDLE_BOTTOM;
137 case XML_br: return RectanglePoint_RIGHT_BOTTOM;
139 return RectanglePoint_LEFT_TOP;
142 const awt::Size lclGetOriginalSize( const GraphicHelper& rGraphicHelper, const Reference< XGraphic >& rxGraphic )
144 awt::Size aSizeHmm( 0, 0 );
147 Reference< beans::XPropertySet > xGraphicPropertySet( rxGraphic, UNO_QUERY_THROW );
148 if( xGraphicPropertySet->getPropertyValue( "Size100thMM" ) >>= aSizeHmm )
150 if( !aSizeHmm.Width && !aSizeHmm.Height )
151 { // MAPMODE_PIXEL USED :-(
152 awt::Size aSourceSizePixel( 0, 0 );
153 if( xGraphicPropertySet->getPropertyValue( "SizePixel" ) >>= aSourceSizePixel )
154 aSizeHmm = rGraphicHelper.convertScreenPixelToHmm( aSourceSizePixel );
158 catch( Exception& )
161 return aSizeHmm;
164 } // namespace
166 void GradientFillProperties::assignUsed( const GradientFillProperties& rSourceProps )
168 if( !rSourceProps.maGradientStops.empty() )
169 maGradientStops = rSourceProps.maGradientStops;
170 moFillToRect.assignIfUsed( rSourceProps.moFillToRect );
171 moTileRect.assignIfUsed( rSourceProps.moTileRect );
172 moGradientPath.assignIfUsed( rSourceProps.moGradientPath );
173 moShadeAngle.assignIfUsed( rSourceProps.moShadeAngle );
174 moShadeFlip.assignIfUsed( rSourceProps.moShadeFlip );
175 moShadeScaled.assignIfUsed( rSourceProps.moShadeScaled );
176 moRotateWithShape.assignIfUsed( rSourceProps.moRotateWithShape );
179 void PatternFillProperties::assignUsed( const PatternFillProperties& rSourceProps )
181 maPattFgColor.assignIfUsed( rSourceProps.maPattFgColor );
182 maPattBgColor.assignIfUsed( rSourceProps.maPattBgColor );
183 moPattPreset.assignIfUsed( rSourceProps.moPattPreset );
186 void BlipFillProperties::assignUsed( const BlipFillProperties& rSourceProps )
188 if( rSourceProps.mxGraphic.is() )
189 mxGraphic = rSourceProps.mxGraphic;
190 moBitmapMode.assignIfUsed( rSourceProps.moBitmapMode );
191 moFillRect.assignIfUsed( rSourceProps.moFillRect );
192 moTileOffsetX.assignIfUsed( rSourceProps.moTileOffsetX );
193 moTileOffsetY.assignIfUsed( rSourceProps.moTileOffsetY );
194 moTileScaleX.assignIfUsed( rSourceProps.moTileScaleX );
195 moTileScaleY.assignIfUsed( rSourceProps.moTileScaleY );
196 moTileAlign.assignIfUsed( rSourceProps.moTileAlign );
197 moTileFlip.assignIfUsed( rSourceProps.moTileFlip );
198 moRotateWithShape.assignIfUsed( rSourceProps.moRotateWithShape );
199 moColorEffect.assignIfUsed( rSourceProps.moColorEffect );
200 moBrightness.assignIfUsed( rSourceProps.moBrightness );
201 moContrast.assignIfUsed( rSourceProps.moContrast );
202 maColorChangeFrom.assignIfUsed( rSourceProps.maColorChangeFrom );
203 maColorChangeTo.assignIfUsed( rSourceProps.maColorChangeTo );
204 maDuotoneColors[0].assignIfUsed( rSourceProps.maDuotoneColors[0] );
205 maDuotoneColors[1].assignIfUsed( rSourceProps.maDuotoneColors[1] );
206 maEffect.assignUsed( rSourceProps.maEffect );
209 void FillProperties::assignUsed( const FillProperties& rSourceProps )
211 moFillType.assignIfUsed( rSourceProps.moFillType );
212 maFillColor.assignIfUsed( rSourceProps.maFillColor );
213 maGradientProps.assignUsed( rSourceProps.maGradientProps );
214 maPatternProps.assignUsed( rSourceProps.maPatternProps );
215 maBlipProps.assignUsed( rSourceProps.maBlipProps );
218 Color FillProperties::getBestSolidColor() const
220 Color aSolidColor;
221 if( moFillType.has() ) switch( moFillType.get() )
223 case XML_solidFill:
224 aSolidColor = maFillColor;
225 break;
226 case XML_gradFill:
227 if( !maGradientProps.maGradientStops.empty() )
229 GradientFillProperties::GradientStopMap::const_iterator aGradientStop =
230 maGradientProps.maGradientStops.begin();
231 if (maGradientProps.maGradientStops.size() > 2)
232 ++aGradientStop;
233 aSolidColor = aGradientStop->second;
235 break;
236 case XML_pattFill:
237 aSolidColor = maPatternProps.maPattBgColor.isUsed() ? maPatternProps.maPattBgColor : maPatternProps.maPattFgColor;
238 break;
240 return aSolidColor;
243 /// Maps the hatch token to drawing::Hatch.
244 static drawing::Hatch createHatch( sal_Int32 nHatchToken, sal_Int32 nColor )
246 drawing::Hatch aHatch;
247 aHatch.Color = nColor;
249 // best-effort mapping; we do not support all the styles in core
250 switch ( nHatchToken )
252 case XML_pct5: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 250; aHatch.Angle = 450; break;
253 case XML_pct10: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 450; break;
254 case XML_pct20: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
255 case XML_pct25: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 200; aHatch.Angle = 450; break;
256 case XML_pct30: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 175; aHatch.Angle = 450; break;
257 case XML_pct40: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
258 case XML_pct50: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 125; aHatch.Angle = 450; break;
259 case XML_pct60: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
260 case XML_pct70: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 125; aHatch.Angle = 450; break;
261 case XML_pct75: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
262 case XML_pct80: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 75; aHatch.Angle = 450; break;
263 case XML_pct90: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 50; aHatch.Angle = 450; break;
264 case XML_horz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
265 case XML_vert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 900; break;
266 case XML_ltHorz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 0; break;
267 case XML_ltVert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 900; break;
268 case XML_dkHorz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 25; aHatch.Angle = 0; break;
269 case XML_dkVert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 25; aHatch.Angle = 900; break;
270 case XML_narHorz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 0; break;
271 case XML_narVert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 900; break;
272 case XML_dashHorz: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 0; break;
273 case XML_dashVert: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 900; break;
274 case XML_cross: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
275 case XML_dnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 1350; break;
276 case XML_upDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
277 case XML_ltDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 1350; break;
278 case XML_ltUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 450; break;
279 case XML_dkDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 1350; break;
280 case XML_dkUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 50; aHatch.Angle = 450; break;
281 case XML_wdDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 1350; break;
282 case XML_wdUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
283 case XML_dashDnDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 1350; break;
284 case XML_dashUpDiag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
285 case XML_diagCross: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
286 case XML_smCheck: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 50; aHatch.Angle = 450; break;
287 case XML_lgCheck: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
288 case XML_smGrid: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 50; aHatch.Angle = 0; break;
289 case XML_lgGrid: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
290 case XML_dotGrid: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 400; aHatch.Angle = 0; break;
291 case XML_smConfetti: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 600; break;
292 case XML_lgConfetti: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 600; break;
293 case XML_horzBrick: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 0; break;
294 case XML_diagBrick: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 450; break;
295 case XML_solidDmnd: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
296 case XML_openDmnd: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 100; aHatch.Angle = 450; break;
297 case XML_dotDmnd: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 300; aHatch.Angle = 450; break;
298 case XML_plaid: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 200; aHatch.Angle = 900; break;
299 case XML_sphere: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
300 case XML_weave: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 150; aHatch.Angle = 450; break;
301 case XML_divot: aHatch.Style = drawing::HatchStyle_TRIPLE; aHatch.Distance = 400; aHatch.Angle = 450; break;
302 case XML_shingle: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 200; aHatch.Angle = 1350; break;
303 case XML_wave: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 100; aHatch.Angle = 0; break;
304 case XML_trellis: aHatch.Style = drawing::HatchStyle_DOUBLE; aHatch.Distance = 75; aHatch.Angle = 450; break;
305 case XML_zigZag: aHatch.Style = drawing::HatchStyle_SINGLE; aHatch.Distance = 75; aHatch.Angle = 0; break;
308 return aHatch;
311 void FillProperties::pushToPropMap( ShapePropertyMap& rPropMap,
312 const GraphicHelper& rGraphicHelper, sal_Int32 nShapeRotation, sal_Int32 nPhClr,
313 bool bFlipH, bool bFlipV ) const
315 if( moFillType.has() )
317 FillStyle eFillStyle = FillStyle_NONE;
318 OSL_ASSERT((moFillType.get() & sal_Int32(0xFFFF0000))==0);
319 switch( moFillType.get() )
321 case XML_noFill:
322 eFillStyle = FillStyle_NONE;
323 break;
325 case XML_solidFill:
326 if( maFillColor.isUsed() )
328 rPropMap.setProperty( SHAPEPROP_FillColor, maFillColor.getColor( rGraphicHelper, nPhClr ) );
329 if( maFillColor.hasTransparency() )
330 rPropMap.setProperty( SHAPEPROP_FillTransparency, maFillColor.getTransparency() );
331 eFillStyle = FillStyle_SOLID;
333 break;
335 case XML_gradFill:
336 // do not create gradient struct if property is not supported...
337 if( rPropMap.supportsProperty( SHAPEPROP_FillGradient ) )
339 sal_Int32 nEndTrans = 0;
340 sal_Int32 nStartTrans = 0;
341 awt::Gradient aGradient;
342 aGradient.Angle = 900;
343 aGradient.StartIntensity = 100;
344 aGradient.EndIntensity = 100;
346 // Old code, values in aGradient overwritten in many cases by newer code below
347 if( maGradientProps.maGradientStops.size() > 1 )
349 aGradient.StartColor = maGradientProps.maGradientStops.begin()->second.getColor( rGraphicHelper, nPhClr );
350 aGradient.EndColor = maGradientProps.maGradientStops.rbegin()->second.getColor( rGraphicHelper, nPhClr );
351 if( maGradientProps.maGradientStops.rbegin()->second.hasTransparency() )
352 nEndTrans = maGradientProps.maGradientStops.rbegin()->second.getTransparency()*255/100;
353 if( maGradientProps.maGradientStops.begin()->second.hasTransparency() )
354 nStartTrans = maGradientProps.maGradientStops.begin()->second.getTransparency()*255/100;
357 // Adjust for flips
358 if ( bFlipH )
359 nShapeRotation = 180*60000 - nShapeRotation;
360 if ( bFlipV )
361 nShapeRotation = -nShapeRotation;
363 // "rotate with shape" not set, or set to false -> do not rotate
364 if ( !maGradientProps.moRotateWithShape.get( false ) )
365 nShapeRotation = 0;
367 sal_Int32 nDmlAngle = 0;
368 if( maGradientProps.moGradientPath.has() )
370 aGradient.Style = (maGradientProps.moGradientPath.get() == XML_circle) ? awt::GradientStyle_ELLIPTICAL : awt::GradientStyle_RECT;
371 // position of gradient center (limited to [30%;70%], otherwise gradient is too hidden)
372 IntegerRectangle2D aFillToRect = maGradientProps.moFillToRect.get( IntegerRectangle2D( 0, 0, MAX_PERCENT, MAX_PERCENT ) );
373 sal_Int32 nCenterX = (MAX_PERCENT + aFillToRect.X1 - aFillToRect.X2) / 2;
374 aGradient.XOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterX / PER_PERCENT, 30, 70 );
375 sal_Int32 nCenterY = (MAX_PERCENT + aFillToRect.Y1 - aFillToRect.Y2) / 2;
376 aGradient.YOffset = getLimitedValue< sal_Int16, sal_Int32 >( nCenterY / PER_PERCENT, 30, 70 );
377 ::std::swap( aGradient.StartColor, aGradient.EndColor );
378 ::std::swap( nStartTrans, nEndTrans );
379 nDmlAngle = nShapeRotation;
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( boost::prior( 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 = boost::prior(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 - boost::prior(aIt)->first > nWidestWidth )
460 nWidestWidth = aIt->first - boost::prior(aIt)->first;
461 aWidestSegmentStart = boost::prior(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 ) == boost::next(aGradientStops.begin())->second.getColor( rGraphicHelper, nPhClr ) &&
475 aGradientStops.begin()->second.getTransparency() == boost::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 = boost::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 boost::next(aGradientStops.begin())->second.getColor( rGraphicHelper, nPhClr ) == boost::prior(aGradientStops.end())->second.getColor( rGraphicHelper, nPhClr ) &&
486 boost::next(aGradientStops.begin())->second.getTransparency() == boost::prior(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 = boost::prior(aGradientStops.end())->first - boost::next(aGradientStops.begin())->first;
491 aGradientStops.erase(boost::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 ) == boost::next(aWidestSegmentStart)->second.getColor( rGraphicHelper, nPhClr ) &&
499 aWidestSegmentStart->second.getTransparency() == boost::next(aWidestSegmentStart)->second.getTransparency() &&
500 ( aWidestSegmentStart == aGradientStops.begin() ||
501 boost::next(aWidestSegmentStart) == boost::prior( 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 = boost::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( boost::next(aWidestSegmentStart) == boost::prior( aGradientStops.end() ) )
511 bSwap = true;
512 nShapeRotation = 180*60000 - nShapeRotation;
515 aGradientStops.erase( aWidestSegmentStart++ );
517 // Look for which is widest now
518 aIt = boost::next(aGradientStops.begin());
519 nWidestWidth = -1;
520 while( aIt != aGradientStops.end() )
522 if( aIt->first - boost::prior(aIt)->first > nWidestWidth )
524 nWidestWidth = aIt->first - boost::prior(aIt)->first;
525 aWidestSegmentStart = boost::prior(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 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 = boost::next(aWidestSegmentStart)->second;
543 aEndColor = aWidestSegmentStart->second;
544 nBorder *= 2;
546 else if( bSwap )
548 aStartColor = boost::next(aWidestSegmentStart)->second;
549 aEndColor = aWidestSegmentStart->second;
551 else
553 aStartColor = aWidestSegmentStart->second;
554 aEndColor = boost::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( SHAPEPROP_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( SHAPEPROP_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( SHAPEPROP_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( SHAPEPROP_FillBitmapNameFromUrl ) && rPropMap.setProperty( SHAPEPROP_FillBitmapNameFromUrl, aGraphicUrl ) )
601 eFillStyle = FillStyle_BITMAP;
602 else if( !aGraphicUrl.isEmpty() && rPropMap.setProperty( SHAPEPROP_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( SHAPEPROP_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( SHAPEPROP_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( SHAPEPROP_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( SHAPEPROP_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( SHAPEPROP_FillBitmapOffsetX, nTileOffsetX );
633 sal_Int16 nTileOffsetY = getDoubleIntervalValue< sal_Int16 >( maBlipProps.moTileOffsetY.get( 0 ) / 3.6 / aOriginalSize.Height, 0, 100 );
634 rPropMap.setProperty( SHAPEPROP_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 break;
659 case XML_pattFill:
661 if( rPropMap.supportsProperty( SHAPEPROP_FillHatch ) )
663 Color aColor( maPatternProps.maPattFgColor );
664 if( aColor.isUsed() && maPatternProps.moPattPreset.has() )
666 // we do not support hatches that have background
667 // color too, so all this is some best-effort approach
668 eFillStyle = FillStyle_HATCH;
669 rPropMap.setProperty( SHAPEPROP_FillHatch, createHatch( maPatternProps.moPattPreset.get(), aColor.getColor( rGraphicHelper, nPhClr ) ) );
671 else if ( maPatternProps.maPattBgColor.isUsed() )
673 aColor = maPatternProps.maPattBgColor;
674 rPropMap.setProperty( SHAPEPROP_FillColor, aColor.getColor( rGraphicHelper, nPhClr ) );
675 if( aColor.hasTransparency() )
676 rPropMap.setProperty( SHAPEPROP_FillTransparency, aColor.getTransparency() );
677 eFillStyle = FillStyle_SOLID;
681 break;
683 case XML_grpFill:
684 // todo
685 eFillStyle = FillStyle_NONE;
686 break;
689 // set final fill style property
690 rPropMap.setProperty( SHAPEPROP_FillStyle, eFillStyle );
694 void GraphicProperties::pushToPropMap( PropertyMap& rPropMap, const GraphicHelper& rGraphicHelper, sal_Int32 nPhClr ) const
696 sal_Int16 nBrightness = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moBrightness.get( 0 ) / PER_PERCENT, -100, 100 );
697 sal_Int16 nContrast = getLimitedValue< sal_Int16, sal_Int32 >( maBlipProps.moContrast.get( 0 ) / PER_PERCENT, -100, 100 );
698 if( maBlipProps.mxGraphic.is() )
700 // created transformed graphic
701 Reference< XGraphic > xGraphic = lclCheckAndApplyDuotoneTransform( maBlipProps, maBlipProps.mxGraphic, rGraphicHelper, nPhClr );
702 xGraphic = lclCheckAndApplyChangeColorTransform( maBlipProps, xGraphic, rGraphicHelper, nPhClr );
703 // MSO uses a different algorithm for contrast+brightness, LO applies contrast before brightness,
704 // while MSO apparently applies half of brightness before contrast and half after. So if only
705 // contrast or brightness need to be altered, the result is the same, but if both are involved,
706 // there's no way to map that, so just force a conversion of the image.
707 if( nBrightness != 0 && nContrast != 0 )
709 xGraphic = applyBrightnessContrast( xGraphic, nBrightness, nContrast );
710 nBrightness = 0;
711 nContrast = 0;
713 rPropMap.setProperty(PROP_Graphic, xGraphic);
715 // do we still need to set GraphicURL as well? (TODO)
716 OUString aGraphicUrl = rGraphicHelper.createGraphicObject( xGraphic );
717 if( !aGraphicUrl.isEmpty() )
718 rPropMap.setProperty(PROP_GraphicURL, aGraphicUrl);
720 // cropping
721 if ( maBlipProps.moClipRect.has() )
723 geometry::IntegerRectangle2D oClipRect( maBlipProps.moClipRect.get() );
724 awt::Size aOriginalSize( rGraphicHelper.getOriginalSize( xGraphic ) );
725 if ( aOriginalSize.Width && aOriginalSize.Height )
727 text::GraphicCrop aGraphCrop( 0, 0, 0, 0 );
728 if ( oClipRect.X1 )
729 aGraphCrop.Left = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X1 ) / 100000 );
730 if ( oClipRect.Y1 )
731 aGraphCrop.Top = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y1 ) / 100000 );
732 if ( oClipRect.X2 )
733 aGraphCrop.Right = rtl::math::round( ( static_cast< double >( aOriginalSize.Width ) * oClipRect.X2 ) / 100000 );
734 if ( oClipRect.Y2 )
735 aGraphCrop.Bottom = rtl::math::round( ( static_cast< double >( aOriginalSize.Height ) * oClipRect.Y2 ) / 100000 );
736 rPropMap.setProperty(PROP_GraphicCrop, aGraphCrop);
741 // color effect
742 ColorMode eColorMode = ColorMode_STANDARD;
743 switch( maBlipProps.moColorEffect.get( XML_TOKEN_INVALID ) )
745 case XML_biLevel: eColorMode = ColorMode_MONO; break;
746 case XML_grayscl: eColorMode = ColorMode_GREYS; break;
748 rPropMap.setProperty(PROP_GraphicColorMode, eColorMode);
750 // brightness and contrast
751 if( nBrightness != 0 )
752 rPropMap.setProperty(PROP_AdjustLuminance, nBrightness);
753 if( nContrast != 0 )
754 rPropMap.setProperty(PROP_AdjustContrast, nContrast);
756 // Media content
757 assert(m_xMediaStream.is() != m_sMediaPackageURL.isEmpty());
758 if (m_xMediaStream.is() && !m_sMediaPackageURL.isEmpty())
760 rPropMap.setProperty(PROP_PrivateStream, m_xMediaStream);
761 rPropMap.setProperty(PROP_MediaURL, m_sMediaPackageURL);
765 bool ArtisticEffectProperties::isEmpty() const
767 return msName.isEmpty();
770 css::beans::PropertyValue ArtisticEffectProperties::getEffect()
772 css::beans::PropertyValue pRet;
773 if( msName.isEmpty() )
774 return pRet;
776 css::uno::Sequence< css::beans::PropertyValue > aSeq( maAttribs.size() + 1 );
777 sal_uInt32 i = 0;
778 for( std::map< OUString, css::uno::Any >::iterator it = maAttribs.begin(); it != maAttribs.end(); ++it )
780 aSeq[i].Name = it->first;
781 aSeq[i].Value = it->second;
782 i++;
785 if( mrOleObjectInfo.maEmbeddedData.hasElements() )
787 css::uno::Sequence< css::beans::PropertyValue > aGraphicSeq( 2 );
788 aGraphicSeq[0].Name = "Id";
789 aGraphicSeq[0].Value = uno::makeAny( mrOleObjectInfo.maProgId );
790 aGraphicSeq[1].Name = "Data";
791 aGraphicSeq[1].Value = uno::makeAny( mrOleObjectInfo.maEmbeddedData );
793 aSeq[i].Name = "OriginalGraphic";
794 aSeq[i].Value = uno::makeAny( aGraphicSeq );
797 pRet.Name = msName;
798 pRet.Value = css::uno::Any( aSeq );
800 return pRet;
803 void ArtisticEffectProperties::assignUsed( const ArtisticEffectProperties& rSourceProps )
805 if( !rSourceProps.isEmpty() )
807 msName = rSourceProps.msName;
808 maAttribs = rSourceProps.maAttribs;
812 OUString ArtisticEffectProperties::getEffectString( sal_Int32 nToken )
814 switch( nToken )
816 // effects
817 case OOX_TOKEN( a14, artisticBlur ): return OUString( "artisticBlur" );
818 case OOX_TOKEN( a14, artisticCement ): return OUString( "artisticCement" );
819 case OOX_TOKEN( a14, artisticChalkSketch ): return OUString( "artisticChalkSketch" );
820 case OOX_TOKEN( a14, artisticCrisscrossEtching ): return OUString( "artisticCrisscrossEtching" );
821 case OOX_TOKEN( a14, artisticCutout ): return OUString( "artisticCutout" );
822 case OOX_TOKEN( a14, artisticFilmGrain ): return OUString( "artisticFilmGrain" );
823 case OOX_TOKEN( a14, artisticGlass ): return OUString( "artisticGlass" );
824 case OOX_TOKEN( a14, artisticGlowDiffused ): return OUString( "artisticGlowDiffused" );
825 case OOX_TOKEN( a14, artisticGlowEdges ): return OUString( "artisticGlowEdges" );
826 case OOX_TOKEN( a14, artisticLightScreen ): return OUString( "artisticLightScreen" );
827 case OOX_TOKEN( a14, artisticLineDrawing ): return OUString( "artisticLineDrawing" );
828 case OOX_TOKEN( a14, artisticMarker ): return OUString( "artisticMarker" );
829 case OOX_TOKEN( a14, artisticMosiaicBubbles ): return OUString( "artisticMosiaicBubbles" );
830 case OOX_TOKEN( a14, artisticPaintStrokes ): return OUString( "artisticPaintStrokes" );
831 case OOX_TOKEN( a14, artisticPaintBrush ): return OUString( "artisticPaintBrush" );
832 case OOX_TOKEN( a14, artisticPastelsSmooth ): return OUString( "artisticPastelsSmooth" );
833 case OOX_TOKEN( a14, artisticPencilGrayscale ): return OUString( "artisticPencilGrayscale" );
834 case OOX_TOKEN( a14, artisticPencilSketch ): return OUString( "artisticPencilSketch" );
835 case OOX_TOKEN( a14, artisticPhotocopy ): return OUString( "artisticPhotocopy" );
836 case OOX_TOKEN( a14, artisticPlasticWrap ): return OUString( "artisticPlasticWrap" );
837 case OOX_TOKEN( a14, artisticTexturizer ): return OUString( "artisticTexturizer" );
838 case OOX_TOKEN( a14, artisticWatercolorSponge ): return OUString( "artisticWatercolorSponge" );
839 case OOX_TOKEN( a14, artisticBrightnessContrast ): return OUString( "artisticBrightnessContrast" );
840 case OOX_TOKEN( a14, artisticColorTemperature ): return OUString( "artisticColorTemperature" );
841 case OOX_TOKEN( a14, artisticSaturation ): return OUString( "artisticSaturation" );
842 case OOX_TOKEN( a14, artisticSharpenSoften ): return OUString( "artisticSharpenSoften" );
844 // attributes
845 case XML_visible: return OUString( "visible" );
846 case XML_trans: return OUString( "trans" );
847 case XML_crackSpacing: return OUString( "crackSpacing" );
848 case XML_pressure: return OUString( "pressure" );
849 case XML_numberOfShades: return OUString( "numberOfShades" );
850 case XML_grainSize: return OUString( "grainSize" );
851 case XML_intensity: return OUString( "intensity" );
852 case XML_smoothness: return OUString( "smoothness" );
853 case XML_gridSize: return OUString( "gridSize" );
854 case XML_pencilSize: return OUString( "pencilSize" );
855 case XML_size: return OUString( "size" );
856 case XML_brushSize: return OUString( "brushSize" );
857 case XML_scaling: return OUString( "scaling" );
858 case XML_detail: return OUString( "detail" );
859 case XML_bright: return OUString( "bright" );
860 case XML_contrast: return OUString( "contrast" );
861 case XML_colorTemp: return OUString( "colorTemp" );
862 case XML_sat: return OUString( "sat" );
863 case XML_amount: return OUString( "amount" );
865 SAL_WARN( "oox.drawingml", "ArtisticEffectProperties::getEffectString - unexpected token" );
866 return OUString();
869 sal_Int32 ArtisticEffectProperties::getEffectToken( const OUString& sName )
871 // effects
872 if( sName == "artisticBlur" )
873 return XML_artisticBlur;
874 else if( sName == "artisticCement" )
875 return XML_artisticCement;
876 else if( sName == "artisticChalkSketch" )
877 return XML_artisticChalkSketch;
878 else if( sName == "artisticCrisscrossEtching" )
879 return XML_artisticCrisscrossEtching;
880 else if( sName == "artisticCutout" )
881 return XML_artisticCutout;
882 else if( sName == "artisticFilmGrain" )
883 return XML_artisticFilmGrain;
884 else if( sName == "artisticGlass" )
885 return XML_artisticGlass;
886 else if( sName == "artisticGlowDiffused" )
887 return XML_artisticGlowDiffused;
888 else if( sName == "artisticGlowEdges" )
889 return XML_artisticGlowEdges;
890 else if( sName == "artisticLightScreen" )
891 return XML_artisticLightScreen;
892 else if( sName == "artisticLineDrawing" )
893 return XML_artisticLineDrawing;
894 else if( sName == "artisticMarker" )
895 return XML_artisticMarker;
896 else if( sName == "artisticMosiaicBubbles" )
897 return XML_artisticMosiaicBubbles;
898 else if( sName == "artisticPaintStrokes" )
899 return XML_artisticPaintStrokes;
900 else if( sName == "artisticPaintBrush" )
901 return XML_artisticPaintBrush;
902 else if( sName == "artisticPastelsSmooth" )
903 return XML_artisticPastelsSmooth;
904 else if( sName == "artisticPencilGrayscale" )
905 return XML_artisticPencilGrayscale;
906 else if( sName == "artisticPencilSketch" )
907 return XML_artisticPencilSketch;
908 else if( sName == "artisticPhotocopy" )
909 return XML_artisticPhotocopy;
910 else if( sName == "artisticPlasticWrap" )
911 return XML_artisticPlasticWrap;
912 else if( sName == "artisticTexturizer" )
913 return XML_artisticTexturizer;
914 else if( sName == "artisticWatercolorSponge" )
915 return XML_artisticWatercolorSponge;
916 else if( sName == "artisticBrightnessContrast" )
917 return XML_artisticBrightnessContrast;
918 else if( sName == "artisticColorTemperature" )
919 return XML_artisticColorTemperature;
920 else if( sName == "artisticSaturation" )
921 return XML_artisticSaturation;
922 else if( sName == "artisticSharpenSoften" )
923 return XML_artisticSharpenSoften;
925 // attributes
926 else if( sName == "visible" )
927 return XML_visible;
928 else if( sName == "trans" )
929 return XML_trans;
930 else if( sName == "crackSpacing" )
931 return XML_crackSpacing;
932 else if( sName == "pressure" )
933 return XML_pressure;
934 else if( sName == "numberOfShades" )
935 return XML_numberOfShades;
936 else if( sName == "grainSize" )
937 return XML_grainSize;
938 else if( sName == "intensity" )
939 return XML_intensity;
940 else if( sName == "smoothness" )
941 return XML_smoothness;
942 else if( sName == "gridSize" )
943 return XML_gridSize;
944 else if( sName == "pencilSize" )
945 return XML_pencilSize;
946 else if( sName == "size" )
947 return XML_size;
948 else if( sName == "brushSize" )
949 return XML_brushSize;
950 else if( sName == "scaling" )
951 return XML_scaling;
952 else if( sName == "detail" )
953 return XML_detail;
954 else if( sName == "bright" )
955 return XML_bright;
956 else if( sName == "contrast" )
957 return XML_contrast;
958 else if( sName == "colorTemp" )
959 return XML_colorTemp;
960 else if( sName == "sat" )
961 return XML_sat;
962 else if( sName == "amount" )
963 return XML_amount;
965 SAL_WARN( "oox.drawingml", "ArtisticEffectProperties::getEffectToken - unexpected token name" );
966 return XML_none;
969 } // namespace drawingml
970 } // namespace oox
972 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */