Re: How to modify SummaryInformation stream of existing Excel



libgsf cannot modify ole2 file members (or zip file members for that
matter) in-place.

The main reason for this is that we have never seriously needed it.
And it is quite a lot of work.

The secondary reason is that doing it is not entirely without problems:
* If not done carefully, old information can be left in unused parts of
   the ole2 file.
* Testing is much more difficult.
* You can end up with fragmented files that require lots of seeking
   to read.

Morten



On Mon, Nov 4, 2013 at 8:13 AM, J.L.Castillo
<jlcastillolorenzo gmail com> wrote:
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
gnumeric-list gnome org
https://mail.gnome.org/mailman/listinfo/gnumeric-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]