22#include <com/sun/star/container/XNameAccess.hpp>
23#include <com/sun/star/container/XNameContainer.hpp>
24#include <com/sun/star/drawing/ColorTable.hpp>
25#include <com/sun/star/uno/Any.hxx>
26#include <com/sun/star/uno/Reference.hxx>
27#include <com/sun/star/uno/RuntimeException.hpp>
28#include <com/sun/star/uno/Sequence.hxx>
30#include <rtl/ustring.hxx>
34#include <unordered_map>
42 ColorNameMap(
const ColorNameMap&) =
delete;
43 ColorNameMap& operator=(
const ColorNameMap&) =
delete;
48 typedef std::unordered_map<tools::Long, OUString> Map;
53ColorNameMap::ColorNameMap()
55 css::uno::Sequence<OUString> aNames;
56 css::uno::Reference<css::container::XNameAccess> xNA;
61 css::uno::Reference<css::container::XNameContainer> xColorTable
70 aNames = xColorTable->getElementNames();
72 catch (css::uno::RuntimeException
const&)
82 for (
const auto& rName : std::as_const(aNames))
87 css::uno::Any aColor = xNA->getByName(rName);
92 catch (css::uno::RuntimeException
const&)
108 return "#" + OUString::number(
color, 16);
116 static ColorNameMap theColorNameMap;
117 return theColorNameMap.lookUp(
color);
OUString lookUpColorName(tools::Long color)
This is a color name lookup targeted to be used by the accessibility <type>DescriptionGenerator</type...
Reference< XComponentContext > getProcessComponentContext()
std::map< OUString, rtl::Reference< Entity > > const & map_