oopapidocs  2.0
docbookdoc.cpp
00001 #include "docbookdoc.h"
00002 
00003 DocbookDoc::DocbookDoc(QString titleString) {
00004     Element root = createElement("book");
00005     appendChild(root);
00006     title(titleString, root);
00007     currentParent = root; 
00008 }
00009 //start id=elements
00010 Element DocbookDoc::bridgehead(QString titleStr) {
00011     Element retval = createElement("bridgehead");
00012     Element titleEl = title(titleStr);
00013     currentParent.appendChild(retval);
00014     return retval;
00015 }
00016 Element DocbookDoc::title(QString name, Element parent) {
00017     Element retval = createElement("title");
00018     QDomText tn = createTextNode(name);
00019     retval.appendChild(tn);
00020     if (parent != Element())
00021         parent.appendChild(retval);
00022     return retval;
00023 }
00024 
00025 Element DocbookDoc::chapter(QString titleString) {
00026     Element chapter = createElement("chapter");
00027     title(titleString, chapter);
00028     documentElement().appendChild(chapter);
00029     currentParent = chapter;
00030     currentChapter = chapter;
00031     return chapter;
00032 }
00033 
00034 Element DocbookDoc::para(QString textstr) {
00035     QDomText tn = createTextNode(textstr);
00036     Element para = createElement("para");
00037     para.appendChild(tn);
00038     currentParent.appendChild(para);
00039     currentPara = para;
00040     return para;
00041 }
00042 //end
00043 
00044 QString DocbookDoc::getTitle(Element element) const {
00045     QString retval;
00046     QDomNode titleNode = element.elementsByTagName("title").item(0);
00047     if (titleNode != QDomNode()) {
00048         Element el = titleNode.toElement();
00049         QString text = el.text();
00050         retval = text;
00051     }
00052     return retval;
00053 }
00054 
00055 Element DocbookDoc::appendix(QString titleString) {
00056     Element appendix = createElement("appendix");
00057     title(titleString, appendix);
00058     currentParent=appendix;
00059     return appendix;
00060 }
00061 
00062 Element DocbookDoc::section(QString titleString) {
00063     Element section = createElement("section");
00064     title(titleString, section);
00065     currentChapter.appendChild(section);
00066     currentParent = section;
00067     return section;
00068 }
00069 
00070 Element DocbookDoc::listitem() {
00071     Element li = createElement("listitem");
00072     currentList.appendChild(li);
00073     return li;
00074 }    
00075 
00076 Element DocbookDoc::orderedlist() {
00077     Element ol = createElement("orderedlist");
00078     currentParent.appendChild(ol);
00079     currentList = ol;
00080     return ol;
00081 }
00082 
00083 Element DocbookDoc::formalpara(QString tit, QString text) {
00084     Element formalp = createElement("formalpara");
00085     Element titleElement = title(tit, formalp);
00086     QDomText tn = createTextNode(text);
00087     formalp.appendChild(tn);
00088     currentParent.appendChild(formalp);
00089     return formalp;
00090 }
00091 
00092 //start id=text
00093 Element DocbookDoc::bold(QString text) {
00094     QDomText tn = createTextNode(text);
00095     Element emphasis = createElement("emphasis");
00096     setRole(emphasis, "strong");
00097     emphasis.appendChild(tn);
00098     currentPara.appendChild(emphasis);
00099     return emphasis;
00100 }
00101 
00102 void  DocbookDoc::setRole(Element el, QString role) {
00103     el.setAttribute("role", role);    
00104 }
00105 //end
00106 
00107 Element DocbookDoc::xref(QString id) {
00108     Element retval = createElement("xref");
00109     retval.setAttribute("linkend", id);
00110     return retval;
00111 }
00112 
00113 Element DocbookDoc::xrefP(QString id) {
00114     Element xr = xref(id);
00115     QDomText open = createTextNode("(");
00116     QDomText close = createTextNode(")");
00117     Element para = createElement("para");
00118     para << open;
00119     para << xr;
00120     para << close;
00121     return para;
00122 }
00123 
00124 
00125 Element DocbookDoc::simplesect(QString titleStr) {
00126     QDomElement retval = createElement("simplesect");
00127     QDomElement titleEl = title(titleStr, retval);
00128     currentParent = retval;
00129     return retval;
00130 }
00131 //end
 All Classes Namespaces Functions Enumerations