Exemple #1
0
QDomElement KWDWriter::createTableCell(int tableno, int nrow,
				int ncol, int colspan, QRect rect) {
	QDomElement parent=docroot().elementsByTagName("FRAMESETS").item(0).toElement();

	QDomElement fs=addFrameSet(parent,1,0,
			QString("Table %1 - %2,%3").arg(tableno).arg(nrow).arg(ncol),
			1);
	fs.setAttribute("grpMgr",QString("Table %1").arg(tableno));
	fs.setAttribute("row",nrow);
	fs.setAttribute("col",ncol);
	fs.setAttribute("cols",colspan); // FIXME do colspan in finishTable
					 // so we don't have to give it as an argument
	fs.setAttribute("rows",1);	// FIXME support rowspan ?
	addFrame(fs,rect);
	return fs;
}
Exemple #2
0
KWDWriter::KWDWriter(KoStore *store)
{
    _store = store;
    _doc = new QDomDocument("DOC");
    _docinfo = new QDomDocument("document-info");

    _doc->appendChild(_doc->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));
    _docinfo->appendChild(_docinfo->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\""));

    QDomElement infodoc = _docinfo->createElement("document-info");
    _docinfoMain = infodoc;
    _docinfo->appendChild(infodoc);

    tableNo = 1;
    insidetable = false;
    QDomElement kwdoc = _doc->createElement("DOC");
    kwdoc.setAttribute("editor", "HTML Import Filter");
    kwdoc.setAttribute("mime", "application/x-kword");
    _doc->appendChild(kwdoc);

    QDomElement paper = _doc->createElement("PAPER");
    kwdoc.appendChild(paper);
    paper.setAttribute("format", 1);
    paper.setAttribute("width", 595);
    paper.setAttribute("height", 841);
    paper.setAttribute("orientation", 0);
    paper.setAttribute("columns", 1);
    paper.setAttribute("columnspacing", 3);
    paper.setAttribute("hType", 0);
    paper.setAttribute("fType", 0);

    QDomElement borders = _doc->createElement("PAPERBORDERS");
    paper.appendChild(borders);
    borders.setAttribute("left", 20);
    borders.setAttribute("top", 10);
    borders.setAttribute("right", 10);
    borders.setAttribute("bottom", 10);

    QDomElement docattrs = _doc->createElement("ATTRIBUTES");
    kwdoc.appendChild(docattrs);
    docattrs.setAttribute("processing", 0);
    docattrs.setAttribute("standardpage", 1);
    docattrs.setAttribute("hasHeader", 0);
    docattrs.setAttribute("hasFooter", 0);
    //docattrs.setAttribute( "unit", "mm" ); // use KWord default instead

    QDomElement framesets = _doc->createElement("FRAMESETS");
    kwdoc.appendChild(framesets);
    QDomElement rootframeset = addFrameSet(framesets);
    _mainFrameset = rootframeset;
    QDomElement mainframe = addFrame(rootframeset, QRect(28, 28, 539, 757));

    QDomElement styles = _doc->createElement("STYLES");
    kwdoc.appendChild(styles);

    QDomElement standard = _doc->createElement("STYLE");
    styles.appendChild(standard);

    QDomElement  tmp;
    tmp = _doc->createElement("NAME");
    tmp.setAttribute("value", "Standard");
    standard.appendChild(tmp);

    tmp = _doc->createElement("FOLLOWING");
    tmp.setAttribute("name", "Standard");
    standard.appendChild(tmp);
    QDomElement fmt;

    fmt = _doc->createElement("FORMAT");
    fmt.setAttribute("id", "1");
    standard.appendChild(fmt);

    tmp = _doc->createElement("SIZE");
    tmp.setAttribute("value", "12"); // HACK !
    fmt.appendChild(tmp);


#define HEADINGSTYLE(a,b)     standard=_doc->createElement("STYLE");\
    styles.appendChild(standard);\
    tmp=_doc->createElement("NAME");\
    tmp.setAttribute("value",#a);\
    standard.appendChild(tmp);\
    tmp=_doc->createElement("FOLLOWING");\
    tmp.setAttribute("name","Standard");\
    standard.appendChild(tmp);\
    fmt=_doc->createElement("FORMAT");\
    fmt.setAttribute("id","1");\
    standard.appendChild(fmt);\
    tmp=_doc->createElement("SIZE");\
    tmp.setAttribute("value",#b);\
    fmt.appendChild(tmp);

    HEADINGSTYLE(h1, 20);
    HEADINGSTYLE(h2, 18);
    HEADINGSTYLE(h3, 16);
    HEADINGSTYLE(h4, 14);
    HEADINGSTYLE(h5, 10);
    HEADINGSTYLE(h6, 8);


}