[prev in list] [next in list] [prev in thread] [next in thread]
List: calligra-devel
Subject: Re: Using ODF Relax NG schema to generate easier XML writing classes
From: Jos van den Oever <jos () vandenoever ! info>
Date: 2011-06-11 22:39:32
Message-ID: 201106120039.32702.jos () vandenoever ! info
[Download RAW message or body]
On Saturday, June 11, 2011 19:07:52 PM Jos van den Oever wrote:
> Note that this currently will output without the required office:version
> and that text:outline-level in text:h is not part of the constructor atm
> even though it is required.
This is now fixed. I found an error in the example code: i forgot the mimetype.
Now this code:
===
#include "odf.h"
#include <QtCore/QBuffer>
#include <QtCore/QFile>
int
main() {
QFile out;
out.open(stdout, QIODevice::WriteOnly);
KoXmlWriter xml(&out);
{
OfficeDocumentWriter doc(&xml, "application/vnd.oasis.opendocument");
OfficeBodyWriter content(doc);
OfficeTextWriter text(content);
TextHWriter h(text, 1);
h.addTextNode("Hello ODF!");
h.end();
TextPWriter p(text);
p.writeTextStyleName("bold");
p.addTextNode("This is paragraph 1.");
p.end();
p = TextPWriter(text);
p.addTextNode("This is paragraph 2.");
p.end();
text.end();
content.end();
doc.end();
}
out.close();
return 0;
}
===
gives this output:
===
<office:document office:version="1.2"
office:mimetype="application/vnd.oasis.opendocument">
<office:body>
<office:text>
<text:h text:outline-level="1">Hello ODF!</text:h>
<text:p text:style-name="bold">This is paragraph 1.</text:p>
<text:p>This is paragraph 2.</text:p>
</office:text>
</office:body>
</office:document>
===
The office:version="1.2" was automatically added since it is always the same
and required. office:mimetype and text:outline-level had to be specified in the
constructor because they are required.
Cheers,
Jos
["odf.h.bz2" (application/x-bzip)]
_______________________________________________
calligra-devel mailing list
calligra-devel@kde.org
https://mail.kde.org/mailman/listinfo/calligra-devel
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic