ShapeUtil.java (645d376b) ShapeUtil.java (3908dc91)
1package testlib.uno;
2
3/**************************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file

--- 11 unchanged lines hidden (view full) ---

20 * under the License.
21 *
22 *************************************************************/
23
24// __________ Imports __________
25
26import com.sun.star.uno.Exception;
27import com.sun.star.uno.UnoRuntime;
1package testlib.uno;
2
3/**************************************************************
4 *
5 * Licensed to the Apache Software Foundation (ASF) under one
6 * or more contributor license agreements. See the NOTICE file
7 * distributed with this work for additional information
8 * regarding copyright ownership. The ASF licenses this file

--- 11 unchanged lines hidden (view full) ---

20 * under the License.
21 *
22 *************************************************************/
23
24// __________ Imports __________
25
26import com.sun.star.uno.Exception;
27import com.sun.star.uno.UnoRuntime;
28import com.sun.star.lang.WrappedTargetException;
28import com.sun.star.lang.XComponent;
29import com.sun.star.lang.XMultiServiceFactory;
30
31import com.sun.star.awt.Point;
32import com.sun.star.awt.Size;
33
34import com.sun.star.beans.XPropertySet;
35
29import com.sun.star.lang.XComponent;
30import com.sun.star.lang.XMultiServiceFactory;
31
32import com.sun.star.awt.Point;
33import com.sun.star.awt.Size;
34
35import com.sun.star.beans.XPropertySet;
36
37import com.sun.star.container.NoSuchElementException;
36import com.sun.star.container.XEnumeration;
37import com.sun.star.container.XEnumerationAccess;
38
39import com.sun.star.drawing.XShape;
40import com.sun.star.drawing.XShapes;
41
42import com.sun.star.text.ControlCharacter;
43import com.sun.star.text.XText;

--- 69 unchanged lines hidden (view full) ---

113 XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(
114 XTextRange.class, xTextCursor);
115 xTextRange.setString(sText);
116 xTextCursor.gotoEnd(true);
117 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
118 XPropertySet.class, xTextRange);
119 return xPropSet;
120 }
38import com.sun.star.container.XEnumeration;
39import com.sun.star.container.XEnumerationAccess;
40
41import com.sun.star.drawing.XShape;
42import com.sun.star.drawing.XShapes;
43
44import com.sun.star.text.ControlCharacter;
45import com.sun.star.text.XText;

--- 69 unchanged lines hidden (view full) ---

115 XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(
116 XTextRange.class, xTextCursor);
117 xTextRange.setString(sText);
118 xTextCursor.gotoEnd(true);
119 XPropertySet xPropSet = (XPropertySet) UnoRuntime.queryInterface(
120 XPropertySet.class, xTextRange);
121 return xPropSet;
122 }
123
124 /**
125 * get a paragraph in a shape. the return value is the PropertySet of the text
126 * range that specified by the index
127 */
128 public static XPropertySet getPortion(XShape xShape, int index) throws NoSuchElementException, WrappedTargetException {
129 XEnumerationAccess m_paraAccess = (XEnumerationAccess)UnoRuntime.queryInterface(XEnumerationAccess.class, xShape);
130 XEnumeration xParaEnum = m_paraAccess.createEnumeration();
131 XPropertySet xPropSet = null;
132 int i=0;
133 while(xParaEnum.hasMoreElements())
134 {
135 if(i == index)
136 {
137 Object aPortionObj = xParaEnum.nextElement();
138 XTextRange xTextRange = (XTextRange)UnoRuntime.queryInterface(XTextRange.class, aPortionObj);
139// System.out.println(xTextRange.getText().getString());
140 xPropSet = (XPropertySet) UnoRuntime.queryInterface(
141 XPropertySet.class, xTextRange);
142 break;
143 }
144 else i++;
145 }
146 return xPropSet;
147 }
121
148
149
122 /**
123 * try to get text of a shape
124 *
125 * @return
126 */
127 public static String getPortion(XShape xShape) {
128 String text = null;
129 XText xText = (XText) UnoRuntime.queryInterface(XText.class, xShape);

--- 33 unchanged lines hidden ---
150 /**
151 * try to get text of a shape
152 *
153 * @return
154 */
155 public static String getPortion(XShape xShape) {
156 String text = null;
157 XText xText = (XText) UnoRuntime.queryInterface(XText.class, xShape);

--- 33 unchanged lines hidden ---