Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / DescriptionGenerator.hxx
blob3603d21aacdefd3cdca5ceb55d855ba9d8824792
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #ifndef INCLUDED_SVX_DESCRIPTIONGENERATOR_HXX
22 #define INCLUDED_SVX_DESCRIPTIONGENERATOR_HXX
24 #include <com/sun/star/drawing/XShape.hpp>
25 #include <com/sun/star/beans/XPropertySet.hpp>
26 #include <rtl/ustrbuf.hxx>
27 #include <svx/svxdllapi.h>
30 namespace accessibility {
32 /** This class creates description strings for shapes.
33 <p>Initialized with a given shape additional calls to the
34 <member>addProperty</member> method will build a descriptive string that
35 starts with a general shape description and the shapes style. Appended
36 are all the specified property names and values that differ from the
37 default values in the style.</p>
39 class SVX_DLLPUBLIC DescriptionGenerator
41 public:
42 enum PropertyType {
43 COLOR,
44 INTEGER,
45 STRING,
46 FILL_STYLE
49 /** Creates a new description generator with an empty description
50 string. Usually you will want to call initialize next to specifiy
51 a general description of the shape.
52 @param xShape
53 The shape from which properties will be extracted by later calls
54 to <member>addProperty</member>.
56 DescriptionGenerator (const ::com::sun::star::uno::Reference<
57 ::com::sun::star::drawing::XShape>& xShape);
59 ~DescriptionGenerator();
61 /** Initialize the description with the given prefix followed by the
62 shape's style in parantheses and a colon.
63 @param sPrefix
64 An introductory description of the shape that is made more
65 specific by later calls to <member>addProperty</member>.
67 void Initialize (const OUString& sPrefix);
69 /** Initialize the description with the specified string from the
70 resource followed by the shape's style in parantheses and a colon.
71 @param nResourceId
72 A resource id the specifies the introductory description of the
73 shape that is made more specific by later calls to
74 <member>addProperty</member>.
76 void Initialize (sal_Int32 nResourceId);
78 /** Returns the description string and then resets it. Usually called
79 as last method before destroying the object.
80 @return
81 The description string in its current form.
83 OUString operator() (void);
85 /** Add the given property name and its associated value to the
86 description string. If the property value does not differ from the
87 default value of the shape's style then the description string is
88 not modified.
89 @param sPropertyName
90 The Name of the property to append.
91 @param aType
92 Type of the property's value. It controls the transformation
93 into the value's string representation.
94 @param sLocalizedName
95 Localized name of the property. An empty string tells the
96 method to use the property name instead.
97 @param nWhichId
98 This which id is used to localize the property value. If it is
99 not known a value of -1 signals to use a default representation.
101 void AddProperty (const OUString& sPropertyName,
102 PropertyType aType,
103 const OUString& sLocalizedName=OUString(),
104 long nWhichId=-1);
106 /** Add the given property name and its associated value to the
107 description string. If the property value does not differ from the
108 default value of the shape's style then the description string is
109 not modified. This method forwards the request to its cousing but
110 first replaces the id of the localized name by the associated string
111 from the resource.
112 @param sPropertyName
113 The Name of the property to append.
114 @param aType
115 Type of the property's value. It controls the transformation
116 into the value's string representation.
117 @param nResourceId
118 Id of the kocalized name of the property int the resource.
119 @param nWhichId
120 This which id is used to localize the property value. If it is
121 not known a value of -1 signals to use a default representation.
123 void AddProperty (const OUString& sPropertyName,
124 PropertyType aType,
125 sal_Int32 nResourceId,
126 long nWhichId=-1);
128 /** Append the given string as is to the current description.
129 @param sString
130 String to append to the current description. It is not modified
131 in any way.
133 void AppendString (const OUString& sString);
135 /** Add properties that describe line and border attributes.
137 void AddLineProperties();
139 /** Add properties that describe how areas are filled.
141 void AddFillProperties();
143 /** Add properties that describesattributes of 3D objects.
145 void Add3DProperties();
147 /** Add properties that describe text attributes.
149 void AddTextProperties();
151 private:
152 /// Reference to the shape from which the properties are extracted.
153 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape> mxShape;
155 /// Reference to the shape's property set.
156 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet> mxSet;
158 /// The description string that is build.
159 OUStringBuffer msDescription;
161 /** This flag is used to determine whether to insert a separator e.g. a
162 comma before the next property.
164 bool mbIsFirstProperty;
166 /** Add a property value formatted as color to the description string.
168 SVX_DLLPRIVATE void AddColor (const OUString& sPropertyName,
169 const OUString& sLocalizedName);
171 /** Add a property value formatted as integer to the description string.
173 SVX_DLLPRIVATE void AddInteger (const OUString& sPropertyName,
174 const OUString& sLocalizedName);
176 /** Add a property value formatted as string to the description string.
177 @param sPropertyName
178 Name of the property.
180 SVX_DLLPRIVATE void AddString (const OUString& sPropertyName,
181 const OUString& sLocalizedName, long nWhichId = -1);
183 /** Add a property value formatted as fill style to the description
184 string. If the fill style is <const>HATCH</const>,
185 <const>GRADIENT</const>, or <const>BITMAP</const>, then the of the
186 hatch, gradient, or bitmap is appended as well.
187 @param sPropertyName
188 Name of the property. Usually this will be "FillStyle".
190 SVX_DLLPRIVATE void AddFillStyle (const OUString& sPropertyName,
191 const OUString& sLocalizedName);
195 } // end of namespace accessibility
198 #endif
200 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */