1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 package com.sun.star.wizards.web.data; 28 29 import javax.xml.parsers.DocumentBuilderFactory; 30 import javax.xml.parsers.ParserConfigurationException; 31 32 import com.sun.star.wizards.common.*; 33 34 import org.w3c.dom.Document; 35 import org.w3c.dom.Node; 36 37 public class CGSession extends ConfigSetItem implements XMLProvider 38 { 39 40 public String cp_InDirectory; 41 public String cp_OutDirectory; 42 public String cp_Name; 43 public CGContent cp_Content = new CGContent(); 44 public CGDesign cp_Design = new CGDesign(); 45 public CGGeneralInfo cp_GeneralInfo = new CGGeneralInfo(); 46 public ConfigSet cp_Publishing = new ConfigSet(CGPublish.class); 47 public CGStyle style; // !!! 48 public boolean valid = false; 49 50 public Node createDOM(Node parent) 51 { 52 Node root = XMLHelper.addElement(parent, "session", 53 new String[] 54 { 55 "name", "screen-size" 56 }, 57 new String[] 58 { 59 cp_Name, getScreenSize() 60 }); 61 62 //cp_Design.createDOM(root); 63 cp_GeneralInfo.createDOM(root); 64 //cp_Publishing.createDOM(root); 65 cp_Content.createDOM(root); 66 67 return root; 68 } 69 70 private String getScreenSize() 71 { 72 switch (cp_Design.cp_OptimizeDisplaySize) 73 { 74 case 0: 75 return "640"; 76 case 1: 77 return "800"; 78 case 2: 79 return "1024"; 80 default: 81 return "800"; 82 } 83 } 84 85 public CGLayout getLayout() 86 { 87 return (CGLayout) ((CGSettings) root).cp_Layouts.getElement(cp_Design.cp_Layout); 88 } 89 90 public CGStyle getStyle() 91 { 92 return (CGStyle) ((CGSettings) root).cp_Styles.getElement(cp_Design.cp_Style); 93 } 94 95 public void setLayout(short[] layout) 96 { 97 //dummy 98 } 99 100 public Node createDOM() 101 throws ParserConfigurationException 102 { 103 104 DocumentBuilderFactory factory = 105 DocumentBuilderFactory.newInstance(); 106 Document doc = factory.newDocumentBuilder().newDocument(); 107 createDOM(doc); 108 return doc; 109 } 110 } 111