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

(-)testuno/.externalToolBuilders/Classpath Builder.launch (-22 / +22 lines)
Lines 1-22 Link Here
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
1
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
2
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
3
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
3
<booleanAttribute key="org.eclipse.ant.ui.ATTR_TARGETS_UPDATED" value="true"/>
4
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
4
<booleanAttribute key="org.eclipse.ant.ui.DEFAULT_VM_INSTALL" value="false"/>
5
<booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/>
5
<booleanAttribute key="org.eclipse.ant.uiSET_INPUTHANDLER" value="false"/>
6
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
6
<stringAttribute key="org.eclipse.debug.core.ATTR_REFRESH_SCOPE" value="${workspace}"/>
7
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
7
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_PATHS">
8
<listEntry value="/testuno"/>
8
<listEntry value="/testuno"/>
9
</listAttribute>
9
</listAttribute>
10
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
10
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
11
<listEntry value="4"/>
11
<listEntry value="4"/>
12
</listAttribute>
12
</listAttribute>
13
<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
13
<booleanAttribute key="org.eclipse.debug.core.capture_output" value="false"/>
14
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
14
<booleanAttribute key="org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON" value="false"/>
15
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
15
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
16
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
16
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.ant.ui.AntClasspathProvider"/>
17
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
17
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="true"/>
18
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="testuno"/>
18
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="testuno"/>
19
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/testuno/builder.xml}"/>
19
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/testuno/builder.xml}"/>
20
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,"/>
20
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,auto,"/>
21
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
21
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
22
</launchConfiguration>
22
</launchConfiguration>
(-)testuno/source/fvt/uno/sw/bookmark/CheckBookmarks.java (-5 / +21 lines)
Lines 57-63 Link Here
57
		XText xText = document.getText();
57
		XText xText = document.getText();
58
		XTextCursor xTextCursor = xText.createTextCursor();
58
		XTextCursor xTextCursor = xText.createTextCursor();
59
		xTextCursor.setString("Contents");
59
		xTextCursor.setString("Contents");
60
		
60
		/**
61
		 * insert bookmark into document
62
		 */
61
		for (int i = 0; i < initBookmarkNames.length; i++) {
63
		for (int i = 0; i < initBookmarkNames.length; i++) {
62
			xTextCursor.gotoEnd(false);
64
			xTextCursor.gotoEnd(false);
63
			XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, xTextCursor);
65
			XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, xTextCursor);
Lines 77-83 Link Here
77
	public static void tearDownConnection() throws Exception {
79
	public static void tearDownConnection() throws Exception {
78
		app.close();
80
		app.close();
79
	}
81
	}
80
	
82
	/**
83
	 * get bookmark content
84
	 * @param xBookmarks
85
	 * @return
86
	 * @throws Exception
87
	 */
81
	private static String[] getBookmarkContents(XNameAccess xBookmarks) throws Exception {
88
	private static String[] getBookmarkContents(XNameAccess xBookmarks) throws Exception {
82
		String[] bookmarkNames = xBookmarks.getElementNames();
89
		String[] bookmarkNames = xBookmarks.getElementNames();
83
		String[] bookmarkContents = new String[bookmarkNames.length];
90
		String[] bookmarkContents = new String[bookmarkNames.length];
Lines 89-102 Link Here
89
		
96
		
90
		return bookmarkContents;
97
		return bookmarkContents;
91
	}
98
	}
92
99
    /**
100
     * verify inserted bookmark by compare their name and content
101
     * @throws Exception
102
     */
93
	@Test
103
	@Test
94
	public void createBookmark() throws Exception {
104
	public void createBookmark() throws Exception {
95
		XNameAccess xBookmarks = ((XBookmarksSupplier)UnoRuntime.queryInterface(XBookmarksSupplier.class, document)).getBookmarks();
105
		XNameAccess xBookmarks = ((XBookmarksSupplier)UnoRuntime.queryInterface(XBookmarksSupplier.class, document)).getBookmarks();
96
		assertArrayEquals("Bookmark name list:", initBookmarkNames, xBookmarks.getElementNames());
106
		assertArrayEquals("Bookmark name list:", initBookmarkNames, xBookmarks.getElementNames());
97
		assertArrayEquals("Bookmark content list:", initBookmarkContents, getBookmarkContents(xBookmarks));
107
		assertArrayEquals("Bookmark content list:", initBookmarkContents, getBookmarkContents(xBookmarks));
98
	}
108
	}
99
	
109
	/**
110
	 * verify bookmark modify
111
	 * @throws Exception
112
	 */
100
	@Test
113
	@Test
101
	public void updateBookmarkContent() throws Exception {
114
	public void updateBookmarkContent() throws Exception {
102
		String[] expectedBookmarkNames= new String[]{"bookmark1", "bookmark2", "bookmark3"};
115
		String[] expectedBookmarkNames= new String[]{"bookmark1", "bookmark2", "bookmark3"};
Lines 113-119 Link Here
113
		assertArrayEquals("Bookmark name list after updating some content:", expectedBookmarkNames, xBookmarks.getElementNames());
126
		assertArrayEquals("Bookmark name list after updating some content:", expectedBookmarkNames, xBookmarks.getElementNames());
114
		assertArrayEquals("Bookmark content list after updating some content:", expectedBookmarkContents, getBookmarkContents(xBookmarks));
127
		assertArrayEquals("Bookmark content list after updating some content:", expectedBookmarkContents, getBookmarkContents(xBookmarks));
115
	}
128
	}
116
	
129
	/**
130
	 * verify bookmark remove
131
	 * @throws Exception
132
	 */
117
	@Test
133
	@Test
118
	public void removeBookmark() throws Exception {
134
	public void removeBookmark() throws Exception {
119
		String[] expectedBookmarkNames= new String[]{"bookmark2", "bookmark3"};
135
		String[] expectedBookmarkNames= new String[]{"bookmark2", "bookmark3"};
(-)testuno/source/fvt/uno/sw/DocumentTest.java (-90 / +22 lines)
Lines 32-37 Link Here
32
import org.openoffice.test.common.FileUtil;
32
import org.openoffice.test.common.FileUtil;
33
import org.openoffice.test.uno.UnoApp;
33
import org.openoffice.test.uno.UnoApp;
34
34
35
import testlib.uno.SWUtil;
36
35
import com.sun.star.text.XTextDocument;
37
import com.sun.star.text.XTextDocument;
36
import com.sun.star.text.XTextCursor;
38
import com.sun.star.text.XTextCursor;
37
import com.sun.star.text.XText;
39
import com.sun.star.text.XText;
Lines 39-48 Link Here
39
import com.sun.star.beans.PropertyValue;
41
import com.sun.star.beans.PropertyValue;
40
import com.sun.star.frame.*;
42
import com.sun.star.frame.*;
41
import com.sun.star.uno.UnoRuntime;
43
import com.sun.star.uno.UnoRuntime;
42
import com.sun.star.util.XCloseable;
43
import com.sun.star.lang.XComponent;
44
import com.sun.star.lang.XComponent;
44
import com.sun.star.container.XEnumerationAccess;
45
import com.sun.star.container.XEnumeration;
46
45
47
46
48
public class DocumentTest {
47
public class DocumentTest {
Lines 51-60 Link Here
51
	File temp = null;
50
	File temp = null;
52
	String workingFilePath = "";
51
	String workingFilePath = "";
53
	String workingTemplatePath = "";
52
	String workingTemplatePath = "";
54
	
53
55
	/**
56
	 * @throws java.lang.Exception
57
	 */
58
	@Before
54
	@Before
59
	public void setUp() throws Exception {
55
	public void setUp() throws Exception {
60
		unoApp.start();
56
		unoApp.start();
Lines 72-142 Link Here
72
	public void tearDown() throws Exception {
68
	public void tearDown() throws Exception {
73
		unoApp.close();
69
		unoApp.close();
74
	}	
70
	}	
75
	
76
	private XComponent newDocumentFromTemplate(String templatePath) throws Exception
77
	{
78
		XComponentLoader componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, unoApp.getDesktop());
79
		PropertyValue[] pros = new PropertyValue[1];
80
		pros[0] = new PropertyValue();
81
		pros[0].Name = "AsTemplate";
82
		pros[0].Value = new Boolean(true);		
83
		
84
		XComponent component = componentLoader.loadComponentFromURL(FileUtil.getUrl(workingTemplatePath), "_blank", 0,pros);
85
		return component;
86
	}
87
	
88
89
	/**
71
	/**
90
	 * test close document
72
	 * test new document and close document
91
	 * @throws Exception
73
	 * @throws Exception
92
	 */
74
	 */
93
	@Test
75
	@Test
94
	public void testCloseDocument() throws Exception
76
	public void testNewAndCloseDocument() throws Exception
95
	{
77
	{
96
		XComponent component = unoApp.newDocument("swriter");
78
		XComponent component = unoApp.newDocument("swriter");
97
		unoApp.closeDocument(component);
98
		XModel xModel = unoApp.getDesktop().getCurrentFrame().getController().getModel();		
99
		Assert.assertTrue("Document has been closed.",xModel==null);
100
	}
101
	
102
	/**
103
	 * test new document
104
	 * @throws Exception
105
	 */
106
	@Test
107
	public void testNewDocument() throws Exception
108
	{
109
		XComponentLoader componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, unoApp.getDesktop());		
110
		XComponent component = componentLoader.loadComponentFromURL("private:factory/" + "swriter", "_blank", 0, new PropertyValue[0]);
111
		textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component);
79
		textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component);
112
		XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument);
80
		XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument);
113
		String title = xTitle.getTitle();
81
		String title = xTitle.getTitle();
114
		Assert.assertEquals("New Document title start with \"Untitled\"",true, title.startsWith("Untitled"));
82
		Assert.assertEquals("New Document title start with \"Untitled\"",true, title.startsWith("Untitled"));
115
		unoApp.closeDocument(textDocument);
83
		unoApp.closeDocument(component);
116
	}
84
		XModel xModel = unoApp.getDesktop().getCurrentFrame().getController().getModel();		
117
	
85
		Assert.assertTrue("Document has been closed.",xModel==null);	
86
	}	
118
	/**
87
	/**
119
	 * test new document from template
88
	 * test new document from template
120
	 * @throws Exception
89
	 * @throws Exception
121
	 */
90
	 */
122
	@Test
91
	@Test
123
	public void testNewDocumentFromTemplate() throws Exception
92
	public void testNewDocumentFromTemplate() throws Exception
124
	{		
93
	{					
125
		XComponent component = this.newDocumentFromTemplate(workingTemplatePath);
94
		XComponent component = SWUtil.newDocumentFromTemplate(workingTemplatePath,unoApp);
126
		textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component);
95
		textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component);
96
		XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument);
127
		XText xText = textDocument.getText();
97
		XText xText = textDocument.getText();
128
		XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument);
129
		xText = textDocument.getText();
130
		XTextCursor xTextCursor = xText.createTextCursor();	
98
		XTextCursor xTextCursor = xText.createTextCursor();	
131
		xTextCursor.gotoEnd(true);		
99
		xTextCursor.gotoEnd(true);		
132
		XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
100
		XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
133
		String paraStyle = (String)xPropertySet.getPropertyValue("ParaStyleName");
101
		String paraStyle = (String)xPropertySet.getPropertyValue("ParaStyleName");		
134
		
102
        Assert.assertEquals("new document from template, heading style in template is remained. ", "Heading 1", paraStyle); 		       
135
        Assert.assertEquals("new document from template, heading style in template is remained. ", "Heading 1", paraStyle); 		
136
        
137
        Assert.assertEquals("new document from template, title start with \"Untitled\".", true, xTitle.getTitle().startsWith("Untitled"));
103
        Assert.assertEquals("new document from template, title start with \"Untitled\".", true, xTitle.getTitle().startsWith("Untitled"));
138
        
139
        unoApp.closeDocument(textDocument);
140
	}
104
	}
141
	
105
	
142
	/**
106
	/**
Lines 151-173 Link Here
151
		XText xText = textDocument.getText();
115
		XText xText = textDocument.getText();
152
		XTextCursor xTextCursor = xText.createTextCursor();	
116
		XTextCursor xTextCursor = xText.createTextCursor();	
153
		xTextCursor.gotoEnd(true);		
117
		xTextCursor.gotoEnd(true);		
154
		XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
118
		XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);		
155
		
119
		xPropertySet.setPropertyValue("ParaStyleName", "Heading 1");				
156
		xPropertySet.setPropertyValue("ParaStyleName", "Heading 1");		
120
		SWUtil.save(textDocument);         
157
		
121
        unoApp.closeDocument(textDocument);              
158
		XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, component);
159
        xStorable.store();         
160
        unoApp.closeDocument(textDocument);        
161
       
162
        component = unoApp.loadDocument(workingFilePath);
122
        component = unoApp.loadDocument(workingFilePath);
163
		textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component);
123
		textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component);
164
		xText = textDocument.getText();
124
		xText = textDocument.getText();
165
		xTextCursor = xText.createTextCursor();	
125
		xTextCursor = xText.createTextCursor();	
166
		xTextCursor.gotoEnd(true);		
126
		xTextCursor.gotoEnd(true);		
167
		xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);		
127
		xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);				
168
		
169
        Assert.assertEquals("Modify plain text to heading 1 style. ", "Heading 1", (String)xPropertySet.getPropertyValue("ParaStyleName"));        
128
        Assert.assertEquals("Modify plain text to heading 1 style. ", "Heading 1", (String)xPropertySet.getPropertyValue("ParaStyleName"));        
170
        unoApp.closeDocument(textDocument);
171
	}
129
	}
172
	
130
	
173
	/**
131
	/**
Lines 186-206 Link Here
186
		
144
		
187
		xPropertySet.setPropertyValue("ParaStyleName", "Heading 1");
145
		xPropertySet.setPropertyValue("ParaStyleName", "Heading 1");
188
		xText.insertString(xTextCursor, "test Save odt as doc.", false);
146
		xText.insertString(xTextCursor, "test Save odt as doc.", false);
189
		
147
		SWUtil.saveAsDoc(textDocument, FileUtil.getUrl(saveAsFile));      
190
		XStorable xStorable = (XStorable)UnoRuntime.queryInterface(XStorable.class, component);
191
        PropertyValue[] storeProps = new PropertyValue[2];
192
        
193
        storeProps[0] = new PropertyValue();
194
        storeProps[0].Name = "Overwrite";
195
        storeProps[0].Value = new Boolean(true);   
196
        
197
        storeProps[1] = new PropertyValue();
198
        storeProps[1].Name = "FilterName";
199
        storeProps[1].Value = "MS Word 97";
200
        
201
        xStorable.storeAsURL(FileUtil.getUrl(saveAsFile), storeProps);        
202
        Assert.assertTrue("Save odt document as doc the file exist: " + saveAsFile.getAbsolutePath(), saveAsFile.exists()); 
148
        Assert.assertTrue("Save odt document as doc the file exist: " + saveAsFile.getAbsolutePath(), saveAsFile.exists()); 
203
        unoApp.closeDocument(textDocument);
204
	}
149
	}
205
	
150
	
206
	/**
151
	/**
Lines 232-239 Link Here
232
        xStorable.storeToURL(FileUtil.getUrl(saveAsFile), storeProps); 
177
        xStorable.storeToURL(FileUtil.getUrl(saveAsFile), storeProps); 
233
       
178
       
234
        Assert.assertTrue("Export document as PDF.", saveAsFile.exists()); 
179
        Assert.assertTrue("Export document as PDF.", saveAsFile.exists()); 
235
        
236
        unoApp.closeDocument(textDocument);
237
	}
180
	}
238
	
181
	
239
	/**
182
	/**
Lines 270-288 Link Here
270
		storeProps[2].Value=new Boolean(true);
213
		storeProps[2].Value=new Boolean(true);
271
		
214
		
272
		xStorable.storeToURL(FileUtil.getUrl(saveAsFile), storeProps);
215
		xStorable.storeToURL(FileUtil.getUrl(saveAsFile), storeProps);
273
		unoApp.closeDocument(textDocument);
216
		unoApp.closeDocument(textDocument);		
274
		
217
		Assert.assertTrue("Export document as ott.", saveAsFile.exists());
275
		component = this.newDocumentFromTemplate(saveAsFile.getAbsolutePath());
276
		textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, component);
277
		XTitle xTitle = (XTitle)UnoRuntime.queryInterface(XTitle.class, textDocument);		
278
		xText = textDocument.getText();
279
		xTextCursor = xText.createTextCursor();	
280
		xTextCursor.gotoEnd(true);		
281
		xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextCursor);
282
		String paraStyle = (String)xPropertySet.getPropertyValue("ParaStyleName");
283
		Assert.assertEquals("Save document as template, heading style is remained. ", "Heading 1", paraStyle); 		
284
        Assert.assertEquals("Save document as template, title start with \"Untitled\".", true, xTitle.getTitle().startsWith("Untitled"));        
285
        unoApp.closeDocument(textDocument);
286
	}
218
	}
287
219
288
}
220
}
(-)testuno/source/fvt/uno/sw/frame/FrameAnchorType.java (+77 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import java.util.Arrays;
6
import java.util.Collection;
7
8
import org.junit.After;
9
import org.junit.Before;
10
import org.junit.Test;
11
import org.junit.runner.RunWith;
12
import org.junit.runners.Parameterized;
13
import org.junit.runners.Parameterized.Parameters;
14
import org.openoffice.test.common.Testspace;
15
import org.openoffice.test.uno.UnoApp;
16
17
import testlib.uno.SWUtil;
18
19
import com.sun.star.beans.XPropertySet;
20
import com.sun.star.container.XNameAccess;
21
import com.sun.star.lang.XMultiServiceFactory;
22
import com.sun.star.text.XText;
23
import com.sun.star.text.XTextCursor;
24
import com.sun.star.text.XTextDocument;
25
import com.sun.star.text.XTextFrame;
26
import com.sun.star.text.XTextFramesSupplier;
27
import com.sun.star.uno.UnoRuntime;
28
@RunWith(value = Parameterized.class)
29
public class FrameAnchorType {
30
	private static final UnoApp app = new UnoApp();
31
	private XTextDocument xTextDocument=null;
32
	private XMultiServiceFactory xWriterFactory=null;
33
	private XText xText=null;
34
	private com.sun.star.text.TextContentAnchorType FrameAnchorType;
35
	public FrameAnchorType(com.sun.star.text.TextContentAnchorType FrameAnchorType){
36
		this.FrameAnchorType=FrameAnchorType;
37
	}
38
	@Parameters
39
    public static Collection<Object[]> data(){
40
    	Object[][] params = new Object[][]{
41
    			{com.sun.star.text.TextContentAnchorType.AS_CHARACTER},
42
    			{com.sun.star.text.TextContentAnchorType.AT_CHARACTER},
43
    			{com.sun.star.text.TextContentAnchorType.AT_PAGE},
44
    			{com.sun.star.text.TextContentAnchorType.AT_PARAGRAPH},
45
    			};
46
    	return Arrays.asList(params);
47
    }
48
	@Before
49
	public void setUp() throws Exception {
50
		app.start();		
51
	}
52
	@After
53
	public void tearDown() throws Exception {
54
		app.close();
55
	}
56
57
	@Test
58
	public void testFrameAnchorType() throws Exception {
59
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
60
		xText=xTextDocument.getText();
61
		XTextCursor xTextCursor = xText.createTextCursor();
62
		// get internal service factory of the document
63
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
64
		// Create a new table from the document's factory
65
		XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
66
		xText.insertTextContent(xTextCursor,xTextFrame1,false);
67
		XPropertySet xTextFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1);
68
		xTextFrameProps1.setPropertyValue("AnchorType",FrameAnchorType);
69
		//reopen the document 
70
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app));
71
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
72
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
73
		XTextFrame xTextFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1"));
74
		XPropertySet xTextFrameProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert1);
75
		assertEquals("assert shadow anchor type",FrameAnchorType,xTextFrameProps_assert1.getPropertyValue("AnchorType"));
76
	}
77
}
(-)testuno/source/fvt/uno/sw/frame/FrameBackColor.java (+68 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import org.junit.After;
6
import org.junit.Before;
7
import org.junit.Test;
8
import org.openoffice.test.common.Testspace;
9
import org.openoffice.test.uno.UnoApp;
10
11
import testlib.uno.SWUtil;
12
13
import com.sun.star.beans.XPropertySet;
14
import com.sun.star.container.XNameAccess;
15
import com.sun.star.lang.XMultiServiceFactory;
16
import com.sun.star.text.XText;
17
import com.sun.star.text.XTextCursor;
18
import com.sun.star.text.XTextDocument;
19
import com.sun.star.text.XTextFrame;
20
import com.sun.star.text.XTextFramesSupplier;
21
import com.sun.star.uno.UnoRuntime;
22
23
public class FrameBackColor {
24
	private static final UnoApp app = new UnoApp();
25
	private XTextDocument xTextDocument=null;
26
	private XMultiServiceFactory xWriterFactory=null;
27
	private XText xText=null;
28
	@Before
29
	public void setUp() throws Exception {
30
		app.start();		
31
	}
32
33
	@After
34
	public void tearDown() throws Exception {
35
		app.close();
36
	}
37
38
	@Test
39
	public void testFrameBackColor() throws Exception {
40
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
41
		xText=xTextDocument.getText();
42
		XTextCursor xTextCursor = xText.createTextCursor();
43
		// get internal service factory of the document
44
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
45
		// Create a new table from the document's factory
46
		XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
47
		xText.insertTextContent(xTextCursor,xTextFrame,false);
48
		XPropertySet xFrameProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);
49
		xFrameProps.setPropertyValue("BackColor",0x0000FF00);
50
		//reopen the document 
51
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
52
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
53
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
54
		Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1");
55
		XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt);
56
		XPropertySet xFrameProps_assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert_odt);
57
		assertEquals("verify Frame background color",0x0000FF00,xFrameProps_assert_odt.getPropertyValue("BackColor"));
58
59
		//reopen the document 
60
		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app));
61
		XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc);
62
		XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames();
63
		Object xTextFrame_obj_doc=xTextFrames_doc.getByName("Frame1");
64
		XTextFrame xTextFrame_Assert_doc=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_doc);
65
		XPropertySet xFrameProps_assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert_doc);
66
		assertEquals("verify frame background color",0x0000FF00,xFrameProps_assert_doc.getPropertyValue("BackColor"));
67
	}
68
}
(-)testuno/source/fvt/uno/sw/frame/FrameBackGraphic.java (+95 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import java.util.Arrays;
6
import java.util.Collection;
7
8
import org.junit.After;
9
import org.junit.Before;
10
import org.junit.Test;
11
import org.junit.runner.RunWith;
12
import org.junit.runners.Parameterized;
13
import org.junit.runners.Parameterized.Parameters;
14
import org.openoffice.test.common.FileUtil;
15
import org.openoffice.test.common.Testspace;
16
import org.openoffice.test.uno.UnoApp;
17
18
import com.sun.star.beans.XPropertySet;
19
import com.sun.star.container.XNameAccess;
20
import com.sun.star.lang.XMultiServiceFactory;
21
import com.sun.star.style.GraphicLocation;
22
import com.sun.star.text.XText;
23
import com.sun.star.text.XTextCursor;
24
import com.sun.star.text.XTextDocument;
25
import com.sun.star.text.XTextFrame;
26
import com.sun.star.text.XTextFramesSupplier;
27
import com.sun.star.uno.UnoRuntime;
28
import testlib.uno.SWUtil;
29
@RunWith(value = Parameterized.class)
30
public class FrameBackGraphic {
31
	private static final UnoApp app = new UnoApp();
32
	private XTextDocument xTextDocument=null;
33
	private XMultiServiceFactory xWriterFactory=null;
34
	private XText xText=null;
35
	private int backGraphicLocation;
36
	private String graphicURL=null;
37
	private String graphicName=null;
38
	public FrameBackGraphic(String graphicURL,String graphicName,int backGraphicLocation){
39
		this.graphicURL=graphicURL;
40
		this.graphicName=graphicName;
41
		this.backGraphicLocation = backGraphicLocation;		
42
	}
43
	@Parameters
44
    public static Collection<Object[]> data(){
45
    	Object[][] params = new Object[][]{
46
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",1},
47
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",2},
48
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",3},
49
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",4},
50
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",5},
51
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",6},
52
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",7},
53
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",8},
54
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",9},
55
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",10},
56
    			{FileUtil.getUrl(Testspace.prepareData("uno/Desert.jpg")),"draw_jpg_Export",11}		
57
    			};
58
    	return Arrays.asList(params);
59
    }
60
    
61
	@Before
62
	public void setUp() throws Exception {
63
		app.start();		
64
	}
65
66
	@After
67
	public void tearDown() throws Exception {
68
		app.close();
69
	}
70
	@Test
71
	public void testFrameBackGraphic() throws Exception {
72
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
73
		xText=xTextDocument.getText();
74
		XTextCursor xTextCursor = xText.createTextCursor();
75
		// get internal service factory of the document
76
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
77
		// Create a new Frame from the document's factory
78
		XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
79
		xText.insertTextContent(xTextCursor,xTextFrame1,false);
80
		XPropertySet xFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1);
81
		xFrameProps1.setPropertyValue("BackGraphicURL",graphicURL);
82
		xFrameProps1.setPropertyValue("BackGraphicFilter",graphicName);
83
		xFrameProps1.setPropertyValue("BackGraphicLocation",backGraphicLocation);
84
		XTextDocument xTextDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
85
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class,xTextDocument_odt);
86
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
87
		Object xFrame_obj1=xTextFrames_odt.getByName("Frame1");
88
		XTextFrame xFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xFrame_obj1);
89
		XPropertySet xFrameProps1_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xFrame_Assert1);
90
		GraphicLocation graphiclocation=(GraphicLocation)xFrameProps1_assert.getPropertyValue("BackGraphicLocation");
91
		assertEquals("verify Frame backgraphic location",backGraphicLocation,graphiclocation.getValue());
92
		assertEquals("verify Frame backgraphic fileter",graphicName,xFrameProps1_assert.getPropertyValue("BackGraphicFilter"));
93
		assertEquals("verify Frame backgraphic URL",graphicURL,xFrameProps1_assert.getPropertyValue("BackGraphicURL"));
94
	}
95
}
(-)testuno/source/fvt/uno/sw/frame/FrameBorder.java (+98 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import org.junit.After;
6
import org.junit.Before;
7
import org.junit.Test;
8
import org.openoffice.test.common.Testspace;
9
import org.openoffice.test.uno.UnoApp;
10
11
import testlib.uno.SWUtil;
12
13
import com.sun.star.beans.XPropertySet;
14
import com.sun.star.container.XNameAccess;
15
import com.sun.star.lang.XMultiServiceFactory;
16
import com.sun.star.table.BorderLine;
17
import com.sun.star.text.XText;
18
import com.sun.star.text.XTextCursor;
19
import com.sun.star.text.XTextDocument;
20
import com.sun.star.text.XTextFrame;
21
import com.sun.star.text.XTextFramesSupplier;
22
import com.sun.star.uno.UnoRuntime;
23
24
public class FrameBorder {
25
	private static final UnoApp app = new UnoApp();
26
	private XTextDocument xTextDocument=null;
27
	private XMultiServiceFactory xWriterFactory=null;
28
	private XText xText=null;
29
	@Before
30
	public void setUp() throws Exception {
31
		app.start();		
32
	}
33
34
	@After
35
	public void tearDown() throws Exception {
36
		app.close();
37
	}
38
39
	@Test
40
	public void testInsertFrame() throws Exception {
41
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
42
		xText=xTextDocument.getText();
43
		XTextCursor xTextCursor = xText.createTextCursor();
44
		// get internal service factory of the document
45
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
46
		// Create a new table from the document's factory
47
		XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
48
		xText.insertTextContent(xTextCursor,xTextFrame,false);		
49
		XPropertySet xTextFramerops = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);
50
		//set frame border	
51
		BorderLine[]borderLine=new BorderLine[] {new BorderLine(),new BorderLine(),new BorderLine(),new BorderLine()};
52
		borderLine[0].Color=0x00FF0000;
53
		borderLine[0].InnerLineWidth=101;
54
		borderLine[0].OuterLineWidth=19;
55
		borderLine[0].LineDistance=100;
56
		borderLine[1].Color =0x00FFFF00;
57
		borderLine[1].InnerLineWidth=101;
58
		borderLine[1].OuterLineWidth=19;
59
		borderLine[1].LineDistance=101;	
60
		borderLine[2].Color =0x0000FF00;
61
		borderLine[2].InnerLineWidth=150;
62
		borderLine[2].OuterLineWidth=19;
63
		borderLine[2].LineDistance=101;
64
		borderLine[3].Color =0x0000FF00;
65
		borderLine[3].InnerLineWidth=150;
66
		borderLine[3].OuterLineWidth=19;
67
		borderLine[3].LineDistance=101;			
68
		xTextFramerops.setPropertyValue("LeftBorder", borderLine[0]);
69
		xTextFramerops.setPropertyValue("RightBorder", borderLine[1]);
70
		xTextFramerops.setPropertyValue("TopBorder", borderLine[2]);
71
		xTextFramerops.setPropertyValue("BottomBorder", borderLine[3]);
72
		//reopen the document 
73
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app));
74
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
75
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
76
		XPropertySet xFrameProps_Assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrames_odt.getByName("Frame1"));
77
		BorderLine LeftBorder_Assert_odt=(BorderLine) UnoRuntime.queryInterface(BorderLine.class, xFrameProps_Assert_odt.getPropertyValue("LeftBorder"));
78
		assertEquals("assert topline color as setting",0x00FF0000,LeftBorder_Assert_odt.Color);
79
		assertEquals("assert topline innerline width as setting",101,LeftBorder_Assert_odt.InnerLineWidth);
80
		assertEquals("assert topline outerlinewidth as setting",19,LeftBorder_Assert_odt.OuterLineWidth);
81
		assertEquals("assert topline linedistance as setting",101,LeftBorder_Assert_odt.LineDistance);
82
		BorderLine RightBorder_Assert_odt=(BorderLine) UnoRuntime.queryInterface(BorderLine.class, xFrameProps_Assert_odt.getPropertyValue("RightBorder"));
83
		assertEquals("assert bottomline color as setting",0x00FFFF00,RightBorder_Assert_odt.Color);
84
		assertEquals("assert bottomline innerline width as setting",101,RightBorder_Assert_odt.InnerLineWidth);
85
		assertEquals("assert bottomline outerlinewidth as setting",19,RightBorder_Assert_odt.OuterLineWidth);
86
		assertEquals("assert bottomline linedistance as setting",101,RightBorder_Assert_odt.LineDistance);
87
		BorderLine TopBorder_Assert_odt=(BorderLine) UnoRuntime.queryInterface(BorderLine.class, xFrameProps_Assert_odt.getPropertyValue("TopBorder"));
88
		assertEquals("assert leftline color as setting",0x0000FF00,TopBorder_Assert_odt.Color);
89
		assertEquals("assert leftline innerline width as setting",150,TopBorder_Assert_odt.InnerLineWidth);
90
		assertEquals("assert leftline outerlinewidth as setting",19,TopBorder_Assert_odt.OuterLineWidth);
91
		assertEquals("assert leftline linedistance as setting",101,TopBorder_Assert_odt.LineDistance);	
92
		BorderLine BottomBorder_Assert_odt=(BorderLine) UnoRuntime.queryInterface(BorderLine.class, xFrameProps_Assert_odt.getPropertyValue("BottomBorder"));
93
		assertEquals("assert rightline color as setting",0x0000FF00,BottomBorder_Assert_odt.Color);
94
		assertEquals("assert rightline linedistance as setting",101,BottomBorder_Assert_odt.LineDistance);		
95
		assertEquals("assert rightline innerline width as setting",150,BottomBorder_Assert_odt.InnerLineWidth);
96
		assertEquals("assert rightline outerlinewidth as setting",19,BottomBorder_Assert_odt.OuterLineWidth);	
97
	}
98
}
(-)testuno/source/fvt/uno/sw/frame/FrameBorderSpacingtoContent.java (+76 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import org.junit.After;
6
import org.junit.Before;
7
import org.junit.Test;
8
import org.openoffice.test.common.Testspace;
9
import org.openoffice.test.uno.UnoApp;
10
11
import testlib.uno.SWUtil;
12
13
import com.sun.star.uno.UnoRuntime;
14
import com.sun.star.text.*;
15
import com.sun.star.lang.XMultiServiceFactory;
16
import com.sun.star.beans.XPropertySet;
17
import com.sun.star.container.XNameAccess;
18
19
20
public class FrameBorderSpacingtoContent {
21
22
	private static final UnoApp app = new UnoApp();
23
	private XTextDocument xTextDocument=null;
24
	private XMultiServiceFactory xWriterFactory=null;
25
	private XText xText=null;
26
	@Before
27
	public void setUp() throws Exception {
28
		app.start();		
29
	}
30
31
	@After
32
	public void tearDown() throws Exception {
33
		app.close();
34
	}
35
	@Test
36
	public void testFrameBorderSpacingtoContent() throws Exception {
37
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
38
		xText=xTextDocument.getText();
39
		XTextCursor xTextCursor = xText.createTextCursor();
40
		// get internal service factory of the document
41
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
42
		// Create a new table from the document's factory
43
		XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
44
		xText.insertTextContent(xTextCursor,xTextFrame,false);
45
		//set frame border spacing to content
46
		XPropertySet xCursorProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame);
47
		xCursorProps.setPropertyValue("LeftBorderDistance",499);
48
		xCursorProps.setPropertyValue("RightBorderDistance",499);
49
		xCursorProps.setPropertyValue("TopBorderDistance",499);
50
		xCursorProps.setPropertyValue("BottomBorderDistance",499);
51
		//reopen the document 
52
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
53
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
54
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
55
		Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1");
56
		XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt);
57
		XPropertySet xCursorProps_assert_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame_Assert_odt);
58
		assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("LeftBorderDistance"));
59
		assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("RightBorderDistance"));
60
		assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("TopBorderDistance"));
61
		assertEquals("assert table border spacing to content",499,xCursorProps_assert_odt.getPropertyValue("BottomBorderDistance"));
62
63
		//reopen the document 
64
		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app));
65
		XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc);
66
		XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames();
67
		Object xTextFrame_obj_doc=xTextFrames_doc.getByName("Frame1");
68
		XTextFrame xTextFrame_Assert_doc=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_doc);
69
		XPropertySet xCursorProps_assert_doc = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class,xTextFrame_Assert_doc);
70
		assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("LeftBorderDistance"));
71
		assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("RightBorderDistance"));
72
		assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("TopBorderDistance"));
73
		assertEquals("assert table border spacing to content",499,xCursorProps_assert_doc.getPropertyValue("BottomBorderDistance"));
74
	}
75
}
76
(-)testuno/source/fvt/uno/sw/frame/FrameDescription.java (+65 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import org.junit.After;
6
import org.junit.AfterClass;
7
import org.junit.Before;
8
import org.junit.Test;
9
import org.openoffice.test.common.Testspace;
10
import org.openoffice.test.uno.UnoApp;
11
12
import testlib.uno.SWUtil;
13
14
import com.sun.star.beans.XPropertySet;
15
import com.sun.star.container.XNameAccess;
16
import com.sun.star.lang.XMultiServiceFactory;
17
import com.sun.star.text.XText;
18
import com.sun.star.text.XTextCursor;
19
import com.sun.star.text.XTextDocument;
20
import com.sun.star.text.XTextFrame;
21
import com.sun.star.text.XTextFramesSupplier;
22
import com.sun.star.uno.UnoRuntime;
23
24
public class FrameDescription {
25
	private static final UnoApp app = new UnoApp();
26
	private XTextDocument xTextDocument=null;
27
	private XMultiServiceFactory xWriterFactory=null;
28
	private XText xText=null;
29
	@Before
30
	public void setUp() throws Exception {
31
		app.start();		
32
	}
33
34
	@After
35
	public void tearDown() throws Exception {
36
		app.closeDocument(xTextDocument);
37
	}
38
	@AfterClass
39
	public static void tearDownConnection() throws Exception {
40
		app.close();
41
	}
42
43
	@Test
44
	public void testFrameDescription() throws Exception {
45
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
46
		xText=xTextDocument.getText();
47
		XTextCursor xTextCursor = xText.createTextCursor();
48
		// get internal service factory of the document
49
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
50
		// Create a new table from the document's factory
51
		XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
52
		xText.insertTextContent(xTextCursor,xTextFrame,false);
53
		XPropertySet xTextFrameProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);
54
		xTextFrameProps.setPropertyValue("Title", "Frame");
55
		xTextFrameProps.setPropertyValue("Description", "Test Frame");
56
		
57
		//save and reopen the document
58
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
59
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
60
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
61
		XPropertySet xTextFrameProps_odt = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrames_odt.getByName("Frame1"));
62
		assertEquals("Test Frame title","Frame", xTextFrameProps_odt.getPropertyValue("Title"));
63
		assertEquals("Test Frame description","Test Frame", xTextFrameProps_odt.getPropertyValue("Description"));
64
	}
65
}
(-)testuno/source/fvt/uno/sw/frame/FrameHyperlink.java (+68 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import org.junit.After;
6
import org.junit.AfterClass;
7
import org.junit.Before;
8
import org.junit.Test;
9
import org.openoffice.test.common.Testspace;
10
import org.openoffice.test.uno.UnoApp;
11
12
import testlib.uno.SWUtil;
13
14
import com.sun.star.beans.XPropertySet;
15
import com.sun.star.container.XNameAccess;
16
import com.sun.star.lang.XMultiServiceFactory;
17
import com.sun.star.text.XText;
18
import com.sun.star.text.XTextCursor;
19
import com.sun.star.text.XTextDocument;
20
import com.sun.star.text.XTextFrame;
21
import com.sun.star.text.XTextFramesSupplier;
22
import com.sun.star.uno.UnoRuntime;
23
24
public class FrameHyperlink {
25
	private static final UnoApp app = new UnoApp();
26
	private XTextDocument xTextDocument=null;
27
	private XMultiServiceFactory xWriterFactory=null;
28
	private XText xText=null;
29
	@Before
30
	public void setUp() throws Exception {
31
		app.start();		
32
	}
33
34
	@After
35
	public void tearDown() throws Exception {
36
		app.closeDocument(xTextDocument);
37
	}
38
	@AfterClass
39
	public static void tearDownConnection() throws Exception {
40
		app.close();
41
	}
42
43
	@Test
44
	public void testFrameHyperlink() throws Exception {
45
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
46
		xText=xTextDocument.getText();
47
		XTextCursor xTextCursor = xText.createTextCursor();
48
		// get internal service factory of the document
49
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
50
		// Create a new table from the document's factory
51
		XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
52
		xText.insertTextContent(xTextCursor,xTextFrame,false);
53
		XPropertySet xTextFrameProps = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);
54
		xTextFrameProps.setPropertyValue("HyperLinkURL","http://www.google.com.hk/");
55
		xTextFrameProps.setPropertyValue("HyperLinkTarget","google");
56
		xTextFrameProps.setPropertyValue("HyperLinkName","FrameHyperlinkToGoogle");
57
58
		//save and reopen the document
59
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
60
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
61
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
62
		XTextFrame xTextFrame_Assert=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1"));
63
		XPropertySet xTextFrameProps_assert = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert);
64
		assertEquals("assert Frame hyperlink url","http://www.google.com.hk/", xTextFrameProps_assert.getPropertyValue("HyperLinkURL"));
65
		assertEquals("assert Frame hyperlink target","google", xTextFrameProps_assert.getPropertyValue("HyperLinkTarget"));
66
		assertEquals("assert Frame hyperlink name", "FrameHyperlinkToGoogle",xTextFrameProps_assert.getPropertyValue("HyperLinkName"));
67
	}
68
}
(-)testuno/source/fvt/uno/sw/frame/FramePosition.java (+93 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import java.util.Arrays;
6
import java.util.Collection;
7
8
import org.junit.After;
9
import org.junit.Before;
10
import org.junit.Test;
11
import org.junit.runner.RunWith;
12
import org.junit.runners.Parameterized;
13
import org.junit.runners.Parameterized.Parameters;
14
import org.openoffice.test.common.Testspace;
15
import org.openoffice.test.uno.UnoApp;
16
17
import testlib.uno.SWUtil;
18
import com.sun.star.beans.XPropertySet;
19
import com.sun.star.container.XNameAccess;
20
import com.sun.star.lang.XMultiServiceFactory;
21
import com.sun.star.text.XText;
22
import com.sun.star.text.XTextCursor;
23
import com.sun.star.text.XTextDocument;
24
import com.sun.star.text.XTextFrame;
25
import com.sun.star.text.XTextFramesSupplier;
26
import com.sun.star.uno.UnoRuntime;
27
@RunWith(value = Parameterized.class)
28
public class FramePosition {
29
	private static final UnoApp app = new UnoApp();
30
	private XTextDocument xTextDocument=null;
31
	private XMultiServiceFactory xWriterFactory=null;
32
	private XText xText=null;
33
	private short HoriOrient;
34
	private short HoriOrientRelation;
35
	private short VertOrient;
36
	private short VertOrientRelation;
37
	public FramePosition(short HoriOrient,short HoriOrientRelation,short VertOrient,short VertOrientRelation){
38
		this.HoriOrient=HoriOrient;
39
		this.HoriOrientRelation = HoriOrientRelation;
40
		this.VertOrient=VertOrient;
41
		this.VertOrientRelation = VertOrientRelation;	
42
	}
43
	@Parameters
44
    public static Collection<Object[]> data(){
45
    	Object[][] params = new Object[][]{
46
    			{(short)0,(short)0,(short)0,(short)0},
47
    			{(short)1,(short)1,(short)1,(short)1},
48
    			{(short)2,(short)2,(short)2,(short)2},
49
    			{(short)3,(short)3,(short)3,(short)2},
50
    			{(short)0,(short)4,(short)2,(short)0},
51
    			{(short)1,(short)5,(short)2,(short)2},		
52
    			};
53
    	return Arrays.asList(params);
54
    }
55
	@Before
56
	public void setUp() throws Exception {
57
		app.start();		
58
	}
59
60
	@After
61
	public void tearDown() throws Exception {
62
		app.close();
63
	}
64
65
	@Test
66
	public void testFramePosition() throws Exception {
67
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
68
		xText=xTextDocument.getText();
69
		XTextCursor xTextCursor = xText.createTextCursor();
70
		// get internal service factory of the document
71
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
72
		// Create a new table from the document's factory
73
		XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
74
		xText.insertTextContent(xTextCursor,xTextFrame,false);
75
		XPropertySet xFrameProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame);
76
		xFrameProps.setPropertyValue("HoriOrient", HoriOrient);
77
		xFrameProps.setPropertyValue("HoriOrientRelation", HoriOrientRelation);
78
		xFrameProps.setPropertyValue("VertOrient", VertOrient);
79
		xFrameProps.setPropertyValue("VertOrientRelation", VertOrientRelation);
80
		
81
		//reopen the odt document 
82
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
83
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
84
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
85
		Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1");
86
		XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt);
87
		XPropertySet xFramProps_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert_odt);
88
		assertEquals("verify Frame position",HoriOrient,xFramProps_odt.getPropertyValue("HoriOrient"));
89
		assertEquals("verify Frame position",HoriOrientRelation,xFramProps_odt.getPropertyValue("HoriOrientRelation"));
90
		assertEquals("verify Frame position",VertOrient,xFramProps_odt.getPropertyValue("VertOrient"));
91
		assertEquals("verify Frame position",VertOrientRelation,xFramProps_odt.getPropertyValue("VertOrientRelation"));
92
	}
93
}
(-)testuno/source/fvt/uno/sw/frame/FrameShadow.java (+93 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import java.util.Arrays;
6
import java.util.Collection;
7
8
import org.junit.After;
9
import org.junit.AfterClass;
10
import org.junit.Before;
11
import org.junit.Test;
12
import org.junit.runner.RunWith;
13
import org.junit.runners.Parameterized;
14
import org.junit.runners.Parameterized.Parameters;
15
import org.openoffice.test.common.Testspace;
16
import org.openoffice.test.uno.UnoApp;
17
18
import testlib.uno.SWUtil;
19
20
import com.sun.star.beans.XPropertySet;
21
import com.sun.star.container.XNameAccess;
22
import com.sun.star.lang.XMultiServiceFactory;
23
import com.sun.star.table.ShadowFormat;
24
import com.sun.star.table.ShadowLocation;
25
import com.sun.star.text.XText;
26
import com.sun.star.text.XTextCursor;
27
import com.sun.star.text.XTextDocument;
28
import com.sun.star.text.XTextFrame;
29
import com.sun.star.text.XTextFramesSupplier;
30
import com.sun.star.uno.UnoRuntime;
31
@RunWith(value = Parameterized.class)
32
public class FrameShadow {
33
	private static final UnoApp app = new UnoApp();
34
	private XTextDocument xTextDocument=null;
35
	private XMultiServiceFactory xWriterFactory=null;
36
	private XText xText=null;
37
	private int shadowColor;
38
	private short shadowWidth;
39
	private ShadowLocation shadowLocation;
40
	public FrameShadow(ShadowLocation shadowLocation,short shadowWidth,int shadowColor){
41
		this.shadowLocation=shadowLocation;
42
		this.shadowWidth=shadowWidth;
43
		this.shadowColor=shadowColor;
44
	}
45
	@Parameters
46
    public static Collection<Object[]> data(){
47
    	Object[][] params = new Object[][]{
48
    			{ShadowLocation.NONE,(short)0,0},
49
    			{ShadowLocation.TOP_LEFT,(short)101,0x00FF00FF},
50
    			{ShadowLocation.TOP_RIGHT,(short)101,0x00FF00FF},
51
    			{ShadowLocation.BOTTOM_LEFT,(short)101,0x00FF00FF},
52
    			{ShadowLocation.BOTTOM_RIGHT,(short)101,0x00FF00FF},	
53
    			};
54
    	return Arrays.asList(params);
55
    }
56
	@Before
57
	public void setUp() throws Exception {
58
		app.start();		
59
	}
60
61
	@After
62
	public void tearDown() throws Exception {
63
		app.close();
64
	}
65
66
	@Test
67
	public void testFrameShadow() throws Exception {
68
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
69
		xText=xTextDocument.getText();
70
		XTextCursor xTextCursor = xText.createTextCursor();
71
		// get internal service factory of the document
72
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
73
		// Create a new table from the document's factory
74
		XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
75
		xText.insertTextContent(xTextCursor,xTextFrame1,false);
76
		XPropertySet xTextFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1);
77
		ShadowFormat shadowFormat=new ShadowFormat();
78
		shadowFormat.Color=shadowColor;
79
		shadowFormat.Location=shadowLocation;
80
		shadowFormat.ShadowWidth=shadowWidth;
81
		xTextFrameProps1.setPropertyValue("ShadowFormat",shadowFormat);
82
		//reopen the document 
83
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app));
84
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
85
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
86
		XTextFrame xTextFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1"));
87
		XPropertySet xTextFrameProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert1);
88
		ShadowFormat shadowFormat_Assert1=(ShadowFormat) UnoRuntime.queryInterface(ShadowFormat.class, xTextFrameProps_assert1.getPropertyValue("ShadowFormat"));
89
		assertEquals("assert shadow color",shadowColor,shadowFormat_Assert1.Color);
90
		assertEquals("assert shadow location",shadowLocation,shadowFormat_Assert1.Location);
91
		assertEquals("assert shadow width",shadowWidth,shadowFormat_Assert1.ShadowWidth);
92
	}
93
}
(-)testuno/source/fvt/uno/sw/frame/FrameSize.java (+82 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import org.junit.After;
6
import org.junit.AfterClass;
7
import org.junit.Before;
8
import org.junit.Test;
9
import org.openoffice.test.common.Testspace;
10
import org.openoffice.test.uno.UnoApp;
11
12
import testlib.uno.SWUtil;
13
14
import com.sun.star.awt.Size;
15
import com.sun.star.container.XNameAccess;
16
import com.sun.star.drawing.XShape;
17
import com.sun.star.lang.XMultiServiceFactory;
18
import com.sun.star.text.XText;
19
import com.sun.star.text.XTextCursor;
20
import com.sun.star.text.XTextDocument;
21
import com.sun.star.text.XTextFrame;
22
import com.sun.star.text.XTextFramesSupplier;
23
import com.sun.star.uno.UnoRuntime;
24
25
public class FrameSize {
26
	private static final UnoApp app = new UnoApp();
27
	private XTextDocument xTextDocument=null;
28
	private XMultiServiceFactory xWriterFactory=null;
29
	private XText xText=null;
30
	@Before
31
	public void setUp() throws Exception {
32
		app.start();		
33
	}
34
35
	@After
36
	public void tearDown() throws Exception {
37
		app.closeDocument(xTextDocument);
38
	}
39
	@AfterClass
40
	public static void tearDownConnection() throws Exception {
41
		app.close();
42
	}
43
44
	@Test
45
	public void testFrameSize() throws Exception {
46
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
47
		xText=xTextDocument.getText();
48
		XTextCursor xTextCursor = xText.createTextCursor();
49
		// get internal service factory of the document
50
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
51
		// Create a new table from the document's factory
52
		XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
53
		xText.insertTextContent(xTextCursor,xTextFrame,false);
54
		// Access the XShape interface of the TextFrame
55
        XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xTextFrame);
56
        // Set the size of the new Text Frame using the XShape's 'setSize' method
57
        Size aSize = new Size();
58
        aSize.Height = 41;
59
        aSize.Width = 15000;
60
        xShape.setSize(aSize);
61
		
62
		//reopen the odt document 
63
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
64
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
65
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
66
		Object xTextFrame_obj_odt=xTextFrames_odt.getByName("Frame1");
67
		XTextFrame xTextFrame_Assert_odt=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_odt);
68
		XShape xShape_odt = (XShape) UnoRuntime.queryInterface(XShape.class, xTextFrame_Assert_odt);
69
		assertEquals("verify Frame height size",41,xShape_odt.getSize().Height);
70
		assertEquals("verify Frame width size",15000,xShape_odt.getSize().Width);
71
72
		//reopen the doc document 
73
		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app));
74
		XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc);
75
		XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames();
76
		Object xTextFrame_obj_doc=xTextFrames_doc.getByName("Frame1");
77
		XTextFrame xTextFrame_Assert_doc=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrame_obj_doc);
78
		XShape xShape_doc = (XShape) UnoRuntime.queryInterface(XShape.class, xTextFrame_Assert_doc);
79
		assertEquals("verify Frame height size",788,xShape_doc.getSize().Height);
80
		assertEquals("verify Frame width size",14998,xShape_doc.getSize().Width);
81
	}
82
}
(-)testuno/source/fvt/uno/sw/frame/FrameWrapType.java (+86 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import java.util.Arrays;
6
import java.util.Collection;
7
8
import org.junit.After;
9
import org.junit.AfterClass;
10
import org.junit.Before;
11
import org.junit.Test;
12
import org.junit.runner.RunWith;
13
import org.junit.runners.Parameterized;
14
import org.junit.runners.Parameterized.Parameters;
15
import org.openoffice.test.common.Testspace;
16
import org.openoffice.test.uno.UnoApp;
17
18
import testlib.uno.SWUtil;
19
20
import com.sun.star.beans.XPropertySet;
21
import com.sun.star.container.XNameAccess;
22
import com.sun.star.lang.XMultiServiceFactory;
23
import com.sun.star.text.WrapTextMode;
24
import com.sun.star.text.XText;
25
import com.sun.star.text.XTextCursor;
26
import com.sun.star.text.XTextDocument;
27
import com.sun.star.text.XTextFrame;
28
import com.sun.star.text.XTextFramesSupplier;
29
import com.sun.star.uno.UnoRuntime;
30
@RunWith(value = Parameterized.class)
31
public class FrameWrapType {
32
	private static final UnoApp app = new UnoApp();
33
	private XTextDocument xTextDocument=null;
34
	private XMultiServiceFactory xWriterFactory=null;
35
	private XText xText=null;
36
	private int FrameWrapType;
37
	public FrameWrapType(int FrameWrapType){
38
		this.FrameWrapType=FrameWrapType;
39
	}
40
	/*
41
	 * 0:NONE 	  
42
	 * 1:THROUGHT 	 
43
	 * 2:PARALLEL 	  
44
	 * 3:DYNAMIC 	  
45
	 * 4:LEFT 	  
46
	 * 5:RIGHT
47
	 */
48
	@Parameters
49
    public static Collection<Object[]> data(){
50
    	Object[][] params = new Object[][]{
51
    	{0},{1},{2},{3},{4},{5},
52
    			};
53
    	return Arrays.asList(params);
54
    }
55
	@Before
56
	public void setUp() throws Exception {
57
		app.start();		
58
	}
59
60
	@After
61
	public void tearDown() throws Exception {
62
		app.close();
63
	}
64
65
	@Test
66
	public void testFrameAnchorType() throws Exception {
67
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
68
		xText=xTextDocument.getText();
69
		XTextCursor xTextCursor = xText.createTextCursor();
70
		// get internal service factory of the document
71
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
72
		// Create a new table from the document's factory
73
		XTextFrame xTextFrame1 = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
74
		xText.insertTextContent(xTextCursor,xTextFrame1,false);
75
		XPropertySet xTextFrameProps1 = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xTextFrame1);
76
		xTextFrameProps1.setPropertyValue("Surround",FrameWrapType);
77
		//reopen the document 
78
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, SWUtil.saveTo_Override_reload(xTextDocument,"writer8", Testspace.getPath("output/test.odt"),app));
79
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
80
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
81
		XTextFrame xTextFrame_Assert1=(XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xTextFrames_odt.getByName("Frame1"));
82
		XPropertySet xTextFrameProps_assert1 = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextFrame_Assert1);
83
		WrapTextMode surrond=(WrapTextMode)UnoRuntime.queryInterface(WrapTextMode.class,xTextFrameProps_assert1.getPropertyValue("Surround"));
84
		assertEquals("assert frame wrap type",FrameWrapType,surrond.getValue());
85
	}
86
}
(-)testuno/source/fvt/uno/sw/frame/InsertFrame.java (+64 lines)
Line 0 Link Here
1
package fvt.uno.sw.frame;
2
3
import static org.junit.Assert.*;
4
5
import org.junit.After;
6
import org.junit.AfterClass;
7
import org.junit.Before;
8
import org.junit.Test;
9
import org.openoffice.test.common.Testspace;
10
import org.openoffice.test.uno.UnoApp;
11
12
import testlib.uno.SWUtil;
13
14
import com.sun.star.container.XNameAccess;
15
import com.sun.star.lang.XMultiServiceFactory;
16
import com.sun.star.text.XText;
17
import com.sun.star.text.XTextCursor;
18
import com.sun.star.text.XTextDocument;
19
import com.sun.star.text.XTextFrame;
20
import com.sun.star.text.XTextFramesSupplier;
21
import com.sun.star.uno.UnoRuntime;
22
23
public class InsertFrame {
24
	private static final UnoApp app = new UnoApp();
25
	private XTextDocument xTextDocument=null;
26
	private XMultiServiceFactory xWriterFactory=null;
27
	private XText xText=null;
28
	@Before
29
	public void setUp() throws Exception {
30
		app.start();		
31
	}
32
33
	@After
34
	public void tearDown() throws Exception {
35
		app.closeDocument(xTextDocument);
36
	}
37
	@AfterClass
38
	public static void tearDownConnection() throws Exception {
39
		app.close();
40
	}
41
42
	@Test
43
	public void testInsertFrame() throws Exception {
44
		xTextDocument =(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));
45
		xText=xTextDocument.getText();
46
		XTextCursor xTextCursor = xText.createTextCursor();
47
		// get internal service factory of the document
48
		xWriterFactory =(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
49
		// Create a new table from the document's factory
50
		XTextFrame xTextFrame = (XTextFrame)UnoRuntime.queryInterface(XTextFrame.class, xWriterFactory.createInstance("com.sun.star.text.TextFrame"));
51
		xText.insertTextContent(xTextCursor,xTextFrame,false);
52
53
		//save and reopen the document
54
		XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "writer8",Testspace.getPath("output/test.odt"), app));
55
		XTextFramesSupplier xTFS_odt = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_odt);
56
		XNameAccess xTextFrames_odt = xTFS_odt.getTextFrames();
57
		assertTrue("Has text frame named Frame1", xTextFrames_odt.hasByName("Frame1"));
58
		//save and reopen the document 
59
		XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,SWUtil.saveTo_Override_reload(xTextDocument, "MS Word 97",Testspace.getPath("output/test.doc"), app));
60
		XTextFramesSupplier xTFS_doc = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, assertDocument_doc);
61
		XNameAccess xTextFrames_doc = xTFS_doc.getTextFrames();
62
		assertTrue("Has text frame named Frame1", xTextFrames_doc.hasByName("Frame1"));
63
	}
64
}
(-)testuno/source/testlib/uno/SWUtil.java (+29 lines)
Lines 21-26 Link Here
21
package testlib.uno;
21
package testlib.uno;
22
22
23
23
24
import org.openoffice.test.common.FileUtil;
24
import org.openoffice.test.uno.UnoApp;
25
import org.openoffice.test.uno.UnoApp;
25
26
26
import com.sun.star.beans.PropertyValue;
27
import com.sun.star.beans.PropertyValue;
Lines 42-47 Link Here
42
import com.sun.star.text.XTextContent;
43
import com.sun.star.text.XTextContent;
43
import com.sun.star.text.XTextCursor;
44
import com.sun.star.text.XTextCursor;
44
import com.sun.star.text.XTextDocument;
45
import com.sun.star.text.XTextDocument;
46
import com.sun.star.frame.XComponentLoader;
45
import com.sun.star.frame.XModel;
47
import com.sun.star.frame.XModel;
46
import com.sun.star.frame.XController;
48
import com.sun.star.frame.XController;
47
import com.sun.star.uno.UnoRuntime;
49
import com.sun.star.uno.UnoRuntime;
Lines 229-232 Link Here
229
        XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle);        
231
        XPropertySet xStyleProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xStyle);        
230
        xStyleProps.setPropertyValue (propertyName.toString(), propertyValue);
232
        xStyleProps.setPropertyValue (propertyName.toString(), propertyValue);
231
	}
233
	}
234
	
235
	public static XTextDocument saveTo_Override_reload(XTextDocument xTextDocument,String filtervalue, String url,UnoApp app) throws Exception {
236
		XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
237
		PropertyValue[] aStoreProperties = new PropertyValue[2];
238
		aStoreProperties[0] = new PropertyValue();
239
		aStoreProperties[1] = new PropertyValue();
240
		aStoreProperties[0].Name = "Override";
241
		aStoreProperties[0].Value = true;
242
		aStoreProperties[1].Name = "FilterName";
243
		aStoreProperties[1].Value = filtervalue;
244
		xStorable_odt.storeToURL(FileUtil.getUrl(url), aStoreProperties);
245
		//reopen the document
246
		return (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(url));	
247
 	}
248
	/**
249
	 * create document from template
250
	 */
251
	public static XComponent newDocumentFromTemplate(String templatePath,UnoApp unoApp) throws Exception
252
	{
253
		XComponentLoader componentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, unoApp.getDesktop());
254
		PropertyValue[] pros = new PropertyValue[1];
255
		pros[0] = new PropertyValue();
256
		pros[0].Name = "AsTemplate";
257
		pros[0].Value = new Boolean(true);				
258
		XComponent component = componentLoader.loadComponentFromURL(FileUtil.getUrl(templatePath), "_blank", 0,pros);
259
		return component;
260
	}
232
}
261
}

Return to issue 121385