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.data; 24 25 import javax.xml.parsers.DocumentBuilderFactory; 26 import javax.xml.parsers.ParserConfigurationException; 27 28 import com.sun.star.wizards.common.*; 29 30 import org.w3c.dom.Document; 31 import org.w3c.dom.Node; 32 33 public class CGSession extends ConfigSetItem implements XMLProvider 34 { 35 36 public String cp_InDirectory; 37 public String cp_OutDirectory; 38 public String cp_Name; 39 public CGContent cp_Content = new CGContent(); 40 public CGDesign cp_Design = new CGDesign(); 41 public CGGeneralInfo cp_GeneralInfo = new CGGeneralInfo(); 42 public ConfigSet cp_Publishing = new ConfigSet(CGPublish.class); 43 public CGStyle style; // !!! 44 public boolean valid = false; 45 createDOM(Node parent)46 public Node createDOM(Node parent) 47 { 48 Node root = XMLHelper.addElement(parent, "session", 49 new String[] 50 { 51 "name", "screen-size" 52 }, 53 new String[] 54 { 55 cp_Name, getScreenSize() 56 }); 57 58 //cp_Design.createDOM(root); 59 cp_GeneralInfo.createDOM(root); 60 //cp_Publishing.createDOM(root); 61 cp_Content.createDOM(root); 62 63 return root; 64 } 65 getScreenSize()66 private String getScreenSize() 67 { 68 switch (cp_Design.cp_OptimizeDisplaySize) 69 { 70 case 0: 71 return "640"; 72 case 1: 73 return "800"; 74 case 2: 75 return "1024"; 76 default: 77 return "800"; 78 } 79 } 80 getLayout()81 public CGLayout getLayout() 82 { 83 return (CGLayout) ((CGSettings) root).cp_Layouts.getElement(cp_Design.cp_Layout); 84 } 85 getStyle()86 public CGStyle getStyle() 87 { 88 return (CGStyle) ((CGSettings) root).cp_Styles.getElement(cp_Design.cp_Style); 89 } 90 setLayout(short[] layout)91 public void setLayout(short[] layout) 92 { 93 //dummy 94 } 95 createDOM()96 public Node createDOM() 97 throws ParserConfigurationException 98 { 99 100 DocumentBuilderFactory factory = 101 DocumentBuilderFactory.newInstance(); 102 Document doc = factory.newDocumentBuilder().newDocument(); 103 createDOM(doc); 104 return doc; 105 } 106 } 107