Hi wheelsdong,

First you should try to use your job implementation manually to see if your implementation was registered successfully as valid UNO service inside services.rdb of OOo.

Please start the Basic IDE and type in the following small macro:

myjob = createUnoService ("com.example.MyAddOn")
msgbox myjob.dbg_supportedInterfaces ()

If it runs without errors it shows you the list of supported UNO interfaces provided by your MyAddOn implementation. If creation of such service fails ... you should check if your class name (including namespace) is the right one and match the configured value !

Further you should check (if creation of your service was successfully) if XJob or XAsyncJob are listed as supported interfaces. If not please check your implementation.


.... btw: Seems there is a further small mistake inside your Jobs.XCU file.
<node oor:name="com.example.MyAddOn.MyJob" oor:op="replace">
You should try oor:op="fuse" instead of "replace". Replace works for STILL existing entries only. But I'm sure that your job was never registered before inside OOo .-) Replace do not mean(!) "add or replace" ... that's why "fuse" was introduced later.

... same for other places where you used oor:op="replace" !

Regards
Andreas

Hi Andreas,

Thank you for finding the errors in the configuration files. I made modifications according to your suggestions. I changed the name of
Job to com.example.MyAddOn.MyJob, and put the proper implementation name of
my project. And registered the event OnViewCreated and onFirstVisibleTask. I
also add vnd.sun.star.job:event=onFirstVisibleTask in the Addons.xcu file.
I wish that the job will be trigged by the event onFirstVisibleTask. But
When I debug the program, the execute() function is not called at all.

I am afraid I am not understanding the Developer Guide correctly. I also
googled for tutorials or sample code, but didn't find any useful resources.
Would you please help review the code? Thank you very much!
Attachment is the project zip file.

The new Job.xcu file is as follows:
<oor:component-data oor:name="Jobs" oor:package="org.openoffice.Office"
xmlns:oor="http://openoffice.org/2001/registry";
xmlns:xs="http://www.w3.org/2001/XMLSchema";
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
    <node oor:name="Jobs">
        <node oor:name="com.example.MyAddOn.MyJob" oor:op="replace">
            <prop oor:name="Service" oor:type="xs:string">
                <value>com.example.MyAddOn</value>
            </prop>
            <node oor:name="Arguments">
                <prop oor:name="arg_1" oor:type="xs:string">
                    <value>val_1</value>
                </prop>
            </node>
        </node>
    </node>
    <node oor:name="Events">
        <node oor:name="OnViewCreated" oor:op="fuse">
            <node oor:name="JobList">
                <node oor:name="com.example.MyAddOn.MyJob"
oor:op="replace"/>
            </node>
        </node>
        <node oor:name="onFirstVisibleTask" oor:op="fuse">
            <node oor:name="JobList">
                <node oor:name="com.example.MyAddOn.MyJob"
oor:op="replace"/>
            </node>
        </node>
    </node>
</oor:component-data>

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

Reply via email to