1*07d7dbdcSHerbert Dürr /************************************************************** 2*07d7dbdcSHerbert Dürr * 3*07d7dbdcSHerbert Dürr * Licensed to the Apache Software Foundation (ASF) under one 4*07d7dbdcSHerbert Dürr * or more contributor license agreements. See the NOTICE file 5*07d7dbdcSHerbert Dürr * distributed with this work for additional information 6*07d7dbdcSHerbert Dürr * regarding copyright ownership. The ASF licenses this file 7*07d7dbdcSHerbert Dürr * to you under the Apache License, Version 2.0 (the 8*07d7dbdcSHerbert Dürr * "License"); you may not use this file except in compliance 9*07d7dbdcSHerbert Dürr * with the License. You may obtain a copy of the License at 10*07d7dbdcSHerbert Dürr * 11*07d7dbdcSHerbert Dürr * http://www.apache.org/licenses/LICENSE-2.0 12*07d7dbdcSHerbert Dürr * 13*07d7dbdcSHerbert Dürr * Unless required by applicable law or agreed to in writing, 14*07d7dbdcSHerbert Dürr * software distributed under the License is distributed on an 15*07d7dbdcSHerbert Dürr * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*07d7dbdcSHerbert Dürr * KIND, either express or implied. See the License for the 17*07d7dbdcSHerbert Dürr * specific language governing permissions and limitations 18*07d7dbdcSHerbert Dürr * under the License. 19*07d7dbdcSHerbert Dürr * 20*07d7dbdcSHerbert Dürr *************************************************************/ 21*07d7dbdcSHerbert Dürr 22eba4d44aSLiu Zhe package fvt.uno.sw.paragraph; 239f0ca99bSLiu Zhe 249f0ca99bSLiu Zhe import static org.junit.Assert.*; 259f0ca99bSLiu Zhe 269f0ca99bSLiu Zhe import org.junit.After; 279f0ca99bSLiu Zhe import org.junit.Before; 289f0ca99bSLiu Zhe import org.junit.Ignore; 299f0ca99bSLiu Zhe import org.junit.Test; 309f0ca99bSLiu Zhe import org.openoffice.test.common.FileUtil; 319f0ca99bSLiu Zhe import org.openoffice.test.common.Testspace; 329f0ca99bSLiu Zhe import org.openoffice.test.uno.UnoApp; 339f0ca99bSLiu Zhe import com.sun.star.text.*; 349f0ca99bSLiu Zhe import com.sun.star.beans.*; 359f0ca99bSLiu Zhe import com.sun.star.frame.XStorable; 369f0ca99bSLiu Zhe import com.sun.star.uno.UnoRuntime; 379f0ca99bSLiu Zhe 389f0ca99bSLiu Zhe public class ParagraphInsertBreak { 399f0ca99bSLiu Zhe private static final UnoApp app = new UnoApp(); 409f0ca99bSLiu Zhe XText xText = null; 419f0ca99bSLiu Zhe 429f0ca99bSLiu Zhe @Before setUp()439f0ca99bSLiu Zhe public void setUp() throws Exception { 449f0ca99bSLiu Zhe app.start(); 459f0ca99bSLiu Zhe 469f0ca99bSLiu Zhe } 479f0ca99bSLiu Zhe 489f0ca99bSLiu Zhe @After tearDown()499f0ca99bSLiu Zhe public void tearDown() throws Exception { 509f0ca99bSLiu Zhe app.close(); 519f0ca99bSLiu Zhe } 529f0ca99bSLiu Zhe @Test InsertPage_BeforeBreak_NoSplit_KeepTogether()539f0ca99bSLiu Zhe public void InsertPage_BeforeBreak_NoSplit_KeepTogether() throws Exception { 549f0ca99bSLiu Zhe 559f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 569f0ca99bSLiu Zhe xText = xTextDocument.getText(); 579f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 589f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 599f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 609f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 619f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 629f0ca99bSLiu Zhe //set paragraph break type 639f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 649f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaSplit",false); 659f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaKeepTogether",true); 669f0ca99bSLiu Zhe //save to odt 679f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 689f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 699f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 709f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 719f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 729f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 739f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 749f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 759f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 769f0ca99bSLiu Zhe //save to doc 779f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 789f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 799f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 809f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 819f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 829f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 839f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 849f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 859f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 869f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 879f0ca99bSLiu Zhe 889f0ca99bSLiu Zhe //reopen the document 899f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 909f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 919f0ca99bSLiu Zhe //verify paragraph break 929f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 939f0ca99bSLiu Zhe assertEquals("assert paragraph break",false,xCursorProps_Assert_odt.getPropertyValue("ParaSplit")); 949f0ca99bSLiu Zhe assertEquals("assert paragraph break",true,xCursorProps_Assert_odt.getPropertyValue("ParaKeepTogether")); 959f0ca99bSLiu Zhe 969f0ca99bSLiu Zhe //reopen the document 979f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 989f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 999f0ca99bSLiu Zhe //verify paragraph background color 1009f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 1019f0ca99bSLiu Zhe assertEquals("assert paragraph break",false,xCursorProps_Assert_doc.getPropertyValue("ParaSplit")); 1029f0ca99bSLiu Zhe assertEquals("assert paragraph break",true,xCursorProps_Assert_doc.getPropertyValue("ParaKeepTogether")); 1039f0ca99bSLiu Zhe } 1049f0ca99bSLiu Zhe @Test InsertPage_BeforeBreak_Orphan_WindowControl()1059f0ca99bSLiu Zhe public void InsertPage_BeforeBreak_Orphan_WindowControl() throws Exception { 1069f0ca99bSLiu Zhe 1079f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 1089f0ca99bSLiu Zhe xText = xTextDocument.getText(); 1099f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 1109f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 1119f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 1129f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 1139f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 1149f0ca99bSLiu Zhe //set paragraph break type 1159f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 1169f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaOrphans",(byte)2); 1179f0ca99bSLiu Zhe xCursorProps.setPropertyValue("ParaWidows",(byte)2); 1189f0ca99bSLiu Zhe //save to odt 1199f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1209f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 1219f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 1229f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 1239f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 1249f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 1259f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 1269f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 1279f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 1289f0ca99bSLiu Zhe //save to doc 1299f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1309f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 1319f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 1329f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 1339f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 1349f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 1359f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 1369f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 1379f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 1389f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 1399f0ca99bSLiu Zhe 1409f0ca99bSLiu Zhe //reopen the document 1419f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 1429f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 1439f0ca99bSLiu Zhe //verify paragraph break 1449f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 1459f0ca99bSLiu Zhe assertEquals("assert paragraph break",(byte)2,xCursorProps_Assert_odt.getPropertyValue("ParaOrphans")); 1469f0ca99bSLiu Zhe assertEquals("assert paragraph break",(byte)2,xCursorProps_Assert_odt.getPropertyValue("ParaWidows")); 1479f0ca99bSLiu Zhe 1489f0ca99bSLiu Zhe //reopen the document 1499f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 1509f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 1519f0ca99bSLiu Zhe //verify paragraph background color 1529f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 1539f0ca99bSLiu Zhe assertEquals("assert paragraph break",(byte)2,xCursorProps_Assert_odt.getPropertyValue("ParaOrphans")); 1549f0ca99bSLiu Zhe assertEquals("assert paragraph break",(byte)2,xCursorProps_Assert_odt.getPropertyValue("ParaWidows")); 1559f0ca99bSLiu Zhe } 156af986861SLiu Zhe @Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.") InsertPage_AfterBreak()1579f0ca99bSLiu Zhe public void InsertPage_AfterBreak() throws Exception { 1589f0ca99bSLiu Zhe 1599f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 1609f0ca99bSLiu Zhe xText = xTextDocument.getText(); 1619f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 1629f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 1639f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 1649f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 1659f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 1669f0ca99bSLiu Zhe //set paragraph break type 1679f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_AFTER); 1689f0ca99bSLiu Zhe //save to odt 1699f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1709f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 1719f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 1729f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 1739f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 1749f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 1759f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 1769f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 1779f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 1789f0ca99bSLiu Zhe //save to doc 1799f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 1809f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 1819f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 1829f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 1839f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 1849f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 1859f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 1869f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 1879f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 1889f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 1899f0ca99bSLiu Zhe 1909f0ca99bSLiu Zhe //reopen the document 1919f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 1929f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 1939f0ca99bSLiu Zhe //verify paragraph break 1949f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_AFTER,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 1959f0ca99bSLiu Zhe 1969f0ca99bSLiu Zhe //reopen the document 1979f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 1989f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 1999f0ca99bSLiu Zhe //verify paragraph break 2009f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_AFTER,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 2019f0ca99bSLiu Zhe } 202af986861SLiu Zhe @Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.") InsertColumn_BeforeBreak()2039f0ca99bSLiu Zhe public void InsertColumn_BeforeBreak() throws Exception { 2049f0ca99bSLiu Zhe 2059f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 2069f0ca99bSLiu Zhe xText = xTextDocument.getText(); 2079f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 2089f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 2099f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 2109f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 2119f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 2129f0ca99bSLiu Zhe //set paragraph break type 2139f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.COLUMN_BEFORE); 2149f0ca99bSLiu Zhe //save to odt 2159f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2169f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 2179f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 2189f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 2199f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 2209f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 2219f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 2229f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 2239f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 2249f0ca99bSLiu Zhe //save to doc 2259f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2269f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 2279f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 2289f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 2299f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 2309f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 2319f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 2329f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 2339f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 2349f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 2359f0ca99bSLiu Zhe 2369f0ca99bSLiu Zhe //reopen the document 2379f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 2389f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 2399f0ca99bSLiu Zhe //verify paragraph break 2409f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 2419f0ca99bSLiu Zhe 2429f0ca99bSLiu Zhe //reopen the document 2439f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 2449f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 2459f0ca99bSLiu Zhe //verify paragraph break 2469f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 2479f0ca99bSLiu Zhe } 248af986861SLiu Zhe @Test@Ignore("Bug #120719 - [testUNO patch]the page_after break change to page_before break when save to doc.") InsertColumn_AfterBreak()2499f0ca99bSLiu Zhe public void InsertColumn_AfterBreak() throws Exception { 2509f0ca99bSLiu Zhe 2519f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 2529f0ca99bSLiu Zhe xText = xTextDocument.getText(); 2539f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 2549f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 2559f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 2569f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 2579f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 2589f0ca99bSLiu Zhe //set paragraph break type 2599f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.COLUMN_AFTER); 2609f0ca99bSLiu Zhe //save to odt 2619f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2629f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 2639f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 2649f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 2659f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 2669f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 2679f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 2689f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 2699f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 2709f0ca99bSLiu Zhe //save to doc 2719f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 2729f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 2739f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 2749f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 2759f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 2769f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 2779f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 2789f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 2799f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 2809f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 2819f0ca99bSLiu Zhe 2829f0ca99bSLiu Zhe //reopen the document 2839f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 2849f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 2859f0ca99bSLiu Zhe //verify paragraph break 2869f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_AFTER,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 2879f0ca99bSLiu Zhe 2889f0ca99bSLiu Zhe //reopen the document 2899f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 2909f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 2919f0ca99bSLiu Zhe //verify paragraph break 2929f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.COLUMN_AFTER,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 2939f0ca99bSLiu Zhe } 294af986861SLiu Zhe @Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.") InsertPage_Endnote_BeforeBreak()2959f0ca99bSLiu Zhe public void InsertPage_Endnote_BeforeBreak() throws Exception { 2969f0ca99bSLiu Zhe 2979f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 2989f0ca99bSLiu Zhe xText = xTextDocument.getText(); 2999f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 3009f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 3019f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 3029f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 3039f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 3049f0ca99bSLiu Zhe //set paragraph break type 3059f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 3069f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","Endnote"); 3079f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 3089f0ca99bSLiu Zhe //save to odt 3099f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 3109f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 3119f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 3129f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 3139f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 3149f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 3159f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 3169f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 3179f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 3189f0ca99bSLiu Zhe //save to doc 3199f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 3209f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 3219f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 3229f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 3239f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 3249f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 3259f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 3269f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 3279f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 3289f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 3299f0ca99bSLiu Zhe 3309f0ca99bSLiu Zhe //reopen the document 3319f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 3329f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 3339f0ca99bSLiu Zhe //verify paragraph break 3349f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 3359f0ca99bSLiu Zhe assertEquals("assert paragraph break","Endnote",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 3369f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 3379f0ca99bSLiu Zhe //reopen the document 3389f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 3399f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 3409f0ca99bSLiu Zhe //verify paragraph background color 3419f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 3429f0ca99bSLiu Zhe assertEquals("assert paragraph break","Endnote",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 3439f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 3449f0ca99bSLiu Zhe } 3459f0ca99bSLiu Zhe 346af986861SLiu Zhe @Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.") InsertPage_Envelop_BeforeBreak()3479f0ca99bSLiu Zhe public void InsertPage_Envelop_BeforeBreak() throws Exception { 3489f0ca99bSLiu Zhe 3499f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 3509f0ca99bSLiu Zhe xText = xTextDocument.getText(); 3519f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 3529f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 3539f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 3549f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 3559f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 3569f0ca99bSLiu Zhe //set paragraph break type 3579f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 3589f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","Envelope"); 3599f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 3609f0ca99bSLiu Zhe //save to odt 3619f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 3629f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 3639f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 3649f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 3659f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 3669f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 3679f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 3689f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 3699f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 3709f0ca99bSLiu Zhe //save to doc 3719f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 3729f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 3739f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 3749f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 3759f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 3769f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 3779f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 3789f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 3799f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 3809f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 3819f0ca99bSLiu Zhe 3829f0ca99bSLiu Zhe //reopen the document 3839f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 3849f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 3859f0ca99bSLiu Zhe //verify paragraph break 3869f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 3879f0ca99bSLiu Zhe assertEquals("assert paragraph break","Envelope",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 3889f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 3899f0ca99bSLiu Zhe //reopen the document 3909f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 3919f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 3929f0ca99bSLiu Zhe //verify paragraph background color 3939f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 3949f0ca99bSLiu Zhe assertEquals("assert paragraph break","Envelope",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 3959f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 3969f0ca99bSLiu Zhe } 3979f0ca99bSLiu Zhe 3989f0ca99bSLiu Zhe @Test InsertPage_Firstpage_BeforeBreak()3999f0ca99bSLiu Zhe public void InsertPage_Firstpage_BeforeBreak() throws Exception { 4009f0ca99bSLiu Zhe 4019f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 4029f0ca99bSLiu Zhe xText = xTextDocument.getText(); 4039f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 4049f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 4059f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 4069f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 4079f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 4089f0ca99bSLiu Zhe //set paragraph break type 4099f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 4109f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","First Page"); 4119f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 4129f0ca99bSLiu Zhe //save to odt 4139f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 4149f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 4159f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 4169f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 4179f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 4189f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 4199f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 4209f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 4219f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 4229f0ca99bSLiu Zhe //save to doc 4239f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 4249f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 4259f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 4269f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 4279f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 4289f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 4299f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 4309f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 4319f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 4329f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 4339f0ca99bSLiu Zhe 4349f0ca99bSLiu Zhe //reopen the document 4359f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 4369f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 4379f0ca99bSLiu Zhe //verify paragraph break 4389f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 4399f0ca99bSLiu Zhe assertEquals("assert paragraph break","First Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 4409f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 4419f0ca99bSLiu Zhe //reopen the document 4429f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 4439f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 4449f0ca99bSLiu Zhe //verify paragraph background color 4459f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 4469f0ca99bSLiu Zhe assertEquals("assert paragraph break","First Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 4479f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 4489f0ca99bSLiu Zhe } 449af986861SLiu Zhe @Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.") InsertPage_Footnote_BeforeBreak()4509f0ca99bSLiu Zhe public void InsertPage_Footnote_BeforeBreak() throws Exception { 4519f0ca99bSLiu Zhe 4529f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 4539f0ca99bSLiu Zhe xText = xTextDocument.getText(); 4549f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 4559f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 4569f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 4579f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 4589f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 4599f0ca99bSLiu Zhe //set paragraph break type 4609f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 4619f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","Footnote"); 4629f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 4639f0ca99bSLiu Zhe //save to odt 4649f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 4659f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 4669f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 4679f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 4689f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 4699f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 4709f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 4719f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 4729f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 4739f0ca99bSLiu Zhe //save to doc 4749f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 4759f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 4769f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 4779f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 4789f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 4799f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 4809f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 4819f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 4829f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 4839f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 4849f0ca99bSLiu Zhe 4859f0ca99bSLiu Zhe //reopen the document 4869f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 4879f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 4889f0ca99bSLiu Zhe //verify paragraph break 4899f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 4909f0ca99bSLiu Zhe assertEquals("assert paragraph break","Footnote",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 4919f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 4929f0ca99bSLiu Zhe //reopen the document 4939f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 4949f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 4959f0ca99bSLiu Zhe //verify paragraph background color 4969f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 4979f0ca99bSLiu Zhe assertEquals("assert paragraph break","Footnote",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 4989f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 4999f0ca99bSLiu Zhe } 500af986861SLiu Zhe @Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.") InsertPage_HTML_BeforeBreak()5019f0ca99bSLiu Zhe public void InsertPage_HTML_BeforeBreak() throws Exception { 5029f0ca99bSLiu Zhe 5039f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 5049f0ca99bSLiu Zhe xText = xTextDocument.getText(); 5059f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 5069f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 5079f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 5089f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 5099f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 5109f0ca99bSLiu Zhe //set paragraph break type 5119f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 5129f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","HTML"); 5139f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 5149f0ca99bSLiu Zhe //save to odt 5159f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 5169f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 5179f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 5189f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 5199f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 5209f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 5219f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 5229f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 5239f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 5249f0ca99bSLiu Zhe //save to doc 5259f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 5269f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 5279f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 5289f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 5299f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 5309f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 5319f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 5329f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 5339f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 5349f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 5359f0ca99bSLiu Zhe 5369f0ca99bSLiu Zhe //reopen the document 5379f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 5389f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 5399f0ca99bSLiu Zhe //verify paragraph break 5409f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 5419f0ca99bSLiu Zhe assertEquals("assert paragraph break","HTML",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 5429f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 5439f0ca99bSLiu Zhe //reopen the document 5449f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 5459f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 5469f0ca99bSLiu Zhe //verify paragraph background color 5479f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 5489f0ca99bSLiu Zhe assertEquals("assert paragraph break","HTML",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 5499f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 5509f0ca99bSLiu Zhe } 551af986861SLiu Zhe @Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.") InsertPage_Index_BeforeBreak()5529f0ca99bSLiu Zhe public void InsertPage_Index_BeforeBreak() throws Exception { 5539f0ca99bSLiu Zhe 5549f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 5559f0ca99bSLiu Zhe xText = xTextDocument.getText(); 5569f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 5579f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 5589f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 5599f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 5609f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 5619f0ca99bSLiu Zhe //set paragraph break type 5629f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 5639f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","Index"); 5649f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 5659f0ca99bSLiu Zhe //save to odt 5669f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 5679f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 5689f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 5699f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 5709f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 5719f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 5729f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 5739f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 5749f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 5759f0ca99bSLiu Zhe //save to doc 5769f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 5779f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 5789f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 5799f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 5809f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 5819f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 5829f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 5839f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 5849f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 5859f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 5869f0ca99bSLiu Zhe 5879f0ca99bSLiu Zhe //reopen the document 5889f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 5899f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 5909f0ca99bSLiu Zhe //verify paragraph break 5919f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 5929f0ca99bSLiu Zhe assertEquals("assert paragraph break","Index",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 5939f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 5949f0ca99bSLiu Zhe //reopen the document 5959f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 5969f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 5979f0ca99bSLiu Zhe //verify paragraph background color 5989f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 5999f0ca99bSLiu Zhe assertEquals("assert paragraph break","Index",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 6009f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 6019f0ca99bSLiu Zhe } 602af986861SLiu Zhe @Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.") InsertPage_Landscape_BeforeBreak()6039f0ca99bSLiu Zhe public void InsertPage_Landscape_BeforeBreak() throws Exception { 6049f0ca99bSLiu Zhe 6059f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 6069f0ca99bSLiu Zhe xText = xTextDocument.getText(); 6079f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 6089f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 6099f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 6109f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 6119f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 6129f0ca99bSLiu Zhe //set paragraph break type 6139f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 6149f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","Landscape"); 6159f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 6169f0ca99bSLiu Zhe //save to odt 6179f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 6189f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 6199f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 6209f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 6219f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 6229f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 6239f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 6249f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 6259f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 6269f0ca99bSLiu Zhe //save to doc 6279f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 6289f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 6299f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 6309f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 6319f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 6329f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 6339f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 6349f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 6359f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 6369f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 6379f0ca99bSLiu Zhe 6389f0ca99bSLiu Zhe //reopen the document 6399f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 6409f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 6419f0ca99bSLiu Zhe //verify paragraph break 6429f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 6439f0ca99bSLiu Zhe assertEquals("assert paragraph break","Landscape",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 6449f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 6459f0ca99bSLiu Zhe //reopen the document 6469f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 6479f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 6489f0ca99bSLiu Zhe //verify paragraph background color 6499f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 6509f0ca99bSLiu Zhe assertEquals("assert paragraph break","Landscape",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 6519f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 6529f0ca99bSLiu Zhe } 653af986861SLiu Zhe @Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.") InsertPage_LeftPage_BeforeBreak()6549f0ca99bSLiu Zhe public void InsertPage_LeftPage_BeforeBreak() throws Exception { 6559f0ca99bSLiu Zhe 6569f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 6579f0ca99bSLiu Zhe xText = xTextDocument.getText(); 6589f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 6599f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 6609f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 6619f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 6629f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 6639f0ca99bSLiu Zhe //set paragraph break type 6649f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 6659f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","Left Page"); 6669f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 6679f0ca99bSLiu Zhe //save to odt 6689f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 6699f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 6709f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 6719f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 6729f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 6739f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 6749f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 6759f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 6769f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 6779f0ca99bSLiu Zhe //save to doc 6789f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 6799f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 6809f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 6819f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 6829f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 6839f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 6849f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 6859f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 6869f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 6879f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 6889f0ca99bSLiu Zhe 6899f0ca99bSLiu Zhe //reopen the document 6909f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 6919f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 6929f0ca99bSLiu Zhe //verify paragraph break 6939f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 6949f0ca99bSLiu Zhe assertEquals("assert paragraph break","Left Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 6959f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 6969f0ca99bSLiu Zhe //reopen the document 6979f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 6989f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 6999f0ca99bSLiu Zhe //verify paragraph background color 7009f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 7019f0ca99bSLiu Zhe assertEquals("assert paragraph break","Left Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 7029f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 7039f0ca99bSLiu Zhe } 704af986861SLiu Zhe @Test@Ignore("Bug #120721 - [testUNO patch]the endnote page break change to page default break when save to doc.") InsertPage_RightPage_BeforeBreak()7059f0ca99bSLiu Zhe public void InsertPage_RightPage_BeforeBreak() throws Exception { 7069f0ca99bSLiu Zhe 7079f0ca99bSLiu Zhe XTextDocument xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, app.newDocument("swriter"));// new a text document 7089f0ca99bSLiu Zhe xText = xTextDocument.getText(); 7099f0ca99bSLiu Zhe xText.setString("we are Chinese,they are American.we are all living in one earth!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!Hello,world!" + 7109f0ca99bSLiu Zhe "Hello,world!Hello,world!"); 7119f0ca99bSLiu Zhe // create text cursor for selecting and formatting text 7129f0ca99bSLiu Zhe XTextCursor xTextCursor = xText.createTextCursor(); 7139f0ca99bSLiu Zhe XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextCursor); 7149f0ca99bSLiu Zhe //set paragraph break type 7159f0ca99bSLiu Zhe xCursorProps.setPropertyValue("BreakType",com.sun.star.style.BreakType.PAGE_BEFORE); 7169f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageDescName","Right Page"); 7179f0ca99bSLiu Zhe xCursorProps.setPropertyValue("PageNumberOffset",(short)3); 7189f0ca99bSLiu Zhe //save to odt 7199f0ca99bSLiu Zhe XStorable xStorable_odt = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 7209f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_odt = new PropertyValue[2]; 7219f0ca99bSLiu Zhe aStoreProperties_odt[0] = new PropertyValue(); 7229f0ca99bSLiu Zhe aStoreProperties_odt[1] = new PropertyValue(); 7239f0ca99bSLiu Zhe aStoreProperties_odt[0].Name = "Override"; 7249f0ca99bSLiu Zhe aStoreProperties_odt[0].Value = true; 7259f0ca99bSLiu Zhe aStoreProperties_odt[1].Name = "FilterName"; 7269f0ca99bSLiu Zhe aStoreProperties_odt[1].Value = "StarOffice XML (Writer)"; 7279f0ca99bSLiu Zhe xStorable_odt.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.odt")), aStoreProperties_odt); 7289f0ca99bSLiu Zhe //save to doc 7299f0ca99bSLiu Zhe XStorable xStorable_doc = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument); 7309f0ca99bSLiu Zhe PropertyValue[] aStoreProperties_doc = new PropertyValue[2]; 7319f0ca99bSLiu Zhe aStoreProperties_doc[0] = new PropertyValue(); 7329f0ca99bSLiu Zhe aStoreProperties_doc[1] = new PropertyValue(); 7339f0ca99bSLiu Zhe aStoreProperties_doc[0].Name = "Override"; 7349f0ca99bSLiu Zhe aStoreProperties_doc[0].Value = true; 7359f0ca99bSLiu Zhe aStoreProperties_doc[1].Name = "FilterName"; 7369f0ca99bSLiu Zhe aStoreProperties_doc[1].Value = "MS Word 97"; 7379f0ca99bSLiu Zhe xStorable_doc.storeToURL(FileUtil.getUrl(Testspace.getPath("output/test.doc")), aStoreProperties_doc); 7389f0ca99bSLiu Zhe app.closeDocument(xTextDocument); 7399f0ca99bSLiu Zhe 7409f0ca99bSLiu Zhe //reopen the document 7419f0ca99bSLiu Zhe XTextDocument assertDocument_odt=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.odt"))); 7429f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_odt = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_odt.getText().createTextCursor()); 7439f0ca99bSLiu Zhe //verify paragraph break 7449f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_odt.getPropertyValue("BreakType")); 7459f0ca99bSLiu Zhe assertEquals("assert paragraph break","Right Page",xCursorProps_Assert_odt.getPropertyValue("PageDescName")); 7469f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_odt.getPropertyValue("PageNumberOffset")); 7479f0ca99bSLiu Zhe //reopen the document 7489f0ca99bSLiu Zhe XTextDocument assertDocument_doc=(XTextDocument)UnoRuntime.queryInterface(XTextDocument.class, app.loadDocument(Testspace.getPath("output/test.doc"))); 7499f0ca99bSLiu Zhe XPropertySet xCursorProps_Assert_doc = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, assertDocument_doc.getText().createTextCursor()); 7509f0ca99bSLiu Zhe //verify paragraph background color 7519f0ca99bSLiu Zhe assertEquals("assert paragraph break",com.sun.star.style.BreakType.PAGE_BEFORE,xCursorProps_Assert_doc.getPropertyValue("BreakType")); 7529f0ca99bSLiu Zhe assertEquals("assert paragraph break","Right Page",xCursorProps_Assert_doc.getPropertyValue("PageDescName")); 7539f0ca99bSLiu Zhe assertEquals("assert paragraph break",(short)3,xCursorProps_Assert_doc.getPropertyValue("PageNumberOffset")); 7549f0ca99bSLiu Zhe } 7559f0ca99bSLiu Zhe } 756