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 package com.sun.star.wizards.web.export; 24 25 import com.sun.star.io.IOException; 26 import com.sun.star.lang.XMultiServiceFactory; 27 import com.sun.star.wizards.common.PropertyNames; 28 import com.sun.star.wizards.ui.event.Task; 29 import com.sun.star.wizards.web.data.CGDocument; 30 import com.sun.star.wizards.web.data.CGSession; 31 32 /** 33 * @author rpiterman 34 * 35 * To change the template for this generated type comment go to 36 * Window>Preferences>Java>Code Generation>Code and Comments 37 */ 38 public class ImpressHTMLExporter extends ConfiguredExporter 39 { 40 41 private static final Integer SMALL_IMAGE = 512; 42 private static final Integer MEDIUM_IMAGE = 640; 43 private static final Integer LARGE_IMAGE = 800; 44 export(CGDocument source, String targetDirectory, XMultiServiceFactory xmsf, Task task)45 public boolean export(CGDocument source, String targetDirectory, XMultiServiceFactory xmsf, Task task) throws IOException 46 { 47 48 /* here set some filter specific properties. 49 * other properties, which are not dependant on 50 * user input are set through the exporter 51 * configuration. 52 */ 53 54 CGSession session = getSession(source); 55 56 props.put("Author", source.cp_Author); 57 props.put("Email", session.cp_GeneralInfo.cp_Email); 58 props.put("HomepageURL", getHomepageURL(session)); 59 props.put("UserText", source.cp_Title); 60 61 props.put(PropertyNames.PROPERTY_WIDTH, getImageWidth(session)); 62 63 /* 64 * props.put("BackColor",...); 65 * props.put("TextColor",...); 66 * props.put("LinkColor",...); 67 * props.put("VLinkColor",...); 68 * props.put("ALinkColor",...); 69 */ 70 props.put("UseButtonSet", new Integer(session.cp_Design.cp_IconSet)); 71 72 73 //now export 74 return super.export(source, targetDirectory, xmsf, task); 75 76 } 77 getHomepageURL(CGSession session)78 private String getHomepageURL(CGSession session) 79 { 80 return "../" + 81 (exporter.cp_OwnDirectory ? "../index.html" : "index.html"); 82 } 83 getImageWidth(CGSession session)84 private Integer getImageWidth(CGSession session) 85 { 86 switch (session.cp_Design.cp_OptimizeDisplaySize) 87 { 88 case 0: 89 return SMALL_IMAGE; 90 case 1: 91 return MEDIUM_IMAGE; 92 case 2: 93 return LARGE_IMAGE; 94 } 95 return MEDIUM_IMAGE; 96 } 97 getSession(CGDocument doc)98 private CGSession getSession(CGDocument doc) 99 { 100 return doc.getSettings().cp_DefaultSession; 101 } 102 } 103