View | Details | Raw Unified | Return to issue 120731
Collapse All | Expand All

(-)testuno/source/testcase/uno/sd/CheckBuildInBullet.java (-1 / +2 lines)
Lines 60-67 Link Here
60
    }
60
    }
61
	@Parameters
61
	@Parameters
62
    public static Collection<String[]> data() {
62
    public static Collection<String[]> data() {
63
        String[][] bulletChar = new String[][] {{"●","●"}, {"•","•"}, {"",""},{"",""},{"➔","➔"}, {"➢","➢"}, {"✗","✗"},{"✔","✔"}};
63
        String[][] bulletChar = new String[][] {{"\u25cf","\u25cf"}, {"\u2022","\u2022"}, {"\ue00c","\ue00c"},{"\ue00a","\ue00a"},{"\u2794","\u2794"}, {"\u27a2","\u27a2"}, {"\u2717","\u2717"},{"\u2714","\u2714"}};
64
        return Arrays.asList(bulletChar);
64
        return Arrays.asList(bulletChar);
65
        
65
    }
66
    }
66
	
67
	
67
	@BeforeClass
68
	@BeforeClass
(-)testuno/source/testcase/uno/sd/GraphicBulletFromFile.java (+156 lines)
Line 0 Link Here
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
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
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
 *************************************************************/
21
/*
22
 * Select a external picture from a file as graphic bullet
23
 * */
24
package testcase.uno.sd;
25
import static org.junit.Assert.*;
26
import static org.openoffice.test.common.Testspace.prepareData;
27
import static testlib.uno.PageUtil.getDrawPageByIndex;
28
import static testlib.uno.ShapeUtil.addPortion;
29
import static testlib.uno.ShapeUtil.getPortion;
30
import static testlib.uno.GraphicUtil.getUniqueIDOfGraphicFile;
31
32
import java.io.File;
33
34
import org.junit.After;
35
import org.junit.AfterClass;
36
import org.junit.Before;
37
import org.junit.BeforeClass;
38
import org.junit.Test;
39
import org.openoffice.test.uno.UnoApp;
40
import org.openoffice.test.common.FileUtil;
41
import org.openoffice.test.common.Testspace;
42
43
import testlib.uno.SDUtil;
44
45
import com.sun.star.awt.Size;
46
import com.sun.star.beans.PropertyValue;
47
import com.sun.star.beans.XPropertySet;
48
import com.sun.star.container.XIndexReplace;
49
import com.sun.star.drawing.XDrawPage;
50
import com.sun.star.drawing.XShape;
51
import com.sun.star.lang.XComponent;
52
import com.sun.star.style.NumberingType;
53
import com.sun.star.uno.UnoRuntime;
54
55
public class GraphicBulletFromFile {
56
57
	private static final UnoApp app = new UnoApp();
58
59
	private XComponent m_xSDComponent = null;
60
	private String m_filePath = null;
61
	private XPropertySet m_xtextProps = null;	
62
	private String m_GraphicPath = null;
63
64
	@Before
65
	public void setUpDocument() throws Exception {
66
		m_filePath = Testspace.getPath("temp/GraphicBulletFromFile.odt");
67
		String abslotePath = prepareData("testcase/uno/sd/36.gif");	
68
		m_GraphicPath = FileUtil.getUrl(new File(abslotePath));	
69
//		m_GraphicPath = "file:///F:/work/36.gif";
70
		if (FileUtil.fileExists(m_filePath)) {//load
71
			m_xtextProps = load();	  
72
		} else {//new
73
			m_xSDComponent = (XComponent) UnoRuntime.queryInterface(
74
					XComponent.class, app.newDocument("simpress"));
75
			Object firstPage = getDrawPageByIndex(m_xSDComponent, 0);			
76
			Object firstTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 0);
77
			XShape xfirstTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, firstTextBox);
78
			m_xtextProps = addPortion(xfirstTextBox, "test Graphic Bullet From a File", false);
79
		}
80
	}
81
	
82
	private XPropertySet load() throws Exception{
83
		m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, 
84
				app.loadDocument(m_filePath));
85
		Object firstPage = getDrawPageByIndex(m_xSDComponent, 0);
86
		XDrawPage firstpage = getDrawPageByIndex(m_xSDComponent, 0);
87
		Object firstTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 0);
88
		XShape xfirstTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, firstTextBox);		
89
		return getPortion(xfirstTextBox, 0);
90
	}
91
92
	@After
93
	public void tearDownDocument() {
94
		app.closeDocument(m_xSDComponent);
95
96
	}
97
98
	@BeforeClass
99
	public static void setUpConnection() throws Exception {
100
		app.start();
101
	}
102
103
	@AfterClass
104
	public static void tearDownConnection() throws InterruptedException,
105
			Exception {
106
		app.close();
107
		//remove the temp file
108
		FileUtil.deleteFile(Testspace.getPath("temp"));
109
	}
110
111
	@Test
112
	public void testGraphicBulletFromFile() throws Exception {				
113
				
114
		Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules");
115
		
116
		XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface(
117
	             XIndexReplace.class, numberingrules); 		
118
		
119
		PropertyValue[] props = new PropertyValue[3];
120
		props[0] = new PropertyValue();
121
	    props[0].Name = "NumberingType";
122
	    props[0].Value = new Short(NumberingType.BITMAP );
123
	    
124
	    props[1] = new PropertyValue();
125
	    props[1].Name = "GraphicURL";
126
	    props[1].Value = "vnd.sun.star.GraphicObject:"+getUniqueIDOfGraphicFile(app, m_xSDComponent, m_GraphicPath);
127
	    
128
	    props[2] = new PropertyValue();
129
	    props[2].Name = "GraphicSize";	    
130
	    props[2].Value = new Size(1000,1000);
131
	    
132
	    xReplace.replaceByIndex(0, props);
133
	    
134
	    m_xtextProps.setPropertyValue("NumberingRules", numberingrules);
135
		  //set numbering level to 0			
136
		m_xtextProps.setPropertyValue("NumberingLevel", new Short((short)0));
137
138
		    	    
139
		app.saveDocument(m_xSDComponent, m_filePath);
140
//			app.closeDocument(m_xSDComponent);
141
		m_xSDComponent.dispose();
142
			//reopen
143
		m_xtextProps = load();
144
					    
145
		Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules");
146
						
147
		XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface(
148
		            XIndexReplace.class, numberingrules2);
149
			
150
		PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0);  
151
		assertEquals("NumberingType should be BITMAP", NumberingType.BITMAP, proValues2[0].Value);
152
		String uniqueID = getUniqueIDOfGraphicFile(app, m_xSDComponent, m_GraphicPath);
153
		assertEquals("Graphic should be the one with uniqueID"+uniqueID, "vnd.sun.star.GraphicObject:"+uniqueID, proValues2[6].Value);
154
155
	}
156
}
(-)testuno/source/testlib/uno/GraphicUtil.java (+72 lines)
Line 0 Link Here
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
9
 * with the License.  You may obtain a copy of the License at
10
 * 
11
 *   http://www.apache.org/licenses/LICENSE-2.0
12
 * 
13
 * Unless required by applicable law or agreed to in writing,
14
 * software distributed under the License is distributed on an
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
 *************************************************************/
21
package testlib.uno;
22
import static org.junit.Assert.*;
23
import static testlib.uno.GraphicUtil.getUniqueIDbyXGraphic;
24
25
import org.junit.After;
26
import org.junit.AfterClass;
27
import org.junit.Before;
28
import org.junit.BeforeClass;
29
import org.junit.Test;
30
import org.openoffice.test.uno.UnoApp;
31
import org.openoffice.test.common.FileUtil;
32
import org.openoffice.test.common.Testspace;
33
34
import com.sun.star.beans.Property;
35
import com.sun.star.beans.PropertyValue;
36
import com.sun.star.beans.XPropertySet;
37
import com.sun.star.beans.XPropertySetInfo;
38
import com.sun.star.graphic.XGraphic;
39
import com.sun.star.graphic.XGraphicObject;
40
import com.sun.star.graphic.XGraphicProvider;
41
import com.sun.star.lang.XComponent;
42
import com.sun.star.lang.XMultiServiceFactory;
43
import com.sun.star.uno.Exception;
44
import com.sun.star.uno.UnoRuntime;
45
46
public class GraphicUtil {
47
	
48
	public static String getUniqueIDbyXGraphic(UnoApp unoApp, XGraphic xgraphic) throws Exception{
49
		Object graphicObj = unoApp.getServiceFactory().createInstance("com.sun.star.graphic.GraphicObject");
50
		XGraphicObject xgraphicObj = (XGraphicObject)UnoRuntime.queryInterface(XGraphicObject.class, graphicObj);
51
		xgraphicObj.setGraphic(xgraphic);
52
		
53
		return xgraphicObj.getUniqueID();
54
	}
55
	
56
//	String sUrl = "file:///F:/work/36.gif";
57
	public static String getUniqueIDOfGraphicFile(UnoApp unoApp, XComponent component, String sUrl) throws Exception{
58
		Object graphicObj = unoApp.getServiceFactory().createInstance("com.sun.star.graphic.GraphicProvider");
59
		XGraphicProvider xgraphicProvider = (XGraphicProvider)UnoRuntime.queryInterface(XGraphicProvider.class, graphicObj);
60
		PropertyValue[] sourceProps = new PropertyValue[1];
61
		sourceProps[0]       = new PropertyValue();
62
		sourceProps[0].Name  = "URL";
63
		sourceProps[0].Value = sUrl;
64
		XGraphic xgraphic = xgraphicProvider.queryGraphic(sourceProps);		
65
		String uniqueID = getUniqueIDbyXGraphic(unoApp, xgraphic);
66
		
67
		return uniqueID;
68
	}
69
	
70
	
71
	
72
}

Return to issue 120731