[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?

Yes, I add the fingerprints of the document's creator into the substorage when saving the document. when opening it, I want to judge if the fingerprints are match the fingerprints of who open it ,if match loading the document as original format.
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. :-)

Sorry, there is no OwnSubFilter service in my openoffice, my openoffice
is based on the source of OOB680 .

I want to try an other way.
My idea is  as following:
1. use loadComponentFromURLto open the document in hidden mode.
2. copy the whole content and style from the XComponent returned fronm loadComponentFromURL to the mxDesDoc which is set by setTargetDocument.
3. close the hidden document.

Can I do in the filter in this way?
Could you tell me how to copy the whole content and style from one document to another if this way works?
Thanks!

Best wishes!

chensuchun

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to