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