1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: DescriptionGenerator.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
32 #ifndef _SVX_ACCESSIBILITY_DESCRIPTION_GENERATOR_HXX
33 #define _SVX_ACCESSIBILITY_DESCRIPTION_GENERATOR_HXX
35 #include <com/sun/star/drawing/XShape.hpp>
36 #include <com/sun/star/beans/XPropertySet.hpp>
37 #include <rtl/ustrbuf.hxx>
38 #include "svx/svxdllapi.h"
41 namespace accessibility
{
43 /** This class creates description strings for shapes.
44 <p>Initialized with a given shape additional calls to the
45 <member>addProperty</member> method will build a descriptive string that
46 starts with a general shape description and the shapes style. Appended
47 are all the specified property names and values that differ from the
48 default values in the style.</p>
50 class SVX_DLLPUBLIC DescriptionGenerator
60 /** Creates a new description generator with an empty description
61 string. Usually you will want to call initialize next to specifiy
62 a general description of the shape.
64 The shape from which properties will be extracted by later calls
65 to <member>addProperty</member>.
67 DescriptionGenerator (const ::com::sun::star::uno::Reference
<
68 ::com::sun::star::drawing::XShape
>& xShape
);
70 ~DescriptionGenerator (void);
72 /** Initialize the description with the given prefix followed by the
73 shape's style in parantheses and a colon.
75 An introductory description of the shape that is made more
76 specific by later calls to <member>addProperty</member>.
78 void Initialize (::rtl::OUString sPrefix
);
80 /** Initialize the description with the specified string from the
81 resource followed by the shape's style in parantheses and a colon.
83 A resource id the specifies the introductory description of the
84 shape that is made more specific by later calls to
85 <member>addProperty</member>.
87 void Initialize (sal_Int32 nResourceId
);
89 /** Returns the description string and then resets it. Usually called
90 as last method before destroying the object.
92 The description string in its current form.
94 ::rtl::OUString
operator() (void);
96 /** Add the given property name and its associated value to the
97 description string. If the property value does not differ from the
98 default value of the shape's style then the description string is
101 The Name of the property to append.
103 Type of the property's value. It controls the transformation
104 into the value's string representation.
105 @param sLocalizedName
106 Localized name of the property. An empty string tells the
107 method to use the property name instead.
109 This which id is used to localize the property value. If it is
110 not known a value of -1 signals to use a default representation.
112 void AddProperty (const ::rtl::OUString
& sPropertyName
,
114 const ::rtl::OUString
& sLocalizedName
=::rtl::OUString(),
117 /** Add the given property name and its associated value to the
118 description string. If the property value does not differ from the
119 default value of the shape's style then the description string is
120 not modified. This method forwards the request to its cousing but
121 first replaces the id of the localized name by the associated string
124 The Name of the property to append.
126 Type of the property's value. It controls the transformation
127 into the value's string representation.
129 Id of the kocalized name of the property int the resource.
131 This which id is used to localize the property value. If it is
132 not known a value of -1 signals to use a default representation.
134 void AddProperty (const ::rtl::OUString
& sPropertyName
,
136 sal_Int32 nResourceId
,
139 /** Append the given string as is to the current description.
141 String to append to the current description. It is not modified
144 void AppendString (const ::rtl::OUString
& sString
);
146 /** This method adds for debuging and development the list of all known
147 properties to the description. Don't use in production code.
149 void AddPropertyNames (void);
151 /** Add properties that describe line and border attributes.
153 void AddLineProperties (void);
155 /** Add properties that describe how areas are filled.
157 void AddFillProperties (void);
159 /** Add properties that describesattributes of 3D objects.
161 void Add3DProperties (void);
163 /** Add properties that describe text attributes.
165 void AddTextProperties (void);
168 /// Reference to the shape from which the properties are extracted.
169 ::com::sun::star::uno::Reference
< ::com::sun::star::drawing::XShape
> mxShape
;
171 /// Reference to the shape's property set.
172 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySet
> mxSet
;
174 /// The description string that is build.
175 ::rtl::OUStringBuffer msDescription
;
177 /** This flag is used to determine whether to insert a separator e.g. a
178 comma before the next property.
180 bool mbIsFirstProperty
;
182 /** Add a property value formated as color to the description string.
184 SVX_DLLPRIVATE
void AddColor (const ::rtl::OUString
& sPropertyName
,
185 const ::rtl::OUString
& sLocalizedName
);
187 /** Add a property value of unknown type to the description string.
189 SVX_DLLPRIVATE
void AddUnknown (const ::rtl::OUString
& sPropertyName
,
190 const ::rtl::OUString
& sLocalizedName
);
192 /** Add a property value formated as integer to the description string.
194 SVX_DLLPRIVATE
void AddInteger (const ::rtl::OUString
& sPropertyName
,
195 const ::rtl::OUString
& sLocalizedName
);
197 /** Add a property value formated as string to the description string.
199 Name of the property.
201 SVX_DLLPRIVATE
void AddString (const ::rtl::OUString
& sPropertyName
,
202 const ::rtl::OUString
& sLocalizedName
, long nWhichId
= -1);
204 /** Add a property value formated as fill style to the description
205 string. If the fill style is <const>HATCH</const>,
206 <const>GRADIENT</const>, or <const>BITMAP</const>, then the of the
207 hatch, gradient, or bitmap is appended as well.
209 Name of the property. Usually this will be "FillStyle".
211 SVX_DLLPRIVATE
void AddFillStyle (const ::rtl::OUString
& sPropertyName
,
212 const ::rtl::OUString
& sLocalizedName
);
216 } // end of namespace accessibility