From 58f8e286e9a7411ab852d74b9cba9cd2b693f2e8 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sun, 16 Mar 2014 20:57:51 +0100 Subject: Add HtmlWriterHelper to svtools. Change-Id: I4d96402cc0fa86d83fe0ade314b84bff86d7db97 --- include/svtools/htmlout.hxx | 7 +++++++ svtools/source/svhtml/htmlout.cxx | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/include/svtools/htmlout.hxx b/include/svtools/htmlout.hxx index 9ae7f1918209..dd3b24510df8 100644 --- a/include/svtools/htmlout.hxx +++ b/include/svtools/htmlout.hxx @@ -26,6 +26,8 @@ #include #include +#include "HtmlWriter.hxx" + class Color; class ImageMap; class SvStream; @@ -104,6 +106,11 @@ struct HTMLOutFuncs OUString *pNonConvertableChars = 0); }; +struct HtmlWriterHelper +{ + SVT_DLLPUBLIC static void applyColor( HtmlWriter& rHtmlWriter, OString aAttributeName, const Color& rColor); +}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/svhtml/htmlout.cxx b/svtools/source/svhtml/htmlout.cxx index 00b7b52f9f50..1a675cf2f016 100644 --- a/svtools/source/svhtml/htmlout.cxx +++ b/svtools/source/svhtml/htmlout.cxx @@ -32,6 +32,8 @@ #include #include "svl/urihelper.hxx" +#include + #define TXTCONV_BUFFER_SIZE 20 HTMLOutContext::HTMLOutContext( rtl_TextEncoding eDestEnc ) @@ -975,4 +977,28 @@ OString HTMLOutFuncs::CreateTableDataOptionsValNum( return aStrTD.makeStringAndClear(); } +void HtmlWriterHelper::applyColor(HtmlWriter& rHtmlWriter, OString aAttributeName, const Color& rColor) +{ + OStringBuffer sBuffer; + + if( rColor.GetColor() == COL_AUTO ) + { + sBuffer.append("#000000"); + } + else + { + sBuffer.append('#'); + std::ostringstream sStringStream; + sStringStream + << std::right + << std::setfill('0') + << std::setw(6) + << std::hex + << rColor.GetRGBColor(); + sBuffer.append(sStringStream.str().c_str()); + } + + rHtmlWriter.attribute(aAttributeName, sBuffer.makeStringAndClear()); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit