Krita Source Code Documentation
Loading...
Searching...
No Matches
HtmlWriter Class Reference

#include <HtmlWriter.h>

Public Member Functions

QStringList errors () const
 
 HtmlWriter (const QList< KoShape * > &toplevelShapes)
 
bool save (QIODevice &outputDevice)
 
QStringList warnings () const
 
virtual ~HtmlWriter ()
 

Private Member Functions

void saveShapes (const QList< KoShape * > shapes, HtmlSavingContext &savingContext)
 

Private Attributes

QStringList m_errors
 
QList< KoShape * > m_toplevelShapes
 
QStringList m_warnings
 

Detailed Description

Definition at line 22 of file HtmlWriter.h.

Constructor & Destructor Documentation

◆ HtmlWriter()

HtmlWriter::HtmlWriter ( const QList< KoShape * > & toplevelShapes)

Definition at line 23 of file HtmlWriter.cpp.

24 : m_toplevelShapes(toplevelShapes)
25{
26}
QList< KoShape * > m_toplevelShapes
Definition HtmlWriter.h:37

◆ ~HtmlWriter()

HtmlWriter::~HtmlWriter ( )
virtual

Definition at line 28 of file HtmlWriter.cpp.

29{
30}

Member Function Documentation

◆ errors()

QStringList HtmlWriter::errors ( ) const

Definition at line 57 of file HtmlWriter.cpp.

58{
59 return m_errors;
60}
QStringList m_errors
Definition HtmlWriter.h:38

References m_errors.

◆ save()

bool HtmlWriter::save ( QIODevice & outputDevice)

Definition at line 32 of file HtmlWriter.cpp.

33{
34 if (m_toplevelShapes.isEmpty()) {
35 return false;
36 }
37
38 QTextStream htmlStream(&outputDevice);
40
41 // header
42 htmlStream << QLatin1String("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" "
43 "\"http://www.w3.org/TR/REC-html40/strict.dtd\">"
44 "<html><head><meta name=\"Krita Svg Text\" />"
45 "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>"
46 "</head>");
47 htmlStream.flush();
48 {
49 HtmlSavingContext savingContext(outputDevice);
50 saveShapes(m_toplevelShapes, savingContext);
51 }
52 htmlStream << "</html>";
53 htmlStream.flush();
54 return true;
55}
The HtmlSavingContext class provides context for saving a flake-based document to html.
void saveShapes(const QList< KoShape * > shapes, HtmlSavingContext &savingContext)
void setUtf8OnStream(QTextStream &stream)

References m_toplevelShapes, saveShapes(), and KisPortingUtils::setUtf8OnStream().

◆ saveShapes()

void HtmlWriter::saveShapes ( const QList< KoShape * > shapes,
HtmlSavingContext & savingContext )
private

Definition at line 67 of file HtmlWriter.cpp.

68{
69 Q_FOREACH (KoShape *shape, shapes) {
70 KoShapeLayer *layer = dynamic_cast<KoShapeLayer*>(shape);
71 if (layer) {
72 m_errors << i18n("Saving KoShapeLayer to html is not implemented yet!");
73 } else {
74 KoShapeGroup *group = dynamic_cast<KoShapeGroup*>(shape);
75 if (group) {
76 m_errors << i18n("KoShapeGroup to html is not implemented yet!");
77 }
78 else {
79 KoSvgTextShape *svgTextShape = dynamic_cast<KoSvgTextShape*>(shape);
80 if (svgTextShape) {
81 if (!svgTextShape->saveHtml(savingContext)) {
82 m_errors << i18n("saving to html failed");
83 }
84 }
85 else {
86 m_errors << i18n("Cannot save %1 to html", shape->name());
87 }
88 }
89 }
90 }
91}
QString name() const
Definition KoShape.cpp:1150
bool saveHtml(HtmlSavingContext &context)

References m_errors, KoShape::name(), and KoSvgTextShape::saveHtml().

◆ warnings()

QStringList HtmlWriter::warnings ( ) const

Definition at line 62 of file HtmlWriter.cpp.

63{
64 return m_warnings;
65}
QStringList m_warnings
Definition HtmlWriter.h:39

References m_warnings.

Member Data Documentation

◆ m_errors

QStringList HtmlWriter::m_errors
private

Definition at line 38 of file HtmlWriter.h.

◆ m_toplevelShapes

QList<KoShape*> HtmlWriter::m_toplevelShapes
private

Definition at line 37 of file HtmlWriter.h.

◆ m_warnings

QStringList HtmlWriter::m_warnings
private

Definition at line 39 of file HtmlWriter.h.


The documentation for this class was generated from the following files: