}
final Color textColor = (Color) styleSheet.getStyleProperty(ElementStyleKeys.PAINT);
final HSSFFontWrapper wrapper = new HSSFFontWrapper
(styleSheet, colorProducer.getNearestColor(textColor));
final RichTextFormat rtf = new RichTextFormat(getTextLength(), wrapper);
// Check the style.
if (formatBuffer.isEmpty())
{
formatBuffer.add(rtf);
}
else
{
int lastIndex = formatBuffer.size() - 1;
final RichTextFormat lastRtf = formatBuffer.get(lastIndex);
if (lastRtf.getPosition() == rtf.getPosition())
{
formatBuffer.set(lastIndex, rtf);
}
else if (lastRtf.getFont().equals(rtf.getFont()) == false)
{
formatBuffer.add(rtf);
}
}