1*a1b4a26bSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*a1b4a26bSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*a1b4a26bSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*a1b4a26bSAndrew Rist * distributed with this work for additional information 6*a1b4a26bSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*a1b4a26bSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*a1b4a26bSAndrew Rist * "License"); you may not use this file except in compliance 9*a1b4a26bSAndrew Rist * with the License. You may obtain a copy of the License at 10*a1b4a26bSAndrew Rist * 11*a1b4a26bSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*a1b4a26bSAndrew Rist * 13*a1b4a26bSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*a1b4a26bSAndrew Rist * software distributed under the License is distributed on an 15*a1b4a26bSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*a1b4a26bSAndrew Rist * KIND, either express or implied. See the License for the 17*a1b4a26bSAndrew Rist * specific language governing permissions and limitations 18*a1b4a26bSAndrew Rist * under the License. 19*a1b4a26bSAndrew Rist * 20*a1b4a26bSAndrew Rist *************************************************************/ 21*a1b4a26bSAndrew Rist 22*a1b4a26bSAndrew Rist 23cdf0e10cSrcweir package com.sun.star.wizards.web.data; 24cdf0e10cSrcweir 25cdf0e10cSrcweir import javax.xml.parsers.DocumentBuilderFactory; 26cdf0e10cSrcweir import javax.xml.parsers.ParserConfigurationException; 27cdf0e10cSrcweir 28cdf0e10cSrcweir import com.sun.star.wizards.common.*; 29cdf0e10cSrcweir 30cdf0e10cSrcweir import org.w3c.dom.Document; 31cdf0e10cSrcweir import org.w3c.dom.Node; 32cdf0e10cSrcweir 33cdf0e10cSrcweir public class CGSession extends ConfigSetItem implements XMLProvider 34cdf0e10cSrcweir { 35cdf0e10cSrcweir 36cdf0e10cSrcweir public String cp_InDirectory; 37cdf0e10cSrcweir public String cp_OutDirectory; 38cdf0e10cSrcweir public String cp_Name; 39cdf0e10cSrcweir public CGContent cp_Content = new CGContent(); 40cdf0e10cSrcweir public CGDesign cp_Design = new CGDesign(); 41cdf0e10cSrcweir public CGGeneralInfo cp_GeneralInfo = new CGGeneralInfo(); 42cdf0e10cSrcweir public ConfigSet cp_Publishing = new ConfigSet(CGPublish.class); 43cdf0e10cSrcweir public CGStyle style; // !!! 44cdf0e10cSrcweir public boolean valid = false; 45cdf0e10cSrcweir createDOM(Node parent)46cdf0e10cSrcweir public Node createDOM(Node parent) 47cdf0e10cSrcweir { 48cdf0e10cSrcweir Node root = XMLHelper.addElement(parent, "session", 49cdf0e10cSrcweir new String[] 50cdf0e10cSrcweir { 51cdf0e10cSrcweir "name", "screen-size" 52cdf0e10cSrcweir }, 53cdf0e10cSrcweir new String[] 54cdf0e10cSrcweir { 55cdf0e10cSrcweir cp_Name, getScreenSize() 56cdf0e10cSrcweir }); 57cdf0e10cSrcweir 58cdf0e10cSrcweir //cp_Design.createDOM(root); 59cdf0e10cSrcweir cp_GeneralInfo.createDOM(root); 60cdf0e10cSrcweir //cp_Publishing.createDOM(root); 61cdf0e10cSrcweir cp_Content.createDOM(root); 62cdf0e10cSrcweir 63cdf0e10cSrcweir return root; 64cdf0e10cSrcweir } 65cdf0e10cSrcweir getScreenSize()66cdf0e10cSrcweir private String getScreenSize() 67cdf0e10cSrcweir { 68cdf0e10cSrcweir switch (cp_Design.cp_OptimizeDisplaySize) 69cdf0e10cSrcweir { 70cdf0e10cSrcweir case 0: 71cdf0e10cSrcweir return "640"; 72cdf0e10cSrcweir case 1: 73cdf0e10cSrcweir return "800"; 74cdf0e10cSrcweir case 2: 75cdf0e10cSrcweir return "1024"; 76cdf0e10cSrcweir default: 77cdf0e10cSrcweir return "800"; 78cdf0e10cSrcweir } 79cdf0e10cSrcweir } 80cdf0e10cSrcweir getLayout()81cdf0e10cSrcweir public CGLayout getLayout() 82cdf0e10cSrcweir { 83cdf0e10cSrcweir return (CGLayout) ((CGSettings) root).cp_Layouts.getElement(cp_Design.cp_Layout); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir getStyle()86cdf0e10cSrcweir public CGStyle getStyle() 87cdf0e10cSrcweir { 88cdf0e10cSrcweir return (CGStyle) ((CGSettings) root).cp_Styles.getElement(cp_Design.cp_Style); 89cdf0e10cSrcweir } 90cdf0e10cSrcweir setLayout(short[] layout)91cdf0e10cSrcweir public void setLayout(short[] layout) 92cdf0e10cSrcweir { 93cdf0e10cSrcweir //dummy 94cdf0e10cSrcweir } 95cdf0e10cSrcweir createDOM()96cdf0e10cSrcweir public Node createDOM() 97cdf0e10cSrcweir throws ParserConfigurationException 98cdf0e10cSrcweir { 99cdf0e10cSrcweir 100cdf0e10cSrcweir DocumentBuilderFactory factory = 101cdf0e10cSrcweir DocumentBuilderFactory.newInstance(); 102cdf0e10cSrcweir Document doc = factory.newDocumentBuilder().newDocument(); 103cdf0e10cSrcweir createDOM(doc); 104cdf0e10cSrcweir return doc; 105cdf0e10cSrcweir } 106cdf0e10cSrcweir } 107