1 /*************************************************************************
3 * $RCSfile: ImageShrink.java,v $
7 * last change: $Author: rt $ $Date: 2005-01-31 16:17:04 $
9 * The Contents of this file are made available subject to the terms of
12 * Copyright (c) 2003 by Sun Microsystems, Inc.
13 * All rights reserved.
15 * Redistribution and use in source and binary forms, with or without
16 * modification, are permitted provided that the following conditions
18 * 1. Redistributions of source code must retain the above copyright
19 * notice, this list of conditions and the following disclaimer.
20 * 2. Redistributions in binary form must reproduce the above copyright
21 * notice, this list of conditions and the following disclaimer in the
22 * documentation and/or other materials provided with the distribution.
23 * 3. Neither the name of Sun Microsystems, Inc. nor the names of its
24 * contributors may be used to endorse or promote products derived
25 * from this software without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
35 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
36 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
37 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39 *************************************************************************/
41 package org
.openoffice
.comp
.test
;
47 * Created on 4. Mai 2002, 20:25
56 import com
.sun
.star
.lang
.XSingleServiceFactory
;
57 import com
.sun
.star
.lang
.XMultiServiceFactory
;
58 import com
.sun
.star
.registry
.XRegistryKey
;
59 import com
.sun
.star
.comp
.loader
.FactoryHelper
;
60 import com
.sun
.star
.lib
.uno
.helper
.WeakBase
;
62 public class ImageShrink
extends WeakBase
63 implements com
.sun
.star
.lang
.XServiceInfo
,
64 org
.openoffice
.test
.XImageShrinkFilter
{
66 com
.sun
.star
.uno
.XComponentContext xComponentContext
= null;
69 // maintain a static implementation id for all instances of ImageShrink
70 // initialized by the first call to getImplementationId()
71 static byte[] _implementationId
;
74 // hold the service name in a private static member variable of the class
75 protected static final String __serviceName
= "org.openoffice.test.ImageShrink";
79 String sourceDir
= "";
80 boolean cancel
= false;
81 com
.sun
.star
.awt
.Size dimension
= new com
.sun
.star
.awt
.Size();
83 /** Creates a new instance of ImageShrink */
84 public ImageShrink() {
88 // static __getServiceFactory() Implementation
89 public static XSingleServiceFactory
__getServiceFactory(String implName
,
90 XMultiServiceFactory multiFactory
,
91 com
.sun
.star
.registry
.XRegistryKey regKey
) {
93 com
.sun
.star
.lang
.XSingleServiceFactory xSingleServiceFactory
= null;
94 if (implName
.equals( ImageShrink
.class.getName()) )
95 xSingleServiceFactory
= FactoryHelper
.getServiceFactory( ImageShrink
.class,
96 ImageShrink
.__serviceName
,
100 return xSingleServiceFactory
;
102 public static boolean __writeRegistryServiceInfo(XRegistryKey regKey
) {
103 //System.out.println(ImageShrink.class.getName());
104 return FactoryHelper
.writeRegistryServiceInfo( ImageShrink
.class.getName(),
109 // XFilter implementation (a sub-interface of XImageShrinkFilter)
110 public void cancel() {
114 public boolean filter(com
.sun
.star
.beans
.PropertyValue
[] propertyValue
) {
115 // while cancel = false,
116 // scale images found in sourceDir according to dimension and
117 // write them to destDir, using the image file format given in
124 // XImageShrink implementation (a sub-interface of XImageShrinkFilter)
125 public String
getDestinationDirectory() {
129 public com
.sun
.star
.awt
.Size
getDimension() {
133 public String
getSourceDirectory() {
137 public void setDestinationDirectory(String str
) {
141 public void setDimension(com
.sun
.star
.awt
.Size size
) {
145 public void setSourceDirectory(String str
) {
149 //XServiceInfo implementation
150 public String
getImplementationName( ) {
151 return getClass().getName();
154 public boolean supportsService(String serviceName
) {
155 if ( serviceName
.equals( __serviceName
))
160 public String
[] getSupportedServiceNames( ) {
161 return new String
[] { __serviceName
};