[EMAIL PROTECTED] wrote:
> sal_Bool SAL_CALL XXFilter::filter( const Sequence< PropertyValue >&
> rDescriptor )
> throw (RuntimeException)
> {
> Window* pFocusWindow = Application::GetFocusWindow();
>
> if( pFocusWindow )
> pFocusWindow->EnterWait();
Please! Don't use any GUI code in filter components. This is not a job
of the filter. You never know in which content your code will be called.
> 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 ?
I don't understand why you need to write a filter that does the same as
the default filter. I assume that you have some additional code in your
filter that loads your own data and then wants to pass the storage to
the document so that it can load as it would to for the original format,
correct?
There's a new API especially for filters that create a legal ODF
document storage themselves and just want to hand it over to the document
model. It goes like this:
Sequence< Any > aArgs( 2 );
aArgs[0] <<= xDoc;
aArgs[1] <<= xStream; // the stream you have got!
Reference< XFilter > xSubFilter;
try
{
// mxMSF is the service factory you received in
// the ctor of your filter
xSubFilter = Reference<XFilter>(
mxMSF->createInstanceWithArguments(
OUString( RTL_CONSTASCII_USTRINGPARAM(
"com.sun.star.document.OwnSubFilter" ) ),
aArgs ),
UNO_QUERY );
xSubFilter->filter( aDescriptor ); // the original descriptor
}
catch(Exception& )
{
// ...
}
I don't know if it works when the provided stream itself *is* an ODF
storage but you can try it out and tell us if it works. :-)
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]