summaryrefslogtreecommitdiff
path: root/svtools/source/svhtml
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-20 14:50:46 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.com>2014-09-22 00:31:47 +0200
commitd42813db533b0a4930528ba1ccd34f33498ffe36 (patch)
tree519cf354a36b3885671a3aecd947062b282e24a0 /svtools/source/svhtml
parent0ce8533ee2b3202922e0ff7ba9f9212080965167 (diff)
Extend HTMLWriter: flush the stack, more values for attribute(..)
Change-Id: I733426ba5f82ee25751387f88942dbc66689821d
Diffstat (limited to 'svtools/source/svhtml')
-rw-r--r--svtools/source/svhtml/HtmlWriter.cxx49
1 files changed, 46 insertions, 3 deletions
diff --git a/svtools/source/svhtml/HtmlWriter.cxx b/svtools/source/svhtml/HtmlWriter.cxx
index 5accc5de633e..f075d40f7804 100644
--- a/svtools/source/svhtml/HtmlWriter.cxx
+++ b/svtools/source/svhtml/HtmlWriter.cxx
@@ -14,7 +14,8 @@ HtmlWriter::HtmlWriter(SvStream& rStream) :
mrStream(rStream),
mbElementOpen(false),
mbContentWritten(false),
- mbPrettyPrint(true)
+ mbPrettyPrint(true),
+ maEncoding(RTL_TEXTENCODING_UTF8)
{}
HtmlWriter::~HtmlWriter()
@@ -25,7 +26,7 @@ void HtmlWriter::prettyPrint(bool bChoice)
mbPrettyPrint = bChoice;
}
-void HtmlWriter::start(const OString &aElement)
+void HtmlWriter::start(const OString& aElement)
{
if (mbElementOpen)
{
@@ -66,6 +67,24 @@ void HtmlWriter::endAttribute()
}
}
+void HtmlWriter::flushStack()
+{
+ while (!maElementStack.empty())
+ {
+ end();
+ }
+}
+
+void HtmlWriter::flushStack(const OString& aElement)
+{
+ OString sCurrentElement;
+ do
+ {
+ sCurrentElement = maElementStack.back();
+ end();
+ } while (!maElementStack.empty() && aElement != sCurrentElement);
+}
+
void HtmlWriter::end()
{
if (mbElementOpen)
@@ -105,7 +124,7 @@ void HtmlWriter::write(const OString &aContent)
mrStream.WriteOString(aContent);
}
-void HtmlWriter::attribute(const OString &aAttribute, const OString &aValue)
+void HtmlWriter::attribute(const OString &aAttribute, const OString& aValue)
{
if (mbElementOpen && !aAttribute.isEmpty() && !aValue.isEmpty())
{
@@ -118,5 +137,29 @@ void HtmlWriter::attribute(const OString &aAttribute, const OString &aValue)
}
}
+void HtmlWriter::attribute(const OString& aAttribute, const sal_Int32 aValue)
+{
+ attribute(aAttribute, OString::number(aValue));
+}
+
+void HtmlWriter::attribute(const OString& aAttribute, const char* pValue)
+{
+ attribute(aAttribute, OString(pValue));
+}
+
+void HtmlWriter::attribute(const OString& aAttribute, const OUString& aValue)
+{
+ attribute(aAttribute, OUStringToOString(aValue, maEncoding));
+}
+
+void HtmlWriter::attribute(const OString& aAttribute)
+{
+ if (mbElementOpen && !aAttribute.isEmpty())
+ {
+ mrStream.WriteChar(' ');
+ mrStream.WriteOString(aAttribute);
+ }
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */