• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.9.5 API Reference
  • KDE Home
  • Contact Us
 

kpimtextedit/richtextbuilders

Public Member Functions | List of all members
KTextHTMLBuilder Class Reference

#include <ktexthtmlbuilder.h>

Inheritance diagram for KTextHTMLBuilder:
Inheritance graph
[legend]

Public Member Functions

 KTextHTMLBuilder ()
virtual void addNewline ()
virtual void appendLiteralText (const QString &text)
virtual void beginAnchor (const QString &href=QString(), const QString &name=QString())
virtual void beginBackground (const QBrush &brush)
virtual void beginEmph ()
virtual void beginFontFamily (const QString &family)
virtual void beginFontPointSize (int size)
virtual void beginForeground (const QBrush &brush)
virtual void beginHeader (int level)
virtual void beginList (QTextListFormat::Style type)
virtual void beginListItem ()
virtual void beginParagraph (Qt::Alignment al=Qt::AlignLeft, qreal topMargin=0.0, qreal bottomMargin=0.0, qreal leftMargin=0.0, qreal rightMargin=0.0)
virtual void beginStrikeout ()
virtual void beginStrong ()
virtual void beginSubscript ()
virtual void beginSuperscript ()
virtual void beginTable (qreal cellpadding, qreal cellspacing, const QString &width)
virtual void beginTableCell (const QString &width, int colspan, int rowspan)
virtual void beginTableHeaderCell (const QString &width, int colspan, int rowspan)
virtual void beginTableRow ()
virtual void beginUnderline ()
virtual void endAnchor ()
virtual void endBackground ()
virtual void endEmph ()
virtual void endFontFamily ()
virtual void endFontPointSize ()
virtual void endForeground ()
virtual void endHeader (int level)
virtual void endList ()
virtual void endListItem ()
virtual void endParagraph ()
virtual void endStrikeout ()
virtual void endStrong ()
virtual void endSubscript ()
virtual void endSuperscript ()
virtual void endTable ()
virtual void endTableCell ()
virtual void endTableHeaderCell ()
virtual void endTableRow ()
virtual void endUnderline ()
virtual QString & getResult ()
virtual void insertHorizontalRule (int width=-1)
virtual void insertImage (const QString &src, qreal width, qreal height)
- Public Member Functions inherited from KAbstractMarkupBuilder
virtual ~KAbstractMarkupBuilder ()
virtual void beginExtraElement (int type, QVariantList args)
virtual void endExtraElement (int type)

Additional Inherited Members

- Public Types inherited from KAbstractMarkupBuilder
enum  ExtraElement { UserElement = 100 }

Detailed Description

The KTextHTMLBuilder creates a clean html markup output.

This class creates html output which is as minimal as possible and restricted to the rich text features supported in Qt. (http://doc.trolltech.com/4.4/richtext-html-subset.htm)

The output contains only the body content, not the head element or other metadata.

eg:

<p>
This is some <strong>formatted content</strong> in a paragraph.
</p>

instead of the content produced by qt:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<html><head><meta name="qrichtext" content="1" /><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><style type="text/css">
p, li { white-space: pre-wrap; }
</style></head><body style=" font-family:'Sans Serif'; font-size:10pt; font-weight:400; font-style:normal;">
<p style=" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">This is some <span style=" font-weight:600;">formatted content</span> in a paragraph. </p></body></html>

Such tags should be created separately. For example:

AbstractMarkupBuilder *b = new KTextHTMLBuilder();
KMarkupDirector *md = new KMarkupDirector(b);
md->constructContent();
QString cleanHtml("<head>\n<title>%1</title>\n</head>\n<body>%2</body>\n</html>")
.arg(document.metaInformation(QTextDocument::DocumentTitle))
.arg(b->getOutput());
QFile.write(cleanHtml);

Font formatting information on elements is represented by individual span elements. eg:

<span style"color:blue;"><span style="background-color:red;">Blue text on red background</span></span>

instead of

<span style="color:blue;background-color:red;">Blue text on red background</span>

It my be possible to change this if necessary.

Todo:
Move this to kdelibs when tested and prooven.
Author
Stephen Kelly steve.nosp@m.ire@.nosp@m.gmail.nosp@m..com
Since
4.2

Definition at line 83 of file ktexthtmlbuilder.h.

Constructor & Destructor Documentation

KTextHTMLBuilder::KTextHTMLBuilder ( )

Creates a new KTextHTMLBuilder.

Definition at line 43 of file ktexthtmlbuilder.cpp.

Member Function Documentation

void KTextHTMLBuilder::addNewline ( )
virtual

Add a newline to the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 272 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::appendLiteralText ( const QString &  text)
virtual

Reimplemented from AbstractMarkupBuilder.

This implementation escapes the text before appending so that

    A sample <b>bold</b> word.

becomes

     A sample &lt;b&gt;bold&lt;/b&gt; word.

Implements KAbstractMarkupBuilder.

Definition at line 431 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginAnchor ( const QString &  href = QString(),
const QString &  name = QString() 
)
virtual

Begin a url anchor element in the markup.

Parameters
hrefThe href of the anchor.
nameThe name of the anchor.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 125 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginBackground ( const QBrush &  brush)
virtual

Begin a decorarated background element in the markup (A text background color)

Reimplemented from KAbstractMarkupBuilder.

Definition at line 113 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginEmph ( )
virtual

Begin an emphasised element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 65 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginFontFamily ( const QString &  family)
virtual

Begin a new font familiy element in the markup.

Parameters
familyThe name of the font family to begin.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 147 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginFontPointSize ( int  size)
virtual

Begin a new font point size.

Parameters
sizeThe new size to begin.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 159 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginForeground ( const QBrush &  brush)
virtual

Begin a decorarated foreground element in the markup (A text color)

Reimplemented from KAbstractMarkupBuilder.

Definition at line 101 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginHeader ( int  level)
virtual

Begin a new header element.

Parameters
levelThe new level to begin.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 212 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginList ( QTextListFormat::Style  style)
virtual

Begin a new list element in the markup.

A list element contains list items, and may contain other lists.

Parameters
styleThe style of list to create.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 296 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginListItem ( )
virtual

Begin a new list item in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 342 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginParagraph ( Qt::Alignment  al = Qt::AlignLeft,
qreal  topMargin = 0.0,
qreal  bottomMargin = 0.0,
qreal  leftMargin = 0.0,
qreal  rightMargin = 0.0 
)
virtual

Begin a new paragraph.

Parameters
alThe new paragraph alignment
topMarginThe new paragraph topMargin
bottomMarginThe new paragraph bottomMargin
leftMarginThe new paragraph leftMargin
rightMarginThe new paragraph rightMargin

Reimplemented from KAbstractMarkupBuilder.

Definition at line 171 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginStrikeout ( )
virtual

Begin a struck out element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 89 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginStrong ( )
virtual

Begin a bold element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 53 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginSubscript ( )
virtual

Begin a subscript element.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 366 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginSuperscript ( )
virtual

Begin a superscript element.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 354 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginTable ( qreal  cellpadding,
qreal  cellspacing,
const QString &  width 
)
virtual

Begin a table element.

Parameters
cellpaddingThe padding attribute for the table.
cellspacingThe spacing attribute for the table.
widthThe width of the table. May be either an integer, or a percentage value.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 379 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginTableCell ( const QString &  width,
int  colSpan,
int  rowSpan 
)
virtual

Begin a new table cell.

Parameters
widthThe width of the cell.
colSpanThe column span of the cell.
rowSpanThe row span of the cell.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 400 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginTableHeaderCell ( const QString &  width,
int  colSpan,
int  rowSpan 
)
virtual

Begin a new table header cell.

Parameters
widthThe width of the cell.
colSpanThe column span of the cell.
rowSpanThe row span of the cell.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 394 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginTableRow ( )
virtual

Begins a new table row.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 388 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::beginUnderline ( )
virtual

Begin an underlined element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 77 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endAnchor ( )
virtual

Close the anchor element.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 141 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endBackground ( )
virtual

Close the decorarated background element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 119 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endEmph ( )
virtual

Close the emphasised element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 71 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endFontFamily ( )
virtual

End font family element.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 153 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endFontPointSize ( )
virtual

End font point size element.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 165 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endForeground ( )
virtual

Close the decorarated foreground element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 107 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endHeader ( int  level)
virtual

End a header element.

Parameters
levelThe new level to end.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 239 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endList ( )
virtual

Close the list.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 323 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endListItem ( )
virtual

End the list item.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 348 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endParagraph ( )
virtual

Close the paragraph in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 266 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endStrikeout ( )
virtual

Close the struck out element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 95 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endStrong ( )
virtual

Close the bold element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 59 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endSubscript ( )
virtual

End subscript element.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 372 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endSuperscript ( )
virtual

End superscript element.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 360 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endTable ( )
virtual

End a table element.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 406 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endTableCell ( )
virtual

End a table cell.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 424 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endTableHeaderCell ( )
virtual

End a table header cell.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 418 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endTableRow ( )
virtual

End a table row.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 412 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::endUnderline ( )
virtual

Close the underlined element in the markup.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 83 of file ktexthtmlbuilder.cpp.

QString & KTextHTMLBuilder::getResult ( )
virtual

Return the fully marked up result of the building process.

This may contain metadata etc, such as a head element in html.

Returns
The fully marked up text.

Implements KAbstractMarkupBuilder.

Definition at line 438 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::insertHorizontalRule ( int  width = -1)
virtual

Insert a horizontal rule into the markup.

Parameters
widthThe width of the rule. Default is full width.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 278 of file ktexthtmlbuilder.cpp.

void KTextHTMLBuilder::insertImage ( const QString &  url,
qreal  width,
qreal  height 
)
virtual

Insert a new image element into the markup.

Parameters
urlThe url of the image
widthThe width of the image
heightThe height of the image.

Reimplemented from KAbstractMarkupBuilder.

Definition at line 287 of file ktexthtmlbuilder.cpp.


The documentation for this class was generated from the following files:
  • ktexthtmlbuilder.h
  • ktexthtmlbuilder.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jan 5 2013 19:44:42 by doxygen 1.8.1.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kpimtextedit/richtextbuilders

Skip menu "kpimtextedit/richtextbuilders"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.9.5 API Reference

Skip menu "kdepimlibs-4.9.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal