Hello Mr. Loiseleur,

Thank you very much for your suggestions, it seems that the second
problem was caused by a parameter disorder, it is gone after I adjusted
the statements
-from-
OTempFileService::getTypes( )
{
...
static ::cppu::OTypeCollection aTypeCollection(
OTempFileBase::getTypes(),
::getCppuType( ( const ::css::uno::Reference< ::css::beans::XPropertySet
>*)NULL ) );
...
}
-to-
OTempFileService::getTypes( )
{
...
static ::cppu::OTypeCollection aTypeCollection(
::getCppuType( ( const ::css::uno::Reference< ::css::beans::XPropertySet
>*)NULL ),
OTempFileBase::getTypes() );
...
}

The first one is a bit more complex, I looked up the definition of class
PropertySetMixin() and did the following changes:
1. In XTempFile.hxx, changed the declaration of ctor OTempFileService();
to OTempFileService(::css::uno::Reference<::css::io::XTempFile> context);
2. In XTempFile.hxx, added another ctor
OTempFileService(OTempFileService &);
3. In XTempFile.cxx, changed the definition of OTempFileService() to:
OTempFileService::OTempFileService(::css::uno::Reference<
::css::uno::XComponentContext > const & context)
: mpStream( NULL )
, mbRemoveFile( sal_True )
, mbInClosed( sal_False )
, mbOutClosed( sal_False )
, mnCachedPos( 0 )
, mbHasCachedPos( sal_False )
,::cppu::PropertySetMixin< ::css::io::XTempFile >(
context
, static_cast< Implements >( IMPLEMENTS_PROPERTY_SET |
IMPLEMENTS_FAST_PROPERTY_SET | IMPLEMENTS_PROPERTY_ACCESS )
, NULL )
{
mpTempFile = new ::utl::TempFile;
mpTempFile->EnableKillingFile( sal_True );
}
4. In XTempFile.cxx, changed the definition of
XTempFile_createInstance() to:
::css::uno::Reference < ::css::uno::XInterface >SAL_CALL
XTempFile_createInstance(
const ::css::uno::Reference< ::css::lang::XMultiServiceFactory > &
/*xMgr*/ )
{
return ::css::uno::Reference< ::css::uno::XInterface >(
::cppu::defaultBootstrap_InitialComponentContext() );
}

After the steps the first error is gone and compiled the unotools module
successfully.

Nevertheless there's a new problem now: when I opened a new writer
document in the hacked version, a "Assertion Failed!"messagebox shows
this(for three times if "Ignore" is selected):
"Error: File xxxxxxx\sfx2\source\doc\objstor.cxx, Line 3039: The
document storage must be created!
(Yes=Abort / No=Ignore / Cancel=Debugger)"

I have not found out how to solve the problem yet. Could somebody give
me some help?

Best Regards,
Felix.

Michel Loiseleur 写道:
> Zhang Xiaofei a écrit :
>   
>> Hi Mikhail,
>>
>> Thanks for your last reply. I fixed the problems in your advice, and
>> some more during the compilation process, but there are still two
>> errors(as in error.log in the attachment), both of which seems to me
>> are originated from data type mismatches. Could you please tell me the
>> causes of and solutions to the errors?
>>     
> You have mainly 2 constructors problems.
>
> The first one is an inheritance problem. The class
> ::cppu::PropertySetMixin<css::io::XTempFile> from which you herit do not
> have any constructor without args. You need to find the appropriate
> constructor and call it in the implementation of your own class ctor.
> Something like this :
> OTempFileService::OTempFileService() :
> property1(init_args),
> property2(),
> ::cppu::PropertySetMixin<::com::sun::star::io::XTempFile>(init_args)
> {}
>
> The second one is because you give him a set of css::Type instead of a
> simple css::Type. That's what the compiler says :
>
> "cannot convert parameter 1 from 'com::sun::star::uno::Sequence<E>' to
> 'const com::sun::star::uno::Type &' with[E=com::sun::star::uno::Type]"
>
> The first parameters of your ctor is OTempFileBase::getTypes() which
> obviously returns a _sequence_ of css::Type. And you need a simple
> css::Type in this ctor.
>
> Possible Solution : Look in the ::cppu::TypeCollection class on how to
> add all thoses Types. But it seems you cannot add them during creation.
>
>
> My 2 cents, hope this helps, I haven't touched any of uno class yet.
> It's just advice from a C++ dev.
>
> Regards,
>   

Reply via email to