GsfInput* OXMLi_PackageManager::getChildByType( GsfInput * parent, OXML_PartType type )
{
	const char * fulltype;
	fulltype = _getFullType(type);
	UT_return_val_if_fail(fulltype != NULL, NULL);
	return gsf_open_pkg_open_rel_by_type(parent, fulltype, NULL);
}
Esempio n. 2
0
/**
 * gsf_input_find_vba:
 * @input: #GsfInput
 * @err: #GError, optionally %NULL.
 *
 * A utility routine that attempts to find the VBA file withint a stream.
 *
 * Returns: (transfer full): a GsfInfile
 **/
GsfInfileMSVBA *
gsf_input_find_vba (GsfInput *input, GError **err)
{
	GsfInput  *vba = NULL;
	GsfInfile *infile;

	if (NULL != (infile = gsf_infile_msole_new (input, NULL))) {
		/* 1) Try XLS */
		vba = gsf_infile_child_by_vname (infile, "_VBA_PROJECT_CUR", "VBA", NULL);
		/* 2) DOC */
		if (NULL == vba)
			vba = gsf_infile_child_by_vname (infile, "Macros", "VBA", NULL);

		/* TODO : PPT is more complex */

		g_object_unref (infile);
	} else if (NULL != (infile = gsf_infile_zip_new (input, NULL))) {
		GsfInput *main_part = gsf_open_pkg_open_rel_by_type (GSF_INPUT (infile),
			"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument",
		        NULL);

		if (NULL != main_part) {
			GsfInput *vba_stream = gsf_open_pkg_open_rel_by_type (main_part,
				"http://schemas.microsoft.com/office/2006/relationships/vbaProject",
			        NULL);
			if (NULL != vba_stream) {
				GsfInfile *ole = gsf_infile_msole_new (vba_stream, err);
				if (NULL != ole) {
					vba = gsf_infile_child_by_vname (ole, "VBA", NULL);
					g_object_unref (ole);
				}
				g_object_unref (vba_stream);
			}
			g_object_unref (main_part);
		}
		g_object_unref (infile);
	}

	if (NULL != vba)
	       return (GsfInfileMSVBA *)
			gsf_infile_msvba_new (GSF_INFILE (vba), err);
	return NULL;
}
Esempio n. 3
0
static void
zip_thumbnail (GsfInfile *infile, const char *out_filename, int thumb_size)
{
	GsfInput *thumbnail;

	/* Office Document thumbnail */
	if (NULL != (thumbnail = gsf_infile_child_by_vname (infile,
			"Thumbnails", "thumbnail.png", NULL))) {
		gsf_off_t len = gsf_input_remaining (thumbnail);
		guint8 const *data = gsf_input_read (thumbnail, len, NULL);
		write_thumbnail (out_filename, data, len, thumb_size);
		g_object_unref (thumbnail);
	/* Check MS Office Open thumbnail */
	} else if (NULL != (thumbnail = gsf_open_pkg_open_rel_by_type (GSF_INPUT(infile),
				"http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail",
																   NULL))) {
		gsf_off_t len = gsf_input_remaining (thumbnail);
		guint8 const *data = gsf_input_read (thumbnail, len, NULL);
		write_thumbnail (out_filename, data, len, thumb_size);
		g_object_unref (thumbnail);
	} else
		show_error_string_and_exit ("Could not find thumbnail in zip file");
}
Esempio n. 4
0
/**
 * gsf_open_pkg_get_rel_by_type: (skip)
 *
 * Deprecated: 1.14.6
 */
GsfInput *gsf_open_pkg_get_rel_by_type (GsfInput *opkg, char const *type) { return gsf_open_pkg_open_rel_by_type (opkg, type, NULL); }