Author: wanglf Date: Thu Oct 25 04:49:24 2012 New Revision: 1401974 URL: http://svn.apache.org/viewvc?rev=1401974&view=rev Log: #120754 - [testuno]Check the numbering bullet types and properties patch by louql, reviewed by WangLifeng
Added: incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingBulletTypes.java incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingProperty.java Modified: incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/CheckBulletStyle.java incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/character/CheckCharacterStyle.java incubator/ooo/trunk/test/testuno/source/testlib/uno/SDUtil.java Modified: incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/CheckBulletStyle.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/CheckBulletStyle.java?rev=1401974&r1=1401973&r2=1401974&view=diff ============================================================================== --- incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/CheckBulletStyle.java (original) +++ incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/CheckBulletStyle.java Thu Oct 25 04:49:24 2012 @@ -67,7 +67,7 @@ public class CheckBulletStyle { @Before public void setUpDocument() throws Exception { - m_filePath = Testspace.getPath("temp/CheckBulletStyle.odt"); + m_filePath = Testspace.getPath("temp/CheckBulletStyle.odp"); if(FileUtil.fileExists(m_filePath)) { //load m_xReplace = load(); @@ -116,6 +116,9 @@ public class CheckBulletStyle { @After public void tearDownDocument() { app.closeDocument(m_xSDComponent); + + //remove the temp file + FileUtil.deleteFile(Testspace.getPath("temp")); } @BeforeClass @@ -127,8 +130,7 @@ public class CheckBulletStyle { public static void tearDownConnection() throws InterruptedException, Exception { app.close(); - //remove the temp file - FileUtil.deleteFile(Testspace.getPath("temp")); + } @Test Added: incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingBulletTypes.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingBulletTypes.java?rev=1401974&view=auto ============================================================================== --- incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingBulletTypes.java (added) +++ incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingBulletTypes.java Thu Oct 25 04:49:24 2012 @@ -0,0 +1,173 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ +/** + * + */ +package fvt.uno.sd.bullet; +import static org.junit.Assert.*; +import static testlib.uno.GraphicUtil.getUniqueIDOfGraphicFile; +import static testlib.uno.PageUtil.getDrawPageByIndex; +import static testlib.uno.ShapeUtil.addPortion; +import static testlib.uno.ShapeUtil.getPortion; + +import java.util.Arrays; +import java.util.Collection; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.junit.runners.Parameterized.Parameters; +import org.openoffice.test.uno.UnoApp; +import org.openoffice.test.common.FileUtil; +import org.openoffice.test.common.Testspace; + +import testlib.uno.SDUtil; + +import com.sun.star.awt.Size; +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexReplace; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XComponent; +import com.sun.star.style.NumberingType; +import com.sun.star.uno.UnoRuntime; + +/** + * @author LouQL + * + */ +@RunWith(Parameterized.class) +public class NumberingBulletTypes { + + private static final UnoApp app = new UnoApp(); + + private XComponent m_xSDComponent = null; + private String m_filePath = null; + private XPropertySet m_xtextProps = null; + private short m_numberingType = 0; + private short m_expectType=0; + + @Before + public void setUpDocument() throws Exception { + m_filePath = Testspace.getPath("temp/NumberingBulletTypes.odp"); + if (FileUtil.fileExists(m_filePath)) {//load + m_xtextProps = load(); + } else {//new + m_xSDComponent = (XComponent) UnoRuntime.queryInterface( + XComponent.class, app.newDocument("simpress")); + Object firstPage = getDrawPageByIndex(m_xSDComponent, 0); + Object secondTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 1); + XShape xsecondTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, secondTextBox); + m_xtextProps = addPortion(xsecondTextBox, "Numbering bullets", false); + } + } + private XPropertySet load() throws Exception{ + m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, + app.loadDocument(m_filePath)); + Object firstPage = getDrawPageByIndex(m_xSDComponent, 0); + XDrawPage firstpage = getDrawPageByIndex(m_xSDComponent, 0); + Object secondTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 1); + XShape xsecondTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, secondTextBox); + return getPortion(xsecondTextBox, 0); + } + + @After + public void tearDownDocument() { + app.closeDocument(m_xSDComponent); + //remove the temp file + FileUtil.deleteFile(Testspace.getPath("temp")); + } + + @BeforeClass + public static void setUpConnection() throws Exception { + app.start(); + } + + @AfterClass + public static void tearDownConnection() throws InterruptedException, + Exception { + app.close(); + + } + + @Parameters + public static Collection<Short[]> data(){ + Short[][] numberingTypes = new Short[][]{ + {NumberingType.CHARS_UPPER_LETTER, NumberingType.CHARS_UPPER_LETTER}, + {NumberingType.CHARS_LOWER_LETTER, NumberingType.CHARS_LOWER_LETTER}, + {NumberingType.ROMAN_UPPER, NumberingType.ROMAN_UPPER}, + {NumberingType.ROMAN_LOWER, NumberingType.ROMAN_LOWER}, + {NumberingType.ARABIC, NumberingType.ARABIC}, + //bug: 120752 +// {NumberingType.CIRCLE_NUMBER, NumberingType.CIRCLE_NUMBER}, + {NumberingType.NUMBER_NONE, NumberingType.NUMBER_NONE}}; + return Arrays.asList(numberingTypes); + } + + public NumberingBulletTypes(short input, short expect){ + m_numberingType = input; + m_expectType = expect; + } + + /*NumberingType: specifies the type of numbering + * GUI entry:Numbering and Bullet dialog->Customize->Numbering + * */ + @Test + public void testNumberingTypes() throws Exception { + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "NumberingType"; + props[0].Value = m_numberingType; + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + //set numbering level to 0 + m_xtextProps.setPropertyValue("NumberingLevel", new Short((short)0)); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); +// m_xSDComponent.dispose(); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + + assertEquals("NumberingType should be"+m_numberingType, m_expectType, proValues2[0].Value); + } +} Added: incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingProperty.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingProperty.java?rev=1401974&view=auto ============================================================================== --- incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingProperty.java (added) +++ incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/bullet/NumberingProperty.java Thu Oct 25 04:49:24 2012 @@ -0,0 +1,613 @@ +/************************************************************** + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + *************************************************************/ +/** + * + */ +package fvt.uno.sd.bullet; +import static org.junit.Assert.*; +import static testlib.uno.PageUtil.getDrawPageByIndex; +import static testlib.uno.ShapeUtil.addPortion; +import static testlib.uno.ShapeUtil.getPortion; + +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Ignore; +import org.junit.Test; +import org.openoffice.test.uno.UnoApp; +import org.openoffice.test.common.FileUtil; +import org.openoffice.test.common.Testspace; + +import testlib.uno.SDUtil; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.UnknownPropertyException; +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XIndexReplace; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XShape; +import com.sun.star.lang.WrappedTargetException; +import com.sun.star.lang.XComponent; +import com.sun.star.style.NumberingType; +import com.sun.star.text.HoriOrientation; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; + +/** + * @author LouQL + * + */ +public class NumberingProperty { + + private static final UnoApp app = new UnoApp(); + + private XComponent m_xSDComponent = null; + private String m_filePath = null; + private XPropertySet m_xtextProps = null; + + @Before + public void setUpDocument() throws Exception { + m_filePath = Testspace.getPath("temp/NumberingProperty.odp"); +// m_filePath = "F:/aa.odp"; + if (FileUtil.fileExists(m_filePath)) {//load + m_xtextProps = load(); + } else {//new + m_xSDComponent = (XComponent) UnoRuntime.queryInterface( + XComponent.class, app.newDocument("simpress")); + Object firstPage = getDrawPageByIndex(m_xSDComponent, 0); + Object secondTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 1); + XShape xsecondTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, secondTextBox); + m_xtextProps = addPortion(xsecondTextBox, + "test the property of Numbering bullets. There are two lines in this test", + false); + setNumberingType(m_xtextProps, NumberingType.ARABIC, (short)0); + } + } + + private XPropertySet load() throws Exception{ + m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, + app.loadDocument(m_filePath)); + Object firstPage = getDrawPageByIndex(m_xSDComponent, 0); + XDrawPage firstpage = getDrawPageByIndex(m_xSDComponent, 0); + Object secondTextBox = SDUtil.getShapeOfPageByIndex(firstPage, 1); + XShape xsecondTextBox = (XShape)UnoRuntime.queryInterface(XShape.class, secondTextBox); + return getPortion(xsecondTextBox, 0); + } + + @After + public void tearDownDocument() { + app.closeDocument(m_xSDComponent); + //remove the temp file + FileUtil.deleteFile(Testspace.getPath("temp")); + } + + @BeforeClass + public static void setUpConnection() throws Exception { + app.start(); + } + + @AfterClass + public static void tearDownConnection() throws InterruptedException, + Exception { + app.close(); + + } + + /*NumberingType: specifies the type of numbering + * GUI entry:Numbering and Bullet dialog->Customize->Numbering + * */ + private void setNumberingType(XPropertySet textPros, short numberingType, short level) throws Exception{ + Object numberingRules = textPros.getPropertyValue("NumberingRules"); + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingRules); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "NumberingType"; + props[0].Value = numberingType; + + xReplace.replaceByIndex(level, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingRules); + //set numbering level to 0 + m_xtextProps.setPropertyValue("NumberingLevel", level); + } + + + + @Test + /* + * Prefix: the prefix of the numbering symbol + * GUI entry: Numbering and Bullet dialog->customize->Before + * */ + public void testPrefix() throws Exception { + String prefix = "Prefix"; + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "Prefix"; + props[0].Value = prefix; + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("Prefix")) + { + assertEquals("Prefix should be "+prefix, prefix, proValues2[i].Value); + break; + } + } + + } + + @Test + /* + * Suffix: the suffix of the numbering symbol + * GUI entry: Numbering and Bullet dialog->customize->After + * */ + public void testSuffix() throws Exception { + String suffix = "--"; + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "Suffix"; + props[0].Value = suffix; + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("Suffix")) + { + assertEquals("Suffix should be "+suffix, suffix, proValues2[i].Value); + break; + } + } + + + } + + @Test + /* + * StartWith: specifies the start value for the numbering. + * GUI entry: Numbering and Bullet dialog->customize->Start At + * */ + public void testStartWith() throws Exception { + short startWith = 5; + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "StartWith"; + props[0].Value = startWith; + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + + String sStartWith = Short.toString(startWith); + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("StartWith")) + { + assertEquals("StartWith should be "+sStartWith, startWith, proValues2[i].Value); + break; + } + } + + } + + + + + @Test + /*FirstLineOffset: specifies the offset between the beginning of the first line + * and the beginning of the following lines of the paragraph. + *GUI entry: paragraph dialog->Position tab->Width of numbering + */ + public void testFirstLineOffset() throws Exception { + Integer firstLineOffset = -4500; + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + XIndexAccess xNum = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, + numberingrules); + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, xNum); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "FirstLineOffset"; + props[0].Value = firstLineOffset; + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("FirstLineOffset")) + { + assertEquals("SymbolTextDistance should be "+Integer.toString(firstLineOffset), + firstLineOffset, proValues2[i].Value); + break; + } + } + + } + + @Test + /*Leftmargin: specifies the left margin of the numbering + * GUI entry: Numbering and Bullet dialog->Position->Indent = Leftmargin+FirstLineOffset + */ + public void testLeftMargin() throws Exception { + Integer leftMargin = 2000; + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + XIndexAccess xNum = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, + numberingrules); + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, xNum); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "LeftMargin"; + props[0].Value = leftMargin; + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("LeftMargin")) + { + assertEquals("Leftmargin should be "+Integer.toString(leftMargin), leftMargin, proValues2[i].Value); + break; + } + } + + } + @Ignore + @Test + /*symbolTextDistance: specifies the distance between the numbering symbol and the text of the paragraph. + *GUI entry: ?? + *This property cannot be set, it's always the same value as FirstLineOffset + */ + public void testSymbolTextDistance() throws Exception { + Integer symbolTextDistance = -2000; + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + XIndexAccess xNum = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, + numberingrules); + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, xNum); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "SymbolTextDistance"; + props[0].Value = symbolTextDistance; + + xReplace.replaceByIndex(0, props); +// PropertyValue[] proValues = (PropertyValue[])xReplace.getByIndex(0); +// for(int m=0;m<proValues.length;m++) +// { +// System.out.println(proValues[m].Name+"="+proValues[m].Value); +// } + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("SymbolTextDistance")) + { + assertEquals("SymbolTextDistance should be "+Integer.toString(symbolTextDistance), + symbolTextDistance, proValues2[i].Value); + break; + } + } + + } + + /* + * Ajust: adjusts the numbering (HoriOrientation_LEFT/RIGHT/CENTER) + * GUI entry: Numbering and Bullet dialog->Position->Numbering alignment + * */ + @Test + public void testAjustRight() throws Exception { + Short ajust = HoriOrientation.RIGHT; + setAjust(ajust); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("Adjust")) + { + assertEquals("Ajust should be HoriOrientation.RIGHT", HoriOrientation.RIGHT, AnyConverter.toUnsignedShort(proValues2[i].Value)); + break; + } + } + } + private void setAjust(Short ajust) throws Exception{ + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "Adjust"; + props[0].Value = ajust; + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + } + + /* + * Ajust: adjusts the numbering (HoriOrientation_LEFT/RIGHT/CENTER) + * GUI entry: Numbering and Bullet dialog->Position->Numbering alignment + * */ + @Test + public void testAjustCenter() throws Exception { + Short ajust = HoriOrientation.CENTER; + setAjust(ajust); + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + String sAdjust = Short.toString(ajust); + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("Adjust")) + { + assertEquals("Ajust should be HoriOrientation.CENTER", HoriOrientation.CENTER, AnyConverter.toUnsignedShort(proValues2[i].Value)); + break; + } + } + + } + + /* + * Ajust: adjusts the numbering (HoriOrientation_LEFT/RIGHT/CENTER) + * GUI entry: Numbering and Bullet dialog->Position->Numbering alignment + * */ + @Test + public void testAjustLeft() throws Exception { + Short ajust = HoriOrientation.LEFT; + setAjust(ajust); + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + String sAdjust = Short.toString(ajust); + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("Adjust")) + { + assertEquals("Ajust should be HoriOrientation.LEFT", + HoriOrientation.LEFT, AnyConverter.toUnsignedShort(proValues2[i].Value)); + break; + } + } + } + + @Test + /*BulletColor: contains the color for the symbol. + * In SDK docs it says this is only valid if the numbering type is NumberingType::CHAR_SPECIAL. + * But infact it also valid here + *GUI entry: Bullet and Numbering dialog->Customize->Color + */ + public void testSymbolColor() throws Exception { + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "BulletColor"; + props[0].Value = new Integer(255); + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + + for(int i=0;i<proValues2.length;i++) + { + + if(proValues2[i].Name.equals("BulletColor")) + { + assertEquals("BulletColor should be Blue", + new Integer(255), proValues2[i].Value); + break; + } + } + + } + + @Test + /*BulletRelSize: contains the size of the symbol relative to the high of the paragraph + * In SDK docs it says this is only valid if the numbering type is NumberingType::CHAR_SPECIAL. + * But in fact it also valid here + *GUI entry: Bullet and Numbering dialog->Customize->Relative Size + */ + public void testSymbolSize() throws Exception { + Object numberingrules = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules); + + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "BulletRelSize"; + props[0].Value = new Short((short)100); + + xReplace.replaceByIndex(0, props); + + m_xtextProps.setPropertyValue("NumberingRules", numberingrules); + + app.saveDocument(m_xSDComponent, m_filePath); + app.closeDocument(m_xSDComponent); + //reopen + m_xtextProps = load(); + + Object numberingrules2 = m_xtextProps.getPropertyValue("NumberingRules"); + + XIndexReplace xReplace2 = (XIndexReplace) UnoRuntime.queryInterface( + XIndexReplace.class, numberingrules2); + + PropertyValue[] proValues2 = (PropertyValue[])xReplace2.getByIndex(0); + + for(int i=0;i<proValues2.length;i++) + { + if(proValues2[i].Name.equals("BulletRelSize")) + { + assertEquals("BulletRelSize should be 100%", + new Short((short)100), proValues2[i].Value); + break; + } + } + + } + +} Modified: incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/character/CheckCharacterStyle.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/character/CheckCharacterStyle.java?rev=1401974&r1=1401973&r2=1401974&view=diff ============================================================================== --- incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/character/CheckCharacterStyle.java (original) +++ incubator/ooo/trunk/test/testuno/source/fvt/uno/sd/character/CheckCharacterStyle.java Thu Oct 25 04:49:24 2012 @@ -34,6 +34,7 @@ package fvt.uno.sd.character; import static org.junit.Assert.*; +import static testlib.uno.SDUtil.saveFileAs; import java.io.File; import org.junit.After; @@ -85,8 +86,7 @@ public class CheckCharacterStyle { @AfterClass public static void tearDownConnection() throws Exception { app.close(); - //remove the temp file - FileUtil.deleteFile(Testspace.getPath("temp")); + } /** @@ -94,7 +94,7 @@ public class CheckCharacterStyle { */ @Before public void setUp() throws Exception { - filePath = Testspace.getPath("temp/CheckCharacterStyle.odt"); + filePath = Testspace.getPath("temp/CheckCharacterStyle.odp"); if(FileUtil.fileExists(filePath)) { //load m_xSDComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, @@ -124,12 +124,16 @@ public class CheckCharacterStyle { public void tearDown() throws Exception { //close odp after each test m_xSDComponent.dispose(); + + //remove the temp file + FileUtil.deleteFile(Testspace.getPath("temp")); } @Test public void testFontColor() throws Exception{ //set font color to red xtextProps.setPropertyValue("CharColor", 0xFF0000); +// saveFileAs(m_xSDComponent, filePath, ".odp"); app.saveDocument(m_xSDComponent, filePath); m_xSDComponent.dispose(); //reopen Modified: incubator/ooo/trunk/test/testuno/source/testlib/uno/SDUtil.java URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/test/testuno/source/testlib/uno/SDUtil.java?rev=1401974&r1=1401973&r2=1401974&view=diff ============================================================================== --- incubator/ooo/trunk/test/testuno/source/testlib/uno/SDUtil.java (original) +++ incubator/ooo/trunk/test/testuno/source/testlib/uno/SDUtil.java Thu Oct 25 04:49:24 2012 @@ -28,9 +28,11 @@ import com.sun.star.beans.PropertyValue; import com.sun.star.container.XIndexAccess; import com.sun.star.drawing.XDrawPage; import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; import com.sun.star.drawing.XShapes; import com.sun.star.frame.XStorable; import com.sun.star.lang.XComponent; +import com.sun.star.uno.Exception; import com.sun.star.uno.UnoRuntime; /** @@ -58,6 +60,28 @@ public class SDUtil { return m_xdrawShapes.getByIndex(index); } + public static Object[] getShapesOfPageByType(XDrawPage xDrawPage, String shapeType) throws Exception { + XShapes m_xdrawShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, xDrawPage); + int count = m_xdrawShapes.getCount(); + Object[] temp = new Object[count]; + int shapeNum=0; + for(int i=0;i<count; i++) + { + Object shape = m_xdrawShapes.getByIndex(i); + XShape xshape = (XShape)UnoRuntime.queryInterface(XShape.class, shape); + String type = xshape.getShapeType(); + if(type.equals(shapeType)) + { + temp[shapeNum] = shape; + shapeNum++; + } + } + + Object[] shapes = new Object[shapeNum]; + System.arraycopy(temp, 0, shapes, 0, shapeNum); + return shapes; + } + public static void saveFileAs(XComponent sdComponent, String fileName, String extName) throws Exception { initFilterName();