From: Dave M. <da...@da...> - 2003-08-05 12:20:38
|
I've been experimenting with implementing support for client-supplied GnomePrintJobs to the GnomePrint part of xmlroff. The motivation is that I'd like to be able to provide a print preview of XSL:FO in Conglomerate (www.conglomerate.org). Attached is a unified diff against CVS xmlroff, so you can get an idea of what I've done. Essentially I've added a constructor that takes a GnomePrintJob, and sets an internal flag. If this flag is set, then xmlroff blithely ignores paper sizes in the input XML and uses whatever is set up on the GnomePrintJob. Hence it shouldn't need to create new print jobs if the paper size changes, and hence everything ought to appear in the print preview. It's a bit of a dirty hack, though it compiles and links, and I've got it hooked into some test code in Conglomerate; however I'm currently getting only blank pages. Here is my test code for reference: FoXslFormatter *fo_xsl_formatter; FoDoc *fo_doc; FoXmlDoc *result_tree; FoLibfoContext *libfo_context; GError *error = NULL; fo_xsl_formatter = fo_xsl_formatter_new(); fo_doc = fo_doc_gp_new_from_gnome_print_job (job); result_tree = fo_xml_doc_new (); fo_xsl_formatter_set_fo_doc (fo_xsl_formatter, fo_doc); fo_xsl_formatter_set_result_tree (fo_xsl_formatter, result_tree); /* FIXME: We have to clone the xml_doc: */ fo_xml_doc_set_xml_doc (result_tree, xml_doc); libfo_context = fo_libfo_context_new (); fo_libfo_context_set_debug_mode (libfo_context, FO_DEBUG_MAX); if (fo_xsl_formatter_format (fo_xsl_formatter, libfo_context, &error)) { if (fo_xsl_formatter_draw (fo_xsl_formatter, libfo_context, &error)) { g_message("success"); } } g_object_unref (G_OBJECT(fo_xsl_formatter)); g_object_unref (G_OBJECT(fo_doc)); fo_xml_doc_unref (result_tree); g_object_unref (G_OBJECT(libfo_context)); Some questions (i) is my test code sane? Am I using the API correctly? (ii) does the FoXMLDoc have to "own" its xml_doc, and hence delete it when it closes down? I'd prefer it if it was the client's responsibility (I sometimes use it after doing all of the above code, hence I need to clone it to make the above code correct). (iii) Is the approach I'm following in the patch a good idea? (iv) Is it worth creating a mini Gnome test-app within the xmlroff source tree which acts as a testbed for this kind of functionality? (perhaps it could become the area tree viewer that has been mentioned before on this list?) Dave Malcolm |