Hi all,

I'm trying to modify the SummaryInformation stream of an existing OLE file
with libgsf. The following code does it right, but deletes all other
streams:

bool SetStreamGSF(string filepath, string streamName, string & contents)
{
    bool success = false;
    GsfOutput  *output = NULL, *stream = NULL;
    GsfOutfile *outfile = NULL;
    GError *err = NULL;

    output = gsf_output_stdio_new (filepath.c_str(), &err);
    if (output == NULL) {goto SetStreamGSF_end;};

    outfile = gsf_outfile_msole_new (output);
    if (outfile == NULL) {goto SetStreamGSF_end;};

    stream = gsf_outfile_new_child (outfile, streamName.c_str(), false);
    if (stream == NULL) {goto SetStreamGSF_end;};

    if(!gsf_output_write (stream, contents.size(), (guint8 *)
contents.data())) {goto SetStreamGSF_end;};

    success = true;

SetStreamGSF_end:

    if(stream) {gsf_output_close(stream); g_object_unref (G_OBJECT
(stream)); }
    if(outfile) {gsf_output_close (GSF_OUTPUT(outfile)); g_object_unref
(G_OBJECT (outfile));}
    if(output) {g_object_unref (G_OBJECT (output));}
    return success;
}

I checked all sample tests in libgsf, and looked for documentation, but I
didn't find the proper way to replace a stream in an OLE file without
deleting other streams. Does anyone know how to do it?

Regards.
Jose
_______________________________________________
gnumeric-list mailing list
[email protected]
https://mail.gnome.org/mailman/listinfo/gnumeric-list

Reply via email to