[Solved] Two services in the same class?

The Application Programming Interface and the OASIS Open Document Format

[Solved] Two services in the same class?

Postby DavidBo » Mon Mar 01, 2021 9:12 pm

I try to modify the StarterProject which goes by the LOEclipse plugin.
I have added the "com.sun.star.frame.ProtocolHandler" and implemented the interfaces
com.sun.star.frame.XDispatchProvider, XDispatch

But only the original service seems to work the "org.libreoffice.example.StarterProject". I don't get any error messages, it is just that none of the newly added methods are ever called. :shock:

Is it not possible to implement two services in the same class?
The beginning of the code:

Code: Select all   Expand viewCollapse view
package org.libreoffice.example.comp;

import com.sun.star.uno.XComponentContext;
import com.sun.star.lib.uno.helper.Factory;

import org.libreoffice.example.dialog.ActionOneDialog;
import org.libreoffice.example.helper.DialogHelper;

import com.sun.star.frame.XFrame;
import com.sun.star.frame.XController;
import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XModel;
import com.sun.star.lang.XMultiComponentFactory;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XSingleComponentFactory;
import com.sun.star.registry.XRegistryKey;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.beans.NamedValue;
import com.sun.star.beans.PropertyValue;
import com.sun.star.frame.XController;
import com.sun.star.ui.XContextMenuInterceptor;
import com.sun.star.ui.XContextMenuInterception;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Type;
import com.sun.star.uno.UnoRuntime;

public final class StarterProjectImpl extends WeakBase
   implements com.sun.star.lang.XServiceInfo,
              com.sun.star.frame.XDispatchProvider, XDispatch
    private final XComponentContext m_xContext;
    private XFrame m_xFrame;
    private static final String m_implementationName = StarterProjectImpl.class.getName();
    private static final String[] m_serviceNames = {
        "org.libreoffice.example.StarterProject","com.sun.star.frame.ProtocolHandler" };

    public StarterProjectImpl( XComponentContext context )
        m_xContext = context;

    public static XSingleComponentFactory __getComponentFactory( String sImplementationName ) {
        XSingleComponentFactory xFactory = null;

        if ( sImplementationName.equals( m_implementationName ) )
            xFactory = Factory.createComponentFactory(StarterProjectImpl.class, m_serviceNames);
        return xFactory;

    public static boolean __writeRegistryServiceInfo( XRegistryKey xRegistryKey ) {
        return Factory.writeRegistryServiceInfo(m_implementationName,

    // com.sun.star.lang.XServiceInfo:
    public String getImplementationName() {
         return m_implementationName;

    public boolean supportsService( String sService ) {
        int len = m_serviceNames.length;

        for( int i=0; i < len; i++) {
            if (sService.equals(m_serviceNames[i]))
                return true;
        return false;

    public String[] getSupportedServiceNames() {
        return m_serviceNames;
Last edited by MrProgrammer on Fri Mar 05, 2021 11:01 pm, edited 3 times in total.
Reason: Tagged [Solved]
Apache Open Office 4.1.9 Windows 10
Posts: 27
Joined: Thu Mar 12, 2009 3:57 pm

Re: Two services in the same class?

Postby DavidBo » Fri Mar 05, 2021 3:27 pm

It is possible to have several services in the same class.
But many of the service methods in my example will not be called unless jobs.xcu, addons.xcu or/and ProtolHandler.xcu have been configured properly.
Apache Open Office 4.1.9 Windows 10
Posts: 27
Joined: Thu Mar 12, 2009 3:57 pm

Re: Two services in the same class?

Postby Hagar Delest » Fri Mar 05, 2021 6:35 pm

Have you fixed your problem eventually?
The green icon (especially in first post) is to tell that the problem has been solved. It can be misleading if you are waiting for further help.
LibreOffice 7.2.1 on Xubuntu 21.04 and 7.2.1 portable on Windows 10
User avatar
Hagar Delest
Posts: 30161
Joined: Sun Oct 07, 2007 9:07 pm
Location: France

Re: Two services in the same class?

Postby DavidBo » Fri Mar 05, 2021 10:21 pm

Yes it has been solved therefore i gave it a green V . The problem was that I didn't configure any *.xcu file
Apache Open Office 4.1.9 Windows 10
Posts: 27
Joined: Thu Mar 12, 2009 3:57 pm

Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest