Hi!
With your help ,the exoprt in filter works well.
But now I get some problem with importing the file that I export.
I implement the XImporter as following:
void SAL_CALL XXFilter::setTargetDocument( const Reference< XComponent >& xDoc
)
throw(IllegalArgumentException, RuntimeException)
{
mxDesDoc = xDoc;
m_bImport = sal_True;
}
sal_Bool SAL_CALL XXFilter::filter( const Sequence< PropertyValue >&
rDescriptor )
throw (RuntimeException)
{
Window* pFocusWindow = Application::GetFocusWindow();
if( pFocusWindow )
pFocusWindow->EnterWait();
sal_Bool bRet ;
if( m_bImport )
bRet = implImport( rDescriptor );
else
bRet = implExport( rDescriptor );
if( pFocusWindow )
pFocusWindow->LeaveWait();
return bRet;
}
sal_Bool XXFilter::implImport( const Sequence< PropertyValue >& rDescriptor )
{
...
uno::Reference< document::XStorageBasedDocument > xDoc( mxDesDoc,
uno::UNO_QUERY );///mxDesDoc is set by setTargetDocument
...
///I use loadFromStorage to load document
uno::Sequence< beans::PropertyValue > afArgs( 1 );
afArgs[0].Name = ::rtl::OUString::createFromAscii( "FilterName" );
afArgs[0].Value <<= ::rtl::OUString::createFromAscii( "writer8" );
/**xSourceStorage is read form InputStream, I remove the sub storage and it's
odt format now */
xDoc->loadFromStorage( xSourceStorage, afArgs );
...
///End
when I open a document,it goes into the function implImport
but the function loadFromStorage don't load the document.
Is there other API or method that I can load the odt document in my filter ?
Thanks!
----- Original Message -----
From:[EMAIL PROTECTED]
To:[email protected]
Subject:[dev] RE:Re: [dev] RE:Re: [dev] RE:[dev] question about use XStorage in
filt
Date:07-06-26 15:17:15
Thank you for your explaination!
Now I get an idea of storing a file clearly.:-)
----- Original Message -----
From:Mathias Bauer
To:[email protected]
Subject:Re: [dev] RE:Re: [dev] RE:[dev] question about use XStorage in filter
Date:07-06-25 14:55:37
Hi,
first thanks for fixing the problem with the mail client.
Now about the possible problem.
[EMAIL PROTECTED] wrote:
> ///create the target storage
>
> uno::Sequence aArgs( 2 );
> aArgs[0] aArgs[1] uno::Reference xTargetStorage(
> xStorageFactory->createInstanceWithArguments( aArgs ),
> uno::UNO_QUERY );
The problem is that you shouldn't use the URL, you must use the
outputstream that is provided to you. The framework opens a temporary
stream and finally copies it over the target file in the Commit() in
SfxObjectShell that you have quoted. The reason is simple: if something
goes wrong in the filter the original files isn't destroyed.
So even if you already create your file at the target location the
SfxObjectShell will overwrite it with all the content stored in the
output stream. In your case the stream is empty, thus the zero byte
length of the result.
Here's what a filter creating a storage should do:
- first create a temporary file
- get the XStream interface from it
- open a storage based on that stream
- copy the document into it
- add your substorage
- commit this storage(!)
- dispose of it
- copy from this stream to the XOutputStream from the arguments
- dispose of the TempFile
The content of the output stream is handled by the framework code. It
will close the stream and copy the bits if everything went fine.
Seeing your code I wonder whether we should add a "Stream" argument so
that you don't need to create the temporary copy. But for the time being
you should proceed as recommended.
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]
-------------------------------------------------------------------
MOTO新摄会 狂拍无极限 超多好礼等你来赢(
http://d1.sina.com.cn/sina/limeng3/mail_zhuiyu/2007/mail_zhuiyu_20070625.html )
===================================================================
注册新浪2G免费邮箱( http://mail.sina.com.cn/chooseMode.html )
-------------------------------------------------------------------
7月11日《变形金刚》首映电影票开抢了!(
http://d1.sina.com.cn/sina/limeng3/mail_zhuiyu/2007/mail_zhuiyu_20070702.html )
===================================================================
注册新浪2G免费邮箱( http://mail.sina.com.cn/chooseMode.html )