From koffice-devel Sat Jan 26 12:16:02 2002 From: Thomas Zander Date: Sat, 26 Jan 2002 12:16:02 +0000 To: koffice-devel Subject: Re: Images and Stores X-MARC-Message: https://marc.info/?l=koffice-devel&m=101204766626479 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--UHN/qo2QbUvPLonB" --UHN/qo2QbUvPLonB Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Jan 26, 2002 at 12:21:28PM +0100, David Faure wrote: > On Saturday 26 January 2002 11:52, Clarence Dang wrote: > > 2. Is it possible to have more than one file open in a store because at= the moment, I have to do this: >=20 > Hehe, I can see Werner smiling from here - we discussed this in length. >=20 > > KoStore *outfile =3D new KoStore (outfilename, KoStore::Write); > >=20 > > outfile->open ("root"); // maindoc.xml > > outfile->write ("Lots and lots of text", length); > > outfile->close (); > >=20 > > outfile->open ("tar:/pictures/picture0.bmp"); // pictures/picture0.bmp > > outfile->write ("raw binary, bitmap data", length); > > outfile->close (); > >=20 > > outfile->open ("tar:/pictures/picture1.bmp"); // pictures/picture1.bmp > > outfile->write ("more raw binary, bitmap data", length); > > outfile->close (); > >=20 > > delete (outfile); > >=20 > > Is this correct? > Yes. >=20 > > I'm finding it rather inconvenient to only be able to have one file in = the store open at a time. > > e.g. suppose I was importing some text and then there was a picture in = the document -- with the current scheme, > > I would have to store the contents of the picture in a buffer and then = output the picture, only after I was finished with the text? > Yes. > Please keep in mind that the underlying contents are a gzipped file. > How on earth would one implement "being able to write at two positions=20 > of the gzipped file at the same time" ? That's impossible. > The only way to provide the API you're requesting would be to buffer _eve= rything_=20 > in memory (all files to be written to the archive), and then write it all= at once. > This would eat memory like an oger. > That's why the buffering has to be done in the application (or filter) : = at least > it can try to minimize the amount of buffering required, since it knows w= hen it > has finished with a given file inside the archive, which can then be writ= ten > for real and the memory for it can be discarded. Fast solution is to create an KoBufferedStore:public KOStore object that do= es=20 just this. And have=20 pictureStore =3D outfile->getBufferedFile(outFilename); to create a bufferedStore object for you. If you close the buffered store like you should, then the close of the KoStore object could loop over all closed buffered stores and store them to the output file sequencially. pictureStore->close(); // does nothing but set a boolean outfile->close(); // closes current stream, writes pictureStore to t= gz Just an idea...=20 --=20 Thomas Zander zander@earthling.n= et The only thing worse than failure is the fear of trying something new --UHN/qo2QbUvPLonB Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQE8Up4BCojCW6H2z/QRAlgjAJ9RpAKx2rTGYSxDTOnyjwb3qwnzEQCfa9Z9 0OeMU3U1bWwmS0gxkBquK58= =XMD8 -----END PGP SIGNATURE----- --UHN/qo2QbUvPLonB-- _______________________________________________ koffice-devel mailing list koffice-devel@mail.kde.org http://mail.kde.org/mailman/listinfo/koffice-devel