summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-03-16 20:57:51 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-04-06 22:02:12 +0200
commit58f8e286e9a7411ab852d74b9cba9cd2b693f2e8 (patch)
treee37141865353c77db62729ae84c41ac9cc18e676
parentc7b69624eec1329113630e308170346fce2be823 (diff)
Add HtmlWriterHelper to svtools.
Change-Id: I4d96402cc0fa86d83fe0ade314b84bff86d7db97
-rw-r--r--include/svtools/htmlout.hxx7
-rw-r--r--svtools/source/svhtml/htmlout.cxx26
2 files changed, 33 insertions, 0 deletions
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 <rtl/string.hxx>
#include <svl/macitem.hxx>
+#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 <svtools/imappoly.hxx>
#include "svl/urihelper.hxx"
+#include <sstream>
+
#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: */