1 *3334a7e6SAndrew Rist /************************************************************** 2 cdf0e10cSrcweir * 3 *3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4 *3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5 *3334a7e6SAndrew Rist * distributed with this work for additional information 6 *3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7 *3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8 *3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 9 *3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10 *3334a7e6SAndrew Rist * 11 *3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12 *3334a7e6SAndrew Rist * 13 *3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14 *3334a7e6SAndrew Rist * software distributed under the License is distributed on an 15 *3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 *3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 17 *3334a7e6SAndrew Rist * specific language governing permissions and limitations 18 *3334a7e6SAndrew Rist * under the License. 19 *3334a7e6SAndrew Rist * 20 *3334a7e6SAndrew Rist *************************************************************/ 21 *3334a7e6SAndrew Rist 22 *3334a7e6SAndrew Rist 23 cdf0e10cSrcweir 24 cdf0e10cSrcweir 25 cdf0e10cSrcweir #ifndef _SVX_ACCESSIBILITY_DESCRIPTION_GENERATOR_HXX 26 cdf0e10cSrcweir #define _SVX_ACCESSIBILITY_DESCRIPTION_GENERATOR_HXX 27 cdf0e10cSrcweir 28 cdf0e10cSrcweir #include <com/sun/star/drawing/XShape.hpp> 29 cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 30 cdf0e10cSrcweir #include <rtl/ustrbuf.hxx> 31 cdf0e10cSrcweir #include "svx/svxdllapi.h" 32 cdf0e10cSrcweir 33 cdf0e10cSrcweir 34 cdf0e10cSrcweir namespace accessibility { 35 cdf0e10cSrcweir 36 cdf0e10cSrcweir /** This class creates description strings for shapes. 37 cdf0e10cSrcweir <p>Initialized with a given shape additional calls to the 38 cdf0e10cSrcweir <member>addProperty</member> method will build a descriptive string that 39 cdf0e10cSrcweir starts with a general shape description and the shapes style. Appended 40 cdf0e10cSrcweir are all the specified property names and values that differ from the 41 cdf0e10cSrcweir default values in the style.</p> 42 cdf0e10cSrcweir */ 43 cdf0e10cSrcweir class SVX_DLLPUBLIC DescriptionGenerator 44 cdf0e10cSrcweir { 45 cdf0e10cSrcweir public: 46 cdf0e10cSrcweir enum PropertyType { 47 cdf0e10cSrcweir COLOR, 48 cdf0e10cSrcweir INTEGER, 49 cdf0e10cSrcweir STRING, 50 cdf0e10cSrcweir FILL_STYLE 51 cdf0e10cSrcweir }; 52 cdf0e10cSrcweir 53 cdf0e10cSrcweir /** Creates a new description generator with an empty description 54 cdf0e10cSrcweir string. Usually you will want to call initialize next to specifiy 55 cdf0e10cSrcweir a general description of the shape. 56 cdf0e10cSrcweir @param xShape 57 cdf0e10cSrcweir The shape from which properties will be extracted by later calls 58 cdf0e10cSrcweir to <member>addProperty</member>. 59 cdf0e10cSrcweir */ 60 cdf0e10cSrcweir DescriptionGenerator (const ::com::sun::star::uno::Reference< 61 cdf0e10cSrcweir ::com::sun::star::drawing::XShape>& xShape); 62 cdf0e10cSrcweir 63 cdf0e10cSrcweir ~DescriptionGenerator (void); 64 cdf0e10cSrcweir 65 cdf0e10cSrcweir /** Initialize the description with the given prefix followed by the 66 cdf0e10cSrcweir shape's style in parantheses and a colon. 67 cdf0e10cSrcweir @param sPrefix 68 cdf0e10cSrcweir An introductory description of the shape that is made more 69 cdf0e10cSrcweir specific by later calls to <member>addProperty</member>. 70 cdf0e10cSrcweir */ 71 cdf0e10cSrcweir void Initialize (::rtl::OUString sPrefix); 72 cdf0e10cSrcweir 73 cdf0e10cSrcweir /** Initialize the description with the specified string from the 74 cdf0e10cSrcweir resource followed by the shape's style in parantheses and a colon. 75 cdf0e10cSrcweir @param nResourceId 76 cdf0e10cSrcweir A resource id the specifies the introductory description of the 77 cdf0e10cSrcweir shape that is made more specific by later calls to 78 cdf0e10cSrcweir <member>addProperty</member>. 79 cdf0e10cSrcweir */ 80 cdf0e10cSrcweir void Initialize (sal_Int32 nResourceId); 81 cdf0e10cSrcweir 82 cdf0e10cSrcweir /** Returns the description string and then resets it. Usually called 83 cdf0e10cSrcweir as last method before destroying the object. 84 cdf0e10cSrcweir @return 85 cdf0e10cSrcweir The description string in its current form. 86 cdf0e10cSrcweir */ 87 cdf0e10cSrcweir ::rtl::OUString operator() (void); 88 cdf0e10cSrcweir 89 cdf0e10cSrcweir /** Add the given property name and its associated value to the 90 cdf0e10cSrcweir description string. If the property value does not differ from the 91 cdf0e10cSrcweir default value of the shape's style then the description string is 92 cdf0e10cSrcweir not modified. 93 cdf0e10cSrcweir @param sPropertyName 94 cdf0e10cSrcweir The Name of the property to append. 95 cdf0e10cSrcweir @param aType 96 cdf0e10cSrcweir Type of the property's value. It controls the transformation 97 cdf0e10cSrcweir into the value's string representation. 98 cdf0e10cSrcweir @param sLocalizedName 99 cdf0e10cSrcweir Localized name of the property. An empty string tells the 100 cdf0e10cSrcweir method to use the property name instead. 101 cdf0e10cSrcweir @param nWhichId 102 cdf0e10cSrcweir This which id is used to localize the property value. If it is 103 cdf0e10cSrcweir not known a value of -1 signals to use a default representation. 104 cdf0e10cSrcweir */ 105 cdf0e10cSrcweir void AddProperty (const ::rtl::OUString& sPropertyName, 106 cdf0e10cSrcweir PropertyType aType, 107 cdf0e10cSrcweir const ::rtl::OUString& sLocalizedName=::rtl::OUString(), 108 cdf0e10cSrcweir long nWhichId=-1); 109 cdf0e10cSrcweir 110 cdf0e10cSrcweir /** Add the given property name and its associated value to the 111 cdf0e10cSrcweir description string. If the property value does not differ from the 112 cdf0e10cSrcweir default value of the shape's style then the description string is 113 cdf0e10cSrcweir not modified. This method forwards the request to its cousing but 114 cdf0e10cSrcweir first replaces the id of the localized name by the associated string 115 cdf0e10cSrcweir from the resource. 116 cdf0e10cSrcweir @param sPropertyName 117 cdf0e10cSrcweir The Name of the property to append. 118 cdf0e10cSrcweir @param aType 119 cdf0e10cSrcweir Type of the property's value. It controls the transformation 120 cdf0e10cSrcweir into the value's string representation. 121 cdf0e10cSrcweir @param nResourceId 122 cdf0e10cSrcweir Id of the kocalized name of the property int the resource. 123 cdf0e10cSrcweir @param nWhichId 124 cdf0e10cSrcweir This which id is used to localize the property value. If it is 125 cdf0e10cSrcweir not known a value of -1 signals to use a default representation. 126 cdf0e10cSrcweir */ 127 cdf0e10cSrcweir void AddProperty (const ::rtl::OUString& sPropertyName, 128 cdf0e10cSrcweir PropertyType aType, 129 cdf0e10cSrcweir sal_Int32 nResourceId, 130 cdf0e10cSrcweir long nWhichId=-1); 131 cdf0e10cSrcweir 132 cdf0e10cSrcweir /** Append the given string as is to the current description. 133 cdf0e10cSrcweir @param sString 134 cdf0e10cSrcweir String to append to the current description. It is not modified 135 cdf0e10cSrcweir in any way. 136 cdf0e10cSrcweir */ 137 cdf0e10cSrcweir void AppendString (const ::rtl::OUString& sString); 138 cdf0e10cSrcweir 139 cdf0e10cSrcweir /** This method adds for debuging and development the list of all known 140 cdf0e10cSrcweir properties to the description. Don't use in production code. 141 cdf0e10cSrcweir */ 142 cdf0e10cSrcweir void AddPropertyNames (void); 143 cdf0e10cSrcweir 144 cdf0e10cSrcweir /** Add properties that describe line and border attributes. 145 cdf0e10cSrcweir */ 146 cdf0e10cSrcweir void AddLineProperties (void); 147 cdf0e10cSrcweir 148 cdf0e10cSrcweir /** Add properties that describe how areas are filled. 149 cdf0e10cSrcweir */ 150 cdf0e10cSrcweir void AddFillProperties (void); 151 cdf0e10cSrcweir 152 cdf0e10cSrcweir /** Add properties that describesattributes of 3D objects. 153 cdf0e10cSrcweir */ 154 cdf0e10cSrcweir void Add3DProperties (void); 155 cdf0e10cSrcweir 156 cdf0e10cSrcweir /** Add properties that describe text attributes. 157 cdf0e10cSrcweir */ 158 cdf0e10cSrcweir void AddTextProperties (void); 159 cdf0e10cSrcweir 160 cdf0e10cSrcweir private: 161 cdf0e10cSrcweir /// Reference to the shape from which the properties are extracted. 162 cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> mxShape; 163 cdf0e10cSrcweir 164 cdf0e10cSrcweir /// Reference to the shape's property set. 165 cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> mxSet; 166 cdf0e10cSrcweir 167 cdf0e10cSrcweir /// The description string that is build. 168 cdf0e10cSrcweir ::rtl::OUStringBuffer msDescription; 169 cdf0e10cSrcweir 170 cdf0e10cSrcweir /** This flag is used to determine whether to insert a separator e.g. a 171 cdf0e10cSrcweir comma before the next property. 172 cdf0e10cSrcweir */ 173 cdf0e10cSrcweir bool mbIsFirstProperty; 174 cdf0e10cSrcweir 175 cdf0e10cSrcweir /** Add a property value formated as color to the description string. 176 cdf0e10cSrcweir */ 177 cdf0e10cSrcweir SVX_DLLPRIVATE void AddColor (const ::rtl::OUString& sPropertyName, 178 cdf0e10cSrcweir const ::rtl::OUString& sLocalizedName); 179 cdf0e10cSrcweir 180 cdf0e10cSrcweir /** Add a property value of unknown type to the description string. 181 cdf0e10cSrcweir */ 182 cdf0e10cSrcweir SVX_DLLPRIVATE void AddUnknown (const ::rtl::OUString& sPropertyName, 183 cdf0e10cSrcweir const ::rtl::OUString& sLocalizedName); 184 cdf0e10cSrcweir 185 cdf0e10cSrcweir /** Add a property value formated as integer to the description string. 186 cdf0e10cSrcweir */ 187 cdf0e10cSrcweir SVX_DLLPRIVATE void AddInteger (const ::rtl::OUString& sPropertyName, 188 cdf0e10cSrcweir const ::rtl::OUString& sLocalizedName); 189 cdf0e10cSrcweir 190 cdf0e10cSrcweir /** Add a property value formated as string to the description string. 191 cdf0e10cSrcweir @param sPropertyName 192 cdf0e10cSrcweir Name of the property. 193 cdf0e10cSrcweir */ 194 cdf0e10cSrcweir SVX_DLLPRIVATE void AddString (const ::rtl::OUString& sPropertyName, 195 cdf0e10cSrcweir const ::rtl::OUString& sLocalizedName, long nWhichId = -1); 196 cdf0e10cSrcweir 197 cdf0e10cSrcweir /** Add a property value formated as fill style to the description 198 cdf0e10cSrcweir string. If the fill style is <const>HATCH</const>, 199 cdf0e10cSrcweir <const>GRADIENT</const>, or <const>BITMAP</const>, then the of the 200 cdf0e10cSrcweir hatch, gradient, or bitmap is appended as well. 201 cdf0e10cSrcweir @param sPropertyName 202 cdf0e10cSrcweir Name of the property. Usually this will be "FillStyle". 203 cdf0e10cSrcweir */ 204 cdf0e10cSrcweir SVX_DLLPRIVATE void AddFillStyle (const ::rtl::OUString& sPropertyName, 205 cdf0e10cSrcweir const ::rtl::OUString& sLocalizedName); 206 cdf0e10cSrcweir }; 207 cdf0e10cSrcweir 208 cdf0e10cSrcweir 209 cdf0e10cSrcweir } // end of namespace accessibility 210 cdf0e10cSrcweir 211 cdf0e10cSrcweir 212 cdf0e10cSrcweir #endif 213 cdf0e10cSrcweir 214