On Friday, June 10, 2011 08:22:04 AM Jos van den Oever wrote: > Here is an idea to improve code quality in Calligra.
Here is a version that works fine with a small example use: #include "odf.h" #include <QtCore/QBuffer> #include <QtCore/QFile> int main() { QFile out; out.open(stdout, QIODevice::WriteOnly); KoXmlWriter xml(&out); { OfficeDocumentWriter doc(&xml); OfficeBodyWriter content(doc); OfficeTextWriter text(content); { TextHWriter h(text); h.addTextNode("Hello ODF!"); } { TextPWriter p(text); p.addTextNode("This is paragraph 1."); } } out.close(); return 0; } In the example, when an element writer has two child elements, the previous element has to be destroyed first. Code could be added to automatically close it when one of it's ancestors is used in a constructor for another element writer. The constructors only accept valid parent element writers. The KoXmlWriter is alway available for situation where flexibility is needed. This version does not handle fixed values or required attributes and has no specialized setters for attributes that take e.g. integers. After all this is just a proposal. You can play with this exmple in an IDE to see the autocompletion. I've added comments so you can see what element or attribute is written. Cheers, Jos -- Jos van den Oever, software architect +49 391 25 19 15 53 074 3491911 http://kogmbh.com/legal/
odf.h.bz2
Description: application/bzip
_______________________________________________ calligra-devel mailing list calligra-devel@kde.org https://mail.kde.org/mailman/listinfo/calligra-devel