Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / svx / inc / DescriptionGenerator.hxx
blobca74204b5977f2f11dd2889b21e065b5e559bcf8
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 <sal/config.h>
24 #include <string_view>
26 #include <com/sun/star/uno/Reference.hxx>
27 #include <rtl/ustrbuf.hxx>
28 #include <unotools/resmgr.hxx>
30 namespace com::sun::star::beans
32 class XPropertySet;
34 namespace com::sun::star::drawing
36 class XShape;
39 namespace accessibility
41 /** This class creates description strings for shapes.
42 <p>Initialized with a given shape additional calls to the
43 <member>addProperty</member> method will build a descriptive string that
44 starts with a general shape description and the shapes style. Appended
45 are all the specified property names and values that differ from the
46 default values in the style.</p>
48 class DescriptionGenerator
50 public:
51 enum class PropertyType
53 Color,
54 Integer
57 /** Creates a new description generator with an empty description
58 string. Usually you will want to call initialize next to specify
59 a general description of the shape.
60 @param xShape
61 The shape from which properties will be extracted by later calls
62 to <member>addProperty</member>.
64 DescriptionGenerator(css::uno::Reference<css::drawing::XShape> xShape);
66 ~DescriptionGenerator();
68 /** Initialize the description with the given prefix followed by the
69 shape style in parentheses and a colon.
70 @param sPrefix
71 An introductory description of the shape that is made more
72 specific by later calls to <member>addProperty</member>.
74 void Initialize(std::u16string_view sPrefix);
76 /** Initialize the description with the specified string from the
77 resource followed by the shape style in parentheses and a colon.
78 @param pResourceId
79 A resource id the specifies the introductory description of the
80 shape that is made more specific by later calls to
81 <member>addProperty</member>.
83 void Initialize(TranslateId pResourceId);
85 /** Returns the description string and then resets it. Usually called
86 as last method before destroying the object.
87 @return
88 The description string in its current form.
90 OUString operator()(void);
92 /** Add the given property name and its associated value to the
93 description string. If the property value does not differ from the
94 default value of the shape's style then the description string is
95 not modified.
96 @param sPropertyName
97 The Name of the property to append.
98 @param aType
99 Type of the property's value. It controls the transformation
100 into the value's string representation.
101 @param sLocalizedName
102 Localized name of the property. An empty string tells the
103 method to use the property name instead.
105 void AddProperty(const OUString& sPropertyName, PropertyType aType);
107 /** Append the given string as is to the current description.
108 @param sString
109 String to append to the current description. It is not modified
110 in any way.
112 void AppendString(std::u16string_view sString);
114 private:
115 /// Reference to the shape from which the properties are extracted.
116 css::uno::Reference<css::drawing::XShape> mxShape;
118 /// Reference to the shape's property set.
119 css::uno::Reference<css::beans::XPropertySet> mxSet;
121 /// The description string that is build.
122 OUStringBuffer msDescription;
124 /** This flag is used to determine whether to insert a separator e.g. a
125 comma before the next property.
127 bool mbIsFirstProperty;
129 /** Add a property value formatted as color to the description string.
131 void AddColor(const OUString& sPropertyName);
133 /** Add a property value formatted as integer to the description string.
135 void AddInteger(const OUString& sPropertyName);
138 } // end of namespace accessibility
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */