Lechner, Jakob wrote: > Hi everybody, > > > > I'm implementing an extension that writes a file into an odt archive just > after the document > gets stored in OOo Writer. For write access of an odt file I use the code > below. With > Linux all works fine and I have no problems. When I use the extension on > Windows XP > the store procedure fails with these error messages: > > error: This package may be read only! > error: general error during transfer
If the file is still opened by OOo you indeed can't write to it. If it works on Linux I assume that locking is disabled or not working. The recommened approach to add something to an odt file is to access the document storage through the getDocumentStorage() method of the model. If you want to make sure that your content survives storing procedures on machines where your component is not available you must put it into a sub storage assigned to a MediaType. I don't understand the code you have provided, especially I don't understand why you want to use a UnoTunnel here. Below I show some code how to add a stream to the document storage using the method described above. using namespace com::sun::star; void Foo::StoreXmlFile(OUString sFilename, xmlChar* pData, int nDataLen) { Reference <document::XStorageBasedDocument> xDoc( xTextDocument, uno::UNO_QUERY ); if (!xStore.is()) return; Reference <emebed::XStorage > xStg( xDoc->getDocumentStorage() ); Reference <emebed::XStorage > xSubStg = xStg-> openStorageElement( sStorName, embed::ElementModes::READWRITE ); ::rtl::OUString MyMediaType(...); // whatever you like ::rtl::OUString MyStgName(...); // whatever you like ::rtl::OUString MyStreamName(...); // whatever you like xSubStg->setPropertyValue(myStgName, makeAny(myMediaType)); Reference <io::XStream > xStream = xSubStg->openStreamElement( myStreamName, embed::ElementModes::READWRITE ); Reference <io::XOutputStream > xOut = xStream->getOutputStream(); // don't know what xmlChar is, I assume it's sal_Int8 sal_Int8* pBytes = (sal_Int8*) pData; uno::Sequence < sal_Int8 > aData( pBytes, nDataLen ); xOut->writeBytes( aData, nDataLen ); xOut->closeOutput(); xSubStg->commit(); } This code must be executed directly before the document is saved, otherwise nothing is stored as only the document itself has the full control when something is written to the final destination. The best way to achieve this is to register a DocumentEventListener at the document and react on the events "OnSave", "OnSaveAs" and "OnCopyTo". Ciao, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't reply to "[EMAIL PROTECTED]". I use it for the OOo lists and only rarely read other mails sent to it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]