/* Fo * libfo-compat.c: LibFo compatibility processing * * Copyright (C) 2006 Sun Microsystems * Copyright (C) 2007 Menteith Consulting * * See COPYING for the status of this software. */ #include "libfo/fo-xml-doc-private.h" #include "libfo/libfo-compat.h" #include "libfo/fo-xslt-transformer.h" #include #include #include #include #include #include #include #include const char *libfo_compat_error_messages [] = { N_("libfo-compat error") }; static const gchar* stylesheet = "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" "\n" " \n" "\n" " \n" " \n" " \n" " \n" " \n" " Stripping all strippable whitespace-only text nodes.\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " 1 and\n" " contains(' ',substring(.,string-length(),1))\">\n" " \n" " \n" " \n" "\n" " \n" " \n" " Correcting text child of fo:list-item-label by removing text\n" " \n" " \n" "\n" " \n" " \n" " Removing \" \".\n" " \n" " \n" "\n" " \n" " \n" " Correcting 'display-align=\"middle\"' to 'display-align=\"center\"'.\n" " \n" " center\n" " \n" "\n" "\n" " \n" " \n" " \n" " Removing unsupported '' property.\n" " \n" " \n" "\n" " \n" " \n" " \n" " auto\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" "\n" " \n" " \n" " \n" " \n" " \n" "\n" " \n" " \n" " Removing 'fo:block-container' with unsupported 'reference-orientation' property.\n" " \n" " \n" "\n" " \n" " \n" " Correcting 'fo:block-container' containing only text.\n" " \n" " \n" " \n" " \n" " \n" "\n" " \n" " \n" " Removing 'fo:region-body' region-name attribute.\n" " \n" " \n" "\n" " \n" " \n" " Removing unsupported 'fo:float'.\n" " \n" " \n" " \n" "\n" " \n" " \n" " Removing unsupported 'fo:footnote'.\n" " \n" " \n" "\n" " \n" " \n" " Removing unsupported 'fo:block' in 'fo:inline-container'.\n" " \n" " \n" "\n" " \n" " \n" " Correcting 'fo:region-before', 'fo:region-after', and 'fo:region-body' order.\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " Correcting 'fo:declarations' and 'fo:layout-master-set' order.\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " Removing unsupported 'fo:static-content'.\n" " \n" " \n" " \n" " \n" " \n" " Auto table layout unsupported. Adding 'width' property.\n" " \n" " \n" " 100%\n" " \n" " \n" " \n" " \n" "\n" " \n" " \n" " Auto table layout unsupported. Adding 'table-layout' property.\n" " \n" " \n" " fixed\n" " \n" " \n" " \n" " \n" "\n" " \n" " \n" " Auto table layout unsupported. Adding 'table-layout' and 'width' properties.\n" " \n" " \n" " fixed\n" " \n" " \n" " \n" " \n" " Computing table-width from 'fo:table-column/@column-width' properties.\n" " \n" " \n" " \n" " \n" " + \n" " \n" " \n" " \n" " \n" " \n" " Using 'width=\"100%\"'.\n" " \n" " 100%\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" "\n" " \n" " \n" " Removing 'fo:wrapper' used in an unsupported context.\n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" " \n" "\n" "\n"; /** * libfo_compat_get_stylesheet: * * Get the built-in compatibility stylesheet as a single, rather long * string. * * Return value: The built-in stylesheet. **/ const gchar* libfo_compat_get_stylesheet (void) { return stylesheet; } /** * libfo_compat_make_compatible: * @result_tree: Result of previous parse or transformation. * @libfo_context: #FoLibfoContext. * @error: Indication of any error that occurred. * * Make @result_tree compatible with libfo by applying the built-in * copy of the 'libfo-compat.xsl' stylesheet. * * Return value: A new result tree. **/ FoXmlDoc * libfo_compat_make_compatible (FoXmlDoc *result_tree, FoLibfoContext *libfo_context, GError **error) { FoXmlDoc *compatible_result; GError *tmp_error = NULL; gchar* base = NULL; g_return_val_if_fail (result_tree != NULL, NULL); base = fo_xml_doc_get_base (result_tree); FoXmlDoc *stylesheet_doc = fo_xml_doc_new_from_string (stylesheet, base, NULL, libfo_context, &tmp_error); if (tmp_error != NULL) { g_propagate_error (error, tmp_error); return NULL; } compatible_result = fo_xslt_transformer_do_transform (result_tree, stylesheet_doc, &tmp_error); fo_xml_doc_set_base (compatible_result, base); g_free (base); if (tmp_error != NULL) { g_propagate_error (error, tmp_error); return NULL; } return compatible_result; }