LibreOffice Module svx (master) 1
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
accessibility::DescriptionGenerator Class Reference

This class creates description strings for shapes. More...

#include <DescriptionGenerator.hxx>

Public Types

enum class  PropertyType {
  Color ,
  Integer
}
 

Public Member Functions

 DescriptionGenerator (css::uno::Reference< css::drawing::XShape > xShape)
 Creates a new description generator with an empty description string. More...
 
 ~DescriptionGenerator ()
 
void Initialize (std::u16string_view sPrefix)
 Initialize the description with the given prefix followed by the shape style in parentheses and a colon. More...
 
void Initialize (TranslateId pResourceId)
 Initialize the description with the specified string from the resource followed by the shape style in parentheses and a colon. More...
 
OUString operator() (void)
 Returns the description string and then resets it. More...
 
void AddProperty (const OUString &sPropertyName, PropertyType aType)
 Add the given property name and its associated value to the description string. More...
 
void AppendString (std::u16string_view sString)
 Append the given string as is to the current description. More...
 

Private Member Functions

void AddColor (const OUString &sPropertyName)
 Add a property value formatted as color to the description string. More...
 
void AddInteger (const OUString &sPropertyName)
 Add a property value formatted as integer to the description string. More...
 

Private Attributes

css::uno::Reference< css::drawing::XShape > mxShape
 Reference to the shape from which the properties are extracted. More...
 
css::uno::Reference< css::beans::XPropertySet > mxSet
 Reference to the shape's property set. More...
 
OUStringBuffer msDescription
 The description string that is build. More...
 
bool mbIsFirstProperty
 This flag is used to determine whether to insert a separator e.g. More...
 

Detailed Description

This class creates description strings for shapes.

Initialized with a given shape additional calls to the <member>addProperty</member> method will build a descriptive string that starts with a general shape description and the shapes style. Appended are all the specified property names and values that differ from the default values in the style.

Definition at line 48 of file DescriptionGenerator.hxx.

Member Enumeration Documentation

◆ PropertyType

Enumerator
Color 
Integer 

Definition at line 51 of file DescriptionGenerator.hxx.

Constructor & Destructor Documentation

◆ DescriptionGenerator()

accessibility::DescriptionGenerator::DescriptionGenerator ( css::uno::Reference< css::drawing::XShape >  xShape)

Creates a new description generator with an empty description string.

Usually you will want to call initialize next to specify a general description of the shape.

Parameters
xShapeThe shape from which properties will be extracted by later calls to <member>addProperty</member>.

Definition at line 39 of file DescriptionGenerator.cxx.

References mxShape.

◆ ~DescriptionGenerator()

accessibility::DescriptionGenerator::~DescriptionGenerator ( )

Definition at line 46 of file DescriptionGenerator.cxx.

Member Function Documentation

◆ AddColor()

void accessibility::DescriptionGenerator::AddColor ( const OUString &  sPropertyName)
private

Add a property value formatted as color to the description string.

Search for the given color in the global color table.

If found append its name to the description. Otherwise append its RGB tuple.

Definition at line 145 of file DescriptionGenerator.cxx.

References accessibility::lookUpColorName(), msDescription, mxSet, and nValue.

Referenced by AddProperty().

◆ AddInteger()

void accessibility::DescriptionGenerator::AddInteger ( const OUString &  sPropertyName)
private

Add a property value formatted as integer to the description string.

Definition at line 166 of file DescriptionGenerator.cxx.

References msDescription, mxSet, and nValue.

Referenced by AddProperty().

◆ AddProperty()

void accessibility::DescriptionGenerator::AddProperty ( const OUString &  sPropertyName,
PropertyType  aType 
)

Add the given property name and its associated value to the description string.

If the property value does not differ from the default value of the shape's style then the description string is not modified.

Parameters
sPropertyNameThe Name of the property to append.
aTypeType of the property's value. It controls the transformation into the value's string representation.
sLocalizedNameLocalized name of the property. An empty string tells the method to use the property name instead.

Definition at line 102 of file DescriptionGenerator.cxx.

References AddColor(), AddInteger(), Color, Integer, mbIsFirstProperty, msDescription, mxSet, mxShape, and SvxResId().

Referenced by accessibility::AccessibleControlShape::CreateAccessibleDescription().

◆ AppendString()

void accessibility::DescriptionGenerator::AppendString ( std::u16string_view  sString)

Append the given string as is to the current description.

Parameters
sStringString to append to the current description. It is not modified in any way.

Definition at line 137 of file DescriptionGenerator.cxx.

References msDescription.

Referenced by accessibility::AccessibleControlShape::CreateAccessibleDescription().

◆ Initialize() [1/2]

void accessibility::DescriptionGenerator::Initialize ( std::u16string_view  sPrefix)

Initialize the description with the given prefix followed by the shape style in parentheses and a colon.

Parameters
sPrefixAn introductory description of the shape that is made more specific by later calls to <member>addProperty</member>.

Definition at line 61 of file DescriptionGenerator.cxx.

References msDescription, mxSet, sPrefix, and SvxResId().

Referenced by accessibility::AccessibleControlShape::CreateAccessibleDescription(), and Initialize().

◆ Initialize() [2/2]

void accessibility::DescriptionGenerator::Initialize ( TranslateId  pResourceId)

Initialize the description with the specified string from the resource followed by the shape style in parentheses and a colon.

Parameters
pResourceIdA resource id the specifies the introductory description of the shape that is made more specific by later calls to <member>addProperty</member>.

Definition at line 48 of file DescriptionGenerator.cxx.

References Initialize(), sPrefix, and SvxResId().

◆ operator()()

OUString accessibility::DescriptionGenerator::operator() ( void  )

Returns the description string and then resets it.

Usually called as last method before destroying the object.

Returns
The description string in its current form.

Definition at line 96 of file DescriptionGenerator.cxx.

References msDescription.

Member Data Documentation

◆ mbIsFirstProperty

bool accessibility::DescriptionGenerator::mbIsFirstProperty
private

This flag is used to determine whether to insert a separator e.g.

a comma before the next property.

Definition at line 127 of file DescriptionGenerator.hxx.

Referenced by AddProperty().

◆ msDescription

OUStringBuffer accessibility::DescriptionGenerator::msDescription
private

The description string that is build.

Definition at line 122 of file DescriptionGenerator.hxx.

Referenced by AddColor(), AddInteger(), AddProperty(), AppendString(), Initialize(), and operator()().

◆ mxSet

css::uno::Reference<css::beans::XPropertySet> accessibility::DescriptionGenerator::mxSet
private

Reference to the shape's property set.

Definition at line 119 of file DescriptionGenerator.hxx.

Referenced by AddColor(), AddInteger(), AddProperty(), and Initialize().

◆ mxShape

css::uno::Reference<css::drawing::XShape> accessibility::DescriptionGenerator::mxShape
private

Reference to the shape from which the properties are extracted.

Definition at line 116 of file DescriptionGenerator.hxx.

Referenced by AddProperty().


The documentation for this class was generated from the following files: