bump product version to 7.2.5.1
[LibreOffice.git] / svx / inc / DescriptionGenerator.hxx
blobdaf169f9b478168c7e83a3839942c612bf73af53
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 .
20 #pragma once
22 #include <com/sun/star/uno/Reference.hxx>
23 #include <rtl/ustrbuf.hxx>
25 namespace com::sun::star::beans
27 class XPropertySet;
29 namespace com::sun::star::drawing
31 class XShape;
34 namespace accessibility
36 /** This class creates description strings for shapes.
37 <p>Initialized with a given shape additional calls to the
38 <member>addProperty</member> method will build a descriptive string that
39 starts with a general shape description and the shapes style. Appended
40 are all the specified property names and values that differ from the
41 default values in the style.</p>
43 class DescriptionGenerator
45 public:
46 enum class PropertyType
48 Color,
49 Integer
52 /** Creates a new description generator with an empty description
53 string. Usually you will want to call initialize next to specify
54 a general description of the shape.
55 @param xShape
56 The shape from which properties will be extracted by later calls
57 to <member>addProperty</member>.
59 DescriptionGenerator(const css::uno::Reference<css::drawing::XShape>& xShape);
61 ~DescriptionGenerator();
63 /** Initialize the description with the given prefix followed by the
64 shape style in parentheses and a colon.
65 @param sPrefix
66 An introductory description of the shape that is made more
67 specific by later calls to <member>addProperty</member>.
69 void Initialize(const OUString& sPrefix);
71 /** Initialize the description with the specified string from the
72 resource followed by the shape style in parentheses and a colon.
73 @param pResourceId
74 A resource id the specifies the introductory description of the
75 shape that is made more specific by later calls to
76 <member>addProperty</member>.
78 void Initialize(const char* pResourceId);
80 /** Returns the description string and then resets it. Usually called
81 as last method before destroying the object.
82 @return
83 The description string in its current form.
85 OUString operator()(void);
87 /** Add the given property name and its associated value to the
88 description string. If the property value does not differ from the
89 default value of the shape's style then the description string is
90 not modified.
91 @param sPropertyName
92 The Name of the property to append.
93 @param aType
94 Type of the property's value. It controls the transformation
95 into the value's string representation.
96 @param sLocalizedName
97 Localized name of the property. An empty string tells the
98 method to use the property name instead.
100 void AddProperty(const OUString& sPropertyName, PropertyType aType);
102 /** Append the given string as is to the current description.
103 @param sString
104 String to append to the current description. It is not modified
105 in any way.
107 void AppendString(std::u16string_view sString);
109 private:
110 /// Reference to the shape from which the properties are extracted.
111 css::uno::Reference<css::drawing::XShape> mxShape;
113 /// Reference to the shape's property set.
114 css::uno::Reference<css::beans::XPropertySet> mxSet;
116 /// The description string that is build.
117 OUStringBuffer msDescription;
119 /** This flag is used to determine whether to insert a separator e.g. a
120 comma before the next property.
122 bool mbIsFirstProperty;
124 /** Add a property value formatted as color to the description string.
126 void AddColor(const OUString& sPropertyName);
128 /** Add a property value formatted as integer to the description string.
130 void AddInteger(const OUString& sPropertyName);
133 } // end of namespace accessibility
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */