try
{ // Create color table in which to look up the given color.
css::uno::Reference<css::container::XNameContainer> xColorTable
= css::drawing::ColorTable::create(comphelper::getProcessComponentContext());
// Get list of color names in order to iterate over the color table.
// Lock the solar mutex here as workaround for missing lock in // called function.
SolarMutexGuard aGuard;
xNA = xColorTable;
aNames = xColorTable->getElementNames();
} catch (css::uno::RuntimeException const&)
{ // When an exception occurred then we have an empty name sequence // and the loop below is not entered.
}
// Fill the map to convert from numerical color values to names. if (!xNA.is()) return;
for (constauto& rName : aNames)
{ // Get the numerical value for the i-th color name. try
{
css::uno::Any aColor = xNA->getByName(rName);
tools::Long nColor = 0;
aColor >>= nColor;
map_[nColor] = rName;
} catch (css::uno::RuntimeException const&)
{ // Ignore the exception: the color who lead to the exception // is not included into the map.
}
}
}
OUString ColorNameMap::lookUp(tools::Long color) const
{
Map::const_iterator i(map_.find(color)); if (i != map_.end())
{ return i->second;
} // Did not find the given color; return its RGB tuple representation: return"#" + OUString::number(color, 16);
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.