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

(-)testuno/source/fvt/uno/sd/bullet/CheckBuildInBullet.java (-4 / +5 lines)
Lines 97-104 Link Here
97
	@AfterClass
97
	@AfterClass
98
	public static void tearDownAfterClass() throws Exception {
98
	public static void tearDownAfterClass() throws Exception {
99
		app.close();
99
		app.close();
100
		//remove the temp file
100
		
101
		FileUtil.deleteFile(Testspace.getPath("temp"));
102
	}
101
	}
103
102
104
	/**
103
	/**
Lines 106-112 Link Here
106
	 */
105
	 */
107
	@Before
106
	@Before
108
	public void setUp() throws Exception {
107
	public void setUp() throws Exception {
109
		m_filePath = Testspace.getPath("temp/CheckBuildInBullet.odt");
108
		m_filePath = Testspace.getPath("temp/CheckBuildInBullet.odp");
110
//		m_filePath = "F:/aa.odp";
109
//		m_filePath = "F:/aa.odp";
111
		if(FileUtil.fileExists(m_filePath))
110
		if(FileUtil.fileExists(m_filePath))
112
		{	//load
111
		{	//load
Lines 127-133 Link Here
127
	 */
126
	 */
128
	@After
127
	@After
129
	public void tearDown() throws Exception {	
128
	public void tearDown() throws Exception {	
130
		app.closeDocument(m_xSDComponent);		
129
		app.closeDocument(m_xSDComponent);	
130
		//remove the temp file
131
		FileUtil.deleteFile(Testspace.getPath("temp"));
131
	}
132
	}
132
	private XPropertySet load() throws Exception{
133
	private XPropertySet load() throws Exception{
133
		m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, 
134
		m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, 
(-)testuno/source/fvt/uno/sd/bullet/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 fvt.uno.sd.bullet;
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.odp");
67
		String abslotePath = prepareData("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_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_GraphicPath);
153
		assertEquals("Graphic should be the one with uniqueID"+uniqueID, "vnd.sun.star.GraphicObject:"+uniqueID, proValues2[6].Value);
154
155
	}
156
}
(-)testuno/source/fvt/uno/sd/CheckBuildInBullet.java (-179 lines)
Lines 1-179 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
/**
23
 * There are 8 build-in bullets. Verify those bullets can be applied successfully.
24
 * insert text into a SD
25
 * apply the 8 bullets one by one, and check
26
 */
27
package fvt.uno.sd;
28
29
import static org.junit.Assert.assertEquals;
30
import static testlib.uno.PageUtil.getDrawPageByIndex;
31
import static testlib.uno.ShapeUtil.addPortion;
32
import static testlib.uno.ShapeUtil.getPortion;
33
34
import java.io.File;
35
import java.util.Arrays;
36
import java.util.Collection;
37
38
import org.junit.After;
39
import org.junit.AfterClass;
40
import org.junit.Before;
41
import org.junit.BeforeClass;
42
import org.junit.Test;
43
import org.junit.runner.RunWith;
44
import org.junit.runners.Parameterized;
45
import org.junit.runners.Parameterized.Parameters;
46
import org.openoffice.test.common.FileUtil;
47
import org.openoffice.test.common.Testspace;
48
import org.openoffice.test.uno.UnoApp;
49
50
import testlib.uno.SDUtil;
51
52
import com.sun.star.beans.PropertyValue;
53
import com.sun.star.beans.XPropertySet;
54
import com.sun.star.container.XIndexReplace;
55
import com.sun.star.drawing.XShape;
56
import com.sun.star.lang.XComponent;
57
import com.sun.star.style.NumberingType;
58
import com.sun.star.uno.UnoRuntime;
59
60
61
/**
62
 * @author LouQL
63
 *
64
 */
65
@RunWith(Parameterized.class)
66
public class CheckBuildInBullet {
67
68
	private static final UnoApp app = new UnoApp();	
69
	private XComponent m_xSDComponent = null;
70
	private String m_filePath = null;
71
	private XPropertySet m_xtextProps = null;
72
	private String m_BulletChar = null;
73
	private String m_expectedBulletChar = null;
74
	/**
75
	 * @throws java.lang.Exception
76
	 */
77
	
78
	public CheckBuildInBullet(String BulletChar, String expected) {
79
        this.m_BulletChar = BulletChar;
80
        m_expectedBulletChar = expected;
81
    }
82
	@Parameters
83
    public static Collection<String[]> data() {
84
        String[][] bulletChar = new String[][] {{"●","●"}, {"•","•"}, {"",""},{"",""},{"➔","➔"}, {"➢","➢"}, {"✗","✗"},{"✔","✔"}};
85
        return Arrays.asList(bulletChar);
86
    }
87
	
88
	@BeforeClass
89
	public static void setUpBeforeClass() throws Exception {
90
		app.start();
91
		File temp = new File(Testspace.getPath("temp"));
92
		temp.mkdirs();
93
	}
94
95
	/**
96
	 * @throws java.lang.Exception
97
	 */
98
	@AfterClass
99
	public static void tearDownAfterClass() throws Exception {
100
		app.close();
101
		//remove the temp file
102
		FileUtil.deleteFile(Testspace.getPath("temp"));
103
	}
104
105
	/**
106
	 * @throws java.lang.Exception
107
	 */
108
	@Before
109
	public void setUp() throws Exception {
110
		m_filePath = Testspace.getPath("temp/CheckBuildInBullet.odt");
111
//		m_filePath = "F:/aa.odp";
112
		if(FileUtil.fileExists(m_filePath))
113
		{	//load
114
			m_xtextProps = load();	  		
115
		}
116
		else{
117
			//create a sd
118
			m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, app.newDocument("simpress"));
119
			Object firstPage = getDrawPageByIndex(m_xSDComponent, 0);
120
			Object firstTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 0);
121
			XShape xfirstTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, firstTextBox);
122
			m_xtextProps = addPortion(xfirstTextBox, "test Build-in Bullet", false);
123
		}			
124
	}
125
	
126
	/**
127
	 * @throws java.lang.Exception
128
	 */
129
	@After
130
	public void tearDown() throws Exception {	
131
		app.closeDocument(m_xSDComponent);		
132
	}
133
	private XPropertySet load() throws Exception{
134
		m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, 
135
				app.loadDocument(m_filePath));
136
		Object firstPage = getDrawPageByIndex(m_xSDComponent, 0);
137
		Object firstTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 0);
138
		XShape xfirstTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, firstTextBox);
139
		return getPortion(xfirstTextBox, 0);
140
	}
141
			
142
	@Test
143
	public void testBuildInBullet() throws Exception {		
144
		    
145
		Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules");
146
					
147
		XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface(
148
	             XIndexReplace.class, numberingrules);    
149
						
150
		PropertyValue[] props = new PropertyValue[2];
151
	    props[0] = new PropertyValue();
152
	    props[0].Name = "NumberingType";
153
	    props[0].Value = new Short(NumberingType.CHAR_SPECIAL );
154
	    
155
	    props[1] = new PropertyValue();
156
	    props[1].Name = "BulletChar";
157
	    props[1].Value = this.m_BulletChar;
158
		
159
	    //set numberingType
160
	    xReplace.replaceByIndex(0, props);
161
	    m_xtextProps.setPropertyValue("NumberingRules", numberingrules);
162
	  //set numbering level to 0			
163
	    m_xtextProps.setPropertyValue("NumberingLevel", new Short((short)0));
164
165
		app.saveDocument(m_xSDComponent, m_filePath);
166
		app.closeDocument(m_xSDComponent);
167
		//reopen
168
		m_xtextProps = load();
169
				    
170
		Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules");
171
					
172
		XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface(
173
	             XIndexReplace.class, numberingrules2);
174
		
175
		PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0);  
176
		assertEquals("NumberingType should be CHAR_SPECIAL", NumberingType.CHAR_SPECIAL, proValues2[0].Value);
177
		assertEquals("BulletChar should be"+m_expectedBulletChar, m_expectedBulletChar, proValues2[4].Value);
178
	}
179
}
(-)testuno/source/fvt/uno/sd/file/CheckFileProperties.java (-10 / +6 lines)
Lines 110-116 Link Here
110
	@After
110
	@After
111
	public void tearDownDocument() {
111
	public void tearDownDocument() {
112
		app.closeDocument(m_xSDComponent);
112
		app.closeDocument(m_xSDComponent);
113
113
		m_filePath = Testspace.getPath("temp/CheckFileProperties.odp");	
114
		FileUtil.deleteFile(m_filePath);
114
	}
115
	}
115
116
116
	@BeforeClass
117
	@BeforeClass
Lines 124-131 Link Here
124
	public static void tearDownConnection() throws InterruptedException,
125
	public static void tearDownConnection() throws InterruptedException,
125
			Exception {
126
			Exception {
126
		app.close();
127
		app.close();
127
		//remove the temp file
128
		
128
		FileUtil.deleteFile(Testspace.getPath("temp"));
129
	}
129
	}
130
130
131
	/*
131
	/*
Lines 317-323 Link Here
317
		app.closeDocument(m_xSDComponent);
317
		app.closeDocument(m_xSDComponent);
318
		m_xSDComponent = app.loadDocument(m_filePath);
318
		m_xSDComponent = app.loadDocument(m_filePath);
319
		XDocumentProperties xDocPro2 = getDocumentProperties();
319
		XDocumentProperties xDocPro2 = getDocumentProperties();
320
		assertEquals("Revision number should be "+ revisionNumber, revisionNumber, xDocPro2.getEditingCycles());		
320
		assertEquals("Revision number should be "+ revisionNumber+1, revisionNumber+1, xDocPro2.getEditingCycles());		
321
	}
321
	}
322
	
322
	
323
	/*
323
	/*
Lines 563-580 Link Here
563
		
563
		
564
		@Test
564
		@Test
565
		public void testCustomRemovePro() throws Exception{					
565
		public void testCustomRemovePro() throws Exception{					
566
			addCustomPro("testPro", "value");
566
			XDocumentProperties xDocPro = getDocumentProperties();
567
			XDocumentProperties xDocPro = getDocumentProperties();
567
			XPropertyContainer proContainer = xDocPro.getUserDefinedProperties();
568
			XPropertyContainer proContainer = xDocPro.getUserDefinedProperties();
568
			XPropertySet xProSet = (XPropertySet)UnoRuntime.queryInterface(
569
			XPropertySet xProSet = (XPropertySet)UnoRuntime.queryInterface(
569
					XPropertySet.class, proContainer);
570
					XPropertySet.class, proContainer);
570
			XPropertySetInfo xproSetInfo = xProSet.getPropertySetInfo();
571
			XPropertySetInfo xproSetInfo = xProSet.getPropertySetInfo();
571
			Property[] pros = xproSetInfo.getProperties();
572
			Property[] pros = xproSetInfo.getProperties();			
572
			
573
			
573
			if(pros.length == 0) //if there is no custom property, add one
574
			{
575
				addCustomPro("testPro", "value");
576
			}
577
			
578
			for(int i=0; i< pros.length;i++)
574
			for(int i=0; i< pros.length;i++)
579
			{
575
			{
580
				proContainer.removeProperty(pros[i].Name);
576
				proContainer.removeProperty(pros[i].Name);

Return to issue 120731