xref: /AOO41X/main/wizards/com/sun/star/wizards/web/data/CGLayout.java (revision a1b4a26b27259a85a9821d1e8083147f257d71ca)
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
10cdf0e10cSrcweir  *
11*a1b4a26bSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
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.
19cdf0e10cSrcweir  *
20*a1b4a26bSAndrew Rist  *************************************************************/
21*a1b4a26bSAndrew Rist 
22*a1b4a26bSAndrew Rist 
23cdf0e10cSrcweir package com.sun.star.wizards.web.data;
24cdf0e10cSrcweir 
25cdf0e10cSrcweir import com.sun.star.wizards.ui.UIConsts;
26cdf0e10cSrcweir import java.util.Hashtable;
27cdf0e10cSrcweir import java.util.Map;
28cdf0e10cSrcweir 
29cdf0e10cSrcweir import javax.xml.transform.*;
30cdf0e10cSrcweir import javax.xml.transform.stream.StreamSource;
31cdf0e10cSrcweir 
32cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory;
33cdf0e10cSrcweir import com.sun.star.wizards.common.FileAccess;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir public class CGLayout extends ConfigSetItem
36cdf0e10cSrcweir {
37cdf0e10cSrcweir 
38cdf0e10cSrcweir     public String cp_Name;
39cdf0e10cSrcweir     public String cp_FSName;
40cdf0e10cSrcweir     private Map templates;
41cdf0e10cSrcweir 
createTemplates(XMultiServiceFactory xmsf)42cdf0e10cSrcweir     private void createTemplates(XMultiServiceFactory xmsf) throws Exception
43cdf0e10cSrcweir     {
44cdf0e10cSrcweir 
45cdf0e10cSrcweir         templates = new Hashtable(3);
46cdf0e10cSrcweir 
47cdf0e10cSrcweir         TransformerFactory tf = TransformerFactory.newInstance();
48cdf0e10cSrcweir 
49cdf0e10cSrcweir         String workPath = getSettings().workPath;
50cdf0e10cSrcweir         FileAccess fa = new FileAccess(xmsf);
51cdf0e10cSrcweir         String stylesheetPath = fa.getURL(getSettings().workPath, "layouts/" + cp_FSName);
52cdf0e10cSrcweir 
53cdf0e10cSrcweir         String[] files = fa.listFiles(stylesheetPath, false);
54cdf0e10cSrcweir 
55cdf0e10cSrcweir         for (int i = 0; i < files.length; i++)
56cdf0e10cSrcweir         {
57cdf0e10cSrcweir             if (FileAccess.getExtension(files[i]).equals("xsl"))
58cdf0e10cSrcweir             {
59cdf0e10cSrcweir                 templates.put(FileAccess.getFilename(files[i]), tf.newTemplates(new StreamSource(files[i])));
60cdf0e10cSrcweir             }
61cdf0e10cSrcweir         }
62cdf0e10cSrcweir     }
63cdf0e10cSrcweir 
getImageUrls()64cdf0e10cSrcweir     public Object[] getImageUrls()
65cdf0e10cSrcweir     {
66cdf0e10cSrcweir         Object[] sRetUrls = new Object[1];
67cdf0e10cSrcweir         int ResId = UIConsts.RID_IMG_WEB + (cp_Index * 2);
68cdf0e10cSrcweir         return new Integer[]
69cdf0e10cSrcweir                 {
70cdf0e10cSrcweir                     new Integer(ResId), new Integer(ResId + 1)
71cdf0e10cSrcweir                 };
72cdf0e10cSrcweir     }
73cdf0e10cSrcweir 
getTemplates(XMultiServiceFactory xmsf)74cdf0e10cSrcweir     public Map getTemplates(XMultiServiceFactory xmsf) throws Exception
75cdf0e10cSrcweir     {
76cdf0e10cSrcweir 
77cdf0e10cSrcweir         // TODO uncomment...
78cdf0e10cSrcweir         // if (templates==null)
79cdf0e10cSrcweir         createTemplates(xmsf);
80cdf0e10cSrcweir 
81cdf0e10cSrcweir         return templates;
82cdf0e10cSrcweir     }
83cdf0e10cSrcweir }
84