SDUtil.java (e6e6073d) | SDUtil.java (43a102b2) |
---|---|
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 --- 6 unchanged lines hidden (view full) --- 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 *************************************************************/ 21package testlib.uno; 22 | 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 --- 6 unchanged lines hidden (view full) --- 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 *************************************************************/ 21package testlib.uno; 22 |
23import java.util.HashMap; 24 25import org.openoffice.test.common.Testspace; 26 27import com.sun.star.beans.PropertyValue; |
|
23import com.sun.star.container.XIndexAccess; 24import com.sun.star.drawing.XDrawPage; 25import com.sun.star.drawing.XDrawPagesSupplier; 26import com.sun.star.drawing.XShapes; | 28import com.sun.star.container.XIndexAccess; 29import com.sun.star.drawing.XDrawPage; 30import com.sun.star.drawing.XDrawPagesSupplier; 31import com.sun.star.drawing.XShapes; |
32import com.sun.star.frame.XStorable; |
|
27import com.sun.star.lang.XComponent; 28import com.sun.star.uno.UnoRuntime; 29 30/** 31 * 32 * 33 */ 34public class SDUtil { 35 | 33import com.sun.star.lang.XComponent; 34import com.sun.star.uno.UnoRuntime; 35 36/** 37 * 38 * 39 */ 40public class SDUtil { 41 |
42 private static HashMap filterName = new HashMap(); 43 |
|
36 private SDUtil() { 37 38 } 39 40 public static Object getPageByIndex(XComponent doc, int index) throws Exception { 41 XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(XDrawPagesSupplier.class, doc); 42 Object drawPages = xDrawPagesSupplier.getDrawPages(); 43 XIndexAccess xIndexedDrawPages = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, drawPages); 44 return xIndexedDrawPages.getByIndex(index); 45 } 46 47 public static Object getShapeOfPageByIndex(Object page, int index) throws Exception { 48 XDrawPage xDrawPage = (XDrawPage) UnoRuntime.queryInterface(XDrawPage.class, page); 49 XShapes m_xdrawShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xDrawPage); 50 return m_xdrawShapes.getByIndex(index); 51 } | 44 private SDUtil() { 45 46 } 47 48 public static Object getPageByIndex(XComponent doc, int index) throws Exception { 49 XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(XDrawPagesSupplier.class, doc); 50 Object drawPages = xDrawPagesSupplier.getDrawPages(); 51 XIndexAccess xIndexedDrawPages = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, drawPages); 52 return xIndexedDrawPages.getByIndex(index); 53 } 54 55 public static Object getShapeOfPageByIndex(Object page, int index) throws Exception { 56 XDrawPage xDrawPage = (XDrawPage) UnoRuntime.queryInterface(XDrawPage.class, page); 57 XShapes m_xdrawShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xDrawPage); 58 return m_xdrawShapes.getByIndex(index); 59 } |
60 61 public static void saveFileAs(XComponent sdComponent, String fileName, String extName) throws Exception { 62 63 initFilterName(); |
|
52 | 64 |
65 String storeUrl = Testspace.getUrl("temp/" + fileName + "." + extName); 66 67 PropertyValue[] storeProps = new PropertyValue[2]; 68 storeProps[0] = new PropertyValue(); 69 storeProps[0].Name = "FilterName"; 70 storeProps[0].Value = filterName.get(extName); 71 storeProps[1] = new PropertyValue(); 72 storeProps[1].Name = "Overwrite"; 73 storeProps[1].Value = new Boolean(true); 74 75 XStorable sdStorable = 76 (XStorable) UnoRuntime.queryInterface(XStorable.class, sdComponent); 77 sdStorable.storeAsURL(storeUrl, storeProps); 78 } 79 80 private static void initFilterName() throws Exception { 81 if (filterName.size() > 0) { 82 return; 83 } 84 85 filterName.put("odp", "impress8"); 86 filterName.put("ppt", "MS PowerPoint 97"); 87 } 88 |
|
53} | 89} |