File: W2XRegistration.java

package info (click to toggle)
writer2latex 1.6.1-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 13,456 kB
  • sloc: java: 33,474; xml: 4,710; javascript: 3,067; sh: 67; makefile: 29
file content (167 lines) | stat: -rw-r--r-- 7,687 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/************************************************************************
 *
 *  W2XRegistration.java
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *  Copyright: 2002-2015 by Henrik Just
 *
 *  All Rights Reserved.
 * 
 *  Version 1.6 (2015-04-28) 
 *
 */ 
 
package org.openoffice.da.comp.writer2xhtml;

import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.lang.XSingleServiceFactory;
import com.sun.star.registry.XRegistryKey;

import com.sun.star.comp.loader.FactoryHelper;

/** This class provides a static method to instantiate our uno components
 * on demand (__getServiceFactory()), and a static method to give
 * information about the components (__writeRegistryServiceInfo()).
 * Furthermore, it saves the XMultiServiceFactory provided to the
 * __getServiceFactory method for future reference by the componentes.
 */
public class W2XRegistration {
    
    public static XMultiServiceFactory xMultiServiceFactory;

    /**
     * Returns a factory for creating the service.
     * This method is called by the <code>JavaLoader</code>
     *
     * @return  returns a <code>XSingleServiceFactory</code> for creating the
     *          component
     *
     * @param   implName     the name of the implementation for which a
     *                       service is desired
     * @param   multiFactory the service manager to be used if needed
     * @param   regKey       the registryKey
     *
     * @see                  com.sun.star.comp.loader.JavaLoader
     */
    public static XSingleServiceFactory __getServiceFactory(String implName,
        XMultiServiceFactory multiFactory, XRegistryKey regKey) {
        xMultiServiceFactory = multiFactory;
        XSingleServiceFactory xSingleServiceFactory = null;
        if (implName.equals(Writer2xhtml.__implementationName) ) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(Writer2xhtml.class,
            Writer2xhtml.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(W2XExportFilter.class.getName()) ) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(W2XExportFilter.class,
            W2XExportFilter.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(BatchConverter.__implementationName) ) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(BatchConverter.class,
            BatchConverter.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(XhtmlOptionsDialog.__implementationName)) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(XhtmlOptionsDialog.class,
            XhtmlOptionsDialog.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(XhtmlOptionsDialogMath.__implementationName)) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(XhtmlOptionsDialogMath.class,
            XhtmlOptionsDialogMath.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(XhtmlOptionsDialogCalc.__implementationName)) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(XhtmlOptionsDialogCalc.class,
            XhtmlOptionsDialogCalc.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(EpubOptionsDialog.__implementationName)) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(EpubOptionsDialog.class,
            EpubOptionsDialog.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(Epub3OptionsDialog.__implementationName)) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(Epub3OptionsDialog.class,
            Epub3OptionsDialog.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(EpubMetadataDialog.__implementationName)) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(EpubMetadataDialog.class,
            EpubMetadataDialog.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(ConfigurationDialog.__implementationName)) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(ConfigurationDialog.class,
            ConfigurationDialog.__serviceName,
            multiFactory,						    
            regKey);
        }
        else if (implName.equals(ToolbarSettingsDialog.__implementationName)) {
            xSingleServiceFactory = FactoryHelper.getServiceFactory(ToolbarSettingsDialog.class,
            ToolbarSettingsDialog.__serviceName,
            multiFactory,						    
            regKey);
        }
        
        return xSingleServiceFactory;
    }
    
    /**
     * Writes the service information into the given registry key.
     * This method is called by the <code>JavaLoader</code>
     * <p>
     * @return  returns true if the operation succeeded
     * @param   regKey       the registryKey
     * @see                  com.sun.star.comp.loader.JavaLoader
     */
    public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
        return
            FactoryHelper.writeRegistryServiceInfo(BatchConverter.__implementationName,
                BatchConverter.__serviceName, regKey) &
            FactoryHelper.writeRegistryServiceInfo(Writer2xhtml.__implementationName,
                        Writer2xhtml.__serviceName, regKey) &
            FactoryHelper.writeRegistryServiceInfo(W2XExportFilter.__implementationName,
                W2XExportFilter.__serviceName, regKey) &
            FactoryHelper.writeRegistryServiceInfo(XhtmlOptionsDialog.__implementationName,
                XhtmlOptionsDialog.__serviceName, regKey) &
                FactoryHelper.writeRegistryServiceInfo(XhtmlOptionsDialogMath.__implementationName,
                        XhtmlOptionsDialogMath.__serviceName, regKey) &
            FactoryHelper.writeRegistryServiceInfo(XhtmlOptionsDialogCalc.__implementationName,
                XhtmlOptionsDialogCalc.__serviceName, regKey) & 
            FactoryHelper.writeRegistryServiceInfo(EpubOptionsDialog.__implementationName,
                        EpubOptionsDialog.__serviceName, regKey) &
            FactoryHelper.writeRegistryServiceInfo(Epub3OptionsDialog.__implementationName,
                        Epub3OptionsDialog.__serviceName, regKey) &
            FactoryHelper.writeRegistryServiceInfo(EpubMetadataDialog.__implementationName,
                        EpubMetadataDialog.__serviceName, regKey) &
            FactoryHelper.writeRegistryServiceInfo(ConfigurationDialog.__implementationName,
                ConfigurationDialog.__serviceName, regKey) &
            FactoryHelper.writeRegistryServiceInfo(ToolbarSettingsDialog.__implementationName,
                ToolbarSettingsDialog.__serviceName, regKey);
    }
}