1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 package org.openoffice.comp.test;
25 
26 
27 /*
28  * ImageShrink.java
29  *
30  * Created on 4. Mai 2002, 20:25
31  */
32 
33 
34 /**
35  *
36  * @author dschulten
37  */
38 
39 import com.sun.star.lang.XSingleServiceFactory;
40 import com.sun.star.lang.XMultiServiceFactory;
41 import com.sun.star.registry.XRegistryKey;
42 import com.sun.star.comp.loader.FactoryHelper;
43 import com.sun.star.lib.uno.helper.WeakBase;
44 
45 public class ImageShrink extends WeakBase
46         implements com.sun.star.lang.XServiceInfo,
47                    org.openoffice.test.XImageShrinkFilter {
48 
49     com.sun.star.uno.XComponentContext xComponentContext = null;
50 
51 
52     // maintain a static implementation id for all instances of ImageShrink
53     // initialized by the first call to getImplementationId()
54     static byte[] _implementationId;
55 
56 
57     // hold the service name in a private static member variable of the class
58     protected static final String __serviceName = "org.openoffice.test.ImageShrink";
59 
60 
61     String destDir = "";
62     String sourceDir = "";
63     boolean cancel = false;
64     com.sun.star.awt.Size dimension = new com.sun.star.awt.Size();
65 
66     /** Creates a new instance of ImageShrink */
ImageShrink()67     public ImageShrink() {
68     }
69 
70 
71         // static __getServiceFactory() Implementation
__getServiceFactory(String implName, XMultiServiceFactory multiFactory, com.sun.star.registry.XRegistryKey regKey)72     public static XSingleServiceFactory __getServiceFactory(String implName,
73             XMultiServiceFactory multiFactory,
74             com.sun.star.registry.XRegistryKey regKey)    {
75 
76         com.sun.star.lang.XSingleServiceFactory xSingleServiceFactory = null;
77         if (implName.equals( ImageShrink.class.getName()) )
78             xSingleServiceFactory = FactoryHelper.getServiceFactory( ImageShrink.class,
79                   ImageShrink.__serviceName,
80                   multiFactory,
81                   regKey);
82 
83         return xSingleServiceFactory;
84     }
85 
86     // This method not longer necessary since OOo 3.4 where the component registration
87     // was changed to passive component registration. For more details see
88     // https://wiki.openoffice.org/wiki/Passive_Component_Registration
89 
90 //     public static boolean __writeRegistryServiceInfo(XRegistryKey regKey)          {
91 //         //System.out.println(ImageShrink.class.getName());
92 //         return FactoryHelper.writeRegistryServiceInfo( ImageShrink.class.getName(),
93 //                                                     __serviceName,
94 //                                                     regKey);
95 //     }
96 
97     // XFilter implementation (a sub-interface of XImageShrinkFilter)
cancel()98     public void cancel() {
99         cancel = true;
100     }
101 
filter(com.sun.star.beans.PropertyValue[] propertyValue)102     public boolean filter(com.sun.star.beans.PropertyValue[] propertyValue) {
103         // while cancel = false,
104         // scale images found in sourceDir according to dimension and
105         // write them to destDir, using the image file format given in
106 
107 
108         // []propertyValue
109         return true;
110     }
111 
112     // XImageShrink implementation (a sub-interface of XImageShrinkFilter)
getDestinationDirectory()113     public String getDestinationDirectory() {
114         return destDir;
115     }
116 
getDimension()117     public com.sun.star.awt.Size getDimension() {
118         return dimension;
119     }
120 
getSourceDirectory()121     public String getSourceDirectory() {
122         return sourceDir;
123     }
124 
setDestinationDirectory(String str)125     public void setDestinationDirectory(String str) {
126         destDir = str;
127     }
128 
setDimension(com.sun.star.awt.Size size)129     public void setDimension(com.sun.star.awt.Size size) {
130         dimension = size;
131     }
132 
setSourceDirectory(String str)133     public void setSourceDirectory(String str) {
134         sourceDir = str;
135     }
136 
137     //XServiceInfo implementation
getImplementationName( )138     public String getImplementationName(  ) {
139         return getClass().getName();
140     }
141 
supportsService(String serviceName)142     public boolean supportsService(String serviceName) {
143         if ( serviceName.equals( __serviceName))
144             return true;
145         return false;
146     }
147 
getSupportedServiceNames( )148     public String[] getSupportedServiceNames(  ) {
149         return new String[] { __serviceName };
150     }
151 
152 }
153 
154