1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef OOX_DRAWINGML_FILLPROPERTIES_HXX 25 #define OOX_DRAWINGML_FILLPROPERTIES_HXX 26 27 #include <map> 28 #include <com/sun/star/graphic/XGraphic.hpp> 29 #include <com/sun/star/geometry/IntegerRectangle2D.hpp> 30 #include "oox/drawingml/color.hxx" 31 #include "oox/helper/helper.hxx" 32 33 namespace oox { 34 class GraphicHelper; 35 class PropertyMap; 36 class PropertySet; 37 } 38 39 namespace oox { 40 namespace drawingml { 41 42 class ShapePropertyMap; 43 44 // ============================================================================ 45 46 struct GradientFillProperties 47 { 48 typedef ::std::map< double, Color > GradientStopMap; 49 50 GradientStopMap maGradientStops; /// Gradient stops (colors/transparence). 51 OptValue< ::com::sun::star::geometry::IntegerRectangle2D > moFillToRect; 52 OptValue< ::com::sun::star::geometry::IntegerRectangle2D > moTileRect; 53 OptValue< sal_Int32 > moGradientPath; /// If set, gradient follows rectangle, circle, or shape. 54 OptValue< sal_Int32 > moShadeAngle; /// Rotation angle of linear gradients. 55 OptValue< sal_Int32 > moShadeFlip; /// Flip mode of gradient, if not stretched to shape. 56 OptValue< bool > moShadeScaled; /// True = scale gradient into shape. 57 OptValue< bool > moRotateWithShape; /// True = rotate gradient with shape. 58 59 /** Overwrites all members that are explicitly set in rSourceProps. */ 60 void assignUsed( const GradientFillProperties& rSourceProps ); 61 }; 62 63 // ============================================================================ 64 65 struct PatternFillProperties 66 { 67 Color maPattFgColor; /// Pattern foreground color. 68 Color maPattBgColor; /// Pattern background color. 69 OptValue< sal_Int32 > moPattPreset; /// Preset pattern type. 70 71 /** Overwrites all members that are explicitly set in rSourceProps. */ 72 void assignUsed( const PatternFillProperties& rSourceProps ); 73 }; 74 75 // ============================================================================ 76 77 struct BlipFillProperties 78 { 79 ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > 80 mxGraphic; /// The fill graphic. 81 OptValue< sal_Int32 > moBitmapMode; /// Bitmap tile or stretch. 82 OptValue< ::com::sun::star::geometry::IntegerRectangle2D > 83 moFillRect; /// Stretch fill offsets. 84 OptValue< ::com::sun::star::geometry::IntegerRectangle2D > 85 moClipRect; 86 OptValue< sal_Int32 > moTileOffsetX; /// Width of bitmap tiles (EMUs). 87 OptValue< sal_Int32 > moTileOffsetY; /// Height of bitmap tiles (EMUs). 88 OptValue< sal_Int32 > moTileScaleX; /// Horizontal scaling of bitmap tiles (1/1000 percent). 89 OptValue< sal_Int32 > moTileScaleY; /// Vertical scaling of bitmap tiles (1/1000 percent). 90 OptValue< sal_Int32 > moTileAlign; /// Anchor point inside bitmap. 91 OptValue< sal_Int32 > moTileFlip; /// Flip mode of bitmap tiles. 92 OptValue< bool > moRotateWithShape; /// True = rotate bitmap with shape. 93 // effects 94 OptValue< sal_Int32 > moColorEffect; /// XML token for a color effect. 95 OptValue< sal_Int32 > moBrightness; /// Brightness in the range [-100000,100000]. 96 OptValue< sal_Int32 > moContrast; /// Contrast in the range [-100000,100000]. 97 Color maColorChangeFrom; /// Start color of color transformation. 98 Color maColorChangeTo; /// Destination color of color transformation. 99 100 /** Overwrites all members that are explicitly set in rSourceProps. */ 101 void assignUsed( const BlipFillProperties& rSourceProps ); 102 }; 103 104 // ============================================================================ 105 106 struct FillProperties 107 { 108 OptValue< sal_Int32 > moFillType; /// Fill type (OOXML token). 109 Color maFillColor; /// Solid fill color and transparence. 110 GradientFillProperties maGradientProps; /// Properties for gradient fills. 111 PatternFillProperties maPatternProps; /// Properties for pattern fills. 112 BlipFillProperties maBlipProps; /// Properties for bitmap fills. 113 114 /** Overwrites all members that are explicitly set in rSourceProps. */ 115 void assignUsed( const FillProperties& rSourceProps ); 116 117 /** Tries to resolve current settings to a solid color, e.g. returns the 118 start color of a gradient. */ 119 Color getBestSolidColor() const; 120 121 /** Writes the properties to the passed property map. */ 122 void pushToPropMap( 123 ShapePropertyMap& rPropMap, 124 const GraphicHelper& rGraphicHelper, 125 sal_Int32 nShapeRotation = 0, 126 sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; 127 }; 128 129 // ============================================================================ 130 131 struct GraphicProperties 132 { 133 BlipFillProperties maBlipProps; /// Properties for the graphic. 134 135 /** Overwrites all members that are explicitly set in rSourceProps. */ 136 void assignUsed( const GraphicProperties& rSourceProps ); 137 138 /** Writes the properties to the passed property map. */ 139 void pushToPropMap( 140 PropertyMap& rPropMap, 141 const GraphicHelper& rGraphicHelper, 142 sal_Int32 nPhClr = API_RGB_TRANSPARENT ) const; 143 }; 144 145 // ============================================================================ 146 147 } // namespace drawingml 148 } // namespace oox 149 150 #endif 151 152