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_FILLPROPERTIESGROUPCONTEXT_HPP 25 #define OOX_DRAWINGML_FILLPROPERTIESGROUPCONTEXT_HPP 26 27 #include "oox/drawingml/colorchoicecontext.hxx" 28 #include "oox/drawingml/fillproperties.hxx" 29 30 namespace oox { 31 namespace drawingml { 32 33 // ============================================================================ 34 35 /** Context handler that imports the a:solidFill element. */ 36 class SolidFillContext : public ColorContext 37 { 38 public: 39 explicit SolidFillContext( 40 ::oox::core::ContextHandler& rParent, 41 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 42 FillProperties& rFillProps ); 43 }; 44 45 // ============================================================================ 46 47 /** Context handler that imports the a:gradFill element. */ 48 class GradientFillContext : public ::oox::core::ContextHandler 49 { 50 public: 51 explicit GradientFillContext( 52 ::oox::core::ContextHandler& rParent, 53 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 54 GradientFillProperties& rGradientProps ); 55 56 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 57 createFastChildContext( 58 sal_Int32 nElement, 59 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 60 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 61 62 private: 63 GradientFillProperties& mrGradientProps; 64 }; 65 66 // ============================================================================ 67 68 /** Context handler that imports the a:pattFill element. */ 69 class PatternFillContext : public ::oox::core::ContextHandler 70 { 71 public: 72 explicit PatternFillContext( 73 ::oox::core::ContextHandler& rParent, 74 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 75 PatternFillProperties& rPatternProps ); 76 77 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 78 createFastChildContext( 79 sal_Int32 nElement, 80 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 81 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 82 83 private: 84 PatternFillProperties& mrPatternProps; 85 }; 86 87 // ============================================================================ 88 // ============================================================================ 89 90 /** Context handler that imports the a:clrChange element containing the colors 91 of a bitmap color change transformation. */ 92 class ColorChangeContext : public ::oox::core::ContextHandler 93 { 94 public: 95 explicit ColorChangeContext( 96 ::oox::core::ContextHandler& rParent, 97 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 98 BlipFillProperties& rBlipProps ); 99 virtual ~ColorChangeContext(); 100 101 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 102 createFastChildContext( 103 sal_Int32 nElement, 104 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 105 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 106 107 private: 108 BlipFillProperties& mrBlipProps; 109 bool mbUseAlpha; 110 }; 111 112 // ============================================================================ 113 114 /** Context handler that imports the a:blip element containing the fill bitmap 115 and bitmap color transformation settings. */ 116 class BlipContext : public ::oox::core::ContextHandler 117 { 118 public: 119 explicit BlipContext( 120 ::oox::core::ContextHandler& rParent, 121 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 122 BlipFillProperties& rBlipProps ); 123 124 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 125 createFastChildContext( 126 sal_Int32 nElement, 127 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 128 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 129 130 private: 131 BlipFillProperties& mrBlipProps; 132 }; 133 134 // ============================================================================ 135 136 /** Context handler that imports the a:blipFill element. */ 137 class BlipFillContext : public ::oox::core::ContextHandler 138 { 139 public: 140 explicit BlipFillContext( 141 ::oox::core::ContextHandler& rParent, 142 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 143 BlipFillProperties& rBlipProps ); 144 145 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 146 createFastChildContext( 147 sal_Int32 nElement, 148 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 149 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 150 151 private: 152 BlipFillProperties& mrBlipProps; 153 }; 154 155 // ============================================================================ 156 // ============================================================================ 157 158 /** Context handler for elements that contain a fill property element 159 (a:noFill, a:solidFill, a:gradFill, a:pattFill, a:blipFill, a:grpFill). */ 160 class FillPropertiesContext : public ::oox::core::ContextHandler 161 { 162 public: 163 explicit FillPropertiesContext( 164 ::oox::core::ContextHandler& rParent, 165 FillProperties& rFillProps ); 166 167 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 168 createFastChildContext( 169 sal_Int32 nElement, 170 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 171 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 172 173 static ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > 174 createFillContext( 175 ::oox::core::ContextHandler& rParent, 176 sal_Int32 nElement, 177 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 178 FillProperties& rFillProps ); 179 180 protected: 181 FillProperties& mrFillProps; 182 }; 183 184 // ============================================================================ 185 186 /** Context handler for elements that contain a fill property element 187 (a:noFill, a:solidFill, a:gradFill, a:pattFill, a:blipFill, a:grpFill). 188 189 This context handler takes a simple color instead of a fill properties 190 struct. The imported fill properties are converted automatically to the 191 best fitting solid color. 192 */ 193 class SimpleFillPropertiesContext : private FillProperties, public FillPropertiesContext 194 { 195 public: 196 explicit SimpleFillPropertiesContext( 197 ::oox::core::ContextHandler& rParent, 198 Color& rColor ); 199 virtual ~SimpleFillPropertiesContext(); 200 201 protected: 202 Color& mrColor; 203 }; 204 205 // ============================================================================ 206 207 } // namespace drawingml 208 } // namespace oox 209 210 #endif 211 212