1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef OOX_DRAWINGML_FILLPROPERTIESGROUPCONTEXT_HPP 29 #define OOX_DRAWINGML_FILLPROPERTIESGROUPCONTEXT_HPP 30 31 #include "oox/drawingml/colorchoicecontext.hxx" 32 #include "oox/drawingml/fillproperties.hxx" 33 34 namespace oox { 35 namespace drawingml { 36 37 // ============================================================================ 38 39 /** Context handler that imports the a:solidFill element. */ 40 class SolidFillContext : public ColorContext 41 { 42 public: 43 explicit SolidFillContext( 44 ::oox::core::ContextHandler& rParent, 45 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 46 FillProperties& rFillProps ); 47 }; 48 49 // ============================================================================ 50 51 /** Context handler that imports the a:gradFill element. */ 52 class GradientFillContext : public ::oox::core::ContextHandler 53 { 54 public: 55 explicit GradientFillContext( 56 ::oox::core::ContextHandler& rParent, 57 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 58 GradientFillProperties& rGradientProps ); 59 60 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 61 createFastChildContext( 62 sal_Int32 nElement, 63 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 64 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 65 66 private: 67 GradientFillProperties& mrGradientProps; 68 }; 69 70 // ============================================================================ 71 72 /** Context handler that imports the a:pattFill element. */ 73 class PatternFillContext : public ::oox::core::ContextHandler 74 { 75 public: 76 explicit PatternFillContext( 77 ::oox::core::ContextHandler& rParent, 78 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 79 PatternFillProperties& rPatternProps ); 80 81 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 82 createFastChildContext( 83 sal_Int32 nElement, 84 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 85 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 86 87 private: 88 PatternFillProperties& mrPatternProps; 89 }; 90 91 // ============================================================================ 92 // ============================================================================ 93 94 /** Context handler that imports the a:clrChange element containing the colors 95 of a bitmap color change transformation. */ 96 class ColorChangeContext : public ::oox::core::ContextHandler 97 { 98 public: 99 explicit ColorChangeContext( 100 ::oox::core::ContextHandler& rParent, 101 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 102 BlipFillProperties& rBlipProps ); 103 virtual ~ColorChangeContext(); 104 105 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 106 createFastChildContext( 107 sal_Int32 nElement, 108 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 109 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 110 111 private: 112 BlipFillProperties& mrBlipProps; 113 bool mbUseAlpha; 114 }; 115 116 // ============================================================================ 117 118 /** Context handler that imports the a:blip element containing the fill bitmap 119 and bitmap color transformation settings. */ 120 class BlipContext : public ::oox::core::ContextHandler 121 { 122 public: 123 explicit BlipContext( 124 ::oox::core::ContextHandler& rParent, 125 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 126 BlipFillProperties& rBlipProps ); 127 128 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 129 createFastChildContext( 130 sal_Int32 nElement, 131 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 132 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 133 134 private: 135 BlipFillProperties& mrBlipProps; 136 }; 137 138 // ============================================================================ 139 140 /** Context handler that imports the a:blipFill element. */ 141 class BlipFillContext : public ::oox::core::ContextHandler 142 { 143 public: 144 explicit BlipFillContext( 145 ::oox::core::ContextHandler& rParent, 146 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 147 BlipFillProperties& rBlipProps ); 148 149 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 150 createFastChildContext( 151 sal_Int32 nElement, 152 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 153 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 154 155 private: 156 BlipFillProperties& mrBlipProps; 157 }; 158 159 // ============================================================================ 160 // ============================================================================ 161 162 /** Context handler for elements that contain a fill property element 163 (a:noFill, a:solidFill, a:gradFill, a:pattFill, a:blipFill, a:grpFill). */ 164 class FillPropertiesContext : public ::oox::core::ContextHandler 165 { 166 public: 167 explicit FillPropertiesContext( 168 ::oox::core::ContextHandler& rParent, 169 FillProperties& rFillProps ); 170 171 virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL 172 createFastChildContext( 173 sal_Int32 nElement, 174 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs ) 175 throw( ::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException ); 176 177 static ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > 178 createFillContext( 179 ::oox::core::ContextHandler& rParent, 180 sal_Int32 nElement, 181 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& rxAttribs, 182 FillProperties& rFillProps ); 183 184 protected: 185 FillProperties& mrFillProps; 186 }; 187 188 // ============================================================================ 189 190 /** Context handler for elements that contain a fill property element 191 (a:noFill, a:solidFill, a:gradFill, a:pattFill, a:blipFill, a:grpFill). 192 193 This context handler takes a simple color instead of a fill properties 194 struct. The imported fill properties are converted automatically to the 195 best fitting solid color. 196 */ 197 class SimpleFillPropertiesContext : private FillProperties, public FillPropertiesContext 198 { 199 public: 200 explicit SimpleFillPropertiesContext( 201 ::oox::core::ContextHandler& rParent, 202 Color& rColor ); 203 virtual ~SimpleFillPropertiesContext(); 204 205 protected: 206 Color& mrColor; 207 }; 208 209 // ============================================================================ 210 211 } // namespace drawingml 212 } // namespace oox 213 214 #endif 215 216