| View previous topic :: View next topic |
| Author |
Message |
t.born.lankester Newbie

Joined: 17 Feb 2005 Posts: 1
|
Posted: Thu Feb 17, 2005 2:46 am Post subject: Save whole Writer/Calc/Math/etc. documents to a database |
|
|
Hello everyone
Perhaps someone know if I could save whole Writer/Calc/Math/etc. documents to a database directly from OpenOffice. Maybe this feature is allready implemented in OpenOffice 1.x or it will be implemented in OpenOffice 2.0?
Thank you for your answers
regards
Max |
|
| Back to top |
|
 |
flex OOo Enthusiast


Joined: 06 Jul 2004 Posts: 122 Location: Vienna | Austria
|
Posted: Thu Feb 17, 2005 7:33 am Post subject: |
|
|
| I don't know what you want to do. How do you want to save a document to a database? |
|
| Back to top |
|
 |
Lazy-legs Super User


Joined: 21 Jul 2004 Posts: 564 Location: Århus, Denmark
|
Posted: Thu Feb 17, 2005 7:51 am Post subject: |
|
|
I think I know what you mean. You want to be able to save a OOo document in a database record, right? I'd also like to know how this can be done. In OpenOffice.org Base 1.9.77, there is a field type called BINARY, which, I guess, can be used to store binary data, including all type if files. Now, the question is, how do I get a file into the field Any suggestions?
Thank you!
Kind regards,
Dmitri _________________ http://code.google.com/p/writertools/ |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Sat Feb 19, 2005 9:55 am Post subject: |
|
|
I assume that you want to save an OOo document into a BLOB field of a database. (BLOB = Binary Large OBject)
You cannot do it from the user interface. Only by using the API.
Therefore, you will need to build your own user interface. Create a custom dialog box in Basic. Then add a menu command such as "Save to database...", which activates your Basic code. Your Basic code would then gain access to some database table, via. a DataSource, and then INSERT a new row into the table, and then save the entire document into one binary field of that new table row.
Loading a document from a database BLOB field is much easier than saving.
When I first figured out how to do this, I thought it was very cold and I was impressed with the flexibility of the OOo API.
Load a document from an XInputStream using private:stream
Load a document from database blob
http://www.oooforum.org/forum/viewtopic.php?t=6807
http://www.oooforum.org/forum/viewtopic.php?t=7032
http://www.oooforum.org/forum/viewtopic.php?t=7010
how to store to blob, technique explained, but no working example
http://www.oooforum.org/forum/viewtopic.php?t=7011
Working example, store a document to private:stream
http://www.oooforum.org/forum/viewtopic.php?p=55665#55665
Document output to Http Response
http://www.oooforum.org/forum/viewtopic.php?p=58945#58945
http://www.oooforum.org/forum/viewtopic.php?p=55665#55665
As for saving to a blob, I had once thought that the Pump service might be useful. But alas, it appears not to be. The problem is that both the storeToUrl() and the updateBinaryStream() both want to have control. If either end of the connection would give you an XOutputStream or XInputStream, this problem would be solvable in a simpler way. As it is, I see no other choice than to first save the document to a temp file, and then suck the bytes of the temp file document into the BLOB field. (Then, of course, delete the temp file of the document you saved.)
DO NOTE that the first link I gave above, if you scroll down far enough in the thread, will explain everything you need, including a working example of how to save to a Binary Blob field. Also is an example of how to export a PDF into a database BLOB field. But be sure to see the other links I gave as well. _________________ Want to make OOo Drawings like the colored flower design to the left?
Last edited by DannyB on Sat Feb 19, 2005 10:17 am; edited 1 time in total |
|
| Back to top |
|
 |
Lazy-legs Super User


Joined: 21 Jul 2004 Posts: 564 Location: Århus, Denmark
|
Posted: Sat Feb 19, 2005 10:14 am Post subject: |
|
|
Hi DannyB,
Thank you for your detailed answer. Unfortunately, for dummies like myself without any significant knowledge of macro programming in OOo, the explanations sounds rather complicated
If it's not too much to ask, could you create a simple working OOo Base database? I'm sure other users will also find it useful.
Thank you!
Kind regards,
Dmitri _________________ http://code.google.com/p/writertools/ |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Sat Feb 19, 2005 11:53 am Post subject: |
|
|
| dmpop wrote: | If it's not too much to ask, could you create a simple working OOo Base database? I'm sure other users will also find it useful.
|
I have not done much playing with OOo 2.0 yet. I don't know how to use Base.
What I could probably do is create a macro example that saves and loads documents to a database server. (i.e. to an MS SQL, or MySQL, or my very favorite: PostgreSQL server.) _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Lazy-legs Super User


Joined: 21 Jul 2004 Posts: 564 Location: Århus, Denmark
|
Posted: Sat Feb 19, 2005 1:10 pm Post subject: |
|
|
Hi DannyB,
| Quote: | | What I could probably do is create a macro example that saves and loads documents to a database server. (i.e. to an MS SQL, or MySQL, or my very favorite: PostgreSQL server.) |
That would be perfect. Thank you!
Kind regards,
Dmitri _________________ http://code.google.com/p/writertools/ |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|