1*e6e6073dSLiu Zhe /************************************************************** 2*e6e6073dSLiu Zhe * 3*e6e6073dSLiu Zhe * Licensed to the Apache Software Foundation (ASF) under one 4*e6e6073dSLiu Zhe * or more contributor license agreements. See the NOTICE file 5*e6e6073dSLiu Zhe * distributed with this work for additional information 6*e6e6073dSLiu Zhe * regarding copyright ownership. The ASF licenses this file 7*e6e6073dSLiu Zhe * to you under the Apache License, Version 2.0 (the 8*e6e6073dSLiu Zhe * "License"); you may not use this file except in compliance 9*e6e6073dSLiu Zhe * with the License. You may obtain a copy of the License at 10*e6e6073dSLiu Zhe * 11*e6e6073dSLiu Zhe * http://www.apache.org/licenses/LICENSE-2.0 12*e6e6073dSLiu Zhe * 13*e6e6073dSLiu Zhe * Unless required by applicable law or agreed to in writing, 14*e6e6073dSLiu Zhe * software distributed under the License is distributed on an 15*e6e6073dSLiu Zhe * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*e6e6073dSLiu Zhe * KIND, either express or implied. See the License for the 17*e6e6073dSLiu Zhe * specific language governing permissions and limitations 18*e6e6073dSLiu Zhe * under the License. 19*e6e6073dSLiu Zhe * 20*e6e6073dSLiu Zhe *************************************************************/ 21*e6e6073dSLiu Zhe package testlib.uno; 22*e6e6073dSLiu Zhe 23*e6e6073dSLiu Zhe import com.sun.star.container.XIndexAccess; 24*e6e6073dSLiu Zhe import com.sun.star.drawing.XDrawPage; 25*e6e6073dSLiu Zhe import com.sun.star.drawing.XDrawPagesSupplier; 26*e6e6073dSLiu Zhe import com.sun.star.drawing.XShapes; 27*e6e6073dSLiu Zhe import com.sun.star.lang.XComponent; 28*e6e6073dSLiu Zhe import com.sun.star.uno.UnoRuntime; 29*e6e6073dSLiu Zhe 30*e6e6073dSLiu Zhe /** 31*e6e6073dSLiu Zhe * 32*e6e6073dSLiu Zhe * 33*e6e6073dSLiu Zhe */ 34*e6e6073dSLiu Zhe public class SDUtil { 35*e6e6073dSLiu Zhe 36*e6e6073dSLiu Zhe private SDUtil() { 37*e6e6073dSLiu Zhe 38*e6e6073dSLiu Zhe } 39*e6e6073dSLiu Zhe 40*e6e6073dSLiu Zhe public static Object getPageByIndex(XComponent doc, int index) throws Exception { 41*e6e6073dSLiu Zhe XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(XDrawPagesSupplier.class, doc); 42*e6e6073dSLiu Zhe Object drawPages = xDrawPagesSupplier.getDrawPages(); 43*e6e6073dSLiu Zhe XIndexAccess xIndexedDrawPages = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, drawPages); 44*e6e6073dSLiu Zhe return xIndexedDrawPages.getByIndex(index); 45*e6e6073dSLiu Zhe } 46*e6e6073dSLiu Zhe 47*e6e6073dSLiu Zhe public static Object getShapeOfPageByIndex(Object page, int index) throws Exception { 48*e6e6073dSLiu Zhe XDrawPage xDrawPage = (XDrawPage) UnoRuntime.queryInterface(XDrawPage.class, page); 49*e6e6073dSLiu Zhe XShapes m_xdrawShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xDrawPage); 50*e6e6073dSLiu Zhe return m_xdrawShapes.getByIndex(index); 51*e6e6073dSLiu Zhe } 52*e6e6073dSLiu Zhe 53*e6e6073dSLiu Zhe } 54