diff options
Diffstat (limited to 'qadevOOo/tests/java/ifc/sheet')
100 files changed, 12722 insertions, 0 deletions
diff --git a/qadevOOo/tests/java/ifc/sheet/_CellAreaLink.java b/qadevOOo/tests/java/ifc/sheet/_CellAreaLink.java new file mode 100644 index 000000000000..cef1fcd32153 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_CellAreaLink.java @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.CellAreaLink</code> +* service properties : +* <ul> +* <li><code> Url</code></li> +* <li><code> Filter</code></li> +* <li><code> FilterOptions</code></li> +* <li><code> RefreshDelay</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.CellAreaLink +*/ +public class _CellAreaLink extends MultiPropertyTest { + +} // finish class _CellAreaLink + + diff --git a/qadevOOo/tests/java/ifc/sheet/_DataPilotField.java b/qadevOOo/tests/java/ifc/sheet/_DataPilotField.java new file mode 100644 index 000000000000..272c49798d54 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_DataPilotField.java @@ -0,0 +1,169 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import com.sun.star.sheet.DataPilotFieldAutoShowInfo; +import com.sun.star.sheet.DataPilotFieldLayoutInfo; +import com.sun.star.sheet.DataPilotFieldReference; +import com.sun.star.sheet.DataPilotFieldSortInfo; +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.DataPilotField</code> +* service properties : +* <ul> +* <li><code> Orientation</code></li> +* <li><code> Function</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.DataPilotField +*/ +public class _DataPilotField extends MultiPropertyTest { + + /** + *This class is destined to custom test of property <code>SortInfo</code>. + */ + protected PropertyTester SortInfoTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + DataPilotFieldSortInfo sortInfo = new DataPilotFieldSortInfo(); + sortInfo.Mode = com.sun.star.sheet.DataPilotFieldSortMode.MANUAL; + sortInfo.IsAscending = false; + sortInfo.Field = "COL1"; + log.println("Having Value and returning a new one"); + return sortInfo.equals(oldValue) ? null : sortInfo; + } + }; + + /** + * Test property <code>SortInfo</code> using custom <code>PropertyTest</code>. + */ + public void _SortInfo() { + testProperty("SortInfo", SortInfoTester); + } + + public void _HasSortInfo() { + requiredMethod("SortInfo"); + testProperty("HasSortInfo"); + } + + /** + *This class is destined to custom test of property <code>LayoutInfo</code>. + */ + protected PropertyTester LayoutInfoTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + DataPilotFieldLayoutInfo layoutInfo = new DataPilotFieldLayoutInfo(); + layoutInfo.LayoutMode = com.sun.star.sheet.DataPilotFieldLayoutMode.OUTLINE_SUBTOTALS_BOTTOM; + layoutInfo.AddEmptyLines = true; + log.println("Having Value and returning a new one"); + return layoutInfo.equals(oldValue) ? null : layoutInfo; + } + }; + + /** + * Test property <code>LayoutInfo</code> using custom <code>PropertyTest</code>. + */ + public void _LayoutInfo() { + testProperty("LayoutInfo", LayoutInfoTester); + } + + public void _HasLayoutInfo() { + requiredMethod("LayoutInfo"); + testProperty("HasLayoutInfo"); + } + + /** + *This class is destined to custom test of property <code>AutoShowInfo</code>. + */ + protected PropertyTester AutoShowInfoTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + DataPilotFieldAutoShowInfo AutoShowInfo = new DataPilotFieldAutoShowInfo(); + AutoShowInfo.DataField = "Col1"; + AutoShowInfo.IsEnabled = true; + log.println("Having Value and returning a new one"); + return AutoShowInfo.equals(oldValue) ? null : AutoShowInfo; + } + }; + + /** + * Test property <code>AutoShowInfo</code> using custom <code>PropertyTest</code>. + */ + public void _AutoShowInfo() { + testProperty("AutoShowInfo", AutoShowInfoTester); + } + + public void _HasAutoShowInfo() { + requiredMethod("AutoShowInfo"); + testProperty("HasAutoShowInfo"); + } + + /** + *This class is destined to custom test of property <code>Reference</code>. + */ + protected PropertyTester ReferenceTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + DataPilotFieldReference Reference = new DataPilotFieldReference(); + Reference.ReferenceField="Col1"; + Reference.ReferenceItemType = com.sun.star.sheet.DataPilotFieldReferenceItemType.NAMED; + log.println("Having Value and returning a new one"); + return Reference.equals(oldValue) ? null : Reference; + } + }; + + /** + * Test property <code>Reference</code> using custom <code>PropertyTest</code>. + */ + public void _Reference() { + testProperty("Reference", ReferenceTester); + } + + public void _HasReference() { + requiredMethod("Reference"); + testProperty("HasReference"); + } + + /* + * this property can only set a true value to false, fo ungrouping purposes + */ + public void _IsGroupField() { + boolean result = true; + try { + Boolean propValue = (Boolean) oObj.getPropertyValue ("IsGroupField"); + if (propValue.booleanValue ()) { + oObj.setPropertyValue ("IsGroupField", Boolean.FALSE); + Boolean propV = (Boolean) oObj.getPropertyValue ("IsGroupField"); + result = !propV.booleanValue (); + } + } catch (Exception e) { + log.println ("Exception while getting Property 'IsGroupField'"+e); + result = false; + } + tRes.tested ("IsGroupField",result); + } +} + + diff --git a/qadevOOo/tests/java/ifc/sheet/_DataPilotItem.java b/qadevOOo/tests/java/ifc/sheet/_DataPilotItem.java new file mode 100644 index 000000000000..a83bd47543f4 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_DataPilotItem.java @@ -0,0 +1,33 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import lib.MultiPropertyTest; + + +public class _DataPilotItem extends MultiPropertyTest { +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_DatabaseImportDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_DatabaseImportDescriptor.java new file mode 100644 index 000000000000..bb819a0f43e7 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_DatabaseImportDescriptor.java @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import util.ValueChanger; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.util.XImportable; + +/** +* Testing <code>com.sun.star.sheet.DatabaseImportDescriptor</code> +* service properties: +* <ul> +* <li><code>DatabaseName</code></li> +* <li><code>SourceObject</code></li> +* <li><code>SourceType</code></li> +* </ul> <p> +* @see com.sun.star.sheet.DatabaseImportDescriptor +*/ +public class _DatabaseImportDescriptor extends MultiMethodTest { + + public XPropertySet oObj = null; + public XImportable xIMP = null; + public PropertyValue[] props = null; + + public void _DatabaseName() { + xIMP = (XImportable) tEnv.getObjRelation("xIMP"); + props = xIMP.createImportDescriptor(true); + changeProp("DatabaseName",0); + } + + public void _SourceObject() { + changeProp("SourceObject",2); + } + + public void _SourceType() { + changeProp("SourceType",1); + } + + public void changeProp(String name, int nr) { + + Object gValue = null; + Object sValue = null; + Object ValueToSet = null; + + if ( ! name.equals(props[nr].Name) ) { + log.println("Property '"+props[nr].Name+"' is tested"); + log.println("But the status is for '"+name+"'"); + } + + + try { + //waitForAllThreads(); + gValue = props[nr].Value; + //waitForAllThreads(); + ValueToSet = ValueChanger.changePValue(gValue); + //waitForAllThreads(); + props[nr].Value=ValueToSet; + sValue = props[nr].Value; + + //check get-set methods + if ( (gValue.equals(sValue)) || (sValue == null) ) { + log.println("Value for '"+name+"' hasn't changed"); + tRes.tested(name, false); + } + else { + log.println("Property '"+name+"' OK"); + tRes.tested(name, true); + } + } catch (Exception e) { + log.println("Exception occured while testing property '" + + name + "'"); + e.printStackTrace(log); + tRes.tested(name, false); + } + }// end of changeProp + + +} // finish class _DatabaseImportDescriptor + + diff --git a/qadevOOo/tests/java/ifc/sheet/_DatabaseRange.java b/qadevOOo/tests/java/ifc/sheet/_DatabaseRange.java new file mode 100644 index 000000000000..f32fe6c27c40 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_DatabaseRange.java @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.DatabaseRange</code> +* service properties : +* <ul> +* <li><code> MoveCells</code></li> +* <li><code> KeepFormats</code></li> +* <li><code> StripData</code></li> +* <li><code> AutoFilter</code></li> +* <li><code> UseFilerCriteriaSource</code></li> +* <li><code> FilerCriteriaSource</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.DatabaseRange +*/ +public class _DatabaseRange extends MultiPropertyTest { +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_DocumentSettings.java b/qadevOOo/tests/java/ifc/sheet/_DocumentSettings.java new file mode 100644 index 000000000000..6074e8e6cb3f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_DocumentSettings.java @@ -0,0 +1,39 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/* + * Generic test for all properties contained in this service + */ + +public class _DocumentSettings extends MultiPropertyTest{ + + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_FunctionDescription.java b/qadevOOo/tests/java/ifc/sheet/_FunctionDescription.java new file mode 100644 index 000000000000..3fe0017ad6db --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_FunctionDescription.java @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import util.ValueChanger; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.lang.XServiceInfo; +import com.sun.star.sheet.FunctionArgument; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +/** +* Testing <code>com.sun.star.sheet.FunctionDescription</code> +* service properties: +* <ul> +* <li><code>Arguments</code></li> +* <li><code>Category</code></li> +* <li><code>Description</code></li> +* <li><code>Id</code></li> +* <li><code>Name</code></li> +* </ul> <p> +* @see com.sun.star.sheet.FunctionDescription +*/ +public class _FunctionDescription extends MultiMethodTest { + + public XPropertySet oObj = null; // oObj filled by MultiMethodTest + + public _FunctionDescription() { + } + + public void _Arguments() { + // check if Service is available + XServiceInfo xInfo = (XServiceInfo) + UnoRuntime.queryInterface(XServiceInfo.class, oObj ); + + if ( ! xInfo.supportsService + ( "com.sun.star.sheet.FunctionDescription" ) ) { + log.println( "Service not available !" ); + tRes.tested( "Supported", false ); + } + + try { + XMultiServiceFactory oDocMSF = (XMultiServiceFactory)tParam.getMSF(); + + XInterface FA = (XInterface)oDocMSF. + createInstance("com.sun.star.sheet.FunctionArgument"); + FunctionArgument arg = (FunctionArgument)AnyConverter.toObject + (FunctionArgument.class, FA); + + arg.Description = "FunctionDescription argument description" ; + arg.Name = "FunctionDescriptiuon argument name" ; + arg.IsOptional = true ; + + Object sValue = oObj.getPropertyValue("Arguments") ; + oObj.setPropertyValue("Arguments", new FunctionArgument[] {arg}) ; + Object nValue = oObj.getPropertyValue("Arguments") ; + + if (sValue.equals(nValue)) { + log.println("Property 'Arguments' didn't change: OK") ; + tRes.tested("Arguments", true) ; + } else { + log.println("Readonly property 'Arguments' changed: Failed") ; + tRes.tested("Arguments", false) ; + } + } catch (Exception e) { + log.println( + "Exception occured while testing property 'Arguments'" ); + e.printStackTrace( log ); + tRes.tested( "Arguments", false ); + } + } + + public void _Category() { + tryChangeProp("Category") ; + } + + public void _Description() { + tryChangeProp( "Category" ); + } + + public void _Id() { + tryChangeProp( "Id" ); + } + + public void _Name() { + tryChangeProp( "Name" ); + } + + public void tryChangeProp( String name ) { + + Object gValue = null; + Object sValue = null; + Object ValueToSet = null; + + + try { + //waitForAllThreads(); + gValue = oObj.getPropertyValue( name ); + + //waitForAllThreads(); + ValueToSet = ValueChanger.changePValue( gValue ); + //waitForAllThreads(); + oObj.setPropertyValue( name, ValueToSet ); + sValue = oObj.getPropertyValue( name ); + + //check get-set methods + if( gValue.equals( sValue ) ) { + log.println( "Value for '"+name+"' hasn't changed. OK." ); + tRes.tested( name, true ); + } + else { + log.println( "Property '" + name + + "' changes it's value : Failed !" ); + tRes.tested( name, false ); + } + } + catch ( Exception e ) { + log.println( + "Exception occured while testing property '" + name + "'" ); + e.printStackTrace( log ); + tRes.tested( name, false ); + } + } // end of changeProp + +} //finish class _TextContent + + diff --git a/qadevOOo/tests/java/ifc/sheet/_GlobalSheetSettings.java b/qadevOOo/tests/java/ifc/sheet/_GlobalSheetSettings.java new file mode 100644 index 000000000000..514645be45b3 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_GlobalSheetSettings.java @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.GlobalSheetSettings</code> +* service properties : +* <ul> +* <li><code> MoveSelection</code></li> +* <li><code> MoveDirection</code></li> +* <li><code> EnterEdit</code></li> +* <li><code> ExtendFormat</code></li> +* <li><code> RangeFinder</code></li> +* <li><code> ExpandReferences</code></li> +* <li><code> MarkHeader</code></li> +* <li><code> UseTabCol</code></li> +* <li><code> Metric</code></li> +* <li><code> Scale</code></li> +* <li><code> DoAutoComplete</code></li> +* <li><code> StatusBarFunction</code></li> +* <li><code> UserLists</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.GlobalSheetSettings +*/ +public class _GlobalSheetSettings extends MultiPropertyTest { +} + + diff --git a/qadevOOo/tests/java/ifc/sheet/_Scenario.java b/qadevOOo/tests/java/ifc/sheet/_Scenario.java new file mode 100644 index 000000000000..b7d206465d2a --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_Scenario.java @@ -0,0 +1,41 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiPropertyTest; + + +public class _Scenario extends MultiPropertyTest { + public void before() { + oObj = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, + tEnv.getObjRelation( + "ScenarioSheet")); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_Shape.java b/qadevOOo/tests/java/ifc/sheet/_Shape.java new file mode 100644 index 000000000000..0d1daca95b54 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_Shape.java @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.table.XCell; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiPropertyTest; + + +public class _Shape extends MultiPropertyTest { + public void _Anchor() { + XSpreadsheetDocument xSheetDoc = (XSpreadsheetDocument) UnoRuntime.queryInterface( + XSpreadsheetDocument.class, + tEnv.getObjRelation( + "DOCUMENT")); + String[] sheetNames = xSheetDoc.getSheets().getElementNames(); + XSpreadsheet xSheet = null; + XCell xCell = null; + + try { + xSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, + xSheetDoc.getSheets().getByName(sheetNames[0])); + xCell = xSheet.getCellByPosition(0, 0); + } catch (com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(); + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(); + } + + testProperty("Anchor", xSheet, xCell); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_SheetCell.java b/qadevOOo/tests/java/ifc/sheet/_SheetCell.java new file mode 100644 index 000000000000..ebb943082792 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SheetCell.java @@ -0,0 +1,38 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + + +public class _SheetCell extends MultiPropertyTest { + + +} + + diff --git a/qadevOOo/tests/java/ifc/sheet/_SheetCellRange.java b/qadevOOo/tests/java/ifc/sheet/_SheetCellRange.java new file mode 100644 index 000000000000..d2db014584a0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SheetCellRange.java @@ -0,0 +1,44 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.SheetCellRange</code> +* service properties : +* <ul> +* <li><code> Position</code></li> +* <li><code> Size</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.SheetCellRange +*/ +public class _SheetCellRange extends MultiPropertyTest { +} // finisch class _SheetCellRange + diff --git a/qadevOOo/tests/java/ifc/sheet/_SheetCellRanges.java b/qadevOOo/tests/java/ifc/sheet/_SheetCellRanges.java new file mode 100644 index 000000000000..7e7ed35e092f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SheetCellRanges.java @@ -0,0 +1,33 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import lib.MultiPropertyTest; + +public class _SheetCellRanges extends MultiPropertyTest { + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_SheetFilterDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_SheetFilterDescriptor.java new file mode 100644 index 000000000000..423042bb8d3a --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SheetFilterDescriptor.java @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.SheetFilterDescriptor</code> +* service properties : +* <ul> +* <li><code> IsCaseSensitive</code></li> +* <li><code> SkipDuplicates</code></li> +* <li><code> UseRegularExpressions</code></li> +* <li><code> SaveOutputPosition</code></li> +* <li><code> Orientation</code></li> +* <li><code> ContainsHeader</code></li> +* <li><code> CopyOutputData</code></li> +* <li><code> OutputPosition</code></li> +* <li><code> MaxFieldCount</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.SheetFilterDescriptor +*/ +public class _SheetFilterDescriptor extends MultiPropertyTest { +} // finish class _SheetFilterDescriptor + + diff --git a/qadevOOo/tests/java/ifc/sheet/_SheetLink.java b/qadevOOo/tests/java/ifc/sheet/_SheetLink.java new file mode 100644 index 000000000000..d4711f878716 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SheetLink.java @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; +import util.ValueChanger; + +/** +* Testing <code>com.sun.star.sheet.SheetLink</code> +* service properties : +* <ul> +* <li><code> Url</code></li> +* <li><code> Filter</code></li> +* <li><code> FilterOptions</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.SheetLink +*/ +public class _SheetLink extends MultiPropertyTest { + + /** + *This class is destined to custom test of property <code>Url</code>. + */ + protected PropertyTester UrlTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + String newValue = (String) ValueChanger.changePValue(oldValue); + if ( !newValue.startsWith("file://") ) { + newValue = "file://" + newValue; + } + + return newValue; + } + }; + + /** + * Test property <code>Url</code> using custom <code>PropertyTest</code>. + */ + public void _Url() { + testProperty("Url", UrlTester); + } + + /** + *This class is destined to custom test of property <code>Filter</code>. + */ + protected PropertyTester FilterTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + return "StarCalc 4.0"; + } + }; + + /** + * Test property <code>Filter</code> using custom <code>PropertyTest</code>. + */ + public void _Filter() { + testProperty("Filter", FilterTester); + } +} + + diff --git a/qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor.java new file mode 100644 index 000000000000..cf63e30250d9 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SheetSortDescriptor.java @@ -0,0 +1,148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import util.ValueChanger; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; +import com.sun.star.table.CellAddress; +import com.sun.star.util.XSortable; + +/** +* Testing <code>com.sun.star.sheet.SheetSortDescriptor</code> +* service properties: <p> +* <ul> +* <li><code>BindFormatsToContent</code></li> +* <li><code>CopyOutputData</code></li> +* <li><code>IsCaseSensitive</code></li> +* <li><code>IsUserListEnabled</code></li> +* <li><code>OutputPosition</code></li> +* <li><code>SortAscending</code></li> +* <li><code>UserListIndex</code></li> +* </ul> <p> +* @see com.sun.star.sheet.SheetSortDescriptor +*/ +public class _SheetSortDescriptor extends MultiMethodTest { + + public XPropertySet oObj = null; + public XSortable xSORT = null; + public PropertyValue[] props = null; + + public void _BindFormatsToContent() { + xSORT = (XSortable) tEnv.getObjRelation("xSORT"); + props = xSORT.createSortDescriptor(); + changeProp("BindFormatsToContent",5); + } + + public void _CopyOutputData() { + changeProp("CopyOutputData",6); + } + + public void _IsCaseSensitive() { + changeProp("IsCaseSensitive",4); + } + + public void _IsUserListEnabled() { + changeProp("IsUserListEnabled",8); + } + + public void _OutputPosition() { + changeProp("OutputPosition",7); + } + + public void _SortAscending() { + //changeProp("SortAscending",3); + log.println("Property 'SortAscending' is not part of the "+ + "property array"); + log.println("Available properties:"); + for (int i=0; i<props.length;i++) { + log.println("\t"+props[i].Name); + } + tRes.tested("SortAscending",false); + } + + public void _UserListIndex() { + changeProp("UserListIndex",9); + } + + public void changeProp(String name, int nr) { + + Object gValue = null; + Object sValue = null; + Object ValueToSet = null; + int gInt = 0; + int sInt = 0; + + if ( ! name.equals(props[nr].Name) ) { + log.println("Property '"+props[nr].Name+"' is tested"); + log.println("But the status is for '"+name+"'"); + } + + + try { + //waitForAllThreads(); + gValue = props[nr].Value; + if ( name.equals("OutputPosition")) { + gInt = ((CellAddress) gValue).Row; + } + //waitForAllThreads(); + ValueToSet = ValueChanger.changePValue(gValue); + //waitForAllThreads(); + props[nr].Value=ValueToSet; + sValue = props[nr].Value; + if ( name.equals("OutputPosition")) { + sInt = ((CellAddress) sValue).Row; + gValue = new Integer(gInt); + sValue = new Integer(sInt); + } + + //check get-set methods + if ( (gValue.equals(sValue)) || (sValue == null) ) { + log.println("Value for '"+name+"' hasn't changed"); + tRes.tested(name, false); + } + else { + log.println("Property '"+name+"' OK"); + tRes.tested(name, true); + } + } catch (Exception e) { + log.println("Exception occured while testing property '" + + name + "'"); + e.printStackTrace(log); + tRes.tested(name, false); + } + + + }// end of changeProp + + +} // finish class _SheetSortDescriptor + + diff --git a/qadevOOo/tests/java/ifc/sheet/_Spreadsheet.java b/qadevOOo/tests/java/ifc/sheet/_Spreadsheet.java new file mode 100644 index 000000000000..f1a78acc64aa --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_Spreadsheet.java @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.Spreadsheet</code> +* service properties : +* <ul> +* <li><code> IsVisible</code></li> +* <li><code> PageStyle</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.Spreadsheet +*/ +public class _Spreadsheet extends MultiPropertyTest { + + /** + *This class is destined to custom test of property <code>PageStyle</code>. + */ + protected PropertyTester styleTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + String str = "Default"; + String str2= "Report"; + return str.equals(oldValue) ? str2 : str; + } + }; + + /** + * Test property <code>PageStyle</code> using custom <code>PropertyTest</code>. + */ + public void _PageStyle() { + testProperty("PageStyle", styleTester); + } +} // finish class _Spreadsheet + + diff --git a/qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument.java b/qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument.java new file mode 100644 index 000000000000..0fe1021d7155 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocument.java @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.SpreadsheetDocument</code> +* service properties : +* <ul> +* <li><code> NamedRanges</code></li> +* <li><code> DatabaseRanges</code></li> +* <li><code> ColumnLabelRanges</code></li> +* <li><code> RowLabelRanges</code></li> +* <li><code> SheetLinks</code></li> +* <li><code> AreaLinks</code></li> +* <li><code> DDELinks</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.SpreadsheetDocument +*/ +public class _SpreadsheetDocument extends MultiPropertyTest { +} // finish class _SpreadsheetDocument + + diff --git a/qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocumentSettings.java b/qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocumentSettings.java new file mode 100644 index 000000000000..6c4abe99f413 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SpreadsheetDocumentSettings.java @@ -0,0 +1,150 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import lib.MultiPropertyTest; + +import com.sun.star.i18n.ForbiddenCharacters; +import com.sun.star.i18n.XForbiddenCharacters; +import com.sun.star.lang.Locale; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.Date; + + +/** +* Testing <code>com.sun.star.sheet.SpreadsheetDocumentSettings</code> +* service properties : +* <ul> +* <li><code> IsIterationEnabled</code></li> +* <li><code> IterationCount</code></li> +* <li><code> IterationEpsilon</code></li> +* <li><code> StandardDecimals</code></li> +* <li><code> NullDate</code></li> +* <li><code> DefaultTabStop</code></li> +* <li><code> IgnoreCase</code></li> +* <li><code> CalcAsShown</code></li> +* <li><code> MatchWholeCell</code></li> +* <li><code> SpellOnline</code></li> +* <li><code> LookUpLabels</code></li> +* <li><code> RegularExpressions</code></li> +* <li><code> ForbiddenCharacters</code></li> +* <li><code> HasDrawPages</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.SpreadsheetDocumentSettings +*/ +public class _SpreadsheetDocumentSettings extends MultiPropertyTest { + /** + *This class is destined to custom test of property <code>NullDate</code>. + */ + protected PropertyTester DateTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + Date date = (Date) oldValue; + Date newDate = new Date((short) (date.Day - 1), date.Month, + date.Year); + + return newDate; + } + }; + + /** + *This class is destined to custom test of property <code>ForbiddenCharacters</code>. + */ + protected PropertyTester ChrTester = new PropertyTester() { + protected Object getNewValue(String propName, Object oldValue) { + return new ForbiddenChrTest(); + } + + protected boolean compare(Object obj1, Object obj2) { + Locale loc = new Locale("ru", "RU", ""); + XForbiddenCharacters fc1 = (XForbiddenCharacters) UnoRuntime.queryInterface( + XForbiddenCharacters.class, + obj1); + XForbiddenCharacters fc2 = (XForbiddenCharacters) UnoRuntime.queryInterface( + XForbiddenCharacters.class, + obj2); + boolean has1 = fc1.hasForbiddenCharacters(loc); + boolean has2 = fc2.hasForbiddenCharacters(loc); + + return has1 == has2; + } + }; + + /** + * Test property <code>NullDate</code> using custom <code>PropertyTest</code>. + */ + public void _NullDate() { + testProperty("NullDate", DateTester); + } + + /** + * Test property <code>ForbiddenCharacters</code> using custom <code>PropertyTest</code>. + */ + public void _ForbiddenCharacters() { + testProperty("ForbiddenCharacters", ChrTester); + } + + /** + * Class implements interface <code>XForbiddenCharacters</code>. + * It's destined to custom test of property <code>ForbiddenCharacters</code>. + * Feature of the class that it supports forbidden characters + * for russian locale. + * @see com.sun.star.i18n.XForbiddenCharacters + */ + protected class ForbiddenChrTest implements XForbiddenCharacters { + protected Locale locale = new Locale("ru", "RU", ""); + protected ForbiddenCharacters chrs = new ForbiddenCharacters("q", "w"); + + public ForbiddenCharacters getForbiddenCharacters(Locale rLocale) + throws com.sun.star.container.NoSuchElementException { + if (rLocale.Country.equals(locale.Country) && + rLocale.Language.equals(locale.Language) && + rLocale.Variant.equals(locale.Variant)) { + return chrs; + } + + throw new com.sun.star.container.NoSuchElementException(); + } + + public void setForbiddenCharacters(Locale rLocale, + ForbiddenCharacters rForbiddenCharacters) { + } + + public void removeForbiddenCharacters(Locale rLocale) { + } + + public boolean hasForbiddenCharacters(Locale rLocale) { + if (rLocale.Country.equals(locale.Country) && + rLocale.Language.equals(locale.Language) && + rLocale.Variant.equals(locale.Variant)) { + return true; + } + + return false; + } + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_SpreadsheetViewSettings.java b/qadevOOo/tests/java/ifc/sheet/_SpreadsheetViewSettings.java new file mode 100644 index 000000000000..c857b2420020 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SpreadsheetViewSettings.java @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.view.DocumentZoomType; + +import lib.MultiPropertyTest; + + +/** +* Testing <code>com.sun.star.sheet.SpreadsheetViewSettings</code> +* service properties : +* <ul> +* <li><code> ShowFormulas</code></li> +* <li><code> ShowZeroValues</code></li> +* <li><code> IsValueHighlightingEnabled</code></li> +* <li><code> ShowNotes</code></li> +* <li><code> HasVerticalScrollBar</code></li> +* <li><code> HasHorizontalScrollBar</code></li> +* <li><code> HasSheetTabs</code></li> +* <li><code> IsOutlineSymbolsSet</code></li> +* <li><code> HasColumnRowHeaders</code></li> +* <li><code> ShowGrid</code></li> +* <li><code> GridColor</code></li> +* <li><code> ShowHelpLines</code></li> +* <li><code> ShowAnchor</code></li> +* <li><code> ShowPageBreaks</code></li> +* <li><code> SolidHandles</code></li> +* <li><code> ShowObjects</code></li> +* <li><code> ShowCharts</code></li> +* <li><code> ShowDrawing</code></li> +* <li><code> HideSpellMarks</code></li> +* <li><code> ZoomType</code></li> +* <li><code> ZoomValue</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.SpreadsheetViewSettings +*/ +public class _SpreadsheetViewSettings extends MultiPropertyTest { + public void _ZoomType() { + testProperty("ZoomType", new Short(DocumentZoomType.PAGE_WIDTH), + new Short(DocumentZoomType.BY_VALUE)); + } + + /** + * Forces environment recreation. + */ + protected void after() { + disposeEnvironment(); + } +} // finish class _SpreadsheetViewSettings diff --git a/qadevOOo/tests/java/ifc/sheet/_SubTotalDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_SubTotalDescriptor.java new file mode 100644 index 000000000000..c478a0f54252 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_SubTotalDescriptor.java @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.SubTotalDescriptor</code> +* service properties : +* <ul> +* <li><code> InsertPageBreaks</code></li> +* <li><code> IsCaseSensitive</code></li> +* <li><code> EnableUserSortList</code></li> +* <li><code> UserSortListIndex</code></li> +* <li><code> BindFormatsToContent</code></li> +* <li><code> SortAscending</code></li> +* <li><code> MaxFieldCount</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.SubTotalDescriptor +*/ +public class _SubTotalDescriptor extends MultiPropertyTest { +} // finish class _SubTotalDescriptor + diff --git a/qadevOOo/tests/java/ifc/sheet/_TableAutoFormat.java b/qadevOOo/tests/java/ifc/sheet/_TableAutoFormat.java new file mode 100644 index 000000000000..bb86aa8bc069 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_TableAutoFormat.java @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.TableAutoFormat</code> +* service properties : +* <ul> +* <li><code> IncludeFont</code></li> +* <li><code> IncludeJustify</code></li> +* <li><code> IncludeBorder</code></li> +* <li><code> IncludeBackground</code></li> +* <li><code> IncludeNumberFormat</code></li> +* <li><code> IncludeWidthAndHeight</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.TableAutoFormat +*/ +public class _TableAutoFormat extends MultiPropertyTest { +} // finish class _TableAutoFormat + + diff --git a/qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField.java b/qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField.java new file mode 100644 index 000000000000..8b6f06acccd9 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_TableAutoFormatField.java @@ -0,0 +1,130 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +import com.sun.star.lang.Locale; + +/** +* Testing <code>com.sun.star.sheet.TableAutoFormatField</code> +* service properties : +* <ul> +* <li><code> CharFontName</code></li> +* <li><code> CharHeight</code></li> +* <li><code> CharWeight</code></li> +* <li><code> CharPosture</code></li> +* <li><code> CharUnderline</code></li> +* <li><code> CharCrossedOut</code></li> +* <li><code> CharContoured</code></li> +* <li><code> CharShadowed</code></li> +* <li><code> CharColor</code></li> +* <li><code> CharLocale</code></li> +* <li><code> CellBackColor</code></li> +* <li><code> IsCellBackgroundTransparent</code></li> +* <li><code> ShadowFormat</code></li> +* <li><code> ParaRightMargin </code></li> +* <li><code> ParaLeftMargin </code></li> +* <li><code> ParaBottomMargin </code></li> +* <li><code> ParaTopMargin </code></li> +* <li><code> RotateReference </code></li> +* <li><code> RotateAngle </code></li> +* <li><code> Orientation </code></li> +* <li><code> IsTextWrapped </code></li> +* <li><code> VertJustify </code></li> +* <li><code> HoriJustify </code></li> +* <li><code> CharPostureComplex </code></li> +* <li><code> CharPostureAsian </code></li> +* <li><code> CharWeightComplex </code></li> +* <li><code> CharWeightAsian </code></li> +* <li><code> CharHeightComplex </code></li> +* <li><code> CharHeightAsian </code></li> +* <li><code> CharFontPitchComplex </code></li> +* <li><code> CharFontPitchAsian </code></li> +* <li><code> CharFontPitch </code></li> +* <li><code> CharFontFamilyComplex </code></li> +* <li><code> CharFontFamilyAsian </code></li> +* <li><code> CharFontFamily </code></li> +* <li><code> CharFontCharSetComplex </code></li> +* <li><code> CharFontCharSetAsian </code></li> +* <li><code> CharFontCharSet </code></li> +* <li><code> CharFontStyleNameComplex </code></li> +* <li><code> CharFontStyleNameAsian </code></li> +* <li><code> CharFontStyleName </code></li> +* <li><code> CharFontNameComplex </code></li> +* <li><code> CharFontNameAsian </code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.TableAutoFormatField +*/ +public class _TableAutoFormatField extends MultiPropertyTest { + + /** + * Only some values can be used (which identify font name). + * In this property value is changed from 'Times New Roman' + * to 'Courier' and vise versa. + */ + public void _CharFontName() { + testProperty("CharFontName", new PropertyTester() { + protected Object getNewValue(String p, Object old) { + return "Courier".equals(old) ? "Times New Roman" : "Courier" ; + } + }) ; + } + + /** + * Locale values are predefined and can't be chaged arbitrary. + * In this property value is changed from ('de', 'DE', '') + * to ('es', 'ES', '') and vise versa. + */ + public void _CharLocale() { + testProperty("CharLocale", new PropertyTester() { + protected Object getNewValue(String p, Object old) { + return old == null || ((Locale)old).Language == "de" ? + new Locale("es", "ES", "") : new Locale("de", "DE", "") ; + } + }) ; + } + + /** + * This property can be void, so if old value is <code> null </code> + * new value must be specified. + */ + public void _ShadowFormat() { + testProperty("ShadowFormat", new PropertyTester() { + protected Object getNewValue(String p, Object old) { + return old == null ? new com.sun.star.table.ShadowFormat() : + super.getNewValue(p, old) ; + } + }) ; + } + +} //finish class _TableAutoFormatField + + + diff --git a/qadevOOo/tests/java/ifc/sheet/_TableValidation.java b/qadevOOo/tests/java/ifc/sheet/_TableValidation.java new file mode 100644 index 000000000000..552664f71c68 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_TableValidation.java @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiPropertyTest; + +/** +* Testing <code>com.sun.star.sheet.TableValidation</code> +* service properties : +* <ul> +* <li><code> Type</code></li> +* <li><code> ShowInputMessage</code></li> +* <li><code> InputTitle</code></li> +* <li><code> InputMessage</code></li> +* <li><code> ShowErrorMessage</code></li> +* <li><code> ErrorTitle</code></li> +* <li><code> ErrorMessage</code></li> +* <li><code> IgnoreBlankCells</code></li> +* <li><code> ErrorAlertStyle</code></li> +* </ul> <p> +* Properties testing is automated by <code>lib.MultiPropertyTest</code>. +* @see com.sun.star.sheet.TableValidation +*/ +public class _TableValidation extends MultiPropertyTest { +} // finish class _TableValidation + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XActivationBroadcaster.java b/qadevOOo/tests/java/ifc/sheet/_XActivationBroadcaster.java new file mode 100644 index 000000000000..c4d03c5abf5f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XActivationBroadcaster.java @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XActivationBroadcaster; +import com.sun.star.sheet.XActivationEventListener; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetView; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + + +public class _XActivationBroadcaster extends MultiMethodTest { + public XActivationBroadcaster oObj; + protected boolean listenerCalled = false; + protected XSpreadsheetView xSpreadsheetView = null; + protected XActivationEventListener listener = null; + protected XSpreadsheet two = null; + + public void _addActivationEventListener() { + + log.println("trying to add an invalid listener"); + oObj.addActivationEventListener(listener); + log.println(".... OK"); + + log.println("adding a valid listener"); + listener = new MyListener(); + oObj.addActivationEventListener(listener); + + XSpreadsheet org = xSpreadsheetView.getActiveSheet(); + xSpreadsheetView.setActiveSheet(two); + + if (!listenerCalled) { + log.println("Listener wasn't called"); + } + + xSpreadsheetView.setActiveSheet(org); + tRes.tested("addActivationEventListener()", listenerCalled); + } + + public void _removeActivationEventListener() { + requiredMethod("addActivationEventListener()"); + listenerCalled = false; + oObj.removeActivationEventListener(listener); + + XSpreadsheet org = xSpreadsheetView.getActiveSheet(); + xSpreadsheetView.setActiveSheet(two); + + if (listenerCalled) { + log.println("Listener was called eventhough it is removed"); + } + + xSpreadsheetView.setActiveSheet(org); + tRes.tested("removeActivationEventListener()", !listenerCalled); + } + + public void before() { + xSpreadsheetView = (XSpreadsheetView) UnoRuntime.queryInterface( + XSpreadsheetView.class, + tEnv.getTestObject()); + + two = (XSpreadsheet) tEnv.getObjRelation("Sheet"); + + if ((xSpreadsheetView == null) || (two == null)) { + throw new StatusException(Status.failed( + "precondition for test is missing")); + } + } + + protected class MyListener implements XActivationEventListener { + public void activeSpreadsheetChanged(com.sun.star.sheet.ActivationEvent activationEvent) { + listenerCalled = true; + } + + public void disposing(com.sun.star.lang.EventObject eventObject) { + } + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XAreaLink.java b/qadevOOo/tests/java/ifc/sheet/_XAreaLink.java new file mode 100644 index 000000000000..74a95f3b2a94 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XAreaLink.java @@ -0,0 +1,159 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XAreaLink; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XAreaLink</code> +* interface methods : +* <ul> +* <li><code> getSourceArea()</code></li> +* <li><code> setSourceArea()</code></li> +* <li><code> getDestArea()</code></li> +* <li><code> setDestArea()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compilant. <p> +* @see com.sun.star.sheet.XAreaLink +*/ +public class _XAreaLink extends MultiMethodTest { + + public XAreaLink oObj = null; + CellRangeAddress oORAdd, oNRAdd, oCRAdd = null; + + /** + * Just calls the method and checks the value returned. + * (More complicated testing done in <code>setDestArea</code>)<p> + * Has <b>OK</b> status if not null value returned. + */ + public void _getDestArea(){ + log.println("testing getDestArea()"); + boolean bResult = false; + oORAdd = oObj.getDestArea(); + if (!(oORAdd == null)){ bResult = true; } + tRes.tested("getDestArea()", bResult) ; + } + + /** + * Just calls the method and checks the value returned. + * (More complicated testing done in <code>setSourceArea</code>)<p> + * Has <b>OK</b> status if not null value returned. + */ + public void _getSourceArea(){ + log.println("testing getSourceArea()"); + boolean bResult = false; + String src = null; + src = oObj.getSourceArea() ; + if (!(src == null)){ bResult = true; } + tRes.tested("getSourceArea()", bResult) ; + } + + /** + * Creates a new desination CellRange address and sets it for + * the link object. <p> + * After setting the DestArea, the link is refreshed and the area is + * adjusted to the size of the source data. + * Therefore EndCol and EndRow will change after setting. <p> + * Has <b>OK</b> status if Sheet, Starting Column and Row + * of the destination range is changed correctly. + */ + public void _setDestArea(){ + log.println("testing setDestArea()"); + boolean bResult = false; + int newStartCol = 3, newStartRow = 4, newEndCol = 5, newEndRow = 8 ; + oORAdd = oObj.getDestArea(); + log.print("Getting: "); + log.println(getCRA(oORAdd)); + oNRAdd = new CellRangeAddress ((short) 2, newStartCol, newStartRow, + newEndCol, newEndRow) ; + oObj.setDestArea(oNRAdd) ; + log.print("Setting: "); + log.println(getCRA(oNRAdd)); + oCRAdd = oObj.getDestArea(); + log.print("Getting: "); + log.println(getCRA(oCRAdd)); + // After setting the DestArea, the link is refreshed and the area is + // adjusted to the size of the source data. + // Therefore EndCol and EndRow will change after setting. + log.println("After setting the DestArea, the link is refreshed "+ + "and the area is"); + log.println("adjusted to the size of the source data."); + log.println("Therefore only 'Sheet', 'StartCol' and 'StartRow' "+ + "are compared."); + if ((oCRAdd.StartColumn == oNRAdd.StartColumn) && + (oCRAdd.Sheet == oNRAdd.Sheet) && + (oCRAdd.StartRow == oNRAdd.StartRow)){ + bResult = true; + oObj.setDestArea(oORAdd); + } + tRes.tested("setDestArea()", bResult) ; + } + + /** + * Sets a new source area for the link and then check + * it using <code>getSourceArea</code> method. <p> + * Has <b>OK</b> status if areas set and get are equal. + */ + public void _setSourceArea(){ + log.println("testing setSourceArea()"); + boolean bResult = false; + String oSrc = oObj.getSourceArea() ; + String nSrc = "a1:b2"; + oObj.setSourceArea(nSrc); + String cSrc = oObj.getSourceArea(); + if( nSrc.equals(cSrc)){ + bResult = true; + oObj.setSourceArea(oSrc); + } + tRes.tested("setSourceArea()", bResult) ; + } + + /** + * Prints cell range structure to LOG + */ + public String getCRA ( CellRangeAddress oCRA ) { + String res = "( Sheet: "; + res += oCRA.Sheet; + res += ";StartColumn: "; + res += oCRA.StartColumn; + res += ";StartRow: "; + res += oCRA.StartRow; + res += ";EndColumn: "; + res += oCRA.EndColumn; + res += ";EndRow: "; + res += oCRA.EndRow; + res += " )"; + return res; + } + +} // EOC _XAreaLink + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XAreaLinks.java b/qadevOOo/tests/java/ifc/sheet/_XAreaLinks.java new file mode 100644 index 000000000000..460bce6c3b84 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XAreaLinks.java @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import com.sun.star.sheet.XAreaLinks; +import com.sun.star.table.CellAddress; +import lib.MultiMethodTest; + +/** +* Testing <code>com.sun.star.sheet.XAreaLinks</code> +* interface methods : +* <ul> +* <li><code> insertAtPosition()</code></li> +* <li><code> removeByIndex()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compilant. <p> +* @see com.sun.star.sheet.XAreaLinks +*/ +public class _XAreaLinks extends MultiMethodTest { + + public XAreaLinks oObj = null; + + /** + * Inserts a new link into collection. Checks number of links + * before and after method call. <p> + * Has <b>OK</b> status if after method call number of + * links increased by 1. + */ + public void _insertAtPosition(){ + boolean bResult = true ; + int cnt = 0; + + cnt = oObj.getCount() ; + CellAddress addr = new CellAddress ((short) 1,2,3) ; + String aSourceArea = util.utils.getFullTestURL("calcshapes.sxc"); + oObj.insertAtPosition (addr, aSourceArea, "a2:b5", "", "") ; + + if (bResult) { + int new_cnt = oObj.getCount() ; + + if (cnt + 1 != new_cnt) { + bResult = false ; + log.println("Number of links before insertAtPosition() call was " + cnt + + ", after call is " + new_cnt) ; + } + } + + tRes.tested("insertAtPosition()", bResult) ; + } + + + /** + * Removes a link from collection. Checks number of links + * before and after method call. <p> + * Has <b>OK</b> status if after method call number of + * links decreases by 1. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> insertAtPosition </code> : to have at least one link. </li> + * </ul> + */ + public void _removeByIndex(){ + requiredMethod("insertAtPosition()") ; + + boolean bResult = true ; + int lcnt = 0; + + lcnt = oObj.getCount() ; + oObj.removeByIndex(0) ; + + int new_lcnt = oObj.getCount() ; + if (lcnt - 1 != new_lcnt) { + bResult = false ; + log.println(" # Number of links before removeByIndex() call was " + + lcnt + ", after call is " + new_lcnt) ; + } + tRes.tested("removeByIndex()", bResult) ; + } + +} //EOC _XAreaLinks + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XArrayFormulaRange.java b/qadevOOo/tests/java/ifc/sheet/_XArrayFormulaRange.java new file mode 100644 index 000000000000..7cb4d8aed12c --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XArrayFormulaRange.java @@ -0,0 +1,182 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XArrayFormulaRange; +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XArrayFormulaRange</code> +* interface methods : +* <ul> +* <li><code> getArrayFormula()</code></li> +* <li><code> setArrayFormula()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'SHEET'</code> (of type <code>XSpreadsheet</code>): +* to check contents of spreadsheet </li> +* <li> <code>'noArray'</code> (of type <code>Object</code>): +* if the relation is null then given component doesn't really support +* this interface </li> +* <ul> <p> +* Test object must implements interface <code>XCellRangeAddressable</code> also. +* @see com.sun.star.sheet.XArrayFormulaRange +* @see com.sun.star.sheet.XSpreadsheet +* @see com.sun.star.sheet.XCellRangeAddressable +*/ +public class _XArrayFormulaRange extends MultiMethodTest { + + public XArrayFormulaRange oObj = null; + String formula = "=1 + 2 * 5"; + + /** + * Test calls the method and then checks content sof spreadsheet using + * object relation <code>'SHEET'</code>. <p> + * Has <b> OK </b> status if values in cells of spreadsheet are equal to 11 + * or ArrayFormula not supported.<p> + */ + public void _setArrayFormula() { + Object noArray = tEnv.getObjRelation("noArray"); + if (noArray != null) { + log.println("Component " + noArray.toString() + + " doesn't really support this Interface"); + log.println("It doesn't make sense to set an ArrayFormula over" + + " the whole sheet"); + tRes.tested("setArrayFormula()", true); + return; + } + + boolean result = true; + double dresult = 11; + + log.println("setArrayFormula() ..."); + + oObj.setArrayFormula(formula); + + log.println("checking that formula was set correctly..."); + XCellRangeAddressable crAddr = + (XCellRangeAddressable) + UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj); + CellRangeAddress addr = crAddr.getRangeAddress() ; + XSpreadsheet oSheet = (XSpreadsheet)tEnv.getObjRelation("SHEET"); + if (oSheet == null) throw new StatusException(Status.failed + ("Relation 'SHEET' not found")); + + XCell oCell = null; + double value; + + for (int i = addr.StartColumn; i <= addr.EndColumn; i++) + for (int j = addr.StartRow; j <= addr.EndRow; j++) { + try { + oCell = oSheet.getCellByPosition(i, j); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + result = false; + break; + } + + value = oCell.getValue(); + result &= (value == dresult); + } + + tRes.tested("setArrayFormula()", result) ; + + } // end setArrayFormula() + + /** + * Test calls the method and compare formula that set by method + * <code>setArrayFormula</code> with returned value ignoring spaces. <p> + * + * Has <b> OK </b> status if values are equal or + * ArrayFormula not supported. <p> + * + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setArrayFormula </code> : to set formula </li> + * </ul> + */ + public void _getArrayFormula() { + + Object noArray = tEnv.getObjRelation("noArray"); + if (noArray != null) { + log.println("Component "+noArray.toString()+" doesn't really support this Interface"); + log.println("It doesn't make sense to set an ArrayFormula over the whole sheet"); + log.println("and therefore 'getArrayFormula()' won't work"); + tRes.tested("getArrayFormula()",true); + return; + } + + requiredMethod("setArrayFormula()"); + boolean result = true; + log.println("Testing getArrayFormula() ..."); + String gFormula = oObj.getArrayFormula() ; + result &= equalIgnoreSpaces("{" + formula + "}", gFormula); + if (!result) + log.println("Method returned : '" + oObj.getArrayFormula() + "'") ; + tRes.tested("getArrayFormula()", result) ; + + } // end getArrayFormula() + + /** + * Method compares two string ignoring spaces. + * @return <code>true</code> if the argument + * is not null and the Strings are equal, + * ignoring spaces; <code>false</code> otherwise. + */ + private boolean equalIgnoreSpaces(String s1, String s2) { + int p1 = 0, p2 = 0 ; + s1 = s1.trim() ; + s2 = s2.trim() ; + while (p1 < s1.length() && p2 < s2.length()) { + while (s1.charAt(p1) == ' ') p1 ++ ; + while (s2.charAt(p2) == ' ') p2 ++ ; + if (s1.charAt(p1) != s2.charAt(p2)) return false ; + p1 ++ ; + p2 ++ ; + } + + return p1 == s1.length() && p2 == s2.length() ; + } + + /** + * Forces environment recreation. + */ + protected void after() { + disposeEnvironment(); + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XCalculatable.java b/qadevOOo/tests/java/ifc/sheet/_XCalculatable.java new file mode 100644 index 000000000000..36bb27423e25 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCalculatable.java @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XCalculatable; +import com.sun.star.table.XCell; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * + */ +public class _XCalculatable extends MultiMethodTest { + public XCalculatable oObj = null; + private boolean bIsAutomaticCalculationEnabled = false; + private XCell[] xCells = null; + + /** + * Get object relation: four cells with values and formulas. + * @see mod._sc.ScModelObj + */ + public void before() { + xCells = (XCell[])tEnv.getObjRelation("XCalculatable.Cells"); + if (xCells == null || xCells.length != 3) + throw new StatusException(Status.failed("Couldn't find correct object relation 'XCalculatable.Cells'")); + + } + + /** + * Restore begin setting + */ + public void after() { + // reset to begin value + oObj.enableAutomaticCalculation(bIsAutomaticCalculationEnabled); + } + + + public void _calculate() { + requiredMethod("isAutomaticCalculationEnabled()"); + boolean result = true; + double ergValue1 = xCells[2].getValue(); + double sourceValue1 = xCells[0].getValue(); + xCells[0].setValue(sourceValue1 +1); + double ergValue2 = xCells[2].getValue(); + result &= ergValue1 == ergValue2; + oObj.calculate(); + ergValue2 = xCells[2].getValue(); + result &= ergValue1 != ergValue2; + tRes.tested("calculate()", result); + } + + public void _calculateAll() { + requiredMethod("isAutomaticCalculationEnabled()"); + boolean result = true; + double ergValue1 = xCells[2].getValue(); + double sourceValue1 = xCells[0].getValue(); + xCells[0].setValue(sourceValue1 +1); + double ergValue2 = xCells[2].getValue(); + result &= ergValue1 == ergValue2; + oObj.calculateAll(); + ergValue2 = xCells[2].getValue(); + result &= ergValue1 != ergValue2; + oObj.calculateAll(); + tRes.tested("calculateAll()", result); + } + + public void _enableAutomaticCalculation() { + bIsAutomaticCalculationEnabled = oObj.isAutomaticCalculationEnabled(); + oObj.enableAutomaticCalculation(!bIsAutomaticCalculationEnabled); + tRes.tested("enableAutomaticCalculation()", true); + } + + public void _isAutomaticCalculationEnabled() { + requiredMethod("enableAutomaticCalculation()"); + boolean result = oObj.isAutomaticCalculationEnabled(); + oObj.enableAutomaticCalculation(false); + tRes.tested("isAutomaticCalculationEnabled()", result != bIsAutomaticCalculationEnabled); + } + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellAddressable.java b/qadevOOo/tests/java/ifc/sheet/_XCellAddressable.java new file mode 100644 index 000000000000..777fe26b1e2e --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellAddressable.java @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XCellAddressable; +import com.sun.star.table.CellAddress; + +/** +* Testing <code>com.sun.star.sheet.XCellAddressable</code> +* interface methods : +* <ul> +* <li><code> getCellAddress()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XCellAddressable +*/ +public class _XCellAddressable extends MultiMethodTest { + + public XCellAddressable oObj = null; + CellAddress sAddr = null; + + /** + * Test calls the method and checks returned value. + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getCellAddress(){ + sAddr = oObj.getCellAddress() ; + tRes.tested("getCellAddress()", sAddr != null) ; + } + + +} //EOC _XCellAddressable + diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellFormatRangesSupplier.java b/qadevOOo/tests/java/ifc/sheet/_XCellFormatRangesSupplier.java new file mode 100644 index 000000000000..4bc93a7f613d --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellFormatRangesSupplier.java @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.sheet.XCellFormatRangesSupplier; + +/** + * Interface test to check the interface XCellFormatRangesSupplier + * + * methods: + * + * getCellFormatRanges() + * + */ + +public class _XCellFormatRangesSupplier extends MultiMethodTest { + + public XCellFormatRangesSupplier oObj = null; + + /** + * call the method getCellFormatRanges and returns OK result if + * the gained XIndexAccess isn't null and the method checkIndexAccess + * returns true. + */ + + public void _getCellFormatRanges() { + boolean res = true; + XIndexAccess xIA = oObj.getCellFormatRanges(); + if (xIA != null) { + res = checkIndexAccess(xIA); + } else { + log.println("The gained IndexAccess is null"); + res = false; + } + tRes.tested("getCellFormatRanges()",res); + } + + /** + * calls the method getCount at the IndexAccess, returns true is it is >0 + * and getByIndex() doesn't throw an exception for Indexes between 0 and count + */ + + protected boolean checkIndexAccess(XIndexAccess xIA) { + boolean res = true; + int count = xIA.getCount(); + log.println("Found "+count+" Elements"); + res &= count>0; + for (int k=0; k<count; k++) { + try { + Object element = xIA.getByIndex(k); + log.println("Element "+k+" = "+element); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected Exception while getting by Index ("+k+")"+e.getMessage()); + res &=false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception while getting by Index ("+k+")"+e.getMessage()); + res &=false; + } + } + return res; + } + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellRangeAddressable.java b/qadevOOo/tests/java/ifc/sheet/_XCellRangeAddressable.java new file mode 100644 index 000000000000..300dcf30dca8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellRangeAddressable.java @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XCellRangeAddressable</code> +* interface methods : +* <ul> +* <li><code> getRangeAddress()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XCellRangeAddressable +*/ +public class _XCellRangeAddressable extends MultiMethodTest { + + public XCellRangeAddressable oObj = null; + + /** + * Test calls the method and checks returned value. + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getRangeAddress() { + CellRangeAddress oAddr = oObj.getRangeAddress(); + tRes.tested("getRangeAddress()", oAddr != null); + } + +} // EOC _XCellRangeAddressable + diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellRangeData.java b/qadevOOo/tests/java/ifc/sheet/_XCellRangeData.java new file mode 100644 index 000000000000..8127164568b1 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellRangeData.java @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import util.ValueComparer; + +import com.sun.star.sheet.XCellRangeData; + +public class _XCellRangeData extends MultiMethodTest { + + public XCellRangeData oObj = null; + private Object[][] maCRData = null; + + /** + * Test calls the method + * state is OK if the resulting Object array + * isn't empty + */ + public void _getDataArray() { + maCRData = oObj.getDataArray(); + boolean bResult = (maCRData.length > 0); + tRes.tested("getDataArray()", bResult); + } + + /** + * Test creates an Array and calls the method + * with this Array as argument + * Then the method getDataArray is called + * and the resulting Array is compared with the + * one formerly set. + */ + public void _setDataArray() { + Object[][] newData = (Object[][]) tEnv.getObjRelation("NewData"); + if (newData == null) { + newData = new Object[maCRData.length][maCRData[0].length]; + for (int i=0; i<newData.length; i++) { + for (int j=0; j<newData[i].length; j++) { + newData[i][j] = new Double(10*i +j); + } + } + } + oObj.setDataArray(newData); + Object[][] oCRData = oObj.getDataArray(); + boolean res = ValueComparer.equalValue(oCRData[0][0],newData[0][0]); + res &= ValueComparer.equalValue(oCRData[0][1],newData[0][1]); + res &= ValueComparer.equalValue(oCRData[1][0],newData[1][0]); + res &= ValueComparer.equalValue(oCRData[1][1],newData[1][1]); + // delete values + Object[][] emptyData = new Object[newData.length][newData[0].length]; + for (int i=0; i<emptyData.length; i++) { + for (int j=0; j<emptyData[i].length; j++) { + emptyData[i][j] = new String(); + } + } + oObj.setDataArray(emptyData); + tRes.tested("setDataArray()", res); + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellRangeFormula.java b/qadevOOo/tests/java/ifc/sheet/_XCellRangeFormula.java new file mode 100644 index 000000000000..e408a3a2b1b0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellRangeFormula.java @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import com.sun.star.sheet.XCellRangeFormula; + +public class _XCellRangeFormula extends lib.MultiMethodTest { + + public XCellRangeFormula oObj = null; + + public String[][] orgValue = null; + + public void _getFormulaArray() { + Object noArray = tEnv.getObjRelation("noArray"); + if (noArray != null) { + log.println("Component " + noArray.toString() + + " doesn't really support this Interface"); + log.println("It doesn't make sense to get an FormulaArray from" + + " the whole sheet"); + tRes.tested("getFormulaArray()", true); + return; + } + orgValue = oObj.getFormulaArray(); + String[][] newValue = oObj.getFormulaArray(); + newValue[0][0] = "inserted"; + oObj.setFormulaArray(newValue); + boolean res = oObj.getFormulaArray()[0][0].equals(newValue[0][0]); + tRes.tested("getFormulaArray()",res); + } + + public void _setFormulaArray() { + requiredMethod("getFormulaArray()"); + Object noArray = tEnv.getObjRelation("noArray"); + if (noArray != null) { + log.println("Component " + noArray.toString() + + " doesn't really support this Interface"); + log.println("It doesn't make sense to set an FormulaArray over" + + " the whole sheet"); + tRes.tested("setFormulaArray()", true); + return; + } + oObj.setFormulaArray(orgValue); + boolean res = oObj.getFormulaArray()[0][0].equals(orgValue[0][0]); + tRes.tested("setFormulaArray()",res); + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement.java b/qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement.java new file mode 100644 index 000000000000..13468122b25e --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellRangeMovement.java @@ -0,0 +1,246 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.CellDeleteMode; +import com.sun.star.sheet.CellInsertMode; +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XCellRangeMovement; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XColumnRowRange; +import com.sun.star.table.XTableRows; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XCellRangeMovement</code> +* interface methods : +* <ul> +* <li><code> insertCells()</code></li> +* <li><code> removeRange()</code></li> +* <li><code> moveRange()</code></li> +* <li><code> copyRange()</code></li> +* </ul> <p> +* Test object must implements interfaces <code>XCellRangeAddressable</code> +* and <code>XSpreadsheet</code> also. <p> +* @see com.sun.star.sheet.XCellRangeMovement +* @see com.sun.star.sheet.XSpreadsheet +* @see com.sun.star.sheet.XCellRangeAddressable +*/ +public class _XCellRangeMovement extends MultiMethodTest { + + public XCellRangeMovement oObj = null; + + /** + * Test sets specific values to cells in the range, copies this cell range + * to another position in document and checks cell's values in new position.<p> + * Has <b> OK </b> status if cell's values in source range are equal to + * cell's values in destination range and no exceptions were thrown. <p> + */ + public void _copyRange(){ + log.println("Prepare cells before test methods."); + XSpreadsheet oSheet = (XSpreadsheet) + UnoRuntime.queryInterface(XSpreadsheet.class, oObj); + try { + oSheet.getCellByPosition(1,1).setValue(100); + oSheet.getCellByPosition(1,2).setValue(200); + oSheet.getCellByPosition(2,1).setValue(300); + oSheet.getCellByPosition(2,2).setValue(400); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + tRes.tested("copyRange()", false); + } + + XCellRangeAddressable oAddr = + (XCellRangeAddressable) + UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj); + short iSheet = oAddr.getRangeAddress().Sheet; + CellAddress sDest; + CellRangeAddress sSrc; + + sSrc = new CellRangeAddress(iSheet, 1, 1, 2, 2); + sDest = new CellAddress(iSheet, 1, 10); + boolean result = true; + boolean loc_result = true; + + oObj.copyRange(sDest, sSrc); + try { + loc_result = (oSheet.getCellByPosition(1, 10).getValue() == 100); + loc_result &= (oSheet.getCellByPosition(1, 11).getValue() == 200); + loc_result &= (oSheet.getCellByPosition(2, 10).getValue() == 300); + loc_result &= (oSheet.getCellByPosition(2, 11).getValue() == 400); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + tRes.tested("copyRange()", false); + } + + result &= loc_result; + tRes.tested("copyRange()", result); + } + + /** + * Test sets specific values to cells in the two contiguous rows, inserts + * new empty row between them and checks value in + * one cell of the inserted row. <p> + * Has <b> OK </b> status if value of cell in the inserted row is zero + * and no exceptions were thrown. <p> + */ + public void _insertCells(){ + boolean result = false; + + XSpreadsheet oSheet = (XSpreadsheet) + UnoRuntime.queryInterface(XSpreadsheet.class, oObj); + XCellRangeAddressable oAddr = (XCellRangeAddressable) + UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj); + short iSheet = oAddr.getRangeAddress().Sheet; + try { + oSheet.getCellByPosition(0,20).setValue(100); + oSheet.getCellByPosition(1,20).setValue(100); + oSheet.getCellByPosition(2,20).setValue(100); + oSheet.getCellByPosition(3,20).setValue(100); + oSheet.getCellByPosition(0,21).setValue(200); + oSheet.getCellByPosition(1,21).setValue(200); + oSheet.getCellByPosition(2,21).setValue(200); + oSheet.getCellByPosition(3,21).setValue(200); + + // catch some sleight of hand threads + if (oSheet.getCellByPosition(1,21).getValue() == 200){ + //log.println("Rows closed."); + } + else{ + log.println("Cells were already inserted. "+ + "Delete old cells now"); + XColumnRowRange oColumnRowRange = (XColumnRowRange) + UnoRuntime.queryInterface(XColumnRowRange.class, oSheet); + + XTableRows oRows = (XTableRows) oColumnRowRange.getRows(); + oRows.removeByIndex(21,1); + } + CellRangeAddress sSrc = new CellRangeAddress(iSheet, 0, 21, 5, 21); + oObj.insertCells (sSrc, CellInsertMode.DOWN) ; + + // check the result + double res = oSheet.getCellByPosition(1, 21).getValue(); + if (res == 0.0) { + result = true; + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + result = false; + } + + tRes.tested("insertCells()", result); + } + + /** + * Test sets specific values to cells in the range, moves this cell range + * to another position in document and checks cell's values in new position. + * <p>Has <b>OK</b> status if sum of values in source range is equal to sum + * of values in destination range and no exceptions were thrown. <p> + */ + public void _moveRange(){ + boolean result = false; + + XSpreadsheet oSheet = (XSpreadsheet) + UnoRuntime.queryInterface(XSpreadsheet.class, oObj); + + XCellRangeAddressable oAddr = (XCellRangeAddressable) + UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj); + + short iSheet = oAddr.getRangeAddress().Sheet; + //prepare source range + try { + oSheet.getCellByPosition(4,0).setValue(111); + oSheet.getCellByPosition(4,1).setValue(222); + + CellRangeAddress sSrc = new CellRangeAddress(iSheet, 4, 0, 4, 1); + CellAddress sDest = new CellAddress(iSheet, 4, 4); + oObj.moveRange(sDest, sSrc); + + double cntA = 0; + double cntB = 0; + cntA = oSheet.getCellByPosition(4, 4).getValue(); + cntB = oSheet.getCellByPosition(4, 5).getValue(); + if (cntA + cntB == 333.0){ result = true; } + //clean up + oSheet.getCellByPosition(4,4).setValue(0); + oSheet.getCellByPosition(4,5).setValue(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + result = false; + } + + tRes.tested("moveRange()", result); + } + + + /** + * Test sets specific values to cells in the range, deletes this cell range + * from document and checks values of cells in position + * of the deleted range. + * <p>Has <b>OK</b> status if sum of cell values in position of the deleted + * range is equal to zero and no exceptions were thrown. <p> + */ + public void _removeRange(){ + boolean result = false; + + XSpreadsheet oSheet = (XSpreadsheet) + UnoRuntime.queryInterface(XSpreadsheet.class, oObj); + XCellRangeAddressable oAddr = (XCellRangeAddressable) + UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj); + short iSheet = oAddr.getRangeAddress().Sheet; + try { + //prepare source range + oSheet.getCellByPosition(5, 0).setValue(333); + oSheet.getCellByPosition(5, 1).setValue(444); + + CellRangeAddress sSrc = new CellRangeAddress(iSheet, 5, 0, 5, 1); + oObj.removeRange(sSrc, CellDeleteMode.UP); + + double cntA = 0; + double cntB = 0; + cntA = oSheet.getCellByPosition(5, 0).getValue(); + cntB = oSheet.getCellByPosition(5, 1).getValue(); + if (cntA + cntB == 0.0){ result = true; } + + //clean up + oSheet.getCellByPosition(5, 0).setValue(0); + oSheet.getCellByPosition(5, 1).setValue(0); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + result = false; + } + + tRes.tested("removeRange()", result); + } + +} // EOC _XCellRangeMovement + diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellRangeReferrer.java b/qadevOOo/tests/java/ifc/sheet/_XCellRangeReferrer.java new file mode 100644 index 000000000000..320c7940d03e --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellRangeReferrer.java @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XCellRangeReferrer; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCellRange; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XCellRangeReferrer</code> +* interface methods : +* <ul> +* <li><code> getReferredCells() </code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'DATAAREA'</code> (of type <code>CellRangeAddress</code>): +* to have cell range address </li> +* <ul> <p> +* @see com.sun.star.sheet.XCellRangeReferrer +* @see com.sun.star.table.CellRangeAddress +*/ +public class _XCellRangeReferrer extends MultiMethodTest { + + public XCellRangeReferrer oObj = null; + + /** + * Test calls the method and compares cell range address of returned cell range + * with cell range address gotten by relation <code>'DATAAREA'</code>. <p> + * Has <b> OK </b> status if all fields of cell range addresses are equal. <p> + */ + public void _getReferredCells() { + boolean bResult = true; + + CellRangeAddress oldCRA = (CellRangeAddress) + tEnv.getObjRelation("DATAAREA"); + if (oldCRA == null) throw new StatusException(Status.failed + ("Relation 'DATAAREA' not found")); + + XCellRange cr = oObj.getReferredCells(); + log.println(cr.toString()); + + if (cr == null) { + log.println("getReferredCells returned NULL."); + tRes.tested("getReferredCells()", false); + return; + } + + XCellRangeAddressable xCRA = (XCellRangeAddressable) + UnoRuntime.queryInterface(XCellRangeAddressable.class, cr); + + CellRangeAddress objCRA = xCRA.getRangeAddress(); + + log.println("The named range was 'ANamedRange A1:B2'"); + log.println("Expected CellRangeAddress: (" + oldCRA.Sheet + + "," + oldCRA.StartColumn + "," + oldCRA.StartRow + "," + + oldCRA.EndColumn + "," + objCRA.EndRow + ")"); + log.println("CellRangeAddress gotten: (" + objCRA.Sheet + "," + + objCRA.StartColumn + "," + objCRA.StartRow + "," + + objCRA.EndColumn + "," + objCRA.EndRow + ")"); + + bResult &= objCRA.EndColumn == oldCRA.EndColumn; + bResult &= objCRA.EndRow == oldCRA.EndRow; + bResult &= objCRA.Sheet == oldCRA.Sheet; + bResult &= objCRA.StartColumn == oldCRA.StartColumn; + bResult &= objCRA.StartRow == oldCRA.StartRow; + + tRes.tested("getReferredCells()", bResult); + } +} + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery.java b/qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery.java new file mode 100644 index 000000000000..eac4a5a31d10 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellRangesQuery.java @@ -0,0 +1,307 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.sheet.CellFlags; +import com.sun.star.sheet.FormulaResult; +import com.sun.star.sheet.XCellRangesQuery; +import com.sun.star.sheet.XSheetCellRanges; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XColumnRowRange; +import com.sun.star.table.XTableColumns; +import com.sun.star.table.XTableRows; +import com.sun.star.uno.UnoRuntime; + +/** + * Test the XCellRangesQuery interface. + * Needed object relations: + * <ul> + * <li>"SHEET": an XSpreadSheet object + * </li> + * <li>"XCellRangesQuery.EXPECTEDRESULTS": the expected results for the test + * methods as a String array.<br> + * @see mod._sc.ScCellCurserObj or + * @see mod._sc.ScCellObj for an example how this should look like. + * </li> + * </ul> + */ +public class _XCellRangesQuery extends MultiMethodTest { + public XCellRangesQuery oObj; + protected XSpreadsheet oSheet; + protected XTableRows oRows; + protected XTableColumns oColumns; + protected String[] mExpectedResults = null; + protected boolean bMakeEntriesAndDispose = false; + String getting = ""; + String expected = ""; + // provide the object with constants to fill the expected results array + public static final int QUERYCOLUMNDIFFERENCES = 0; + public static final int QUERYCONTENTCELLS = 1; + public static final int QUERYEMPTYCELLS = 2; + public static final int QUERYFORMULACELLS = 3; + public static final int QUERYINTERSECTION = 4; + public static final int QUERYROWDIFFERENCES = 5; + public static final int QUERYVISIBLECELLS = 6; + + protected void before() { + oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET"); + + if (oSheet == null) { + log.println("Object relation oSheet is missing"); + log.println("Trying to query the needed Interface"); + oSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, tEnv.getTestObject()); + + if (oSheet == null) { + throw new StatusException(Status.failed( + "Object relation oSheet is missing")); + } + } + + // expected results + mExpectedResults = (String[])tEnv.getObjRelation( + "XCellRangesQuery.EXPECTEDRESULTS"); + + XColumnRowRange oColumnRowRange = (XColumnRowRange) UnoRuntime.queryInterface( + XColumnRowRange.class, + oSheet); + oRows = (XTableRows)oColumnRowRange.getRows(); + oColumns = (XTableColumns) oColumnRowRange.getColumns(); + + // set this in object if the interface has to make its own settings + // and the environment has to be disposed: this is necessary for objects + // that do not make entries on the sheet themselves + Object o = tEnv.getObjRelation("XCellRangesQuery.CREATEENTRIES"); + if (o != null && o instanceof Boolean) { + bMakeEntriesAndDispose = ((Boolean)o).booleanValue(); + } + if(bMakeEntriesAndDispose) { + oRows.removeByIndex(4, oRows.getCount() - 4); + oColumns.removeByIndex(4, oColumns.getCount() - 4); + + try { + oSheet.getCellByPosition(1, 1).setValue(5); + oSheet.getCellByPosition(1, 2).setValue(15); + oSheet.getCellByPosition(2, 1).setFormula("=B2+B3"); + oSheet.getCellByPosition(1, 3).setFormula("=B2+B4"); + oSheet.getCellByPosition(3, 2).setFormula(""); + oSheet.getCellByPosition(3, 3).setFormula(""); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't fill cells " + e.getLocalizedMessage()); + } + } + + } + + /** + * Tested method returns each cell of each column that is different to the + * cell in a given row + */ + public void _queryColumnDifferences() { + boolean res = true; + XSheetCellRanges ranges = oObj.queryColumnDifferences( + new CellAddress((short) 0, 1, 1)); + getting = ranges.getRangeAddressesAsString(); + expected = mExpectedResults[QUERYCOLUMNDIFFERENCES]; + + if (!getting.startsWith(expected)) { + log.println("Getting: " + getting); + log.println("Should have started with: " + expected); + res = false; + } + + tRes.tested("queryColumnDifferences()", res); + } + + /** + * Tested method returns all cells of a given type, defind in + * CellFlags + * @see com.sun.star.sheet.CellFlags + */ + public void _queryContentCells() { + boolean res = true; + XSheetCellRanges ranges = oObj.queryContentCells( + (short) CellFlags.VALUE); + getting = ranges.getRangeAddressesAsString(); + expected = mExpectedResults[QUERYCONTENTCELLS]; + + if (!getting.startsWith(expected)) { + log.println("Getting: " + getting); + log.println("Should have started with: " + expected); + res = false; + } + + tRes.tested("queryContentCells()", res); + } + + /** + * Tested method returns all empty cells of the range + */ + public void _queryEmptyCells() { + boolean res = true; + XSheetCellRanges ranges = oObj.queryEmptyCells(); + getting = ranges.getRangeAddressesAsString(); + expected = mExpectedResults[QUERYEMPTYCELLS]; + + int startIndex = 0; + int endIndex = -5; + String checkString = null; + + while (endIndex != -1) { + startIndex = endIndex + 5; + endIndex = expected.indexOf(" ... ", startIndex); + if (endIndex == -1) { + checkString = expected.substring(startIndex); + } + else { + checkString = expected.substring(startIndex, endIndex); + } + res &= (getting.indexOf(checkString) > -1); + } + + if (!res) { + log.println("Getting: " + getting); + log.println("Should have contained: " + expected); + } + + tRes.tested("queryEmptyCells()", res); + } + + /** + * Tested method returns all cells of a given type, defind in + * FormulaResult + * @see com.sun.star.sheet.FormulaResult + */ + public void _queryFormulaCells() { + boolean res = true; + XSheetCellRanges ranges = oObj.queryFormulaCells( + (short) FormulaResult.VALUE); + getting = ranges.getRangeAddressesAsString(); + expected = mExpectedResults[QUERYFORMULACELLS]; + + if (!getting.equals(expected)) { + log.println("Getting: " + getting); + log.println("Expected: " + expected); + res = false; + } + + tRes.tested("queryFormulaCells()", res); + } + + public void _queryIntersection() { + boolean res = true; + XSheetCellRanges ranges = oObj.queryIntersection( + new CellRangeAddress((short) 0, 3, 3, 7, 7)); + getting = ranges.getRangeAddressesAsString(); + expected = mExpectedResults[QUERYINTERSECTION]; + + if (!getting.startsWith(expected)) { + log.println("Getting: " + getting); + log.println("Should have started with: " + expected); + res = false; + } + + tRes.tested("queryIntersection()", res); + } + + /** + * Tested method returns each cell of each row that is different to the + * cell in a given column + */ + public void _queryRowDifferences() { + boolean res = true; + XSheetCellRanges ranges = oObj.queryRowDifferences( + new CellAddress((short) 0, 1, 1)); + getting = ranges.getRangeAddressesAsString(); + expected = mExpectedResults[QUERYROWDIFFERENCES]; + + if (!getting.startsWith(expected)) { + log.println("Getting: " + getting); + log.println("Should have started with: " + expected); + res = false; + } + + tRes.tested("queryRowDifferences()", res); + } + + public void _queryVisibleCells() { + setRowVisible(false); + + boolean res = true; + XSheetCellRanges ranges = oObj.queryVisibleCells(); + getting = ranges.getRangeAddressesAsString(); + expected = mExpectedResults[QUERYVISIBLECELLS]; + + if (!getting.startsWith(expected)) { + log.println("Getting: " + getting); + log.println("Should have started with: " + expected); + res = false; + } + + setRowVisible(true); + tRes.tested("queryVisibleCells()", res); + } + + protected void setRowVisible(boolean vis) { + try { + XPropertySet rowProp = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, + oRows.getByIndex(0)); + rowProp.setPropertyValue("IsVisible", new Boolean(vis)); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("couldn't get Row " + e.getLocalizedMessage()); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("problems setting Property 'isVisible' " + + e.getLocalizedMessage()); + } catch (com.sun.star.beans.UnknownPropertyException e) { + log.println("problems setting Property 'isVisible' " + + e.getLocalizedMessage()); + } catch (com.sun.star.beans.PropertyVetoException e) { + log.println("problems setting Property 'isVisible' " + + e.getLocalizedMessage()); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("problems setting Property 'isVisible' " + + e.getLocalizedMessage()); + } + } + + /** + * Forces environment recreation. + */ + protected void after() { + if(bMakeEntriesAndDispose) { + disposeEnvironment(); + } + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XCellSeries.java b/qadevOOo/tests/java/ifc/sheet/_XCellSeries.java new file mode 100644 index 000000000000..7ed3b4e61761 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XCellSeries.java @@ -0,0 +1,244 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import helper.LoggingThread; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XCellSeries; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.uno.UnoRuntime; +import share.LogWriter; + + +public class _XCellSeries extends MultiMethodTest { + public XCellSeries oObj = null; + protected XSpreadsheet oSheet = null; + protected boolean isSpreadSheet = false; + protected boolean fillAuto = true; + protected boolean forceFillAuto = false; + + + protected void before() { + oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET"); + + if (oSheet == null) { + log.println("Object relation oSheet is missing"); + log.println("Trying to query the needed Interface"); + oSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, tEnv.getTestObject()); + + if (oSheet == null) { + throw new StatusException(Status.failed( + "Object relation oSheet is missing")); + } else { + isSpreadSheet = true; + } + } + + Boolean myFillAuto = (Boolean) tEnv.getObjRelation("XCELLSERIES_FILLAUTO"); + + if (myFillAuto != null) fillAuto = myFillAuto.booleanValue(); + + if (tParam.containsKey("force_fillauto")){ + fillAuto = tParam.getBool("force_fillauto"); + forceFillAuto = tParam.getBool("force_fillauto"); + } + } + + public void _fillAuto() { + + if ((isSpreadSheet && !forceFillAuto) || !fillAuto) { + log.println("This method consumes to much time for a complete SpreadSheet"); + log.println("Please use parameter '-force_fillauto true' to force this test"); + tRes.tested("fillAuto()",Status.skipped(true)); + return; + } + + boolean res = true; + + try { + oSheet.getCellByPosition(0, 0).setValue(2); + + log.println( + "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1)"); + oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_RIGHT, 1); + oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)"); + + double getting = oSheet.getCellByPosition(0, 4).getValue(); + boolean locres = (getting == 14); + + if (!locres) { + log.println("Operation failed"); + } else { + log.println("Successful"); + } + + res &= locres; + + log.println( + "calling oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1)"); + oObj.fillAuto(com.sun.star.sheet.FillDirection.TO_BOTTOM, 1); + oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)"); + getting = oSheet.getCellByPosition(4, 0).getValue(); + locres = (getting == 14); + + if (!locres) { + log.println("Operation failed"); + } else { + log.println("Successful"); + } + + res &= locres; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't set initial version to cell"); + res = false; + } + + tRes.tested("fillAuto()", res); + } + + public void _fillSeries() { + + if (isSpreadSheet) { + log.println("This method consumes to much time for a complete SpreadSheet"); + tRes.tested("fillSeries()",Status.skipped(true)); + return; + } + + boolean res = true; + + try { + oSheet.getCellByPosition(0, 0).setValue(2); + + LoggingThread logger = new LoggingThread((LogWriter)log, tParam); + logger.start(); + + log.println( + "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.LINEAR, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8)"); + oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, + com.sun.star.sheet.FillMode.LINEAR, + com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8); + oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)"); + + double getting = oSheet.getCellByPosition(0, 4).getValue(); + boolean locres = (getting == 20); + + logger.finish(); + + if (!locres) { + log.println("Operation failed"); + } else { + log.println("Successful"); + } + + res &= locres; + + logger = new LoggingThread((LogWriter)log, tParam); + logger.start(); + + log.println( + "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, com.sun.star.sheet.FillMode.GROWTH, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 16)"); + oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_RIGHT, + com.sun.star.sheet.FillMode.GROWTH, + com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, + 16); + oSheet.getCellByPosition(0, 4).setFormula("=sum(A1:D1)"); + getting = oSheet.getCellByPosition(0, 4).getValue(); + locres = (getting == 30); + + logger.finish(); + + if (!locres) { + log.println("Operation failed"); + } else { + log.println("Successful"); + } + + res &= locres; + + logger = new LoggingThread((LogWriter)log, tParam); + logger.start(); + + log.println( + "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, com.sun.star.sheet.FillMode.LINEAR, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8)"); + oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, + com.sun.star.sheet.FillMode.LINEAR, + com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 8); + oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)"); + getting = oSheet.getCellByPosition(4, 0).getValue(); + locres = (getting == 20); + + logger.finish(); + + if (!locres) { + log.println("Operation failed"); + } else { + log.println("Successful"); + } + + res &= locres; + + logger = new LoggingThread((LogWriter)log, tParam); + logger.start(); + + log.println( + "calling oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, com.sun.star.sheet.FillMode.GROWTH, com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, 16)"); + oObj.fillSeries(com.sun.star.sheet.FillDirection.TO_BOTTOM, + com.sun.star.sheet.FillMode.GROWTH, + com.sun.star.sheet.FillDateMode.FILL_DATE_DAY, 2, + 16); + oSheet.getCellByPosition(4, 0).setFormula("=sum(A1:A4)"); + getting = oSheet.getCellByPosition(4, 0).getValue(); + locres = (getting == 30); + + logger.finish(); + + if (!locres) { + log.println("Operation failed"); + } else { + log.println("Successful"); + } + + res &= locres; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't set initial version to cell"); + res = false; + } + + tRes.tested("fillSeries()", res); + } + + /** + * Forces environment recreation. + */ + public void after() { + disposeEnvironment(); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XConsolidatable.java b/qadevOOo/tests/java/ifc/sheet/_XConsolidatable.java new file mode 100644 index 000000000000..08fc51dc3672 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XConsolidatable.java @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XConsolidatable; +import com.sun.star.sheet.XConsolidationDescriptor; +import lib.MultiMethodTest; + +/** + * Test the XConsolidatable interface + */ +public class _XConsolidatable extends MultiMethodTest { + public XConsolidatable oObj = null; + XConsolidationDescriptor xDescriptor = null; + + /** + * Check consolidation + */ + public void _consolidate() { + requiredMethod("createConsolidationDescriptor()"); + oObj.consolidate(xDescriptor); + tRes.tested("consolidate()", true); + } + + /** + * Check the creation of a ConsolidationDescriptor + */ + public void _createConsolidationDescriptor() { + xDescriptor = oObj.createConsolidationDescriptor(true); + tRes.tested("createConsolidationDescriptor()", xDescriptor != null); + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XConsolidationDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_XConsolidationDescriptor.java new file mode 100644 index 000000000000..f7638dacf5b4 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XConsolidationDescriptor.java @@ -0,0 +1,264 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import util.ValueComparer; + +import com.sun.star.sheet.GeneralFunction; +import com.sun.star.sheet.XConsolidationDescriptor; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XConsolidationDescriptor</code> +* interface methods : +* <ul> +* <li><code> getFunction()</code></li> +* <li><code> setFunction()</code></li> +* <li><code> getSources()</code></li> +* <li><code> setSources()</code></li> +* <li><code> getStartOutputPosition()</code></li> +* <li><code> setStartOutputPosition()</code></li> +* <li><code> getUseColumnHeaders()</code></li> +* <li><code> setUseColumnHeaders()</code></li> +* <li><code> getUseRowHeaders()</code></li> +* <li><code> setUseRowHeaders()</code></li> +* <li><code> getInsertLinks()</code></li> +* <li><code> setInsertLinks()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XConsolidationDescriptor +*/ +public class _XConsolidationDescriptor extends MultiMethodTest { + + public XConsolidationDescriptor oObj = null; + public GeneralFunction aFunction = null; + public boolean insertLinks = false; + public boolean useColumnHeaders = false; + public boolean useRowHeaders = false; + public CellRangeAddress[] CRaddr = null; + public CellAddress addr = null; + + /** + * Test calls the method, stores and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getFunction() { + aFunction = oObj.getFunction(); + tRes.tested("getFunction()", aFunction != null ); + } + + /** + * Test calls the method and stores returned value. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _getInsertLinks() { + insertLinks = oObj.getInsertLinks(); + tRes.tested("getInsertLinks()", true); + } + + /** + * Test calls the method and stores returned value. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _getSources() { + CRaddr = oObj.getSources(); + int wiev = CRaddr.length; + tRes.tested("getSources()", true); + } + + /** + * Test calls the method and stores returned value. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _getStartOutputPosition() { + addr = oObj.getStartOutputPosition(); + tRes.tested("getStartOutputPosition()", true); + } + + /** + * Test calls the method and stores returned value. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _getUseColumnHeaders() { + useColumnHeaders = oObj.getUseColumnHeaders(); + tRes.tested("getUseColumnHeaders()", true); + } + + /** + * Test calls the method and stores returned value. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _getUseRowHeaders() { + useRowHeaders = oObj.getUseRowHeaders(); + tRes.tested("getUseRowHeaders()", true); + } + + /** + * Test sets the new current function, gets current function + * and compare function gotten by method <code>getFunction()</code> with + * function that was set. <p> + * Has <b> OK </b> status if the functions aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getFunction() </code> : to have current value of + * the function by which the ranges are consolidated </li> + * </ul> + */ + public void _setFunction() { + requiredMethod("getFunction()"); + GeneralFunction aFunction2 = null; + if (aFunction.equals(GeneralFunction.SUM)) { + aFunction2 = GeneralFunction.COUNT; + } + else { + aFunction2 = GeneralFunction.SUM; + } + oObj.setFunction(aFunction2); + aFunction2 = oObj.getFunction(); + tRes.tested("setFunction()", !aFunction.equals(aFunction2)); + } + + /** + * Test sets property to value that negative to the current value + * and compares returned value with value that was set. <p> + * Has <b> OK </b> status if returned value isn't equal to value that was + * stored by method <code>getInsertLinks()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getInsertLinks() </code> : to have current value of + * this property </li> + * </ul> + */ + public void _setInsertLinks() { + requiredMethod("getInsertLinks()"); + oObj.setInsertLinks( !insertLinks ); + boolean insertLinks2 = oObj.getInsertLinks(); + tRes.tested("setInsertLinks()", insertLinks != insertLinks2); + } + + /** + * Test sets new cell ranges and compares cell ranges gotten by method + * <code>getSources()</code> with the cell range that was set. <p> + * Has <b> OK </b> status if returned value isn't equal to value that was + * stored by method <code>getSources()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getSources() </code> : to have the cell ranges which + * are consolidated </li> + * </ul> + */ + public void _setSources() { + requiredMethod("getSources()"); + oObj.setSources(newCRaddr()); + CellRangeAddress[] CRaddr2 = oObj.getSources(); + tRes.tested("setSources()",!ValueComparer.equalValue(CRaddr, CRaddr2)); + } + + /** + * Test sets new cell address for start output position and compares + * cell address gotten by method <code>getStartOutputPosition()</code> + * with the cell address that was set. <p> + * Has <b> OK </b> status if returned value isn't equal to value that was + * stored by method <code>getStartOutputPosition()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getStartOutputPosition() </code> : to have the cell address + * of start output position </li> + * </ul> + */ + public void _setStartOutputPosition() { + requiredMethod("getStartOutputPosition()"); + CellAddress addr2 = new CellAddress(); + addr2.Column = addr.Column + 1; + addr2.Row = addr.Row + 1; + oObj.setStartOutputPosition(addr2); + tRes.tested("setStartOutputPosition()", + !ValueComparer.equalValue(addr, addr2)); + } + + /** + * Test sets property to value that negative to the current value + * and compares returned value with value that was set. <p> + * Has <b> OK </b> status if returned value isn't equal to value that was + * stored by method <code>getUseColumnHeaders()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getUseColumnHeaders() </code> : to have current value of + * this property </li> + * </ul> + */ + public void _setUseColumnHeaders() { + requiredMethod("getUseColumnHeaders()"); + oObj.setUseColumnHeaders( !useColumnHeaders ); + boolean uCH = oObj.getUseColumnHeaders(); + tRes.tested("setUseColumnHeaders()", useColumnHeaders != uCH); + } + + /** + * Test sets property to value that negative to the current value + * and compares returned value with value that was set. <p> + * Has <b> OK </b> status if returned value isn't equal to value that was + * stored by method <code>getUseRowHeaders()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getUseRowHeaders() </code> : to have current value of + * this property </li> + * </ul> + */ + public void _setUseRowHeaders() { + requiredMethod("getUseRowHeaders()"); + oObj.setUseRowHeaders(!useRowHeaders); + boolean uRH = oObj.getUseRowHeaders(); + tRes.tested("setUseRowHeaders()", useRowHeaders != uRH ); + } + + /** + * Constructs new cell range addresses using old cell range addresses. + * @param CRaddr old cell range addresses + * @return new cell range addresses + */ + public CellRangeAddress[] newCRaddr() { + + CellRangeAddress[] back = new CellRangeAddress[1]; + + CellRangeAddress cra1 = new CellRangeAddress(); + cra1.EndColumn=5; + cra1.EndRow=5; + cra1.Sheet=(short)0; + cra1.StartColumn=1; + cra1.StartRow=1; + back[0]=cra1; + + return back; + } + + +} // finish class _XConsolidationDescriptor + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDDELink.java b/qadevOOo/tests/java/ifc/sheet/_XDDELink.java new file mode 100644 index 000000000000..5c475e3c0208 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDDELink.java @@ -0,0 +1,111 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XDDELink; + +/** +* Testing <code>com.sun.star.sheet.XDDELink</code> +* interface methods : +* <ul> +* <li><code> getApplication()</code></li> +* <li><code> getTopic()</code></li> +* <li><code> getItem()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'APPLICATION'</code> (of type <code>String</code>): +* to have application name </li> +* <li> <code>'ITEM'</code> (of type <code>String</code>): +* to have DDE item </li> +* <li> <code>'TOPIC'</code> (of type <code>String</code>): +* to have DDE topic </li> +* <ul> <p> +* @see com.sun.star.sheet.XDDELink +*/ +public class _XDDELink extends MultiMethodTest { + public XDDELink oObj = null; + + /** + * Test calls the method and compares returned value to value obtained by + * relation <code>'APPLICATION'</code>. <p> + * Has <b> OK </b> status if values are equal. <p> + */ + public void _getApplication(){ + log.println("testing getApplication()"); + boolean bResult = false; + + String oAppl = (String)tEnv.getObjRelation("APPLICATION"); + if (oAppl == null) throw new StatusException(Status.failed + ("Relation 'APPLICATION' not found")); + + bResult = oAppl.equals(oObj.getApplication()); + tRes.tested("getApplication()", bResult) ; + } + + /** + * Test calls the method and compares returned value to value obtained by + * relation <code>'ITEM'</code>. <p> + * Has <b> OK </b> status if values are equal. <p> + */ + public void _getItem(){ + log.println("testing getItem()"); + boolean bResult = false; + String sItem = oObj.getItem(); + + String oItem = (String)tEnv.getObjRelation("ITEM"); + if (oItem == null) throw new StatusException(Status.failed + ("Relation 'ITEM' not found")); + + bResult = oItem.equals(sItem); + tRes.tested("getItem()", bResult) ; + } + + /** + * Test calls the method and compares returned value to value obtained by + * relation <code>'TOPIC'</code>. <p> + * Has <b> OK </b> status if values are equal. <p> + */ + public void _getTopic(){ + log.println("testing getTopic()"); + boolean bResult = false; + String sTopic = oObj.getTopic(); + + String oTopic = (String)tEnv.getObjRelation("TOPIC"); + if (oTopic == null) throw new StatusException(Status.failed + ("Relation 'TOPIC' not found")); + + bResult = oTopic.equals(sTopic); + tRes.tested("getTopic()", bResult) ; + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDataPilotDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_XDataPilotDescriptor.java new file mode 100644 index 000000000000..e95aa5870d38 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDataPilotDescriptor.java @@ -0,0 +1,429 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNamed; +import com.sun.star.sheet.DataPilotFieldOrientation; +import com.sun.star.sheet.XDataPilotDescriptor; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XDataPilotDescriptor</code> +* interface methods : +* <ul> +* <li><code> getTag()</code></li> +* <li><code> setTag()</code></li> +* <li><code> getSourceRange()</code></li> +* <li><code> setSourceRange()</code></li> +* <li><code> getFilterDescriptor()</code></li> +* <li><code> getDataPilotFields()</code></li> +* <li><code> getColumnFields()</code></li> +* <li><code> getRowFields()</code></li> +* <li><code> getPageFields()</code></li> +* <li><code> getDataFields()</code></li> +* <li><code> getHiddenFields()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'FIELDSAMOUNT'</code> (of type <code>Integer</code>): +* to have number of fields </li> +* <ul> <p> +* @see com.sun.star.sheet.XDataPilotDescriptor +*/ +public class _XDataPilotDescriptor extends MultiMethodTest { + + public XDataPilotDescriptor oObj = null; + CellRangeAddress CRA = new CellRangeAddress((short)1, 1, 1, 5, 5); + CellRangeAddress oldCRA = null ; + String sTag = new String ("XDataPilotDescriptor_Tag"); + String fieldsNames[]; + int fieldsAmount = 0; + int tEnvFieldsAmount = 0; + + /** + * Retrieves object relations. + * @throws StatusException If one of relations not found. + */ + protected void before() { + Integer amount = (Integer)tEnv.getObjRelation("FIELDSAMOUNT"); + if (amount == null) throw new StatusException(Status.failed + ("Relation 'FIELDSAMOUNT' not found")); + tEnvFieldsAmount = amount.intValue(); + } + + /** + * Test calls the method and compares returned value with value that was set + * in method <code>setSourceRange()</code>. <p> + * Has <b> OK </b> status if all fields of cell range addresses are equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setSourceRange() </code> : to have current source range </li> + * </ul> + */ + public void _getSourceRange(){ + requiredMethod("setSourceRange()"); + boolean bResult = true; + + CellRangeAddress objRA = oObj.getSourceRange(); + bResult &= objRA.Sheet == CRA.Sheet; + bResult &= objRA.StartRow == CRA.StartRow; + bResult &= objRA.StartColumn == CRA.StartColumn; + bResult &= objRA.EndRow == CRA.EndRow; + bResult &= objRA.EndColumn == CRA.EndColumn; + + tRes.tested("getSourceRange()", bResult); + } + + /** + * Test gets the current source range, stores it and sets new source range.<p> + * Has <b> OK </b> status if the method successfully returns. <p> + * The following method tests are to be executed before : + * <ul> + * <li> <code> getColumnFields() </code> </li> + * <li> <code> getRowFields() </code> </li> + * <li> <code> getDataFields() </code> </li> + * <li> <code> getHiddenFields() </code> </li> + * <li> <code> getPageFields() </code> </li> + * </ul> + */ + public void _setSourceRange(){ + executeMethod("getColumnFields()") ; + executeMethod("getRowFields()") ; + executeMethod("getDataFields()") ; + executeMethod("getHiddenFields()") ; + executeMethod("getPageFields()") ; + + oldCRA = oObj.getSourceRange() ; + oObj.setSourceRange(CRA); + + tRes.tested("setSourceRange()", true); + } + + /** + * Test calls the method and checks returned value with value that was set + * by method <code>setTag()</code>. <p> + * Has <b> OK </b> status if returned value is equal to value that was set + * by method <code>setTag()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setTag() </code> : to have current tag </li> + * </ul> + */ + public void _getTag(){ + requiredMethod("setTag()"); + boolean bResult = true; + + String objTag = oObj.getTag(); + bResult &= objTag.equals(sTag); + + tRes.tested("getTag()", bResult); + } + + /** + * Test just calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _setTag(){ + oObj.setTag(sTag); + tRes.tested("setTag()", true); + } + + /** + * Test calls the method , checks returned value, compares + * number of fields goten from returned value and obtained by object + * relation <code>'FIELDSAMOUNT'</code> and set property + * <code>Orientation</code> to one of DataPilotFieldOrientation values. <p> + * Has <b> OK </b> status if returned value isn't null, number of fields + * goten from returned value is less than number of fields obtained by relation + * and no exceptions were thrown. <p> + */ + public void _getDataPilotFields(){ + boolean bResult = true; + XIndexAccess IA = null; + + IA = oObj.getDataPilotFields(); + if (IA == null) { + log.println("Returned value is null."); + tRes.tested("getDataPilotFields()", false); + return; + } else {log.println("getDataPilotFields returned not Null value -- OK");} + + fieldsAmount = IA.getCount(); + if (fieldsAmount < tEnvFieldsAmount) { + log.println("Number of fields is less than number goten by relation."); + tRes.tested("getDataPilotFields()", false); + return; + } else {log.println("count of returned fields -- OK");} + + fieldsNames = new String[tEnvFieldsAmount]; + int i = -1 ; + int cnt = 0 ; + while (++i < fieldsAmount) { + Object field; + try { + field = IA.getByIndex(i); + } catch(com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + tRes.tested("getDataPilotFields()", false); + return; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + tRes.tested("getDataPilotFields()", false); + return; + } + + XNamed named = (XNamed) + UnoRuntime.queryInterface(XNamed.class, field); + String name = named.getName(); + + log.print("Field : '" + name + "' ... ") ; + + if (!name.equals("Data")) { + + fieldsNames[cnt] = name ; + + XPropertySet props = (XPropertySet) + UnoRuntime.queryInterface(XPropertySet.class, field); + + try { + switch (cnt % 5) { + case 0 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.COLUMN); + log.println(" Column") ; + break; + case 1 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.ROW); + log.println(" Row") ; + break; + case 2 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.DATA); + log.println(" Data") ; + break; + case 3 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.HIDDEN); + log.println(" Hidden") ; + break; + case 4 : + props.setPropertyValue("Orientation", + DataPilotFieldOrientation.PAGE); + log.println(" Page") ; + break; + } } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + tRes.tested("getDataPilotFields()", false); + return; + } catch (com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + tRes.tested("getDataPilotFields()", false); + return; + } catch (com.sun.star.beans.PropertyVetoException e) { + e.printStackTrace(log); + tRes.tested("getDataPilotFields()", false); + return; + } catch (com.sun.star.beans.UnknownPropertyException e) { + e.printStackTrace(log); + tRes.tested("getDataPilotFields()", false); + return; + } + if (++cnt > 4) break; + } else { + tRes.tested("getDataPilotFields()", false); + return; + } + } + + tRes.tested("getDataPilotFields()", bResult); + } + + /** + * Test calls the method and checks returned collection using the method + * <code>CheckNames()</code>. <p> + * Has <b> OK </b> status if the method <code>CheckNames()</code> returns true + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + */ + public void _getColumnFields(){ + requiredMethod("getDataPilotFields()"); + XIndexAccess IA = oObj.getColumnFields(); + boolean bResult = CheckNames(IA, 0); + tRes.tested("getColumnFields()", bResult); + } + + /** + * Test calls the method and checks returned collection using the method + * <code>CheckNames()</code>. <p> + * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + */ + public void _getDataFields(){ + requiredMethod("getDataPilotFields()"); + XIndexAccess IA = oObj.getDataFields(); + boolean bResult = CheckNames(IA, 2); + tRes.tested("getDataFields()", bResult); + } + + /** + * Test calls the method and checks returned collection using the method + * <code>CheckNames()</code>. <p> + * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + */ + public void _getHiddenFields(){ + requiredMethod("getDataPilotFields()"); + XIndexAccess IA = oObj.getHiddenFields(); + boolean bResult = CheckNames(IA, 3); + tRes.tested("getHiddenFields()", bResult); + } + + /** + * Test calls the method and checks returned collection using the method + * <code>CheckNames()</code>. <p> + * Has <b> OK </b> status if the method <code>CheckNames()</code> returned true + * and no exceptions were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + */ + public void _getRowFields(){ + requiredMethod("getDataPilotFields()"); + XIndexAccess IA = oObj.getRowFields(); + boolean bResult = CheckNames(IA, 1); + tRes.tested("getRowFields()", bResult); + } + + /** + * setting of PageFields isn't supported by StarOffice Calc + * Has <b> OK </b> status if the returned IndexAccess + * isn't NULL. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getDataPilotFields() </code> : to have array of field names </li> + * </ul> + */ + public void _getPageFields(){ + requiredMethod("getDataPilotFields()"); + XIndexAccess IA = oObj.getPageFields(); + boolean bResult = (IA != null); + // boolean bResult = CheckNames(IA, 4); + tRes.tested("getPageFields()", bResult); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null + * and no exceptions were thrown. <p> + */ + public void _getFilterDescriptor(){ + boolean bResult = oObj.getFilterDescriptor() != null; + tRes.tested("getFilterDescriptor()", bResult); + } + + /** + * Method checks that the field with index <code>rem</code> exists + * in the array <code>IA</code>. + * @param IA collection of elements that support interface <code>XNamed</code> + * @param rem index of field in the array of field names that was stored in + * the method <code>getDataPilotFields()</code> + * @return true if required field name exists in passed collection; + * false otherwise + * @see com.sun.star.container.XNamed + */ + boolean CheckNames(XIndexAccess IA, int rem) { + String name = null; + + if (IA == null) { + log.println("Null retruned.") ; + return false ; + } + + if (fieldsNames[rem] == null) { + log.println("No fields were set to this orientation - cann't check result") ; + return true ; + } + + if (IA.getCount() == 0) { + log.println("No fields found. Must be at least '" + + fieldsNames[rem] + "'") ; + return false ; + } + + try { + log.print("Fields returned ") ; + for (int i = 0; i < IA.getCount(); i++) { + Object field = IA.getByIndex(i); + XNamed named = (XNamed)UnoRuntime.queryInterface + (XNamed.class, field); + name = named.getName(); + log.print(" " + name) ; + if (fieldsNames[rem].equals(name)) { + log.println(" - OK") ; + return true ; + } + } + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log) ; + return false ; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log) ; + return false ; + } + log.println(" - FAILED (field " + fieldsNames[rem] + " was not found.") ; + return false ; + } + + /** + * Recreates object(to back old orientations of the fields). + */ + protected void after() { + disposeEnvironment(); + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDataPilotField.java b/qadevOOo/tests/java/ifc/sheet/_XDataPilotField.java new file mode 100644 index 000000000000..6e29ad3ceaa4 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDataPilotField.java @@ -0,0 +1,70 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.sheet.XDataPilotField; + +import lib.MultiMethodTest; + + +public class _XDataPilotField extends MultiMethodTest { + public XDataPilotField oObj = null; + + public void _getItems() { + XIndexAccess xIA = oObj.getItems(); + tRes.tested("getItems()", checkIndexAccess(xIA)); + } + + /** + * calls the method getCount at the IndexAccess, returns true is it is >0 + * and getByIndex() doesn't throw an exception for Indexes between 0 and count + */ + protected boolean checkIndexAccess(XIndexAccess xIA) { + boolean res = true; + int count = xIA.getCount(); + log.println("Found " + count + " Elements"); + res &= (count > 0); + + for (int k = 0; k < count; k++) { + try { + Object element = xIA.getByIndex(k); + log.println("Element " + k + " = " + element); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected Exception while getting by Index (" + k + + ")" + e.getMessage()); + res &= false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception while getting by Index (" + k + + ")" + e.getMessage()); + res &= false; + } + } + + return res; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XDataPilotFieldGrouping.java b/qadevOOo/tests/java/ifc/sheet/_XDataPilotFieldGrouping.java new file mode 100644 index 000000000000..5f17837fdb0d --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDataPilotFieldGrouping.java @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import com.sun.star.container.XNameAccess; +import com.sun.star.sheet.DataPilotFieldGroupBy; +import com.sun.star.sheet.DataPilotFieldGroupInfo; +import com.sun.star.sheet.XDataPilotField; +import com.sun.star.sheet.XDataPilotFieldGrouping; +import com.sun.star.uno.UnoRuntime; +import lib.MultiMethodTest; + +/** + * + * @author sw93809 + */ +public class _XDataPilotFieldGrouping extends MultiMethodTest +{ + public XDataPilotFieldGrouping oObj = null; + + public void _createNameGroup() { + boolean result = true; + try { + XDataPilotField xDataPilotField = (XDataPilotField) UnoRuntime.queryInterface(XDataPilotField.class, oObj); + XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDataPilotField.getItems ()); + String[] elements = xNameAccess.getElementNames (); + oObj.createNameGroup(elements); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Exception while checking createNameGroup"+e); + result = false; + } + tRes.tested ("createNameGroup()",result); + } + + public void _createDateGroup() { + boolean result = true; + try { + DataPilotFieldGroupInfo aInfo = new DataPilotFieldGroupInfo(); + aInfo.GroupBy = DataPilotFieldGroupBy.MONTHS; + aInfo.HasDateValues = true; + oObj.createDateGroup(aInfo); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Exception while checking createDateGroup"+e); + result = false; + } + tRes.tested ("createDateGroup()",result); + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XDataPilotTable.java b/qadevOOo/tests/java/ifc/sheet/_XDataPilotTable.java new file mode 100644 index 000000000000..a63617672ed8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDataPilotTable.java @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XDataPilotTable; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; + +/** +* Testing <code>com.sun.star.sheet.XDataPilotTable</code> +* interface methods : +* <ul> +* <li><code> getOutputRange()</code></li> +* <li><code> refresh()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'OUTPUTRANGE'</code> (of type <code>CellAddress</code>): +* to check value returned by method <code>getOutputRange()</code> </li> +* <li> <code>'CELLFORCHANGE'</code> (of type <code>XCell</code>): +* to check the method refresh(value of this cell will be changed)</li> +* <li> <code>'CELLFORCHECK'</code> (of type <code>XCell</code>): +* to check the method refresh (value of this cell must be changed after refresh +* call) </li><ul> <p> +* @see com.sun.star.sheet.XDataPilotTable +* @see com.sun.star.table.CellAddress +*/ +public class _XDataPilotTable extends MultiMethodTest { + + public XDataPilotTable oObj = null; + XCell xCellForChange = null; + XCell xCellForCheck = null; + CellAddress OutputRange = null; + + protected void before() { + xCellForChange = (XCell)tEnv.getObjRelation("CELLFORCHANGE"); + xCellForCheck = (XCell)tEnv.getObjRelation("CELLFORCHECK"); + OutputRange = (CellAddress)tEnv.getObjRelation("OUTPUTRANGE"); + if (xCellForChange == null || OutputRange == null || + xCellForCheck == null) { + throw new StatusException(Status.failed("Relation not found")); + } + } + /** + * Test calls the method and checks returned value using value obtained by + * object relation <code>'OUTPUTRANGE'</code>. <p> + * Has <b> OK </b> status if values are equal. <p> + */ + public void _getOutputRange(){ + boolean bResult = true; + CellRangeAddress objRange = oObj.getOutputRange(); + bResult &= OutputRange.Sheet == objRange.Sheet; + bResult &= OutputRange.Row == objRange.StartRow; + bResult &= OutputRange.Column == objRange.StartColumn; + tRes.tested("getOutputRange()", bResult); + } + + /** + * Test sets new value of the cell obtained by object relation + * 'CELLFORCHANGE', and checks value of the cell obtained by object + * relation 'CELLFORCHECK'.<p> + * Has <b>OK</b> status if value of the cell obtained by object relation + * 'CELLFORCHECK' is changed. <p> + */ + public void _refresh(){ + xCellForChange.setValue(5); + double oldData = xCellForCheck.getValue(); + oObj.refresh(); + double newData = xCellForCheck.getValue(); + log.println("Old data:" + oldData + "; new data:" + newData); + + tRes.tested("refresh()", oldData != newData); + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDataPilotTable2.java b/qadevOOo/tests/java/ifc/sheet/_XDataPilotTable2.java new file mode 100644 index 000000000000..f3096efc12ab --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDataPilotTable2.java @@ -0,0 +1,576 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +package ifc.sheet; + +import java.util.ArrayList; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.sheet.*; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellCursor; +import com.sun.star.table.XCellRange; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * Testing <code>com.sun.star.sheet.XDataPilotTable2</code> + * interface methods : + * <ul> + * <li><code> getDrillDownData()</code><li> + * <li><code> getPositionData()</code></li> + * <li><code> insertDrillDownSheet()</code></li> + * <li><code> getOutputRangeByType</code></li> + * </ul> + * + * @see com.sun.star.sheet.XDataPilotTable2 + * @see com.sun.star.table.CellAddress + * + */ +public class _XDataPilotTable2 extends MultiMethodTest +{ + private XSpreadsheetDocument xSheetDoc = null; + private XDataPilotTable2 xDPTab2 = null; + private CellRangeAddress mRangeWhole = null; + private CellRangeAddress mRangeTable = null; + private CellRangeAddress mRangeResult = null; + private ArrayList mDataFieldDims = null; + private ArrayList mResultCells = null; + + /** + * exception to be thrown when obtaining a result data for a cell fails + * (probably because the cell is not a result cell). + */ + private class ResultCellFailure extends com.sun.star.uno.Exception {} + + protected void before() + { + Object o = tEnv.getObjRelation("DATAPILOTTABLE2"); + xDPTab2 = (XDataPilotTable2)UnoRuntime.queryInterface( + XDataPilotTable2.class, o); + + if (xDPTab2 == null) + throw new StatusException(Status.failed("Relation not found")); + + xSheetDoc = (XSpreadsheetDocument)tEnv.getObjRelation("SHEETDOCUMENT"); + + getOutputRanges(); + buildDataFields(); + try + { + buildResultCells(); + } + catch (ResultCellFailure e) + { + e.printStackTrace(log); + throw new StatusException( "Failed to build result cells.", e); + } + } + + public void _getDrillDownData() + { + boolean testResult = true; + int cellCount = mResultCells.size(); + for (int i = 0; i < cellCount; ++i) + { + CellAddress addr = (CellAddress)mResultCells.get(i); + DataPilotTablePositionData posData = xDPTab2.getPositionData(addr); + DataPilotTableResultData resData = (DataPilotTableResultData)posData.PositionData; + int dim = ((Integer)mDataFieldDims.get(resData.DataFieldIndex)).intValue(); + DataResult res = resData.Result; + double val = res.Value; + + Object[][] data = xDPTab2.getDrillDownData(addr); + double sum = 0.0; + if (data.length > 1) + { + for (int row = 1; row < data.length; ++row) + { + Object o = data[row][dim]; + if (AnyConverter.isDouble(o)) + sum += ((Double)o).doubleValue(); + } + } + log.println(formatCell(addr) + ": " + data.length + " rows (" + (data.length-1) + " records)"); + + if (val != sum) + testResult = false; + } + tRes.tested("getDrillDownData()", testResult); + } + + public void _getPositionData() + { + boolean testResult = false; + + do + { + CellAddress addr = new CellAddress(); + addr.Sheet = mRangeTable.Sheet; + + boolean rangeGood = true; + for (int x = mRangeTable.StartColumn; x <= mRangeTable.EndColumn && rangeGood; ++x) + { + for (int y = mRangeTable.StartRow; y <= mRangeTable.EndRow && rangeGood; ++y) + { + addr.Column = x; + addr.Row = y; + log.println("checking " + formatCell(addr)); + DataPilotTablePositionData posData = xDPTab2.getPositionData(addr); + if (posData.PositionType == DataPilotTablePositionType.NOT_IN_TABLE) + { + log.println("specified cell address not in table: " + formatCell(addr)); + rangeGood = false; + continue; + } + + switch (posData.PositionType) + { + case DataPilotTablePositionType.NOT_IN_TABLE: + break; + case DataPilotTablePositionType.COLUMN_HEADER: + printHeaderData(posData); + break; + case DataPilotTablePositionType.ROW_HEADER: + printHeaderData(posData); + break; + case DataPilotTablePositionType.RESULT: + printResultData(posData); + break; + case DataPilotTablePositionType.OTHER: + break; + default: + log.println("unknown position"); + } + } + } + + if (!rangeGood) + { + log.println("table range check failed"); + break; + } + + testResult = true; + } + while (false); + + tRes.tested("getPositionData()", testResult); + } + + public void _insertDrillDownSheet() + { + boolean testResult = true; + int cellCount = mResultCells.size(); + XSpreadsheets xSheets = xSheetDoc.getSheets(); + XIndexAccess xIA = (XIndexAccess)UnoRuntime.queryInterface( + XIndexAccess.class, xSheets); + int sheetCount = xIA.getCount(); + for (int i = 0; i < cellCount && testResult; ++i) + { + CellAddress addr = (CellAddress)mResultCells.get(i); + + Object[][] data = xDPTab2.getDrillDownData(addr); + + // sheet is always inserted at the current sheet position. + xDPTab2.insertDrillDownSheet(addr); + + int newSheetCount = xIA.getCount(); + if (newSheetCount == sheetCount + 1) + { + log.println("drill-down sheet for " + formatCell(addr) + " inserted"); + if (data.length < 2) + { + // There is no data for this result. It should never have + // inserted a drill-down sheet. + log.println("new sheet inserted; however, there is no data for this result"); + testResult = false; + continue; + } + + // Retrieve the object of the sheet just inserted. + XSpreadsheet xSheet = null; + try + { + xSheet = (XSpreadsheet)UnoRuntime.queryInterface( + XSpreadsheet.class, xIA.getByIndex(addr.Sheet)); + } + catch (com.sun.star.uno.Exception e) + { + e.printStackTrace(); + throw new StatusException("Failed to get the spreadsheet object.", e); + } + + // Check the integrity of the data on the inserted sheet. + if (!checkDrillDownSheetContent(xSheet, data)) + { + log.println("dataintegrity check on the inserted sheet failed"); + testResult = false; + continue; + } + + log.println(" sheet data integrity check passed"); + + // Remove the sheet just inserted. + + XNamed xNamed = (XNamed)UnoRuntime.queryInterface(XNamed.class, xSheet); + String name = xNamed.getName(); + try + { + xSheets.removeByName(name); + } + catch (com.sun.star.uno.Exception e) + { + e.printStackTrace(); + throw new StatusException("Failed to removed the inserted sheet named " + name + ".", e); + } + } + else if (newSheetCount == sheetCount) + { + if (data.length > 1) + { + // There is data for this result. It should have inserted + // a new sheet. + log.println("no new sheet is inserted, despite the data being present."); + testResult = false; + } + } + else + { + log.println("what just happened!?"); + testResult = false; + } + } + + tRes.tested("insertDrillDownSheet()", testResult); + } + + public void _getOutputRangeByType() + { + boolean testResult = false; + + do + { + // Let's make sure this doesn't cause a crash. A range returned for an + // out-of-bound condition is undefined. + try + { + CellRangeAddress rangeOutOfBound = xDPTab2.getOutputRangeByType(-1); + log.println("exception not raised"); + break; + } + catch (IllegalArgumentException e) + { + log.println("exception raised on invalid range type (good)"); + } + + try + { + CellRangeAddress rangeOutOfBound = xDPTab2.getOutputRangeByType(100); + log.println("exception not raised"); + break; + } + catch (IllegalArgumentException e) + { + log.println("exception raised on invalid range type (good)"); + } + + // Check to make sure the whole range is not empty. + if (mRangeWhole.EndColumn - mRangeWhole.StartColumn <= 0 || + mRangeWhole.EndRow - mRangeWhole.EndColumn <= 0) + { + log.println("whole range is empty"); + break; + } + + log.println("whole range is not empty (good)"); + + // Table range must be of equal width with the whole range, and the same + // bottom. + if (mRangeTable.Sheet != mRangeWhole.Sheet || + mRangeTable.StartColumn != mRangeWhole.StartColumn || + mRangeTable.EndColumn != mRangeWhole.EndColumn || + mRangeTable.EndRow != mRangeWhole.EndRow) + { + log.println("table range is incorrect"); + break; + } + + log.println("table range is correct"); + + // Result range must be smaller than the table range, and must share the + // same lower-right corner. + if (mRangeResult.Sheet != mRangeTable.Sheet || + mRangeResult.StartColumn < mRangeTable.StartColumn || + mRangeResult.StartRow < mRangeTable.StartRow || + mRangeResult.EndColumn != mRangeTable.EndColumn || + mRangeResult.EndRow != mRangeTable.EndRow) + break; + + log.println("result range is correct"); + + testResult = true; + } + while (false); + + tRes.tested("getOutputRangeByType()", testResult); + } + + private void printHeaderData(DataPilotTablePositionData posData) + { + DataPilotTableHeaderData header = (DataPilotTableHeaderData)posData.PositionData; + String posType = ""; + if (posData.PositionType == DataPilotTablePositionType.COLUMN_HEADER) + posType = "column header"; + else if (posData.PositionType == DataPilotTablePositionType.ROW_HEADER) + posType = "row header"; + + log.println(posType + "; member name: " + header.MemberName + "; dimension: " + + header.Dimension + "; hierarchy: " + header.Hierarchy + + "; level: " + header.Level); + } + + private void printResultData(DataPilotTablePositionData posData) + { + DataPilotTableResultData resultData = (DataPilotTableResultData)posData.PositionData; + int dataId = resultData.DataFieldIndex; + DataResult res = resultData.Result; + double val = res.Value; + int flags = res.Flags; + int filterCount = resultData.FieldFilters.length; + log.println("result; data field index: " + dataId + "; value: " + val + "; flags: " + flags + + "; filter count: " + filterCount); + + for (int i = 0; i < filterCount; ++i) + { + DataPilotFieldFilter fil = resultData.FieldFilters[i]; + log.println(" field name: " + fil.FieldName + "; match value: " + fil.MatchValue); + } + } + + private String formatCell(CellAddress addr) + { + String str = "(" + addr.Column + "," + addr.Row + ")"; + return str; + } + + private void printRange(String text, CellRangeAddress rangeAddr) + { + log.println(text + ": (" + rangeAddr.StartColumn + "," + rangeAddr.StartRow + ") - (" + + rangeAddr.EndColumn + "," + rangeAddr.EndRow + ")"); + } + + private void buildResultCells() throws ResultCellFailure + { + if (mResultCells != null) + return; + + getOutputRanges(); + + mResultCells = new ArrayList(); + for (int x = mRangeResult.StartColumn; x <= mRangeResult.EndColumn; ++x) + { + for (int y = mRangeResult.StartRow; y <= mRangeResult.EndRow; ++y) + { + CellAddress addr = new CellAddress(); + addr.Sheet = mRangeResult.Sheet; + addr.Column = x; + addr.Row = y; + DataPilotTablePositionData posData = xDPTab2.getPositionData(addr); + if (posData.PositionType != DataPilotTablePositionType.RESULT) + { + log.println(formatCell(addr) + ": this is not a result cell"); + throw new ResultCellFailure(); + } + mResultCells.add(addr); + } + } + } + + private void buildDataFields() + { + mDataFieldDims = new ArrayList(); + XDataPilotDescriptor xDesc = (XDataPilotDescriptor)UnoRuntime.queryInterface( + XDataPilotDescriptor.class, xDPTab2); + + XIndexAccess xFields = xDesc.getDataPilotFields(); + int fieldCount = xFields.getCount(); + for (int i = 0; i < fieldCount; ++i) + { + try + { + Object field = xFields.getByIndex(i); + XPropertySet propSet = (XPropertySet)UnoRuntime.queryInterface( + XPropertySet.class, field); + DataPilotFieldOrientation orient = + (DataPilotFieldOrientation)propSet.getPropertyValue("Orientation"); + if (orient == DataPilotFieldOrientation.DATA) + { + Integer item = new Integer(i); + mDataFieldDims.add(item); + } + } + catch (com.sun.star.uno.Exception e) + { + e.printStackTrace(log); + throw new StatusException( "Failed to get a field.", e); + } + } + } + + private void getOutputRanges() + { + if (mRangeWhole != null && mRangeTable != null && mRangeResult != null) + return; + + try + { + mRangeWhole = xDPTab2.getOutputRangeByType(DataPilotOutputRangeType.WHOLE); + printRange("whole range ", mRangeWhole); + mRangeTable = xDPTab2.getOutputRangeByType(DataPilotOutputRangeType.TABLE); + printRange("table range ", mRangeTable); + mRangeResult = xDPTab2.getOutputRangeByType(DataPilotOutputRangeType.RESULT); + printRange("result range", mRangeResult); + } + catch (IllegalArgumentException e) + { + e.printStackTrace(log); + throw new StatusException( "Failed to get output range by type.", e); + } + } + + private boolean checkDrillDownSheetContent(XSpreadsheet xSheet, Object[][] data) + { + CellAddress lastCell = getLastUsedCellAddress(xSheet, 0, 0); + if (data.length <= 0 || lastCell.Row == 0 || lastCell.Column == 0) + { + log.println("empty data condition"); + return false; + } + + if (data.length != lastCell.Row + 1 || data[0].length != lastCell.Column + 1) + { + log.println("data size differs"); + return false; + } + + XCellRange xCR = null; + try + { + xCR = xSheet.getCellRangeByPosition(0, 0, lastCell.Column, lastCell.Row); + } + catch (com.sun.star.lang.IndexOutOfBoundsException e) + { + return false; + } + + XCellRangeData xCRD = (XCellRangeData)UnoRuntime.queryInterface( + XCellRangeData.class, xCR); + + Object[][] sheetData = xCRD.getDataArray(); + for (int x = 0; x < sheetData.length; ++x) + { + for (int y = 0; y < sheetData[x].length; ++y) + { + Object cell1 = sheetData[x][y]; + Object cell2 = data[x][y]; + if (AnyConverter.isString(cell1) && AnyConverter.isString(cell2)) + { + String s1 = (String)cell1, s2 = (String)(cell2); + if (!s1.equals(s2)) + { + log.println("string cell values differ"); + return false; + } + } + else if (AnyConverter.isDouble(cell1) && AnyConverter.isDouble(cell2)) + { + double f1 = 0.0, f2 = 0.0; + try + { + f1 = AnyConverter.toDouble(cell1); + f2 = AnyConverter.toDouble(cell2); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + log.println("failed to convert cells to double"); + return false; + } + + if (f1 != f2) + { + log.println("numerical cell values differ"); + return false; + } + } + else + { + log.println("cell types differ"); + return false; + } + } + } + + return true; + } + + private CellAddress getLastUsedCellAddress(XSpreadsheet xSheet, int nCol, int nRow) + { + try + { + XCellRange xRng = xSheet.getCellRangeByPosition(nCol, nRow, nCol, nRow); + XSheetCellRange xSCR = (XSheetCellRange)UnoRuntime.queryInterface( + XSheetCellRange.class, xRng); + + XSheetCellCursor xCursor = xSheet.createCursorByRange(xSCR); + XCellCursor xCellCursor = (XCellCursor)UnoRuntime.queryInterface( + XCellCursor.class, xCursor); + + xCellCursor.gotoEnd(); + XCell xCell = xCursor.getCellByPosition(0, 0); + XCellAddressable xCellAddr = (XCellAddressable)UnoRuntime.queryInterface( + XCellAddressable.class, xCell); + + return xCellAddr.getCellAddress(); + } + catch (com.sun.star.lang.IndexOutOfBoundsException ex) + { + } + return null; + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDataPilotTables.java b/qadevOOo/tests/java/ifc/sheet/_XDataPilotTables.java new file mode 100644 index 000000000000..09ee1da76551 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDataPilotTables.java @@ -0,0 +1,157 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XDataPilotDescriptor; +import com.sun.star.sheet.XDataPilotTables; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.CellAddress; + +/** +* Testing <code>com.sun.star.sheet.XDataPilotTables</code> +* interface methods : +* <ul> +* <li><code> createDataPilotDescriptor()</code></li> +* <li><code> insertNewByName()</code></li> +* <li><code> removeByName()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'SHEET'</code> (of type <code>XSpreadsheet</code>): +* to have a spreadsheet document for document content checking</li> +* <ul> <p> +* @see com.sun.star.sheet.XDataPilotTables +*/ +public class _XDataPilotTables extends MultiMethodTest { + + public XDataPilotTables oObj = null; + XDataPilotDescriptor DPDscr = null; + String name = "XDataPilotTables"; + CellAddress CA = new CellAddress((short)0, 9, 8); + XSpreadsheet oSheet = null; + + /** + * Retrieves object relations. + * @throws StatusException If one of relations not found. + */ + protected void before() { + oSheet = (XSpreadsheet)tEnv.getObjRelation("SHEET"); + if (oSheet == null) throw new StatusException(Status.failed + ("Relation 'SHEET' not found")); + } + + /** + * Test calls the method, stores returned value and checks returned value. + * <p>Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _createDataPilotDescriptor(){ + DPDscr = oObj.createDataPilotDescriptor(); + tRes.tested("createDataPilotDescriptor()", DPDscr != null); + } + + /** + * Test calls the method inserting new table with new name and then calls + * the method inserting table with existent name. <p> + * Has <b> OK </b> status if the cell content where table was inserted is + * equal to 'Filter' after first call and exception was thrown during + * second call. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> createDataPilotDescriptor() </code> : to have + * <code>XDataPilotDescriptor</code> created by this method</li> + * </ul> + */ + public void _insertNewByName(){ + requiredMethod("createDataPilotDescriptor()"); + boolean bResult = true; + log.println("Inserting new Table \"" + name + "\""); + try { + oObj.insertNewByName(name, CA, DPDscr); + bResult &= oSheet.getCellByPosition + (CA.Column, CA.Row).getFormula().equals("Filter"); + } catch (com.sun.star.uno.Exception e) { + log.println("Exception occured! " + e); + bResult = false; + } + + log.println(bResult ? "OK" : "FAILED"); + log.println("Trying to insert element with existent name"); + + try { + oObj.insertNewByName(name,new CellAddress((short)0, 7, 7), DPDscr); + log.println("No exception! - FAILED"); + bResult = false; + } catch (com.sun.star.uno.RuntimeException e) { + log.println("Expected exception - OK " + e); + } + + log.println("Inserting new table " + (bResult ? "OK" : "FAILED")); + tRes.tested("insertNewByName()", bResult); + } + + /** + * Test calls the method for existent table and for unexistent table. <p> + * Has <b> OK </b> status if the cell where table was removed from is empty + * after first call and exception was thrown during second call. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code>insertNewByName()</code>: to have name of existent table</li> + * </ul> + */ + public void _removeByName(){ + requiredMethod("insertNewByName()"); + boolean bResult = true; + log.println("Remove table with name " + name); + try { + oObj.removeByName(name); + bResult &= oSheet.getCellByPosition + (CA.Column, CA.Row).getFormula().equals(""); + } catch (com.sun.star.uno.Exception e) { + log.println("Exception occured ! " + e); + bResult = false; + } + log.println(bResult ? "OK" : "FAILED"); + log.println("Removing unexistent element"); + try { + oObj.removeByName(name); + log.println("No exception! - FAILED"); + bResult = false; + } catch (com.sun.star.uno.RuntimeException e) { + log.println("Expected exception - OK " + e); + } + + log.println("Removing a table " + (bResult ? "OK" : "FAILED")); + tRes.tested("removeByName()", bResult); + } + +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDataPilotTablesSupplier.java b/qadevOOo/tests/java/ifc/sheet/_XDataPilotTablesSupplier.java new file mode 100644 index 000000000000..a291d3513f8f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDataPilotTablesSupplier.java @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XDataPilotTables; +import com.sun.star.sheet.XDataPilotTablesSupplier; + +/** +* Testing <code>com.sun.star.sheet.XDataPilotTablesSupplier</code> +* interface methods : +* <ul> +* <li><code> getDataPilotTables()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XDataPilotTablesSupplier +*/ +public class _XDataPilotTablesSupplier extends MultiMethodTest { + + public XDataPilotTablesSupplier oObj = null; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null + * and no exceptions were thrown. <p> + */ + public void _getDataPilotTables() { + XDataPilotTables DPTables = oObj.getDataPilotTables(); + tRes.tested("getDataPilotTables()", DPTables != null); + } + + +} // EOC _XDataPilotTablesSupplier + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDatabaseRange.java b/qadevOOo/tests/java/ifc/sheet/_XDatabaseRange.java new file mode 100644 index 000000000000..3b3d3713a5b2 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDatabaseRange.java @@ -0,0 +1,244 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.sheet.SubTotalColumn; +import com.sun.star.sheet.XDatabaseRange; +import com.sun.star.sheet.XSheetFilterDescriptor; +import com.sun.star.sheet.XSubTotalDescriptor; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; + +/** +* Testing <code>com.sun.star.sheet.XDatabaseRange</code> +* interface methods : +* <ul> +* <li><code> getDataArea()</code></li> +* <li><code> setDataArea()</code></li> +* <li><code> getSortDescriptor()</code></li> +* <li><code> getFilterDescriptor()</code></li> +* <li><code> getSubTotalDescriptor()</code></li> +* <li><code> getImportDescriptor()</code></li> +* <li><code> refresh()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'DATAAREA'</code> (of type <code>CellRangeAddress</code>): +* to have cell range address for test of method <code>getDataArea()</code></li> +* <li> <code>'XCELLRANGE'</code> (of type <code>XCellRange</code>): +* cell range of the spreadsheet with database range, +* to get values of cell</li> +* <ul> <p> +* @see com.sun.star.sheet.XDatabaseRange +* @see com.sun.star.table.CellRangeAddress +*/ +public class _XDatabaseRange extends MultiMethodTest { + + public XDatabaseRange oObj = null; + CellRangeAddress oldCRA = null; + XCellRange xCellRange = null; + + /** + * Retrieves object relations. + * @throws StatusException If one of relations not found. + */ + protected void before() { + oldCRA = (CellRangeAddress)tEnv.getObjRelation("DATAAREA"); + if (oldCRA == null) { + throw new StatusException(Status.failed + ("Relation 'DATAAREA' not found")); + } + xCellRange = (XCellRange)tEnv.getObjRelation("XCELLRANGE"); + if (xCellRange == null) { + throw new StatusException(Status.failed + ("Relation 'XCELLRANGE' not found")); + } + } + + /** + * Test calls the method and compares returned cell range address with + * cell range address obtained by object relation <code>'DATAAREA'</code>.<p> + * Has <b> OK </b> status if all fields of cell range addresses are equal. <p> + */ + public void _getDataArea() { + boolean bResult = true; + CellRangeAddress objCRA = oObj.getDataArea(); + bResult &= objCRA.EndColumn == oldCRA.EndColumn; + bResult &= objCRA.EndRow == oldCRA.EndRow; + bResult &= objCRA.Sheet == oldCRA.Sheet; + bResult &= objCRA.StartColumn == oldCRA.StartColumn; + bResult &= objCRA.StartRow == oldCRA.StartRow; + tRes.tested("getDataArea()", bResult); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getFilterDescriptor() { + XSheetFilterDescriptor FD = oObj.getFilterDescriptor(); + tRes.tested("getFilterDescriptor()", FD != null); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getImportDescriptor() { + PropertyValue[] pva = oObj.getImportDescriptor(); + tRes.tested("getImportDescriptor()", pva != null); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getSortDescriptor() { + PropertyValue[] pva = oObj.getSortDescriptor(); + tRes.tested("getSortDescriptor()", pva != null); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getSubTotalDescriptor() { + STD = oObj.getSubTotalDescriptor(); + tRes.tested("getSubTotalDescriptor()", STD != null); + } + + XSubTotalDescriptor STD = null; + + /** + * Test adds new SubTotalDescriptor and checks value of cell with + * subtotal sum after refresh() call. <p> + * Has <b> OK </b> if value of cell with subtotal sum was changed + * after refresh() call.<p> + */ + public void _refresh() { + requiredMethod("getSubTotalDescriptor()"); + requiredMethod("setDataArea()"); + + for(int i = STARTROW; i < ENDROW+1; i++) { + try { + XCell cell = xCellRange.getCellByPosition(COL, i); + cell.setValue(i); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + tRes.tested("refresh()", false); + } + } + + SubTotalColumn[] STC = new SubTotalColumn[1]; + STC[0] = new SubTotalColumn(); + STC[0].Column = COL; + STC[0].Function = com.sun.star.sheet.GeneralFunction.SUM; + + double oldVal = 0; + try { + XCell checkCell = xCellRange.getCellByPosition(COL, ENDROW); + oldVal = checkCell.getValue(); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + tRes.tested("refresh()", false); + } + log.println("Value of the cell (" + COL + ", " + ENDROW + + ") : " + oldVal ); + + log.println("Set new SubTotal descriptor..."); + + STD.clear(); + STD.addNew(STC, 1); + + double valBeforeRefresh = 0; + try { + XCell checkCell = xCellRange.getCellByPosition(COL, ENDROW); + valBeforeRefresh = checkCell.getValue(); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + tRes.tested("refresh()", false); + } + log.println("Value of the cell (" + COL + ", " + ENDROW + + ") : " + valBeforeRefresh ); + + log.println("Now call refresh()..."); + oObj.refresh(); + + double valAfterRefresh = 0; + try { + XCell checkCell = xCellRange.getCellByPosition(COL, ENDROW); + valAfterRefresh = checkCell.getValue(); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected exception"); + e.printStackTrace(log); + tRes.tested("refresh()", false); + } + log.println("Value of the cell (" + COL + ", " + ENDROW + + ") : " + valAfterRefresh ); + + tRes.tested("refresh()", oldVal != valAfterRefresh && + oldVal == valBeforeRefresh); + } + + final short COL = 0; + final short STARTROW = 0; + final short ENDROW = 5; + + /** + * Test creates new cell range address and calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _setDataArea() { + executeMethod("getDataArea()"); + CellRangeAddress newCRA = new CellRangeAddress(); + newCRA.Sheet = oldCRA.Sheet; + newCRA.StartColumn = COL; + newCRA.EndColumn = COL; + newCRA.StartRow = STARTROW; + newCRA.EndRow = ENDROW; + + oObj.setDataArea(newCRA); + + tRes.tested("setDataArea()", true); + } + + protected void after() { + disposeEnvironment(); + } +} + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges.java b/qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges.java new file mode 100644 index 000000000000..c5f5307cda41 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDatabaseRanges.java @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XDatabaseRanges; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XDatabaseRanges</code> +* interface methods : +* <ul> +* <li><code> addNewByName()</code></li> +* <li><code> removeByName()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XDatabaseRanges +*/ +public class _XDatabaseRanges extends MultiMethodTest { + + public XDatabaseRanges oObj = null; + CellRangeAddress CRA = null; + String name = null; + + /** + * Test adds a new database range to the collection, checks that range with + * this name exist in collection and then tries to add range with the same + * name. <p> + * Has <b> OK </b> status if the added range exists in collection and + * exception was thrown when trying to add range with name that is same as name + * of existent range. <p> + */ + public void _addNewByName() { + boolean bResult = true; + log.println("Trying to add range with proper name."); + + CRA = new CellRangeAddress((short)0, 1, 2, 3, 4); + name = "_XDatabaseRanges_addNewByRange"; + + oObj.addNewByName(name, CRA); + + bResult &= oObj.hasByName(name); + + if (bResult) log.println("Ok"); + log.println("Trying to add existing element."); + + try { + oObj.addNewByName(name, CRA); + log.println("Exception expected... Test failed."); + bResult = false; + } catch(com.sun.star.uno.RuntimeException e) { + log.println("Exception occured while testing addNewByName() : " + e); + bResult = true; + } + + tRes.tested("addNewByName()", bResult); + } + + /** + * Test removes the database range with name that exist exactly and then + * tries to remove the range with name that doesn't exist exactly. <p> + * Has <b> OK </b> status if first range was succesfully removed and + * exception was thrown when trying to remove non-existent database range.<p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> addNewByName() </code> : to have definitely existed database + * range </li> + * </ul> + */ + public void _removeByName(){ + boolean bResult = true; + requiredMethod("addNewByName()"); + + log.println("Remove inserted element."); + + try { + oObj.removeByName(name); + bResult &= !oObj.hasByName(name); + } catch (com.sun.star.uno.RuntimeException e) { + log.println("Exception occured while testing removeByName() : " + e); + bResult = false; + } + + log.println("OK.\nTrying to remove unexistant element."); + + try { + oObj.removeByName(name); + log.println("Exception expected... - FAILED"); + bResult = false; + } catch (com.sun.star.uno.RuntimeException e) { + log.println("Expected exception. - OK : " + e); + } + tRes.tested("removeByName()", bResult); + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing.java b/qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing.java new file mode 100644 index 000000000000..084ce09934c7 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XDocumentAuditing.java @@ -0,0 +1,228 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.awt.Point; +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNamed; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPagesSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.frame.XDispatchHelper; +import com.sun.star.frame.XDispatchProvider; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XDocumentAuditing; +import com.sun.star.sheet.XSheetAuditing; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellAddress; +import com.sun.star.uno.UnoRuntime; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * + */ +public class _XDocumentAuditing extends MultiMethodTest { + public XDocumentAuditing oObj = null; + XDrawPage xDrawPage = null; + XSpreadsheet[] xSheet = null; + int elementCount = 0; + String sheetName = null; + Point pos = null; + + public void before() { + Exception ex = null; + // get two sheets + xSheet = new XSpreadsheet[2]; + try { + XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument) + UnoRuntime.queryInterface(XSpreadsheetDocument.class, oObj); + XSpreadsheets oSheets = xSpreadsheetDocument.getSheets(); + XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface( + XIndexAccess.class, oSheets); + XSpreadsheet oSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, oIndexSheets.getByIndex(0)); + xSheet[0] = oSheet; + oSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, oIndexSheets.getByIndex(1)); + xSheet[1] = oSheet; + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + ex = e; + } + catch(com.sun.star.lang.WrappedTargetException e) { + ex = e; + } + catch(java.lang.NullPointerException e) { + ex = e; + } + if (ex != null) { + throw new StatusException("Could not get two sheets.", ex); + } + + // get the draw page for checking the shapes + xDrawPage = (XDrawPage)tEnv.getObjRelation("XDocumentAuditing.DrawPage"); + if (xDrawPage == null) { // get from object + try { + XDrawPagesSupplier oDPS = (XDrawPagesSupplier) + UnoRuntime.queryInterface(XDrawPagesSupplier.class, oObj); + Object o = oDPS.getDrawPages().getByIndex(1); + xDrawPage = (XDrawPage)UnoRuntime.queryInterface(XDrawPage.class, o); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + } // ignore exceptions, we'll run into next if statement anyway + catch(com.sun.star.lang.WrappedTargetException e) { + } + } + if (xDrawPage == null) { + throw new StatusException(Status.failed("'XSheetAuditing.DrawPage' object relation not found.")); + } + if (xDrawPage.hasElements()) { + elementCount = xDrawPage.getCount(); + } + + // switch off the automatic refresh + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "AutoRefreshArrows"; + props[0].Value = Boolean.FALSE; + XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class, oObj); + dispatch(xModel.getCurrentController().getFrame(), (XMultiServiceFactory)tParam.getMSF(), ".uno:AutoRefreshArrows", props); + + // prepare the sheets + try { + xSheet[0].getCellByPosition(6, 6).setValue(9); + XNamed xNamed = (XNamed)UnoRuntime.queryInterface(XNamed.class, xSheet[0]); + sheetName = xNamed.getName(); + xSheet[1].getCellByPosition(6, 6).setValue(16); + xSheet[1].getCellByPosition(6, 7).setFormula("= SQRT(G7)"); + XSheetAuditing xSheetAuditing = (XSheetAuditing)UnoRuntime.queryInterface(XSheetAuditing.class, xSheet[1]); + CellAddress add = new CellAddress((short)1, 6, 7); + xSheetAuditing.showPrecedents(add); + boolean ok = hasRightAmountOfShapes(1); + if (!ok) + throw new StatusException(Status.failed("Wrong amount of shapes on page.")); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + throw new StatusException("Could not set formulas on sheets.", e); + } + } + + public void after() { + // switch the automatic refresh back on + PropertyValue[] props = new PropertyValue[1]; + props[0] = new PropertyValue(); + props[0].Name = "AutoRefreshArrows"; + props[0].Value = Boolean.TRUE; + XModel xModel = (XModel)UnoRuntime.queryInterface(XModel.class, oObj); + dispatch(xModel.getCurrentController().getFrame(), (XMultiServiceFactory)tParam.getMSF(), ".uno:AutoRefreshArrows", props); + } + + public void _refreshArrows() { + boolean result = true; + + Point p0 = pos; + + try { + result &= xSheet[1].getCellByPosition(6, 7).getValue() == 4; + xSheet[1].getCellByPosition(6, 7).setFormula("= SQRT(" + sheetName + ".G7)"); + result &= xSheet[1].getCellByPosition(6, 7).getValue() == 3; + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + throw new StatusException("Could not set formulas on sheets.", e); + } + + result &= hasRightAmountOfShapes(1); + Point p1 = pos; + + // points have to be the same: if not we have an auto update + boolean res = (p0.X == p1.X && p0.Y == p1.Y); + result &= res; + if (!res) + log.println("Arrow has been refreshed, but this should have been switched off."); + + oObj.refreshArrows(); + + result &= hasRightAmountOfShapes(1); + Point p2 = pos; + + // points have to differ + res = (p1.X != p2.X || p1.Y != p2.Y); + result &= res; + if (!res) + log.println("Arrow has not been refreshed."); + + tRes.tested("refreshArrows()", result); + } + + /** + * Check if the amount of shapes is the right one after displaying that stuff + * 2do improve this: check taht the shapes are the correct ones -> convwatch + * @desiredValue That's the amount of shapes that have to be here. + * @return True, if the actual count of shapes is the same + */ + private boolean hasRightAmountOfShapes(int desiredValue) { + int newCount = xDrawPage.getCount(); + if (newCount != elementCount + desiredValue) { + return false; + } + else { + if (desiredValue >= 0) { + for (int i=elementCount; i<newCount; i++) { + try { + Object o = xDrawPage.getByIndex(i); + XShape xShape = (XShape)UnoRuntime.queryInterface(XShape.class, o); + pos = xShape.getPosition(); + System.out.println("Shape Type: " + xShape.getShapeType()); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace(); + } + } + } + } + return true; + } + + private void dispatch(Object oProvider, XMultiServiceFactory xMSF, String url, PropertyValue[] prop) { + XDispatchProvider xDispatchProvider = (XDispatchProvider)UnoRuntime.queryInterface(XDispatchProvider.class, oProvider); + Object dispatcher = null; + try { + dispatcher = xMSF.createInstance("com.sun.star.frame.DispatchHelper"); + } + catch(com.sun.star.uno.Exception e) { + } + + XDispatchHelper xDispatchHelper = (XDispatchHelper)UnoRuntime.queryInterface(XDispatchHelper.class, dispatcher); + xDispatchHelper.executeDispatch(xDispatchProvider, url, "", 0, prop); + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster.java b/qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster.java new file mode 100644 index 000000000000..2034bb892047 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XEnhancedMouseClickBroadcaster.java @@ -0,0 +1,163 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.awt.Point; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XEnhancedMouseClickHandler; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XTopWindow; +import com.sun.star.awt.XWindow; +import com.sun.star.frame.XModel; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.XEnhancedMouseClickBroadcaster; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; + +import lib.MultiMethodTest; +import lib.StatusException; + +import util.AccessibilityTools; +import util.DesktopTools; +import util.utils; + +import java.awt.Robot; +import java.awt.event.InputEvent; + + +public class _XEnhancedMouseClickBroadcaster extends MultiMethodTest { + public XEnhancedMouseClickBroadcaster oObj; + protected boolean mousePressed = false; + protected boolean mouseReleased = false; + protected XEnhancedMouseClickHandler listener = new MyListener(); + private XModel docModel = null; + + public void before() { + docModel = (XModel) UnoRuntime.queryInterface( + XModel.class,tEnv.getObjRelation("FirstModel")); + DesktopTools.bringWindowToFront(docModel); + } + + public void _addEnhancedMouseClickHandler() { + oObj.addEnhancedMouseClickHandler(listener); + clickOnSheet(); + + //make sure that the listener is removed even if the test fails + if ((!mousePressed) || (!mouseReleased)) { + oObj.removeEnhancedMouseClickHandler(listener); + } + + tRes.tested("addEnhancedMouseClickHandler()", + mousePressed && mouseReleased); + } + + public void _removeEnhancedMouseClickHandler() { + requiredMethod("addEnhancedMouseClickHandler()"); + mousePressed = false; + mouseReleased = false; + oObj.removeEnhancedMouseClickHandler(listener); + clickOnSheet(); + tRes.tested("removeEnhancedMouseClickHandler()", + (!mousePressed) && (!mouseReleased)); + } + + protected boolean clickOnSheet() { + log.println("try to open contex menu..."); + AccessibilityTools at = new AccessibilityTools(); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)tParam.getMSF(), docModel); + + XAccessible xRoot = at.getAccessibleObject(xWindow); + + XInterface oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.PANEL); + + XAccessibleComponent window = (XAccessibleComponent) UnoRuntime.queryInterface( + XAccessibleComponent.class, oObj); + + Point point = window.getLocationOnScreen(); + Rectangle rect = window.getBounds(); + + log.println("klick mouse button..."); + try { + Robot rob = new Robot(); + int x = point.X + (rect.Width / 2)+50; + int y = point.Y + (rect.Height / 2)+50; + rob.mouseMove(x, y); + System.out.println("Press Button"); + rob.mousePress(InputEvent.BUTTON3_MASK); + System.out.println("Release Button"); + rob.mouseRelease(InputEvent.BUTTON3_MASK); + System.out.println("done"); + System.out.println("warte"); + shortWait(); + System.out.println("Press Button"); + rob.mousePress(InputEvent.BUTTON1_MASK); + System.out.println("Release Button"); + rob.mouseRelease(InputEvent.BUTTON1_MASK); + System.out.println("done "+rob.getAutoDelay()); + } catch (java.awt.AWTException e) { + log.println("couldn't press mouse button"); + } + + + return true; + } + + private void shortWait() { + try { + Thread.currentThread().sleep(2000); + } catch (InterruptedException e) { + System.out.println("While waiting :" + e); + } + } + + protected class MyListener implements XEnhancedMouseClickHandler { + public void disposing( + com.sun.star.lang.EventObject eventObject) { + } + + public boolean mousePressed( + com.sun.star.awt.EnhancedMouseEvent enhancedMouseEvent) { + log.println("mousePressed"); + mousePressed = true; + + return true; + } + + public boolean mouseReleased( + com.sun.star.awt.EnhancedMouseEvent enhancedMouseEvent) { + log.println("mouseReleased"); + mouseReleased = true; + + return true; + } + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XFormulaQuery.java b/qadevOOo/tests/java/ifc/sheet/_XFormulaQuery.java new file mode 100644 index 000000000000..3e04690ac47b --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XFormulaQuery.java @@ -0,0 +1,201 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XFormulaQuery; +import com.sun.star.sheet.XSheetCellRanges; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +import com.sun.star.uno.UnoRuntime; + +/** + * + * @author sw93809 + */ +public class _XFormulaQuery extends MultiMethodTest { + + public XFormulaQuery oObj; + + protected XSpreadsheet oSheet = null; + private XCell mxCell; + private int miQueryThisDependentRange = 1; + private int miQueryThisPrecedentRange = 1; + private int[] miExpectedDependentValues; + private int[] miExpectedPrecedentValues; + + protected void before() { + oSheet = (XSpreadsheet)tEnv.getObjRelation("SHEET"); + + if (oSheet == null) { + log.println("Object relation oSheet is missing"); + log.println("Trying to query the needed Interface"); + oSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, tEnv.getTestObject()); + + if (oSheet == null) { + throw new StatusException(Status.failed( + "Object relation oSheet is missing")); + } + } + Object o = tEnv.getObjRelation("MAKEENTRYINCELL"); + if (o != null) { + mxCell = (XCell)o; + } + else { + try { + mxCell = oSheet.getCellByPosition(15, 15); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + throw new StatusException( + Status.failed("Couldn't get initial cell")); + } + } + + o = tEnv.getObjRelation("RANGEINDICES"); + if (o != null) { + int[]index = (int[])o; + miQueryThisDependentRange = index[0]; + miQueryThisPrecedentRange = index[1]; + } + + o = tEnv.getObjRelation("EXPECTEDDEPENDENTVALUES"); + if (o != null) { + miExpectedDependentValues = (int[])o; + } + else { + miExpectedDependentValues = new int[4]; + miExpectedDependentValues[0] = 15; + miExpectedDependentValues[1] = 15; + miExpectedDependentValues[2] = 15; + miExpectedDependentValues[3] = 15; + } + + o = tEnv.getObjRelation("EXPECTEDPRECEDENTVALUES"); + if (o != null) { + miExpectedPrecedentValues = (int[])o; + } + else { + miExpectedPrecedentValues = new int[4]; + miExpectedPrecedentValues[0] = 0; + miExpectedPrecedentValues[1] = 0; + miExpectedPrecedentValues[2] = 15; + miExpectedPrecedentValues[3] = 15; + } + } + + public void _queryDependents() { + boolean res = true; + + try { + mxCell.setFormula("=sum(A1:D1)"); + oSheet.getCellByPosition(0, 0).setValue(1); + oSheet.getCellByPosition(1, 0).setValue(1); + oSheet.getCellByPosition(2, 0).setValue(1); + oSheet.getCellByPosition(3, 0).setValue(1); + + log.println( + "calling oObj.queryDependents(false)"); + XSheetCellRanges getting = oObj.queryDependents(false); + CellRangeAddress[] range = getting.getRangeAddresses(); + + res = ((range[miQueryThisDependentRange].StartColumn==miExpectedDependentValues[0]) && + (range[miQueryThisDependentRange].EndColumn==miExpectedDependentValues[1]) && + (range[miQueryThisDependentRange].StartRow==miExpectedDependentValues[2]) && + (range[miQueryThisDependentRange].EndRow==miExpectedDependentValues[3])); + + if (!res) { + log.println("Getting (" + +(range[miQueryThisDependentRange]).StartColumn+"," + +(range[miQueryThisDependentRange]).EndColumn+"," + +(range[miQueryThisDependentRange]).StartRow+"," + +(range[miQueryThisDependentRange]).EndRow+")"); + log.println("Expected (" + miExpectedDependentValues[0] + "," + + miExpectedDependentValues[1] + "," + + miExpectedDependentValues[2] + "," + + miExpectedDependentValues[3] + ")"); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't set initial version to cell"); + res = false; + } + + tRes.tested("queryDependents()", res); + } + + public void _queryPrecedents() { + boolean res = true; + + try { + mxCell.setFormula("=sum(A1:D1)"); + oSheet.getCellByPosition(0, 0).setValue(1); + oSheet.getCellByPosition(1, 0).setValue(1); + oSheet.getCellByPosition(2, 0).setValue(1); + oSheet.getCellByPosition(3, 0).setValue(1); + oSheet.getCellByPosition(1, 2).setFormula("=A16*2"); + + log.println( + "calling oObj.queryPrecedents(false)"); + XSheetCellRanges getting = oObj.queryPrecedents(false); + CellRangeAddress[] range = getting.getRangeAddresses(); + + res = ((range[miQueryThisPrecedentRange].StartColumn==miExpectedPrecedentValues[0]) && + (range[miQueryThisPrecedentRange].EndColumn==miExpectedPrecedentValues[1]) && + (range[miQueryThisPrecedentRange].StartRow==miExpectedPrecedentValues[2]) && + (range[miQueryThisPrecedentRange].EndRow==miExpectedPrecedentValues[3])); + + if (!res) { + log.println("Getting (" + +(range[miQueryThisPrecedentRange]).StartColumn+"," + +(range[miQueryThisPrecedentRange]).EndColumn+"," + +(range[miQueryThisPrecedentRange]).StartRow+"," + +(range[miQueryThisPrecedentRange]).EndRow+")"); + log.println("Expected (" + miExpectedPrecedentValues[0] + "," + + miExpectedPrecedentValues[1] + "," + + miExpectedPrecedentValues[2] + "," + + miExpectedPrecedentValues[3] + ")"); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't set initial version to cell"); + res = false; + } + + tRes.tested("queryPrecedents()", res); + } + + /** + * Forces environment recreation. + */ + protected void after() { + disposeEnvironment(); + } + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions.java b/qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions.java new file mode 100644 index 000000000000..5f16c7640fec --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XFunctionDescriptions.java @@ -0,0 +1,131 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import java.util.Random; + +import lib.MultiMethodTest; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.sheet.XFunctionDescriptions; + +/** +* Testing <code>com.sun.star.sheet.XFunctionDescriptions</code> +* interface methods : +* <ul> +* <li><code> getById()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XFunctionDescriptions +*/ +public class _XFunctionDescriptions extends MultiMethodTest { + + public XFunctionDescriptions oObj = null; + + /** + * Test finds available id, calls method using this id, checks returned + * value and then tries to get description with wrong id. <p> + * Has <b>OK</b> status if returned value is equal to value obtained by the + * method <code>getByIndex()</code> in first call and exception + * <code>IllegalArgumentException</code> was thrown in second call.<p> + * @see com.sun.star.lang.IllegalArgumentException + */ + public void _getById() { + boolean bResult = true; + // Finding available id... + + int count = oObj.getCount(); + if (count > 0) { + Random rnd = new Random(); + int nr = rnd.nextInt(count); + + PropertyValue[] PVals = null; + try { + PVals = (PropertyValue[])oObj.getByIndex(nr); + } catch(com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + tRes.tested("getById()", false); + return; + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + tRes.tested("getById()", false); + return; + } + + String FName = null; + Integer FId = null; + + for (int i = 0; i < PVals.length; i++) { + if (PVals[i].Name.equals("Name")) + FName = (String)PVals[i].Value; + if (PVals[i].Name.equals("Id")) + FId = (Integer)PVals[i].Value; + } + + log.println("The id of function '" + FName + "' is " + FId); + + PropertyValue[] PVals2 = null; + try { + PVals2 = oObj.getById(FId.intValue()); + } catch(com.sun.star.lang.IllegalArgumentException e) { + e.printStackTrace(log); + tRes.tested("getById()", false); + return; + } + + String objFName = null; + Integer objFId = null; + for (int i = 0; i < PVals2.length; i++) { + if (PVals2[i].Name.equals("Name")) + objFName = (String)PVals[i].Value; + if (PVals2[i].Name.equals("Id")) + objFId = (Integer)PVals[i].Value; + } + + log.println("The id of returned function '" + + objFName + "' is " + objFId); + + bResult &= FName.equals(objFName); + bResult &= FId.equals(objFId); + } + + log.println("OK."); + + try { + log.println("Now trying to get description with wrong id ... "); + oObj.getById(-1); + bResult = false; + log.println("Exception expected! - FAILED"); + } catch (com.sun.star.lang.IllegalArgumentException e) { + log.println("Expected exception " + e + " - OK!"); + } + + tRes.tested("getById()", bResult); + } +} // finish class _XFunctionDescriptions + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XGoalSeek.java b/qadevOOo/tests/java/ifc/sheet/_XGoalSeek.java new file mode 100644 index 000000000000..24dad9db4bda --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XGoalSeek.java @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.sheet.GoalResult; +import com.sun.star.sheet.XGoalSeek; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; +import com.sun.star.table.CellAddress; +import com.sun.star.uno.UnoRuntime; +import lib.MultiMethodTest; +import lib.StatusException; + +/** + * + */ +public class _XGoalSeek extends MultiMethodTest { + public XGoalSeek oObj = null; + XSpreadsheet xSheet = null; + CellAddress aFormula = null; + CellAddress aValue = null; + + public void before() { + Exception ex = null; + // get two sheets + try { + XSpreadsheetDocument xSpreadsheetDocument = (XSpreadsheetDocument) + UnoRuntime.queryInterface(XSpreadsheetDocument.class, oObj); + XSpreadsheets oSheets = xSpreadsheetDocument.getSheets(); + XIndexAccess oIndexSheets = (XIndexAccess) UnoRuntime.queryInterface( + XIndexAccess.class, oSheets); + xSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, oIndexSheets.getByIndex(1)); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + ex = e; + } + catch(com.sun.star.lang.WrappedTargetException e) { + ex = e; + } + catch(java.lang.NullPointerException e) { + ex = e; + } + if (ex != null) { + throw new StatusException("Could not get a sheet.", ex); + } + + // set value and formula + try { + xSheet.getCellByPosition(3, 4).setValue(9); + xSheet.getCellByPosition(3, 5).setFormula("= SQRT(D5)"); + aValue = new CellAddress((short)1, 3, 4); + aFormula = new CellAddress((short)1, 3, 5); + } + catch(Exception e) { + throw new StatusException("Could not get set formulas on the sheet.", e); + } + } + + public void _seekGoal() { + boolean result = true; + double divergence = 0.01; + GoalResult goal = oObj.seekGoal(aFormula, aValue, "4"); + log.println("Goal Result: " + goal.Result + " Divergence: " + goal.Divergence); + result &= goal.Divergence < divergence; + result &= goal.Result > 16 - divergence || goal.Result < 16 + divergence; + + goal = oObj.seekGoal(aFormula, aValue, "-4"); + log.println("Goal Result: " + goal.Result + " Divergence: " + goal.Divergence); + result &= goal.Divergence > 1/divergence; + result &= goal.Result < divergence || goal.Result > -divergence; + + // just curious: let goal seek find a limiting value + try { + xSheet.getCellByPosition(3, 4).setValue(0.8); + xSheet.getCellByPosition(3, 5).setFormula("= (D5 ^ 2 - 1) / (D5 - 1)"); + } + catch(Exception e) {} + goal = oObj.seekGoal(aFormula, aValue, "2"); + log.println("Goal Result: " + goal.Result + " Divergence: " + goal.Divergence); + result &= goal.Divergence < divergence; + result &= goal.Result > 16 - divergence || goal.Result < 16 + divergence; + + tRes.tested("seekGoal()", result); + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XHeaderFooterContent.java b/qadevOOo/tests/java/ifc/sheet/_XHeaderFooterContent.java new file mode 100644 index 000000000000..d3ee84f7cdc2 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XHeaderFooterContent.java @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XHeaderFooterContent; +import com.sun.star.text.XText; + +/** + * Testing <code>com.sun.star.sheet.XHeaderFooterContent</code> + * interface methods : + * <ul> + * <li><code> getLeftText()</code></li> + * <li><code> getCenterText()</code></li> + * <li><code> getRightText()</code></li> + * </ul> <p> + * + * @see com.sun.star.sheet.XHeaderFooterContent + */ +public class _XHeaderFooterContent extends MultiMethodTest { + + public XHeaderFooterContent oObj = null; + + /** + * Test calls the method and checks string obtained from returned value. <p> + * Has <b>OK</b> status if obtained string is equal to <code>"LEFT"</code>. + * <p> + */ + public void _getLeftText() { + XText left = oObj.getLeftText(); + tRes.tested("getLeftText()",left.getString().equals("LEFT")); + } + + /** + * Test calls the method and checks string obtained from returned value. <p> + * Has <b>OK</b> status if obtained string is equal to <code>"RIGHT"</code>. + * <p> + */ + public void _getRightText() { + XText right = oObj.getRightText(); + tRes.tested("getRightText()",right.getString().equals("RIGHT")); + } + + /** + * Test calls the method and checks string obtained from returned value. <p> + * Has <b>OK</b> status if obtained string is equal to <code>"CENTER"</code>. + * <p> + */ + public void _getCenterText() { + XText center = oObj.getCenterText(); + tRes.tested("getCenterText()",center.getString().equals("CENTER")); + } + +} // finish class _XHeaderFooterContent + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XLabelRange.java b/qadevOOo/tests/java/ifc/sheet/_XLabelRange.java new file mode 100644 index 000000000000..3bc34fdef5bd --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XLabelRange.java @@ -0,0 +1,109 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import util.ValueComparer; + +import com.sun.star.sheet.XLabelRange; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XLabelRange</code> +* interface methods : +* <ul> +* <li><code> getLabelArea()</code></li> +* <li><code> setLabelArea()</code></li> +* <li><code> getDataArea()</code></li> +* <li><code> setDataArea()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XLabelRange +*/ +public class _XLabelRange extends MultiMethodTest { + + public XLabelRange oObj = null; + public CellRangeAddress setDAddress = null; + public CellRangeAddress setLAddress = null; + + /** + * Test creates and stores <code>CellRangeAddress</code>, calls the method. + * <p>Has <b> OK </b> status if the method successfully returns. <p> + * @see com.sun.star.table.CellRangeAddress + */ + public void _setDataArea() { + int nr = Thread.activeCount(); + setDAddress = new CellRangeAddress((short)1, nr, 1, nr, 8); + oObj.setDataArea(setDAddress); + tRes.tested("setDataArea()", true); + } + + /** + * Test creates and stores <code>CellRangeAddress</code>, calls the method. + * <p>Has <b> OK </b> status if the method successfully returns. <p> + * @see com.sun.star.table.CellRangeAddress + */ + public void _setLabelArea() { + int nr = Thread.activeCount(); + setLAddress = new CellRangeAddress((short)1, nr, 0, nr, 0); + oObj.setLabelArea(setLAddress); + tRes.tested("setLabelArea()", true); + } + + /** + * Test calls the method and compares returned value with value that was set. + * <p>Has <b> OK </b> status if values are equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setDataArea() </code> : to have address of the cell range for + * which the labels are valid</li> + * </ul> + */ + public void _getDataArea() { + requiredMethod("setDataArea()"); + CellRangeAddress gA = oObj.getDataArea(); + tRes.tested("getDataArea()", ValueComparer.equalValue(gA, setDAddress)); + } + + /** + * Test calls the method and compares returned value with value set before. + * <p>Has <b> OK </b> status if if values are equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setLabelArea() </code>: to have the cell range that contains + * the labels</li> + * </ul> + */ + public void _getLabelArea() { + requiredMethod("setLabelArea()"); + CellRangeAddress gA1 = oObj.getLabelArea(); + tRes.tested("getLabelArea()", + ValueComparer.equalValue(gA1, setLAddress)); + } +} // finish class _XLabelRange + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XLabelRanges.java b/qadevOOo/tests/java/ifc/sheet/_XLabelRanges.java new file mode 100644 index 000000000000..9d4d28ff634c --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XLabelRanges.java @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XLabelRanges; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XLabelRanges</code> +* interface methods : +* <ul> +* <li><code> addNew()</code></li> +* <li><code> removeByIndex()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XLabelRanges +*/ +public class _XLabelRanges extends MultiMethodTest { + + public XLabelRanges oObj = null; + + /** + * Test calls the method and compares number of label range before method + * call and after. <p> + * Has <b>OK</b> status if number of label range before method call is less + * than after and no exceptions were thrown. <p> + */ + public void _addNew() { + int anz = oObj.getCount(); + oObj.addNew( + new CellRangeAddress((short)0, 1, 0, 1, 0), + new CellRangeAddress((short)0, 1, 1, 1, 6) ); + tRes.tested("addNew()", anz < oObj.getCount()); + } + + /** + * Test removes an existent label range first and tries to remove + * non-existent label range. <p> + * Has <b> OK </b> status if number of range decreased by one after first + * call and exception was thrown in second. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> addNew() </code> : to have one label range at least </li> + * </ul> + */ + public void _removeByIndex() { + requiredMethod("addNew()"); + int anz = oObj.getCount(); + log.println("First remove an existent LabelRange"); + + oObj.removeByIndex(anz - 1); + boolean result = (anz - 1 == oObj.getCount()); + + log.println("Remove a nonexistent LabelRange"); + try { + oObj.removeByIndex(anz); + log.println("No Exception thrown while removing nonexisting "+ + "LabelRange"); + result &= false; + } catch (com.sun.star.uno.RuntimeException e) { + log.println("Expected exception thrown while removing "+ + "nonexisting LabelRange: "+e); + result &= true; + } + + tRes.tested("removeByIndex()", result); + } + +} // finish class _XLabelRanges + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XMultipleOperation.java b/qadevOOo/tests/java/ifc/sheet/_XMultipleOperation.java new file mode 100644 index 000000000000..e10ca8d55f2f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XMultipleOperation.java @@ -0,0 +1,182 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.awt.Point; +import com.sun.star.sheet.TableOperationMode; +import com.sun.star.sheet.XCellAddressable; +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XMultipleOperation; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + + +public class _XMultipleOperation extends MultiMethodTest { + public XMultipleOperation oObj = null; + protected XSpreadsheet oSheet = null; + boolean both = true; + + protected void before() { + oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET"); + + if (oSheet == null) { + throw new StatusException(Status.failed( + "Object relation oSheet is missing")); + } + + if (UnoRuntime.queryInterface(XSpreadsheet.class, tEnv.getTestObject()) != null) { + log.println("We have a sheet and won't do TableOperationMode.BOTH"); + both = false; + } + } + + public void _setTableOperation() { + boolean res = true; + XCellRange cellRange = oSheet.getCellRangeByName("$A$17:$A$17"); + XCellRangeAddressable CRA = (XCellRangeAddressable) UnoRuntime.queryInterface( + XCellRangeAddressable.class, + cellRange); + XCell cell = null; + XCell cell2 = null; + + try { + cell = oSheet.getCellByPosition(0, 16); + cell.setFormula("=a15+a16"); + cell = oSheet.getCellByPosition(0, 14); + cell2 = oSheet.getCellByPosition(0, 15); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception while getting Cell " + e.getMessage()); + } + + XCellAddressable CA = (XCellAddressable) UnoRuntime.queryInterface( + XCellAddressable.class, cell); + XCellAddressable CA2 = (XCellAddressable) UnoRuntime.queryInterface( + XCellAddressable.class, cell2); + Point[] cellCoords = new Point[3]; + double[] cellValues = new double[3]; + + log.println("filling cells"); + fillCells(); + log.println("setting TableOperation with parameter ROW"); + oObj.setTableOperation(CRA.getRangeAddress(), TableOperationMode.ROW, + CA.getCellAddress(), CA2.getCellAddress()); + log.println("checking values"); + cellCoords = new Point[] { + new Point(1, 1), new Point(2, 1), new Point(3, 1) + }; + cellValues = new double[] { 5, 10, 15 }; + res &= checkValues(cellCoords, cellValues); + + log.println("filling cells"); + fillCells(); + log.println("setting TableOperation with parameter COLUMN"); + oObj.setTableOperation(CRA.getRangeAddress(), + TableOperationMode.COLUMN, CA.getCellAddress(), + CA2.getCellAddress()); + log.println("checking values"); + cellCoords = new Point[] { + new Point(1, 1), new Point(1, 2), new Point(1, 3) + }; + cellValues = new double[] { 12, 24, 36 }; + res &= checkValues(cellCoords, cellValues); + + if (both) { + log.println("filling cells"); + fillCells(); + log.println("setting TableOperation with parameter BOTH"); + oObj.setTableOperation(CRA.getRangeAddress(), + TableOperationMode.BOTH, + CA.getCellAddress(), CA2.getCellAddress()); + log.println("checking values"); + cellCoords = new Point[] { + new Point(1, 1), new Point(2, 2), new Point(3, 3) + }; + cellValues = new double[] { 17, 34, 51 }; + res &= checkValues(cellCoords, cellValues); + } + + tRes.tested("setTableOperation()", res); + } + + protected void fillCells() { + XCell cell = null; + + try { + for (int k = 1; k < 5; k++) { + cell = oSheet.getCellByPosition(0, k); + cell.setValue(k * 12); + cell = oSheet.getCellByPosition(k, 0); + cell.setValue(k * 5); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception while filling Cells " + e.getMessage()); + } + } + + protected boolean checkValues(Point[] cellCoords, double[] cellValues) { + boolean res = true; + + for (int i = 0; i < cellValues.length; i++) { + try { + boolean locres = oSheet.getCellByPosition(cellCoords[i].X, + cellCoords[i].Y) + .getValue() == cellValues[i]; + res &= locres; + + if (!locres) { + log.println("Result differs for cell (" + + cellCoords[i].X + "," + cellCoords[i].Y + + ")"); + log.println("Expected: " + cellValues[i]); + log.println("Getting: " + + oSheet.getCellByPosition(cellCoords[i].X, + cellCoords[i].Y) + .getValue()); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Exception while checking Values " + + e.getMessage()); + res &= false; + } + } + + return res; + } + + /** + * Restores initial component text. + */ + protected void after() { + disposeEnvironment(); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XNamedRange.java b/qadevOOo/tests/java/ifc/sheet/_XNamedRange.java new file mode 100644 index 000000000000..06c76956adff --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XNamedRange.java @@ -0,0 +1,209 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import java.util.Random; +import java.util.StringTokenizer; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.NamedRangeFlag; +import com.sun.star.sheet.XNamedRange; +import com.sun.star.table.CellAddress; + +/** +* Testing <code>com.sun.star.sheet.XNamedRange</code> +* interface methods : +* <ul> +* <li><code> getContent()</code></li> +* <li><code> setContent()</code></li> +* <li><code> getReferencePosition()</code></li> +* <li><code> setReferencePosition()</code></li> +* <li><code> getType()</code></li> +* <li><code> setType()</code></li> +* </ul> <p> +* After test completion object environment has to be recreated. +* @see com.sun.star.sheet.XNamedRange +*/ +public class _XNamedRange extends MultiMethodTest { + + public XNamedRange oObj = null; + String sContent = ""; + int type = 0; + CellAddress CA = null; + + /** + * Test calls the method and compares returned value to value that was set + * by method <code>setContent()</code>. <p> + * Has <b> OK </b> status if values are equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setContent() </code> : to have current content </li> + * </ul> + */ + public void _getContent() { + requiredMethod("setContent()"); + String content = oObj.getContent(); + log.println("Returned content is \"" + content + "\""); + boolean bResult = content.equals(sContent); + tRes.tested("getContent()", bResult); + } + + /** + * Test creates and stores random content and calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _setContent() { + sContent = getRandomContent("A1;A4:C5;=B2"); + log.println("Set content to \"" + sContent + "\""); + oObj.setContent(sContent); + + tRes.tested("setContent()", true); + } + + /** + * Test calls the method and compares returned value to value that was set + * by method <code>setType()</code>. <p> + * Has <b> OK </b> status if values are equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setType() </code> : to have current type </li> + * </ul> + */ + public void _getType() { + requiredMethod("setType()"); + + int rtype = oObj.getType(); + log.println("Returned type is " + rtype); + + tRes.tested("getType()", type == rtype); + } + + /** + * Test sets random type and stores it. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _setType() { + /* + * The type must be 0 or a combination of the NamedRangeFlag + * constants and controls if the named range is listed in + * dialogs prompting for special ranges + * + * NamedRangeFlag: COLUMN_HEADER + * FILTER_CRITERIA + * PRINT_AREA + * ROW_HEADER + * + */ + boolean bResult = true; + int types[] = { 0, + NamedRangeFlag.COLUMN_HEADER, + NamedRangeFlag.FILTER_CRITERIA, + NamedRangeFlag.PRINT_AREA, + NamedRangeFlag.ROW_HEADER + }; + + Random rnd = new Random(); + type = types[rnd.nextInt(5)]; + + oObj.setType(type); + log.println("The type was set to " + type); + + tRes.tested("setType()", bResult); + } + + /** + * Test calls the method and compares returned value to value that was set + * by method <code>setReferencePosition()</code>. <p> + * Has <b> OK </b> status if all fields of values are equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setReferencePosition() </code> : to have current reference + * position </li> + * </ul> + */ + public void _getReferencePosition() { + requiredMethod("setReferencePosition()"); + + CellAddress rCA = oObj.getReferencePosition(); + log.println("getReferencePosition returned (" + + rCA.Sheet + ", " + + rCA.Column + ", " + rCA.Row + ")" ); + + boolean bResult = rCA.Sheet == CA.Sheet; + bResult &= rCA.Column == CA.Column; + bResult &= rCA.Row == CA.Row; + + tRes.tested("getReferencePosition()", bResult); + } + + /** + * Test creates and stores cell address and calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _setReferencePosition() { + CA = new CellAddress((short)0, 2, 3); + oObj.setReferencePosition(CA); + log.println("ReferencePosition was set to (" + + CA.Sheet + ", " + + CA.Column + ", " + CA.Row + ")"); + + tRes.tested("setReferencePosition()", true); + } + + + /** + * Method make string of random content. + * @return string of random content + */ + String getRandomContent(String str) { + + String gRS = "none"; + Random rnd = new Random(); + + StringTokenizer ST = new StringTokenizer(str, ";"); + int nr = rnd.nextInt(ST.countTokens()); + if (nr < 1) nr++; + + for (int i = 1; i < nr + 1; i++) + gRS = ST.nextToken(); + + return gRS; + + } + + /** + * Forces object environment recreation. + */ + protected void after() { + disposeEnvironment(); + } + +} + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XNamedRanges.java b/qadevOOo/tests/java/ifc/sheet/_XNamedRanges.java new file mode 100644 index 000000000000..6baffd4bfdfe --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XNamedRanges.java @@ -0,0 +1,327 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import java.util.Random; +import java.util.StringTokenizer; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.sheet.Border; +import com.sun.star.sheet.NamedRangeFlag; +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XCellRangeReferrer; +import com.sun.star.sheet.XNamedRanges; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.CellAddress; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextRange; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XNamedRanges</code> +* interface methods : +* <ul> +* <li><code> addNewByName()</code></li> +* <li><code> addNewFromTitles()</code></li> +* <li><code> removeByName()</code></li> +* <li><code> outputList()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'SHEET'</code> (of type <code>XSpreadsheet</code>): +* to have a spreadsheet </li> +* <ul> <p> +* @see com.sun.star.sheet.XNamedRanges +* @see com.sun.star.sheet.XSpreadsheet +*/ +public class _XNamedRanges extends MultiMethodTest { + + public XNamedRanges oObj = null; + String name = "_XNamedRanges"; + XSpreadsheet oSheet = null; + + /** + * Retrieves object relations. + * @throws StatusException If one of relations not found. + */ + protected void before() { + oSheet = (XSpreadsheet)tEnv.getObjRelation("SHEET"); + if (oSheet == null) throw new StatusException(Status.failed + ("Relation 'SHEET' not found")); + } + + /** + * Test creates and stores random content and random type, calls the method + * and checks that new range exists in collection using method + * <code>hasByName()</code>. <p> + * Has <b> OK </b> status if new range exists in collection + * and no exceptions were thrown. <p> + */ + public void _addNewByName() { + boolean bResult = true; + CellAddress aPosition = new CellAddress((short)0, 2, 2); + int nType = getRandomType(); + String sContent = getRandomContent("D3;A6:B9;=F12"); + name += sContent; + log.println("Adding new range with name=\"" + name + + "\", sContent = \"" + sContent + + "\", aPosition = (" + aPosition.Sheet + ", " + + aPosition.Column + ", " + + aPosition.Row + + "), Type = " + nType + "."); + + oObj.addNewByName(name, sContent, aPosition, nType); + + //inserted for a bug + CellAddress listOutputPosition = new CellAddress((short)0, 1, 1); + oObj.outputList(listOutputPosition); + String s = null; + String s1 = null; + try { + s = oSheet.getCellByPosition(1, 1).getFormula(); + s1 = oSheet.getCellByPosition(2, 1).getFormula(); + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Can't get cell by position: " + e); + bResult = false; + } + log.println("Outputlist returns: " + s + " " + s1); + //end of insertion + + bResult &= oObj.hasByName(name); + + tRes.tested("addNewByName()", bResult); + } + + /** + * Test creates a table with left and top titles, creates new ranges from + * top titles and left titles, checks all new title ranges. <p> + * Has <b> OK </b> status if all required title ranges are present + * in collection, if each of them have valid size and position and + * no exceptions were thrown. <p> + */ + public void _addNewFromTitles() { + boolean bResult = true; + + // First, create a small table. + log.println("Creating a small table."); + try { + XCell cell = null; + XTextRange textrange = null; + + for (int i = 1; i < 4; i++) { + cell = oSheet.getCellByPosition(0, i); + textrange = (XTextRange)UnoRuntime. + queryInterface(XTextRange.class, cell); + textrange.setString("Row" + i); + + cell = oSheet.getCellByPosition(i, 0); + textrange = (XTextRange)UnoRuntime. + queryInterface(XTextRange.class, cell); + textrange.setString("Column" + i); + } + + for (int i = 1; i < 4; i++) + for (int j = 1; j < 4; j++) { + cell = oSheet.getCellByPosition(i, j); + textrange = (XTextRange)UnoRuntime. + queryInterface(XTextRange.class, cell); + textrange.setString("Val" + ((j - 1) * 3 + i)); + } + log.println("Finished creating table."); + log.println("Creating new ranges from titles"); + + CellRangeAddress CRA = new CellRangeAddress((short)0, 0, 0, 3, 3); + Border border = Border.TOP; + oObj.addNewFromTitles(CRA, border); + for (int i = 1; i < 4; i++) { + bResult &= oObj.hasByName("Column" + i); + + Object range = oObj.getByName("Column" + i); + XCellRangeReferrer CRR = (XCellRangeReferrer)UnoRuntime. + queryInterface(XCellRangeReferrer.class,range); + + XCellRange CR = CRR.getReferredCells(); + XCellRangeAddressable xCRA = (XCellRangeAddressable) + UnoRuntime.queryInterface(XCellRangeAddressable.class, CR); + + CellRangeAddress objCRA = xCRA.getRangeAddress(); + + bResult &= (objCRA.EndColumn == i && objCRA.StartColumn == i); + bResult &= objCRA.StartRow == 1; + bResult &= objCRA.EndRow == 3; + bResult &= objCRA.Sheet == 0; + } + + border = Border.LEFT; + oObj.addNewFromTitles(CRA, border); + for (int i = 1; i < 4; i++) { + bResult &= oObj.hasByName("Row" + i); + + Object range = oObj.getByName("Row" + i); + XCellRangeReferrer CRR = (XCellRangeReferrer)UnoRuntime. + queryInterface(XCellRangeReferrer.class,range); + + XCellRange CR = CRR.getReferredCells(); + XCellRangeAddressable xCRA = (XCellRangeAddressable) + UnoRuntime.queryInterface(XCellRangeAddressable.class, CR); + + CellRangeAddress objCRA = xCRA.getRangeAddress(); + + bResult &= (objCRA.EndRow == i && objCRA.StartRow == i); + bResult &= objCRA.StartColumn == 1; + bResult &= objCRA.EndColumn == 3; + bResult &= objCRA.Sheet == 0; + } + + oObj.outputList(new CellAddress((short)0, 5, 5)); + + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + bResult = false; + } catch (com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + bResult = false; + } catch (com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(log); + bResult = false; + } + + tRes.tested("addNewFromTitles()", bResult); + } + + /** + * Test calls the method and checks existing of named ranges obtained + * by relation <code>'SHEET'</code>. <p> + * Has <b> OK </b> status if all output named ranges exist + * and no exceptions were thrown. <p> + */ + public void _outputList() { + boolean bResult = true; + CellAddress CA = new CellAddress((short)0, 0, 0); + + XIndexAccess IA = (XIndexAccess)UnoRuntime. + queryInterface(XIndexAccess.class, oObj); + + int elementsCount = IA.getCount(); + + oObj.outputList(CA); + + try { + for (int i = 0; i < elementsCount; i++) { + XCell cell = oSheet.getCellByPosition(0, i); + XTextRange textrange = (XTextRange) + UnoRuntime.queryInterface(XTextRange.class, cell); + String str = textrange.getString(); + bResult &= oObj.hasByName(str); + } + } catch(com.sun.star.lang.IndexOutOfBoundsException e) { + e.printStackTrace(log); + bResult = false; + } + + tRes.tested("outputList()", bResult); + } + + /** + * Test calls the method for existing range, checks number of ranges in + * collection after method call, calls method for non-existent named range. + * <p>Has <b> OK </b> status if number of named ranges is less by one than + * before method call and exception was thrown during second call. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> addNewByName() </code> : to have name of existent + * named range </li> + * </ul> + */ + public void _removeByName() { + requiredMethod("addNewByName()"); + boolean bResult = true; + XIndexAccess IA = (XIndexAccess)UnoRuntime. + queryInterface(XIndexAccess.class, oObj); + + int elementsCount = IA.getCount(); + + // Removing existent element + oObj.removeByName(name); + bResult = elementsCount == IA.getCount() + 1; + + try { + // Removing unexistent element. + oObj.removeByName(name); + log.println("Exception expected when removed unexistent element!"); + bResult = false; + } catch (com.sun.star.uno.RuntimeException e) { + log.println("Expected exception occured while testing" + + "removeByName() when removed unexistent element."); + + } + + tRes.tested("removeByName()", bResult); + } + + /** + * Method make string of random content. + * @return string of random content + */ + String getRandomContent(String str) { + String gRS = "none"; + Random rnd = new Random(); + + StringTokenizer ST = new StringTokenizer(str, ";"); + int nr = rnd.nextInt(ST.countTokens()); + if (nr < 1) + nr++; + + for (int i=1; i < nr + 1; i++) + gRS = ST.nextToken(); + + return gRS; + } + + /** + * Returns random value of named range flag. + */ + int getRandomType(){ + int types[] = { 0, + NamedRangeFlag.COLUMN_HEADER, + NamedRangeFlag.FILTER_CRITERIA, + NamedRangeFlag.PRINT_AREA, + NamedRangeFlag.ROW_HEADER + }; + + Random rnd = new Random(); + return types[rnd.nextInt(5)]; + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XPrintAreas.java b/qadevOOo/tests/java/ifc/sheet/_XPrintAreas.java new file mode 100644 index 000000000000..9c4e865bd52a --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XPrintAreas.java @@ -0,0 +1,158 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XPrintAreas; +import com.sun.star.table.CellRangeAddress; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.ValueComparer; + +/** + * + */ +public class _XPrintAreas extends MultiMethodTest { + public XPrintAreas oObj = null; + CellRangeAddress address = null; + CellRangeAddress subaddress = null; + CellRangeAddress titleColumns; + CellRangeAddress titleRows; + + public void before() { + address = (CellRangeAddress)tEnv.getObjRelation("CellRangeAddress"); + subaddress = (CellRangeAddress)tEnv.getObjRelation("CellRangeSubAddress"); + if (address == null) + throw new StatusException(Status.failed("Object relation CellRangeAddress not found")); + if (subaddress == null) + throw new StatusException(Status.failed("Object relation CellRangeSubAddress not found")); + } + + public void _getPrintAreas() { + requiredMethod("getPrintTitleColumns()"); + requiredMethod("getPrintTitleRows()"); + executeMethod("getTitleColumns()"); + executeMethod("getTitleRows()"); + CellRangeAddress[] printAreas = oObj.getPrintAreas(); + CellRangeAddress[] setValue = new CellRangeAddress[]{address}; + boolean ret = ValueComparer.equalValue(printAreas, setValue); + // delete the print area + oObj.setPrintAreas(null); + printAreas = oObj.getPrintAreas(); + ret &= printAreas.length == 0; + + tRes.tested("getPrintAreas()", ret); + } + + public void _getPrintTitleColumns() { + requiredMethod("setPrintTitleColumns()"); + tRes.tested("getPrintTitleColumns()", !oObj.getPrintTitleColumns()); + } + + public void _getPrintTitleRows() { + requiredMethod("setPrintTitleRows()"); + tRes.tested("getPrintTitleRows()", !oObj.getPrintTitleRows()); + } + + public void _getTitleColumns() { + requiredMethod("setTitleColumns()"); + CellRangeAddress setValue = oObj.getTitleColumns(); + tRes.tested("getTitleColumns()", ValueComparer.equalValue(setValue,titleColumns)); + } + + public void _getTitleRows() { + requiredMethod("setTitleRows()"); + CellRangeAddress setValue = oObj.getTitleRows(); + tRes.tested("getTitleRows()", ValueComparer.equalValue(setValue,titleRows)); + } + + public void _setPrintAreas() { + boolean ret = false; + CellRangeAddress[]setValue = new CellRangeAddress[]{subaddress}; + oObj.setPrintAreas(setValue); + CellRangeAddress[]newVal = oObj.getPrintAreas(); + ret = ValueComparer.equalValue(newVal, setValue); + setValue = new CellRangeAddress[]{address}; + oObj.setPrintAreas(setValue); + newVal = oObj.getPrintAreas(); + ret &= ValueComparer.equalValue(newVal, setValue); + tRes.tested("setPrintAreas()", ret); + } + + public void _setPrintTitleColumns() { + requiredMethod("setTitleColumns()"); + boolean ret = false; + boolean value = oObj.getPrintTitleColumns(); + oObj.setPrintTitleColumns(!value); + ret = value != oObj.getPrintTitleColumns(); + oObj.setPrintTitleColumns(false); + tRes.tested("setPrintTitleColumns()", ret); + } + + public void _setPrintTitleRows() { + requiredMethod("setTitleRows()"); + boolean ret = false; + boolean value = oObj.getPrintTitleRows(); + oObj.setPrintTitleRows(!value); + ret = value != oObj.getPrintTitleRows(); + oObj.setPrintTitleRows(false); + tRes.tested("setPrintTitleRows()", ret); + } + + public void _setTitleColumns() { + requiredMethod("setPrintAreas()"); + boolean ret = false; + CellRangeAddress newVal = oObj.getTitleColumns(); + ret = ValueComparer.equalValue(newVal, new CellRangeAddress((short)0, 0, 0, 0, 0)); + // use first row of range as title column + titleColumns = new CellRangeAddress(); + titleColumns.Sheet = address.Sheet; + titleColumns.StartColumn = address.StartColumn; + titleColumns.StartRow = address.StartRow; + titleColumns.EndColumn = address.EndColumn; + titleColumns.EndRow = address.StartRow; + oObj.setTitleColumns(titleColumns); + tRes.tested("setTitleColumns()", ret); + } + + public void _setTitleRows() { + requiredMethod("setPrintAreas()"); + boolean ret = false; + CellRangeAddress newVal = oObj.getTitleRows(); + ret = ValueComparer.equalValue(newVal, new CellRangeAddress((short)0, 0, 0, 0, 0)); + // use first column of range as title row + titleRows = new CellRangeAddress(); + titleRows.Sheet = address.Sheet; + titleRows.StartColumn = address.StartColumn; + titleRows.StartRow = address.StartRow; + titleRows.EndColumn = address.StartColumn; + titleRows.EndRow = address.EndRow; + oObj.setTitleColumns(titleRows); + tRes.tested("setTitleRows()", ret); + } + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XRangeSelection.java b/qadevOOo/tests/java/ifc/sheet/_XRangeSelection.java new file mode 100644 index 000000000000..bb61dbe55049 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XRangeSelection.java @@ -0,0 +1,380 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleComponent; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.awt.Point; +import com.sun.star.awt.PosSize; +import com.sun.star.awt.Rectangle; +import com.sun.star.awt.XExtendedToolkit; +import com.sun.star.awt.XTopWindow; +import com.sun.star.awt.XWindow; +import com.sun.star.beans.PropertyValue; +import com.sun.star.frame.XModel; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sheet.RangeSelectionEvent; +import com.sun.star.sheet.XRangeSelection; +import com.sun.star.sheet.XRangeSelectionChangeListener; +import com.sun.star.sheet.XRangeSelectionListener; +import com.sun.star.uno.UnoRuntime; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.io.PrintWriter; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.AccessibilityTools; + +/** + * Check the XRangeSelection interface. + */ +public class _XRangeSelection extends MultiMethodTest { + public XRangeSelection oObj = null; + MyRangeSelectionListener aListener = null; + + public void before() { + aListener = new _XRangeSelection.MyRangeSelectionListener(log); + // workaround for i34499 + XModel xModel = (XModel)tEnv.getObjRelation("FirstModel"); + if (xModel == null) + throw new StatusException(Status.failed("Object relation FirstModel' not set.")); + XWindow xWindow = xModel.getCurrentController().getFrame().getContainerWindow(); + XTopWindow xTopWindow = (XTopWindow)UnoRuntime.queryInterface(XTopWindow.class, xWindow); + xTopWindow.toFront(); + util.utils.shortWait(500); + } + + + public void _abortRangeSelection() { + requiredMethod("removeRangeSelectionChangeListener()"); + requiredMethod("removeRangeSelectionListener()"); + oObj.abortRangeSelection(); + tRes.tested("abortRangeSelection()", true); + } + + public void _addRangeSelectionChangeListener() { + oObj.addRangeSelectionChangeListener(aListener); + tRes.tested("addRangeSelectionChangeListener()", true); + } + + public void _addRangeSelectionListener() { + oObj.addRangeSelectionListener(aListener); + tRes.tested("addRangeSelectionListener()", true); + } + + public void _removeRangeSelectionChangeListener() { + oObj.removeRangeSelectionChangeListener(aListener); + tRes.tested("removeRangeSelectionChangeListener()", true); + } + + public void _removeRangeSelectionListener() { + oObj.removeRangeSelectionListener(aListener); + tRes.tested("removeRangeSelectionListener()", true); + } + + public void _startRangeSelection() { + requiredMethod("addRangeSelectionChangeListener()"); + requiredMethod("addRangeSelectionListener()"); + + // get the sheet center + Point center = getSheetCenter();; + if (center == null) + throw new StatusException(Status.failed("Couldn't get the sheet center.")); + + PropertyValue[] props = new PropertyValue[3]; + props[0] = new PropertyValue(); + props[0].Name = "InitialValue"; + props[0].Value = "B3:D5"; + props[1] = new PropertyValue(); + props[1].Name = "Title"; + props[1].Value = "the title"; + props[2] = new PropertyValue(); + props[2].Name = "CloseOnMouseRelease"; + props[2].Value = Boolean.FALSE; + oObj.startRangeSelection(props); + // wait for listeners + util.utils.shortWait(1000); + + // get closer button: move if window cobvers the sheet center + Point closer = getCloser(center); + if (closer == null) + throw new StatusException(Status.failed("Couldn't get the close Button.")); + + // do something to trigger the listeners + clickOnSheet(center); + util.utils.shortWait(5000); + + // click on closer + clickOnSheet(closer); + util.utils.shortWait(5000); + +// System.out.println("X: " + closer.X + " Y: " + closer.Y); + + // just check that we do not have the page instead of the range descriptor +/* int childCount = xRoot.getAccessibleContext().getAccessibleChildCount(); + if (childCount > 3) {// too many children: wrong type + throw new StatusException(Status.failed("Could not get the Range Descriptor")); + } + XAccessible xAcc = null; + try { + xAcc = xRoot.getAccessibleContext().getAccessibleChild(1); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + + } + accTools.printAccessibleTree(log, xAcc); +*/ + // open a new range selection + props[0].Value = "C4:E6"; + oObj.startRangeSelection(props); + util.utils.shortWait(1000); + props[0].Value = "C2:E3"; + oObj.startRangeSelection(props); + util.utils.shortWait(1000); + + oObj.startRangeSelection(props); + util.utils.shortWait(1000); + oObj.abortRangeSelection(); + aListener.reset(); + System.out.println("Listener called: " + aListener.bAbortCalled); + + tRes.tested("startRangeSelection()", aListener.listenerCalled()); + } + + /** + * Determine the current top window center and return this as a point. + * @ return a point representing the sheet center. + */ + protected Point getSheetCenter() { + log.println("Trying to get AccessibleSpreadsheet"); + AccessibilityTools at = new AccessibilityTools(); + XComponent xSheetDoc = (XComponent) tEnv.getObjRelation("DOCUMENT"); + + XModel xModel = (XModel) + UnoRuntime.queryInterface(XModel.class, xSheetDoc); + System.out.println("Name: " + xModel.getCurrentController().getFrame().getName()); + + XWindow xWindow = at.getCurrentWindow((XMultiServiceFactory)tParam.getMSF(), xModel); + XAccessible xRoot = at.getAccessibleObject(xWindow); + + at.getAccessibleObjectForRole(xRoot, AccessibleRole.TABLE ); + + XAccessibleComponent AccessibleSpreadsheet = (XAccessibleComponent) UnoRuntime.queryInterface(XAccessibleComponent.class,AccessibilityTools.SearchedContext); + + log.println("Got " + util.utils.getImplName(AccessibleSpreadsheet)); + + Object toolkit = null; + + try { + toolkit = ((XMultiServiceFactory)tParam.getMSF()).createInstance("com.sun.star.awt.Toolkit"); + } catch (com.sun.star.uno.Exception e) { + log.println("Couldn't get toolkit"); + e.printStackTrace(log); + throw new StatusException("Couldn't get toolkit", e); + } + + XExtendedToolkit tk = (XExtendedToolkit) UnoRuntime.queryInterface( + XExtendedToolkit.class, toolkit); + + XTopWindow tw = null; + + int k = tk.getTopWindowCount(); + for (int i=0;i<k;i++) { + try { + XTopWindow tw_temp = tk.getTopWindow(i); + XAccessible xacc = (XAccessible) UnoRuntime.queryInterface(XAccessible.class, tw_temp); + if (xacc != null) { + if (xacc.getAccessibleContext().getAccessibleName().indexOf("d2")>0) { + tw=tw_temp; + }; + } else { + log.println("\t unknown window"); + } + + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + if (tw == null) { + System.out.println("No TopWindow :-("); + return null; + } + + Point point = AccessibleSpreadsheet.getLocationOnScreen(); + Rectangle rect = AccessibleSpreadsheet.getBounds(); + Point retPoint = new Point(); + retPoint.X = point.X + (rect.Width / 2); + retPoint.Y = point.Y + (rect.Height / 2); + return retPoint; + } + + /** + * Get the closer button on the right top of the current window. + * @return A point representing the closer button. + */ + private Point getCloser(Point center) { + XMultiServiceFactory xMSF = (XMultiServiceFactory)tParam.getMSF(); + Object aToolkit = null; + try { + aToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit"); + } + catch(com.sun.star.uno.Exception e) { + throw new StatusException("Could not create 'com.sun.star.awt.Toolkit'.", e); + } + XExtendedToolkit xExtendedToolkit = (XExtendedToolkit)UnoRuntime.queryInterface(XExtendedToolkit.class, aToolkit); + XTopWindow tw = null; + + XAccessibleComponent xAccessibleComponent = null; + int k = xExtendedToolkit.getTopWindowCount(); + for (int i=0;i<k;i++) { + try { + XTopWindow tw_temp = xExtendedToolkit.getTopWindow(i); + XAccessible xacc = (XAccessible)UnoRuntime.queryInterface(XAccessible.class, tw_temp); + if (xacc != null) { + System.out.println("Name: " + xacc.getAccessibleContext().getAccessibleName()); + if (xacc.getAccessibleContext().getAccessibleName().startsWith("the title")) { + tw = tw_temp; + XAccessibleContext xContext = xacc.getAccessibleContext(); + xAccessibleComponent = (XAccessibleComponent)UnoRuntime.queryInterface(XAccessibleComponent.class, xContext); + if (xAccessibleComponent == null) + System.out.println("!!!! MIST !!!!"); + else + System.out.println("########## KLAPPT ########## "); + } + } + else { + log.println("\t unknown window"); + } + + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + } + } + if (tw == null) { + System.out.println("No TopWindow :-("); + return null; + } + + XWindow xWindow = (XWindow)UnoRuntime.queryInterface(XWindow.class, tw); + Rectangle posSize = xWindow.getPosSize(); + + // compare the center point with the dimensions of the current top window + boolean windowOK = false; + while(!windowOK) { + if (posSize.X <= center.X && center.X <= posSize.X + posSize.Width) { + if (posSize.Y <= center.Y && center.Y <= posSize.Y +posSize.Height) { + // move window out of the way + posSize.X = posSize.X + 10; + posSize.Y = posSize.Y +10; + xWindow.setPosSize(posSize.X, posSize.Y, posSize.Width, posSize.Height, PosSize.POS); + } + else { + windowOK = true; + } + } + else { + windowOK = true; + } + + } + + Point p = xAccessibleComponent.getLocationOnScreen(); +// System.out.println("ScreenPoint: " + p.X + " " + p.Y ); +// System.out.println("WindowPoint: " + posSize.X + " " + posSize.Y + " " + posSize.Width + " " + posSize.Height); + Point closer = new Point(); + closer.X = p.X + posSize.Width - 2; + closer.Y = p.Y + 5; + System.out.println("Closer: " + closer.X + " " + closer.Y); + return closer; + } + + protected boolean clickOnSheet(Point point) { + log.println("Clicking in the center of the AccessibleSpreadsheet"); + + try { + Robot rob = new Robot(); + rob.mouseMove(point.X, point.Y); + rob.mousePress(InputEvent.BUTTON1_MASK); + util.utils.shortWait(1000); + rob.mouseRelease(InputEvent.BUTTON1_MASK); + util.utils.shortWait(1000); + } catch (java.awt.AWTException e) { + log.println("couldn't press mouse button"); + } + + return true; + } + + /** + * + */ + public static class MyRangeSelectionListener implements XRangeSelectionListener, XRangeSelectionChangeListener { + boolean bAbortCalled = false; + boolean bChangeCalled = false; + boolean bDoneCalled = false; + PrintWriter log = null; + + public MyRangeSelectionListener(PrintWriter log) { + this.log = log; + } + + public void aborted(RangeSelectionEvent rangeSelectionEvent) { + log.println("Called 'aborted' with: " + rangeSelectionEvent.RangeDescriptor); + bAbortCalled = true; + } + + public void descriptorChanged(RangeSelectionEvent rangeSelectionEvent) { + log.println("Called 'descriptorChanged' with: " + rangeSelectionEvent.RangeDescriptor); + bChangeCalled = true; + } + + public void done(RangeSelectionEvent rangeSelectionEvent) { + log.println("Called 'done' with: " + rangeSelectionEvent.RangeDescriptor); + bDoneCalled = true; + } + + public boolean listenerCalled() { + return bAbortCalled & bChangeCalled & bDoneCalled; + } + + public void reset() { + bAbortCalled = false; + bChangeCalled = false; + bDoneCalled = false; + } + + /** + * ignore disposing + * @param eventObject The event. + */ + public void disposing(EventObject eventObject) { + } + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XRecentFunctions.java b/qadevOOo/tests/java/ifc/sheet/_XRecentFunctions.java new file mode 100644 index 000000000000..117e7607e1c0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XRecentFunctions.java @@ -0,0 +1,168 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import java.util.Random; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.XNameAccess; +import com.sun.star.sheet.XRecentFunctions; + +/** +* Testing <code>com.sun.star.sheet.XRecentFunctions</code> +* interface methods : +* <ul> +* <li><code> getRecentFunctionIds()</code></li> +* <li><code> setRecentFunctionIds()</code></li> +* <li><code> getMaxRecentFunctions()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'FUNCTIONLIST'</code> (of type <code>XNameAccess</code>): +* to have the set of available functions </li> +* <ul> <p> +* @see com.sun.star.sheet.XRecentFunctions +*/ +public class _XRecentFunctions extends MultiMethodTest { + + public XRecentFunctions oObj = null; + int iMaxNumber = 0; + + /** + * Test calls the method, checks returned value and stores it. <p> + * Has <b> OK </b> status if returned value isn't equal to zero. <p> + */ + public void _getMaxRecentFunctions() { + + iMaxNumber = oObj.getMaxRecentFunctions(); + log.println("Maximum recent functions : " + iMaxNumber); + + tRes.tested("getMaxRecentFunctions()", iMaxNumber != 0); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null, if length of returned + * array is equal or less to the maximum number of functions and obtained + * array doesn't contain equal functions. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getMaxRecentFunctions() </code> : to have the maximum number + * of recent functions </li> + * </ul> + */ + public void _getRecentFunctionIds() { + requiredMethod("getMaxRecentFunctions()"); + + boolean bResult = true; + int[] IDs = null; + int iNumber = 0; + + IDs = oObj.getRecentFunctionIds(); + iNumber = IDs.length; + bResult &= (iNumber <= iMaxNumber); + log.println("Now there are " + iNumber + " recent functions"); + bResult &= (IDs != null); + if (bResult) { + for (int i = 0; i < iNumber - 1; i++) + for (int j = i + 1; j < iNumber; j++) { + bResult &= (IDs[i] != IDs[j]); + } + } + + tRes.tested("getRecentFunctionIds()", bResult); + } + + /** + * Test gets the set of available functions, sets empty list of recent + * functions, sets list of maximum size. <p> + * Has <b> OK </b> status if length of recent function list is equal to zero + * after list was set to empty, if length of list is equal to maximum size + * after list was set to it's maximum size and no exception were thrown. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getMaxRecentFunctions() </code> : to have the maximum number + * of recent functions </li> + * </ul> + */ + public void _setRecentFunctionIds() { + requiredMethod("getMaxRecentFunctions()"); + + boolean bResult = true; + int[] IDs = new int[0]; + XNameAccess functionList = null; + + log.println("First, get the set of available functions."); + functionList = (XNameAccess)tEnv.getObjRelation("FUNCTIONLIST"); + if (functionList == null) throw new StatusException(Status.failed + ("Relation 'FUNCTIONLIST' not found")); + + log.println("Now trying to set empty list."); + oObj.setRecentFunctionIds(IDs); + bResult &= (oObj.getRecentFunctionIds().length == 0); + + log.println("Now trying to set list of maximum size."); + String[] names = functionList.getElementNames(); + Random rnd = new Random(); + + IDs = new int[iMaxNumber]; + int startIdx = rnd.nextInt(names.length - iMaxNumber - 1) + 1; + + try { + for (int i = startIdx; i < startIdx + iMaxNumber; i++) { + PropertyValue[] propVals = (PropertyValue[]) + functionList.getByName(names[i]); + for (int j = 0; j < propVals.length; j++) { + String propName = (String)propVals[j].Name; + if (propName.equals("Id")) { + IDs[i - startIdx] = + ((Integer)propVals[j].Value).intValue(); + break; + } + } + } + } catch(com.sun.star.lang.WrappedTargetException e) { + e.printStackTrace(log); + bResult = false; + } catch(com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(log); + bResult = false; + } + + oObj.setRecentFunctionIds(IDs); + bResult &= (oObj.getRecentFunctionIds().length == iMaxNumber); + + tRes.tested("setRecentFunctionIds()", bResult); + } + +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XScenario.java b/qadevOOo/tests/java/ifc/sheet/_XScenario.java new file mode 100644 index 000000000000..ea158b8a2cd1 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XScenario.java @@ -0,0 +1,100 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XScenario; +import com.sun.star.table.CellRangeAddress; +import lib.MultiMethodTest; +import lib.Status; + +/** + * + */ +public class _XScenario extends MultiMethodTest { + public XScenario oObj = null; + CellRangeAddress address = null; + String comment = null; + boolean skipTest = false; + + public void before() { + // testing a scenario containing the whole sheet does not make sense. + // test is skipped until this interface is implemented somewhere else + skipTest = true; + } + + public void _addRanges() { + if (skipTest) { + tRes.tested("addRanges()",Status.skipped(true)); + return; + } + oObj.addRanges(new CellRangeAddress[] {address}); + tRes.tested("addRanges()", true); + } + + public void _apply() { + requiredMethod("addRanges()"); + if (skipTest) { + tRes.tested("apply()",Status.skipped(true)); + return; + } + oObj.apply(); + tRes.tested("apply()", true); + } + + public void _getIsScenario() { + requiredMethod("apply()"); + if (skipTest) { + tRes.tested("getIsScenario()",Status.skipped(true)); + return; + } + boolean getIs = oObj.getIsScenario(); + tRes.tested("getIsScenario()", getIs); + } + + public void _getScenarioComment() { + if (skipTest) { + tRes.tested("getScenarioComment()",Status.skipped(true)); + return; + } + comment = oObj.getScenarioComment(); + tRes.tested("getScenarioComment()", true); + } + + public void _setScenarioComment() { + requiredMethod("getScenarioComment()"); + if (skipTest) { + tRes.tested("setScenarioComment()",Status.skipped(true)); + return; + } + boolean res = false; + oObj.setScenarioComment("MyComment"); + String c = oObj.getScenarioComment(); + res = c.equals("MyComment"); + oObj.setScenarioComment(comment); + tRes.tested("setScenarioComment()", res); + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced.java b/qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced.java new file mode 100644 index 000000000000..42fac78d7d81 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XScenarioEnhanced.java @@ -0,0 +1,93 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XScenarioEnhanced; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.uno.UnoRuntime; + +import lib.MultiMethodTest; + + +/** + * + * @author sw93809 + */ +public class _XScenarioEnhanced extends MultiMethodTest { + public XScenarioEnhanced oObj = null; + + public void before() { + oObj = (XScenarioEnhanced) UnoRuntime.queryInterface( + XScenarioEnhanced.class, + tEnv.getObjRelation("ScenarioSheet")); + } + + public void _getRanges() { + boolean res = true; + CellRangeAddress[] getting = oObj.getRanges(); + System.out.println("Count " + getting.length); + + CellRangeAddress first = getting[0]; + + if (!(first.Sheet == 1)) { + log.println( + "wrong RangeAddress is returned, expected Sheet=0 and got " + + first.Sheet); + res = false; + } + + if (!(first.StartColumn == 0)) { + log.println( + "wrong RangeAddress is returned, expected StartColumn=0 and got " + + first.StartColumn); + res = false; + } + + if (!(first.EndColumn == 10)) { + log.println( + "wrong RangeAddress is returned, expected EndColumn=10 and got " + + first.EndColumn); + res = false; + } + + if (!(first.StartRow == 0)) { + log.println( + "wrong RangeAddress is returned, expected StartRow=0 and got " + + first.StartRow); + res = false; + } + + if (!(first.EndRow == 10)) { + log.println( + "wrong RangeAddress is returned, expected EndRow=10 and got " + + first.EndRow); + res = false; + } + + tRes.tested("getRanges()", res); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XScenarios.java b/qadevOOo/tests/java/ifc/sheet/_XScenarios.java new file mode 100644 index 000000000000..efd4dcb458a0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XScenarios.java @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XScenarios; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XScenarios</code> +* interface methods : +* <ul> +* <li><code> addNewByName()</code></li> +* <li><code> removeByName()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'ADDR'</code> (of type <code>CellRangeAddress[]</code>): +* the array of cell range addresses for adding new scenario </li> +* <ul> <p> +* @see com.sun.star.sheet.XScenarios +*/ +public class _XScenarios extends MultiMethodTest { + + public XScenarios oObj = null; + + /** + * Test adds new scenario, stores name of this scenario and checks that + * scenario with this name is present in collection. <p> + * Has <b> OK </b> status if the new scenario is present in collection. <p> + */ + public void _addNewByName() { + CellRangeAddress[] oAddr = (CellRangeAddress[]) + tEnv.getObjRelation("ADDR"); + if (oAddr == null) throw new StatusException(Status.failed + ("Relation 'ADDR' not found")); + + oObj.addNewByName("XScenarios", oAddr, "new"); + tRes.tested("addNewByName()",oObj.hasByName("XScenarios")); + } + + /** + * Test removes the scenario with stored name and checks that scenario + * with this name isn't present in collection. <p> + * Has <b> OK </b> status if the scenario with stored name isn't present in + * collection after it was removed. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> addNewByName() </code> : to have name of the scenario </li> + * </ul> + */ + public void _removeByName() { + requiredMethod("addNewByName()"); + oObj.removeByName("XScenarios"); + tRes.tested("removeByName()",!oObj.hasByName("XScenarios")); + } + + +} // EOC _XScenarios + diff --git a/qadevOOo/tests/java/ifc/sheet/_XScenariosSupplier.java b/qadevOOo/tests/java/ifc/sheet/_XScenariosSupplier.java new file mode 100644 index 000000000000..f1766b82a7da --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XScenariosSupplier.java @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XScenarios; +import com.sun.star.sheet.XScenariosSupplier; + +/** +* Testing <code>com.sun.star.sheet.XSheetAnnotationsSupplier</code> +* interface methods : +* <ul> +* <li><code> getAnnotations()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetAnnotationsSupplier +*/ +public class _XScenariosSupplier extends MultiMethodTest { + public XScenariosSupplier oObj = null; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getScenarios(){ + XScenarios oSc = oObj.getScenarios(); + tRes.tested("getScenarios()", oSc != null); + } + +} // EOC _XScenariosSupplier + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotation.java b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotation.java new file mode 100644 index 000000000000..a50d63f817f9 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotation.java @@ -0,0 +1,141 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; +import util.ValueComparer; + +import com.sun.star.sheet.XSheetAnnotation; +import com.sun.star.table.CellAddress; +import com.sun.star.text.XSimpleText; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XSheetAnnotation</code> +* interface methods : +* <ul> +* <li><code> getPosition()</code></li> +* <li><code> getAuthor()</code></li> +* <li><code> getDate()</code></li> +* <li><code> getIsVisible()</code></li> +* <li><code> setIsVisible()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'CELLPOS'</code> (of type +* <code>com.sun.star.table.CellAddress</code>): +* The position of cell with annotation. </li> +* <ul> <p> +* Test is <b> NOT </b> multithread compilant. <p> +* @see com.sun.star.sheet.XSheetAnnotation +*/ +public class _XSheetAnnotation extends MultiMethodTest { + + public XSheetAnnotation oObj = null; + + /** + * Gets the author of annotation. <p> + * Has <b>OK</b> status if not null value returned. + */ + public void _getAuthor() { + String author = oObj.getAuthor(); + tRes.tested("getAuthor()", author != null); + } + + /** + * Gets the modification date of annotation. <p> + * Has <b>OK</b> status if not null value returned. + */ + public void _getDate() { + String date = oObj.getDate(); + tRes.tested("getDate()", date != null); + } + + /** + * Sets the string of annotation, then makes it visible and + * checks the value returned by <code>getIsVisible</code> method. <p> + * Has <b>OK</b> status if the method returns <code>true</code>. + */ + public void _getIsVisible() { + XSimpleText oText = (XSimpleText) + UnoRuntime.queryInterface(XSimpleText.class, oObj); + oText.setString("XSheetAnnotation"); + oObj.setIsVisible(true); + boolean bVis = oObj.getIsVisible(); + tRes.tested("getIsVisible()", bVis); + } + + /** + * Gets the position of annotated cell and compares it to + * the position passed as relation. <p> + * Has <b>OK</b> status if these positions are equal and not + * null. + */ + public void _getPosition() { + boolean bResult = false; + CellAddress sCAddr = (CellAddress) tEnv.getObjRelation("CELLPOS") ; + if (sCAddr == null) throw new StatusException(Status.failed + ("Relation 'CELLPOS' not found")); + + CellAddress oCAddr = oObj.getPosition(); + + bResult = (oCAddr != null) && (sCAddr != null) && + ValueComparer.equalValue(oCAddr, sCAddr) ; + + tRes.tested("getPosition()", bResult); + } + + /** + * Sets the string of annotation, makes it hidden and then + * visible. Visibility is checked in both cases. <p> + * Has <b>OK</b> status if the <code>getIsVisible</code> method + * returns <code>flase</code> in the first case and <code>true</code> + * in the second. + */ + public void _setIsVisible() { + boolean bResult = true; + XSimpleText oText = (XSimpleText) + UnoRuntime.queryInterface(XSimpleText.class, oObj); + oText.setString("XSheetAnnotation"); + oObj.setIsVisible(false); + boolean bVis = oObj.getIsVisible(); + if (!bVis) { + oObj.setIsVisible(true); + bVis = oObj.getIsVisible(); + if (bVis) { + bResult = true; + } + } + + tRes.tested("setIsVisible()", bResult); + } + +} // EOC _XSheetAnnotation + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor.java b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor.java new file mode 100644 index 000000000000..76a5b97b0aaf --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationAnchor.java @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XSheetAnnotation; +import com.sun.star.sheet.XSheetAnnotationAnchor; +import com.sun.star.table.CellAddress; +import com.sun.star.text.XSimpleText; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XSheetAnnotationAnchor</code> +* interface methods : +* <ul> +* <li><code> getAnnotation()</code></li> +* </ul> +* @see com.sun.star.sheet.XSheetAnnotationAnchor +*/ +public class _XSheetAnnotationAnchor extends MultiMethodTest { + + public XSheetAnnotationAnchor oObj = null; + protected XSheetAnnotation anno = null; + + public void _getAnnotation() { + anno = oObj.getAnnotation(); + tRes.tested("getAnnotation()",checkAnnotation()); + } + + protected boolean checkAnnotation() { + boolean res = true; + res &= check_getAuthor(); + res &= check_getDate(); + res &= check_getIsVisible(); + res &= check_getPosition(); + res &= check_setIsVisible(); + return res; + } + + /** + * Gets the author of annotation. <p> + * Returns <b>true</b> if not null value returned. + */ + protected boolean check_getAuthor() { + String author = anno.getAuthor(); + return (author != null); + } + + /** + * Gets the modification date of annotation. <p> + * Returns <b>true</b> if not null value returned. + */ + protected boolean check_getDate() { + String date = anno.getDate(); + return (date != null); + } + + /** + * Sets the string of annotation, then makes it visible and + * checks the value returned by <code>getIsVisible</code> method. <p> + * Returns <b>true</b> if the method returns <code>true</code>. + */ + protected boolean check_getIsVisible() { + XSimpleText oText = (XSimpleText) + UnoRuntime.queryInterface(XSimpleText.class, anno); + oText.setString("XSheetAnnotation"); + anno.setIsVisible(true); + boolean bVis = anno.getIsVisible(); + return bVis; + } + + /** + * Gets the position of annotated cell + * Returns <b>true</b> if this position is not null. + */ + protected boolean check_getPosition() { + CellAddress oCAddr = anno.getPosition(); + return (oCAddr != null); + } + + /** + * Sets the string of annotation, makes it hidden and then + * visible. Visibility is checked in both cases. <p> + * Returns <b>true</b> if the <code>getIsVisible</code> method + * returns <code>false</code> in the first case and <code>true</code> + * in the second. + */ + protected boolean check_setIsVisible() { + boolean bResult = true; + XSimpleText oText = (XSimpleText) + UnoRuntime.queryInterface(XSimpleText.class, anno); + oText.setString("XSheetAnnotation"); + anno.setIsVisible(false); + boolean bVis = anno.getIsVisible(); + if (!bVis) { + anno.setIsVisible(true); + bVis = anno.getIsVisible(); + if (bVis) { + bResult = true; + } + } + + return bResult; + } + +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationShapeSupplier.java b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationShapeSupplier.java new file mode 100644 index 000000000000..9b0f3c193b73 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationShapeSupplier.java @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import com.sun.star.drawing.XShape; +import com.sun.star.sheet.XSheetAnnotationShapeSupplier; +import lib.MultiMethodTest; + +public class _XSheetAnnotationShapeSupplier extends MultiMethodTest +{ + public XSheetAnnotationShapeSupplier oObj = null; + + public void _getAnnotationShape() { + XShape xShape = oObj.getAnnotationShape (); + tRes.tested ("getAnnotationShape()",xShape!=null); + } + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotations.java b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotations.java new file mode 100644 index 000000000000..d24f2cbf9416 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotations.java @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XSheetAnnotations; +import com.sun.star.table.CellAddress; + + +/** +* Testing <code>com.sun.star.sheet.XSheetAnnotations</code> +* interface methods : +* <ul> +* <li><code> insertNew()</code></li> +* <li><code> removeByIndex()</code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compilant. <p> +* @see com.sun.star.sheet.XSheetAnnotations +*/ +public class _XSheetAnnotations extends MultiMethodTest { + + public XSheetAnnotations oObj = null; + + /** + * Adds two new annotations into collection. <p> + * Has <b>OK</b> status if the number of elements in collection + * increased by 2 after method call. + */ + public void _insertNew(){ + boolean bResult = false; + + int initialAmount = oObj.getCount(); + String sAnno = oObj.toString(); + + oObj.insertNew(new CellAddress((short)1, 2, 5), sAnno + "1"); + oObj.insertNew(new CellAddress((short)1, 1, 1), sAnno + "2"); + + bResult = (oObj.getCount() == 2 + initialAmount); + tRes.tested("insertNew()", bResult); + } + + /** + * Removes one annotation from collection. <p> + * Has <b>OK</b> status if the number of elements in collection + * decreased after method call. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> insertNew </code> : to be sure at least two elements + * exist in the collection.</li> + * </ul> + */ + public void _removeByIndex(){ + requiredMethod("insertNew()"); + int tmpCnt = oObj.getCount(); + + oObj.removeByIndex(1); + int newCnt = oObj.getCount(); + + tRes.tested("removeByIndex()", newCnt < tmpCnt); + } + +} // EOC _XSheetAnnotations + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationsSupplier.java b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationsSupplier.java new file mode 100644 index 000000000000..544d19c8f630 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetAnnotationsSupplier.java @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XSheetAnnotations; +import com.sun.star.sheet.XSheetAnnotationsSupplier; + +/** +* Testing <code>com.sun.star.sheet.XSheetAnnotationsSupplier</code> +* interface methods : +* <ul> +* <li><code> getAnnotations()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetAnnotationsSupplier +*/ +public class _XSheetAnnotationsSupplier extends MultiMethodTest { + + public XSheetAnnotationsSupplier oObj = null; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getAnnotations(){ + log.println("testing getAnnotations"); + XSheetAnnotations oSheetAnno = oObj.getAnnotations(); + tRes.tested("getAnnotations()", oSheetAnno != null ); + } + +} // EOC _XSheetAnnotationsSupplier + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetAuditing.java b/qadevOOo/tests/java/ifc/sheet/_XSheetAuditing.java new file mode 100644 index 000000000000..a721275ed684 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetAuditing.java @@ -0,0 +1,206 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.drawing.XDrawPage; +import com.sun.star.drawing.XDrawPageSupplier; +import com.sun.star.drawing.XShape; +import com.sun.star.sheet.ValidationType; +import com.sun.star.sheet.XSheetAuditing; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.CellAddress; +import com.sun.star.table.XCell; +import com.sun.star.text.XText; +import com.sun.star.uno.UnoRuntime; +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +/** + * + */ +public class _XSheetAuditing extends MultiMethodTest { + public XSheetAuditing oObj = null; + CellAddress address = null; + CellAddress precedentAddress = null; + CellAddress dependentAddress = null; + XCell xAddress = null; + XCell xPrecedentAddress = null; + XCell xDependentAddress = null; + XDrawPage xDrawPage = null; + int elementCount = 0; + + public void before() { + address = (CellAddress)tEnv.getObjRelation("XSheetAuditing.CellAddress"); + precedentAddress = (CellAddress)tEnv.getObjRelation("XSheetAuditing.PrecedentCellAddress"); + dependentAddress= (CellAddress)tEnv.getObjRelation("XSheetAuditing.DependentCellAddress"); + if (address == null || precedentAddress == null || dependentAddress == null) { + throw new StatusException(Status.failed("Necessary CellAddress object relations not found.")); + } + + // get the draw page for checking the shapes + xDrawPage = (XDrawPage)tEnv.getObjRelation("XSheetAuditing.DrawPage"); + if (xDrawPage == null) { // get from object + XDrawPageSupplier oDPS = (XDrawPageSupplier) + UnoRuntime.queryInterface(XDrawPageSupplier.class, oObj); + xDrawPage = (XDrawPage) oDPS.getDrawPage(); + } + if (xDrawPage == null) { + throw new StatusException(Status.failed("'XSheetAuditing.DrawPage' object relation not found.")); + } + if (xDrawPage.hasElements()) { + elementCount = xDrawPage.getCount(); + } + + // get a sheet for changing the cells + XSpreadsheet xSheet = (XSpreadsheet)tEnv.getObjRelation("XSheetAuditing.Spreadsheet"); + if (xSheet == null) // query on ther object + xSheet = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class, oObj); + if (xSheet == null) + throw new StatusException(Status.failed("'XSheetAuditing.Spreadsheet' object relation not found.")); + try { + xAddress = xSheet.getCellByPosition(address.Column, address.Row); + xDependentAddress = xSheet.getCellByPosition(dependentAddress.Column, dependentAddress.Row); + xPrecedentAddress = xSheet.getCellByPosition(precedentAddress.Column, precedentAddress.Row); + } + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + throw new StatusException(Status.failed("Invalid cell addresses in object relations.")); + } + } + + public void _clearArrows() { + requiredMethod("hideDependents()"); + boolean erg = false; + oObj.showDependents(address); + oObj.showPrecedents(address); + erg = hasRightAmountOfShapes(3); + oObj.clearArrows(); + erg &= hasRightAmountOfShapes(0); + tRes.tested("clearArrows()", erg); + } + + public void _hideDependents() { + requiredMethod("showDependents()"); + oObj.hideDependents(address); + tRes.tested("hideDependents()", hasRightAmountOfShapes(0)); + } + + public void _hidePrecedents() { + requiredMethod("showPrecedents()"); +// requiredMethod("showPrecedents()"); + oObj.hidePrecedents(address); + tRes.tested("hidePrecedents()", hasRightAmountOfShapes(0)); + } + + public void _showDependents() { + requiredMethod("hidePrecedents()"); + oObj.showDependents(address); + tRes.tested("showDependents()", hasRightAmountOfShapes(1)); + } + + public void _showErrors() { + requiredMethod("clearArrows()"); + // construct an error: square root from -3 + xPrecedentAddress.setValue(-9); + String cellAddress = new String(new byte[]{(byte)(precedentAddress.Column + 65)}) + (precedentAddress.Row+1); + xAddress.setFormula("=SQRT(" + cellAddress + ")"); + XText xText = (XText)UnoRuntime.queryInterface(XText.class, xAddress); + // correct error in cell: + String error = xText.getString(); + boolean erg = error.equals("Err:502"); + log.println("Content: " + error); + oObj.showErrors(dependentAddress); + erg &= hasRightAmountOfShapes(2); + tRes.tested("showErrors()", erg); + } + + public void _showInvalid() { + requiredMethod("showErrors()"); + boolean result = true; + // insert a value + xAddress.setValue(2.5); + try { + // add a validitation to a cell: only whole numbers are allowed + XPropertySet xPropertySet = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, xAddress); + Object o = xPropertySet.getPropertyValue("Validation"); + XPropertySet xValidation = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, o); + xValidation.setPropertyValue("Type", ValidationType.WHOLE); + xPropertySet.setPropertyValue("Validation", xValidation); + // test + oObj.showInvalid(); + result = hasRightAmountOfShapes(1); + oObj.clearArrows(); + result &= hasRightAmountOfShapes(0); + // revoke the validitation to a cell + xValidation.setPropertyValue("Type", ValidationType.ANY); + xPropertySet.setPropertyValue("Validation", xValidation); + // test again + oObj.showInvalid(); + result &= hasRightAmountOfShapes(0); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace((java.io.PrintWriter)log); + result = false; + } + + tRes.tested("showInvalid()", result); + } + + public void _showPrecedents() { + oObj.showPrecedents(address); + tRes.tested("showPrecedents()", hasRightAmountOfShapes(2)); + } + + /** + * Check if the amount of shapes is the right one after displaying that stuff + * 2do improve this: check taht the shapes are the correct ones -> convwatch + * @desiredValue That's the amount of shapes that have to be here. + * @return True, if the actual count of shapes is the same + */ + private boolean hasRightAmountOfShapes(int desiredValue) { + int newCount = xDrawPage.getCount(); + if (newCount != elementCount + desiredValue) { + return false; + } + else { + if (desiredValue >= 0) { + for (int i=elementCount; i<newCount; i++) { + try { + Object o = xDrawPage.getByIndex(i); + XShape xShape = (XShape)UnoRuntime.queryInterface(XShape.class, o); + System.out.println("Shape Type: " + xShape.getShapeType()); + } + catch(com.sun.star.uno.Exception e) { + e.printStackTrace(); + } + } + } + } + return true; + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor.java b/qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor.java new file mode 100644 index 000000000000..ec484f9bf0d6 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetCellCursor.java @@ -0,0 +1,403 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.CellFlags; +import com.sun.star.sheet.XArrayFormulaRange; +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XSheetCellCursor; +import com.sun.star.sheet.XSheetOperation; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.XCellRange; +import com.sun.star.table.XColumnRowRange; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XMergeable; + +/** +* Testing <code>com.sun.star.sheet.XSheetCellCursor</code> +* interface methods : +* <ul> +* <li><code> collapseToCurrentRegion()</code></li> +* <li><code> collapseToCurrentArray()</code></li> +* <li><code> collapseToMergedArea()</code></li> +* <li><code> expandToEntireColumns()</code></li> +* <li><code> expandToEntireRows()</code></li> +* <li><code> collapseToSize()</code></li> +* </ul> <p> +* Component must also implement the following interfaces : +* <ul> +* <li> <code> com.sun.star.sheet.XCellRangeAddressable </code> : +* to get range address </li> +* <ul> <p> +* Range of cursor must be of size 4 x 4. <p> +* @see com.sun.star.sheet.XSheetCellCursor +*/ +public class _XSheetCellCursor extends MultiMethodTest { + + public XSheetCellCursor oObj = null; + + /** + * Test creates the array formula, assigns this array to another array, + * collapses cursor into one cell, applies method, checks the size of the + * result range, erases array formula, checks that array formula has been + * cleared. <p> + * Has <b>OK</b> status if no exceptions were thrown, if size of the result + * range is equal to size of the range where the array formula was set and + * if array formula was successfully cleared. <p> + */ + public void _collapseToCurrentArray() { + boolean bResult = false; + + XCellRangeAddressable crAddr = (XCellRangeAddressable) + UnoRuntime.queryInterface(XCellRangeAddressable.class, oObj); + CellRangeAddress addr = crAddr.getRangeAddress() ; + int leftCol = addr.StartColumn ; + int topRow = addr.StartRow ; + int width = addr.EndColumn - addr.StartColumn + 1 ; + int height = addr.EndRow - addr.StartRow + 1 ; + + log.println( "Object area is ((" + leftCol + "," + topRow + "),(" + + (leftCol + width - 1) + "," + (topRow + height - 1) + ")" ); + + XCellRange new_range = null; + try { + // first we need to create an array formula + new_range = + oObj.getCellRangeByPosition(0, 0, 0, height - 1); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.print("Get cell range by position failed: "); + e.printStackTrace(log); + tRes.tested("collapseToCurrentArray()", false); + } + + log.println("DB: Successfully new range created"); + XArrayFormulaRange arrFormulaRange = (XArrayFormulaRange) + UnoRuntime.queryInterface (XArrayFormulaRange.class, new_range); + // write a simple formula (this array assigns another array) + arrFormulaRange.setArrayFormula("A1:A" + height) ; + + // collapse cursor into one cell and then try to apply the method + oObj.collapseToSize (1, 1) ; + oObj.collapseToCurrentArray() ; + + // check the size of result range + int cols = ( (XColumnRowRange)UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getColumns().getCount(); + int rows = ( (XColumnRowRange)UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getRows().getCount(); + + if (cols == 1 && rows == height) { + bResult = true; + } else { + bResult = false; + log.println("The size of cell range must be 1x" + height + + ", but after method call it was " + cols + "x" + rows); + } + + // erase array formula + arrFormulaRange.setArrayFormula(""); + + // check if array formula has been cleared with last statement + try { + // if array formula isn't cleared exception is thrown + new_range.getCellByPosition(0,0).setValue(111) ; + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + bResult = false ; + log.println( + "Array formula hasn't been cleared with setArrayFormula(\"\")"); + XSheetOperation clearRange = (XSheetOperation) + UnoRuntime.queryInterface (XSheetOperation.class, new_range); + int allFlags = + CellFlags.ANNOTATION | CellFlags.DATETIME | CellFlags.EDITATTR; + allFlags = allFlags + | CellFlags.HARDATTR | CellFlags.OBJECTS | CellFlags.STRING; + allFlags = allFlags + | CellFlags.VALUE | CellFlags.FORMULA | CellFlags.STYLES; + clearRange.clearContents(allFlags) ; + } + + tRes.tested("collapseToCurrentArray()", bResult ); + } + + /** + * Test clears contents of spreadsheet, collapses cursor to current range, + * checks size of cursor range, fills a cell that is close to + * cursor range, collapses cursor to current range, checks size of cursor + * range again and restores original size. <p> + * Has <b> OK </b> status if after clearing of content and collapsing cursor + * range size remains 4 x 4, if after filling of cell and collapsing cursor + * range extends by one in both dimensions and no exceptions were thrown.<p> + */ + public void _collapseToCurrentRegion(){ + boolean bResult = true; + int width = 4, height = 4; + int leftCol = -1, topRow = -1; + + XSpreadsheet oSheet = oObj.getSpreadsheet(); + ((XSheetOperation) UnoRuntime.queryInterface( + XSheetOperation.class, oSheet) ).clearContents(65535); + oObj.collapseToCurrentRegion(); + int cols = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getColumns().getCount(); + int rows = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getRows().getCount(); + + if (cols != width || rows != height) { + bResult = false ; + log.println("After collapseToCurrentRegion()" + + " call Region must have size " + width + "x" + height + + " but it is " + cols + "x" + rows); + } + + // if previous test was successful try more complicated case + if (bResult) { + if (leftCol != -1 && topRow != -1) { + try { + oSheet.getCellByPosition( + leftCol + width, topRow + height).setValue(1); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.print("Can't get cell by position:"); + e.printStackTrace(log); + bResult = false; + } + + oObj.collapseToCurrentRegion() ; + + // checking results + cols = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj)).getColumns().getCount(); + rows = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj)).getRows().getCount(); + + if (cols == width + 1 && rows == height + 1) { + bResult &= true; + } else { + bResult = false; + log.println("After collapseToCurrentRegion() call [2]" + + " region must have size " + (width+1) + "x" + + (height + 1) + " but it is " + cols + "x" + rows ); + } + } + } + + tRes.tested("collapseToCurrentRegion()", bResult); + + // restore original size + oObj.collapseToSize(width, height); + } + + /** + * Test merges a cells of range that has a greater size, collapses cursor to + * merged area, checks size of cursor range and restores original size + * of cursor range. <p> + * Has <b> OK </b> status if after merging of cells and collapsing cursor + * range extends by one in both dimensions and no exceptions were thrown.<p> + */ + public void _collapseToMergedArea(){ + int width = 1, height = 1 ; + int leftCol = 0, topRow = 0 ; + + boolean bResult = true ; + + log.println("DB: Starting collapseToMergedArea() method test ...") ; + XSpreadsheet oSheet = oObj.getSpreadsheet() ; + log.println ("DB: got Spreadsheet.") ; + + XCellRange newRange = null; + try { + newRange = oSheet.getCellRangeByPosition ( + leftCol + width - 1, topRow + height - 1, + leftCol + width, topRow + height ); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Can't get cell range by position"); + e.printStackTrace(log); + bResult = false; + } + + XMergeable mergeRange = (XMergeable) + UnoRuntime.queryInterface (XMergeable.class, newRange); + if (mergeRange == null) { + log.println("DB: newRange doesn't implement XMergeable interface"); + } else { + log.println("DB: XMergeable interface successfully queried."); + } + + mergeRange.merge(true); + log.println("DB: Successfuly merged.") ; + + oObj.collapseToMergedArea() ; + log.println("DB: Succesfully collapseToMergedArea() method called"); + + // unmerge area to restore SpreadSheet + mergeRange.merge(false); + log.println("DB: Successfully unmerged.") ; + + // checking results + int cols = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getColumns().getCount(); + int rows = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getRows().getCount(); + log.println("DB: Column and row numbers succesfully get") ; + + if (cols == width + 1 && rows == height + 3) { + bResult &= true; + } else { + bResult = false; + log.println( + "After collapseToMergedArea() call region must have size " + + (width + 1) + "x" + (height + 1) + " but it is " + cols + + "x" + rows ); + } + + tRes.tested("collapseToMergedArea()", bResult) ; + + // restore original size + oObj.collapseToSize(width, height); + } + + /** + * Test collapses cursor to the new size, checks size + * of cursor range and restores original size of cursor range. <p> + * Has <b> OK </b> status if after collapsing cursor + * range extends by three in both dimensions. <p> + */ + public void _collapseToSize(){ + boolean bResult = false; + int width = 1, height = 1; + + // collapseToSize() method test + oObj.collapseToSize (width + 3, height + 3); + + // checking results + int cols = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getColumns().getCount(); + int rows = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getRows().getCount(); + + if (cols == width + 3 && rows == height + 3) { + bResult = true ; + } else { + bResult = false ; + log.println( "After collapseToSize() call region must have size " + + (width + 3) + "x" + (height + 3) + " but it is " + + cols + "x" +rows); + } + + tRes.tested("collapseToSize()", bResult) ; + + // restore original size + oObj.collapseToSize(width, height) ; + } + + /** + * Test expands cursor to entire columns, checks size + * of cursor range and restores original size of cursor range. <p> + * Has <b> OK </b> status if after expanding cursor + * range extends to all rows in the columns (number of rows is greater than + * 32000 and number of columns remains the same). <p> + */ + public void _expandToEntireColumns(){ + boolean bResult = false; + int width = 1, height = 1 ; + + // expandToEntireColumns() method test + oObj.expandToEntireColumns () ; + + // checking results + int cols = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getColumns().getCount(); + int rows = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getRows().getCount(); + + if (cols == width && rows >= 32000) { + bResult = true ; + } else { + bResult = false ; + log.println( + "After expandToEntireColumns() call region must have size "+ + width + "x(>=32000) but it is " + cols + "x" + rows); + } + + tRes.tested("expandToEntireColumns()", bResult) ; + + // restore original size + oObj.collapseToSize(width, height) ; + } + + /** + * Test expands cursor to entire rows, checks size + * of cursor range and restores original size of cursor range. <p> + * Has <b> OK </b> status if after expanding cursor + * range extends to all columns in the rows (number of columns is greater + * than 256 and number of rows remains the same). <p> + */ + public void _expandToEntireRows(){ + boolean bResult = false; + int width = 1, height = 1 ; + + // expandToEntireRows() method test + oObj.expandToEntireRows () ; + + // checking results + int cols = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getColumns().getCount(); + int rows = ((XColumnRowRange) + UnoRuntime.queryInterface( + XColumnRowRange.class, oObj) ).getRows().getCount(); + + if (cols >= 256 && rows == height) { + bResult = true; + } else { + bResult = false ; + log.println("After expandToEntireRows() call region " + + "must have size (>=256)x" + height + " but it is " + + cols + "x" + rows ); + } + + tRes.tested("expandToEntireRows()", bResult) ; + + // restore original size + oObj.collapseToSize(width, height) ; + } + +} // EOC _XSheetCellCursor + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetCellRange.java b/qadevOOo/tests/java/ifc/sheet/_XSheetCellRange.java new file mode 100644 index 000000000000..95688c660c91 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetCellRange.java @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XSheetCellRange; +import com.sun.star.sheet.XSpreadsheet; + +/** +* Testing <code>com.sun.star.sheet.XSheetCellRange</code> +* interface methods : +* <ul> +* <li><code> getSpreadsheet()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetCellRange +*/ +public class _XSheetCellRange extends MultiMethodTest { + + public XSheetCellRange oObj = null; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getSpreadsheet(){ + XSpreadsheet oSheet = oObj.getSpreadsheet(); + tRes.tested("getSpreadsheet()", oSheet != null); + } + +} // EOC _XSheetCellRange + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer.java b/qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer.java new file mode 100644 index 000000000000..230306b300cd --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetCellRangeContainer.java @@ -0,0 +1,205 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.StatusException; + +import com.sun.star.sheet.XSheetCellRangeContainer; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XSheetCellRangeContainer</code> +* interface methods : +* <ul> +* <li><code> addRangeAddress() </code></li> +* <li><code> removeRangeAddress() </code></li> +* <li><code> addRangeAddresses() </code></li> +* <li><code> removeRangeAddresses() </code></li> +* </ul> <p> +* Test is <b> NOT </b> multithread compilant. <p> +* @see com.sun.star.sheet.XSheetCellRangeContainer +*/ +public class _XSheetCellRangeContainer extends MultiMethodTest { + public XSheetCellRangeContainer oObj = null; + public CellRangeAddress[] rAddr = new CellRangeAddress[3]; + + /** + * After method called, the new array of structures 'CellRangeAddress' + * is created. Then container is cleared. + */ + public void before() { + for ( short i=0; i<=2; i++ ) { + rAddr[i] = new CellRangeAddress(); + rAddr[i].Sheet = i; + rAddr[i].StartColumn = i; + rAddr[i].StartRow = i; + rAddr[i].EndColumn = i + 3; + rAddr[i].EndRow = i + 3; + try { + oObj.removeRangeAddresses(oObj.getRangeAddresses()); + } catch (com.sun.star.uno.Exception e) { + e.printStackTrace(log); + throw new StatusException("Error: Cannot remove "+ + "range addresses." ,e); + } + } + } + + /** + * The method called. Then new value is added to Container. + * Next we try to obtain back added value and check it. <p> + * + * Has <b> OK </b> status if the range just added presents among + * all ranges in the container. + */ + public void _addRangeAddress() { + boolean result = true; + + log.println("Elements before adding: " + oObj.getCount()); + oObj.addRangeAddress(rAddr[0], false); + log.println("Elements after adding: " + oObj.getCount()); + CellRangeAddress[] addr = oObj.getRangeAddresses(); + boolean exist = false ; + for (int i=0; i<=oObj.getCount()-1; i++) { + if ( addr[i].Sheet == rAddr[0].Sheet && + addr[i].StartColumn == rAddr[0].StartColumn && + addr[i].StartRow == rAddr[0].StartRow && + addr[i].EndColumn == rAddr[0].EndColumn && + addr[i].EndRow == rAddr[0].EndRow) { + + exist = true; + } + } + + result &= exist ; + + tRes.tested("addRangeAddress()" ,result); + } + + /** + * The method called. Then a value added before is removed. + * Next we check Container for existence of removed value. <p> + * Has <b> OK </b> status if the range just removed doesn't presents among + * all ranges in the container. + */ + public void _removeRangeAddress() { + boolean result = true; + + log.println("Elements before removing: " + oObj.getCount()); + try { + oObj.removeRangeAddress(rAddr[0]); + } catch (com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(log); + result = false; + } + log.println("Elements after removing: " + oObj.getCount()); + CellRangeAddress[] addr = oObj.getRangeAddresses(); + for (int i=0; i<=oObj.getCount()-1; i++) { + if ( (addr[i].Sheet == rAddr[0].Sheet) && + (addr[i].StartColumn == rAddr[0].StartColumn) && + (addr[i].StartRow == rAddr[0].StartRow) && + (addr[i].EndColumn == rAddr[0].EndColumn) && + (addr[i].EndRow == rAddr[0].EndRow) ) { + result = false; + } + } + tRes.tested("removeRangeAddress()" ,result); + } + + /** + * The method called. Then new values are added to Container. + * Next we try to obtain back all added values and check it. <p> + * + * Has <b> OK </b> status if the count of ranges increases by + * number of added ranges - 1 (one of ranges already exists in the + * container). And if all of ranges added exist in the container. + */ + public void _addRangeAddresses() { + executeMethod("addRangeAddress()"); + + boolean result = true; + + int cntBefore = oObj.getCount(); + log.println("Elements before adding: " + cntBefore); + oObj.addRangeAddresses(rAddr, false); + log.println("Elements after adding: " + oObj.getCount()); + CellRangeAddress[] addr = oObj.getRangeAddresses(); + + result &= cntBefore + rAddr.length == oObj.getCount(); + + for (int j = 0; j < rAddr.length; j++) { + boolean exist = false ; + for (int i=0; i < oObj.getCount(); i++) { + if ( addr[i].Sheet == rAddr[j].Sheet && + addr[i].StartColumn == rAddr[j].StartColumn && + addr[i].StartRow == rAddr[j].StartRow && + addr[i].EndColumn == rAddr[j].EndColumn && + addr[i].EndRow == rAddr[j].EndRow ) { + + exist = true; + break; + } + } + result &= exist; + } + + tRes.tested("addRangeAddresses()" ,result); + } + + /** + * All ranges are remover from contaier. + * + * Has <b> OK </b> status if there are no more ranges in the container. + */ + public void _removeRangeAddresses() { + boolean result = false; + int cnt; + + log.println("Elements before removing: " + oObj.getCount()); + try { + oObj.removeRangeAddresses(oObj.getRangeAddresses()); + } catch (com.sun.star.container.NoSuchElementException e) { + e.printStackTrace(log); + result = false; + } + if ( (cnt = oObj.getCount()) == 0) { + result = true; + } + log.println("Elements after removing: " + cnt); + tRes.tested("removeRangeAddresses()" ,result); + } + + /** + * Forces environment recreation. + */ + protected void after() { + disposeEnvironment(); + } + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges.java b/qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges.java new file mode 100644 index 000000000000..c64aeae807c4 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetCellRanges.java @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.container.XEnumeration; +import com.sun.star.sheet.XSheetCellRanges; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XSheetCellRanges</code> +* interface methods : +* <ul> +* <li><code> getCells()</code></li> +* <li><code> getRangeAddressesAsString()</code></li> +* <li><code> getRangeAddresses()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetCellRanges +*/ +public class _XSheetCellRanges extends MultiMethodTest{ + + public XSheetCellRanges oObj = null; + + /** + * Test calls the method, creates enumeration of returned value + * and checks that the enumeration has elements. <p> + * Has <b> OK </b> status if gained enumeration has elements. <p> + */ + public void _getCells() { + log.println("Testing getCells ..."); + + XEnumeration oEnum = oObj.getCells().createEnumeration(); + boolean res = oEnum.hasMoreElements(); + if (!res) { + log.println( + "The Enumeration gained via getCells() has no Elements"); + } + tRes.tested("getCells()", res); + } + + /** + * Test calls the method and checks length of returned array. <p> + * Has <b> OK </b> status if length of returned array is greater than 2.<p> + */ + public void _getRangeAddresses() { + log.println("Testing getRangeAddresses ..."); + CellRangeAddress[] oRanges = oObj.getRangeAddresses(); + int howmuch = oRanges.length; + tRes.tested("getRangeAddresses()", (howmuch > 2) ); + } + + /** + * Test calls the method and checks returned string. <p> + * Has <b> OK </b> status if returned string starts from 'Sheet'.<p> + */ + public void _getRangeAddressesAsString() { + log.println("Testing getRangeAddressesAsString ..."); + String oRanges = oObj.getRangeAddressesAsString(); + tRes.tested("getRangeAddressesAsString()",oRanges.indexOf("C1:D4")>0); + } + +} // finished class _XSheetCellRanges + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetCondition.java b/qadevOOo/tests/java/ifc/sheet/_XSheetCondition.java new file mode 100644 index 000000000000..05b0e0f4a3c0 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetCondition.java @@ -0,0 +1,158 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import util.ValueChanger; + +import com.sun.star.sheet.ConditionOperator; +import com.sun.star.sheet.XSheetCondition; +import com.sun.star.table.CellAddress; + +/** +* Testing <code>com.sun.star.sheet.XSheetCondition</code> +* interface methods : +* <ul> +* <li><code> getOperator()</code></li> +* <li><code> setOperator()</code></li> +* <li><code> getFormula1()</code></li> +* <li><code> setFormula1()</code></li> +* <li><code> getFormula2()</code></li> +* <li><code> setFormula2()</code></li> +* <li><code> getSourcePosition()</code></li> +* <li><code> setSourcePosition()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetCondition +*/ +public class _XSheetCondition extends MultiMethodTest { + public XSheetCondition oObj = null; + public String Formula1 = null; + public String Formula2 = null; + public ConditionOperator Operator = null; + public CellAddress SourcePosition = null; + + /** + * Test calls the method, checks and stores returned value. <p> + * Has <b> OK </b> status if returned vakue isn't null. <p> + */ + public void _getFormula1() { + Formula1 = oObj.getFormula1(); + tRes.tested("getFormula1()", Formula1 != null); + } + + /** + * Test calls the method, checks and stores returned value. <p> + * Has <b> OK </b> status if returned vakue isn't null. <p> + */ + public void _getFormula2() { + Formula2 = oObj.getFormula2(); + tRes.tested("getFormula2()", Formula2 != null); + } + + /** + * Test calls the method, checks and stores returned value. <p> + * Has <b> OK </b> status if returned vakue isn't null. <p> + */ + public void _getOperator() { + Operator = oObj.getOperator(); + tRes.tested("getOperator()", Operator != null); + } + + /** + * Test calls the method, checks and stores returned value. <p> + * Has <b> OK </b> status if returned vakue isn't null. <p> + */ + public void _getSourcePosition() { + SourcePosition = oObj.getSourcePosition(); + tRes.tested("getSourcePosition()", SourcePosition != null); + } + + /** + * Test sets new value of formula1, gets formula1 again and compares + * returned value with value that was stored by method + * <code>getFormula1()</code>. <p> + * Has <b> OK </b> status if values aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getFormula1() </code> : to have value of 'Formula1' </li> + * </ul> + */ + public void _setFormula1() { + requiredMethod("getFormula1()"); + oObj.setFormula1("$Sheet1.$C$" + Thread.activeCount()); + tRes.tested("setFormula1()", !Formula1.equals( oObj.getFormula1() ) ); + } + + /** + * Test sets new value of formula2, gets formula2 again and compares + * returned value with value that was stored by method + * <code>getFormula2()</code>. <p> + * Has <b> OK </b> status if values aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getFormula2() </code> : to have value of 'Formula2' </li> + * </ul> + */ + public void _setFormula2() { + requiredMethod("getFormula2()"); + oObj.setFormula2("$Sheet1.$A$" + Thread.activeCount()); + tRes.tested("setFormula2()", !Formula2.equals( oObj.getFormula2() ) ); + } + + /** + * Test sets new value of operator, gets operator and compares + * returned value with value that was set. <p> + * Has <b> OK </b> status if values aren't equal. <p> + */ + public void _setOperator() { + oObj.setOperator(ConditionOperator.BETWEEN); + tRes.tested("setOperator()", !Operator.equals( oObj.getOperator() ) ); + } + + /** + * Test change value that was stored by method + * <code>getSourcePosition()</code>, sets this new value, gets source + * position again and compares returned value with value that was set. <p> + * Has <b> OK </b> status if values aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getSourcePosition() </code> : to have value of source + * position </li> + * </ul> + */ + public void _setSourcePosition() { + requiredMethod("getSourcePosition()"); + oObj.setSourcePosition( + (CellAddress)ValueChanger.changePValue(SourcePosition)); + tRes.tested( + "setSourcePosition()", + !SourcePosition.equals( oObj.getSourcePosition() ) ); + } + +} // finish class _XSheetCondition + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries.java b/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries.java new file mode 100644 index 000000000000..ba8448366bca --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntries.java @@ -0,0 +1,137 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.sheet.ConditionOperator; +import com.sun.star.sheet.XSheetConditionalEntries; +import com.sun.star.table.CellAddress; + +/** +* Testing <code>com.sun.star.sheet.XSheetConditionalEntries</code> +* interface methods : +* <ul> +* <li><code> addNew()</code></li> +* <li><code> removeByIndex()</code></li> +* <li><code> clear()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetConditionalEntries +*/ +public class _XSheetConditionalEntries extends MultiMethodTest { + public XSheetConditionalEntries oObj = null; + int nNum = 0; + + /** + * Test adds a conditional entry to the format. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _addNew() { + nNum = oObj.getCount(); + oObj.addNew( Conditions(4) ); + boolean res = (nNum + 1) == oObj.getCount(); + + tRes.tested("addNew()", res); + } + + /** + * Test calls the method and checks number of conditional entries in + * collection. <p> + * Has <b> OK </b> status if number of conditional entries in co0llection + * after method call is equal zero. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> addNew() </code> : to have one conditional entry in + * collection at least </li> + * </ul> + */ + public void _clear() { + requiredMethod("removeByIndex()"); + oObj.clear(); + int anz = oObj.getCount(); + tRes.tested("clear()", anz == 0); + } + + /** + * Test adds a conditional entry, removes entry with index 0 + * and compares number of entries after adding to number of entries after + * removing. <p> + * Has <b> OK </b> status if number of entries after adding is greater + * than number of entries after removing. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> clear() </code> : to be sure that collection hasn't + * elements </li> + * </ul> + */ + public void _removeByIndex() { + requiredMethod("addNew()"); + oObj.removeByIndex(0); + int pastNum = oObj.getCount(); + tRes.tested("removeByIndex()", pastNum == nNum); + } + + /** + * Method creates array of property value for conditional entry using + * passed parameter <code>nr</code>. + * @param nr number of row for conditional entry + */ + protected PropertyValue[] Conditions(int nr) { + PropertyValue[] con = new PropertyValue[5]; + CellAddress ca = new CellAddress(); + ca.Column = 1; + ca.Row = 5; + ca.Sheet = 0; + con[0] = new PropertyValue(); + con[0].Name = "StyleName"; + con[0].Value = "Result2"; + con[1] = new PropertyValue(); + con[1].Name = "Formula1"; + con[1].Value = "$Sheet1.$B$"+nr; + con[2] = new PropertyValue(); + con[2].Name = "Formula2"; + con[2].Value = ""; + con[3] = new PropertyValue(); + con[3].Name = "Operator"; + con[3].Value = ConditionOperator.EQUAL; + con[4] = new PropertyValue(); + con[4].Name = "SourcePosition"; + con[4].Value = ca; + return con; + } + + /** + * Forces object environment recreation. + */ + protected void after() { + this.disposeEnvironment(); + } +} // finish class _XSheetConditionalEntries + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntry.java b/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntry.java new file mode 100644 index 000000000000..efa3fcc44862 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetConditionalEntry.java @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XSheetConditionalEntry; + +/** +* Testing <code>com.sun.star.sheet.XSheetConditionalEntry</code> +* interface methods : +* <ul> +* <li><code> getStyleName()</code></li> +* <li><code> setStyleName()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetConditionalEntry +*/ +public class _XSheetConditionalEntry extends MultiMethodTest { + + public XSheetConditionalEntry oObj = null; + public String StyleName = null; + + /** + * Test calls the method, stores and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getStyleName() { + StyleName = oObj.getStyleName(); + tRes.tested("getStyleName()", StyleName != null); + } + + /** + * Test sets new value of style name, gets current style name and compares + * returned value with value that was stored by method <code>getStyleName() + * </code>. <p> + * Has <b> OK </b> status if values aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getStyleName() </code> : to have current style name </li> + * </ul> + */ + public void _setStyleName() { + requiredMethod("getStyleName()"); + oObj.setStyleName("Heading"); + tRes.tested("setStyleName()", !StyleName.equals(oObj.getStyleName())); + } + +} // finish class _XSheetConditionalEntry + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetFilterDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_XSheetFilterDescriptor.java new file mode 100644 index 000000000000..ebb6a0a6db57 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetFilterDescriptor.java @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import util.ValueComparer; + +import com.sun.star.sheet.TableFilterField; +import com.sun.star.sheet.XSheetFilterDescriptor; + +/** +* Testing <code>com.sun.star.sheet.XSheetFilterDescriptor</code> +* interface methods : +* <ul> +* <li><code> getFilterFields()</code></li> +* <li><code> setFilterFields()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetFilterDescriptor +*/ +public class _XSheetFilterDescriptor extends MultiMethodTest { + + public XSheetFilterDescriptor oObj = null; + public TableFilterField[] TFF = null; + + /** + * Test calls the method, stores and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getFilterFields(){ + TFF = oObj.getFilterFields(); + tRes.tested("getFilterFields()", TFF != null ); + } + + /** + * Test sets new value of the definitions of the filter fields, + * gets the current definitions of the filter fields and compares + * returned value with value that was stored by method + * <code>getFilterFields()</code>. <p> + * Has <b> OK </b> status if values aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getFilterFields() </code> : to have the current definitions + * of the filter fields </li> + * </ul> + */ + public void _setFilterFields() { + requiredMethod("getFilterFields()"); + TableFilterField[] newTFF = new TableFilterField[1]; + newTFF[0] = new TableFilterField(); + oObj.setFilterFields(newTFF); + newTFF = oObj.getFilterFields(); + tRes.tested("setFilterFields()", ! ValueComparer.equalValue(TFF, newTFF)); + } + +} // finish class _XSheetFilterDescriptor + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetFilterable.java b/qadevOOo/tests/java/ifc/sheet/_XSheetFilterable.java new file mode 100644 index 000000000000..385b7a2e150d --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetFilterable.java @@ -0,0 +1,135 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.beans.XPropertySet; +import com.sun.star.sheet.TableFilterField; +import com.sun.star.sheet.XSheetFilterDescriptor; +import com.sun.star.sheet.XSheetFilterable; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.XColumnRowRange; +import com.sun.star.table.XTableRows; +import com.sun.star.uno.UnoRuntime; + + +public class _XSheetFilterable extends MultiMethodTest { + public XSheetFilterable oObj; + protected XSpreadsheet oSheet; + protected XSheetFilterDescriptor desc; + + protected void before() { + oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET"); + + if (oSheet == null) { + log.println("Object relation oSheet is missing"); + log.println("Trying to query the needed Interface"); + oSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, tEnv.getTestObject()); + + if (oSheet == null) { + throw new StatusException(Status.failed( + "Object relation oSheet is missing")); + } + } + } + + public void _createFilterDescriptor() { + desc = oObj.createFilterDescriptor(true); + + TableFilterField[] tff = new TableFilterField[2]; + tff[0] = new TableFilterField(); + tff[0].IsNumeric = true; + tff[0].Field = 0; + tff[0].NumericValue = 2; + tff[0].Operator = com.sun.star.sheet.FilterOperator.GREATER_EQUAL; + tff[1] = new TableFilterField(); + tff[1].IsNumeric = false; + tff[1].Field = 1; + tff[1].StringValue = "C"; + tff[1].Operator = com.sun.star.sheet.FilterOperator.LESS; + desc.setFilterFields(tff); + tRes.tested("createFilterDescriptor()", true); + } + + public void _filter() { + boolean res = true; + + try { + oSheet.getCellByPosition(0, 0).setValue(1); + oSheet.getCellByPosition(0, 1).setValue(2); + oSheet.getCellByPosition(0, 2).setValue(3); + oSheet.getCellByPosition(1, 0).setFormula("A"); + oSheet.getCellByPosition(1, 1).setFormula("D"); + oSheet.getCellByPosition(1, 2).setFormula("B"); + oObj.filter(desc); + + XColumnRowRange oColumnRowRange = (XColumnRowRange) UnoRuntime.queryInterface( + XColumnRowRange.class, + oSheet); + XTableRows oRows = (XTableRows) oColumnRowRange.getRows(); + XPropertySet rowProp = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, + oRows.getByIndex(0)); + boolean locRes = ((Boolean) rowProp.getPropertyValue("IsVisible")).booleanValue(); + + if (locRes) { + log.println("Row 1 should be invisible after filter()"); + res &= false; + } else { + res &= true; + } + + rowProp = (XPropertySet) UnoRuntime.queryInterface( + XPropertySet.class, oRows.getByIndex(1)); + locRes = ((Boolean) rowProp.getPropertyValue("IsVisible")).booleanValue(); + + if (locRes) { + log.println("Row 2 should be invisible after filter()"); + res &= false; + } else { + res &= true; + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("couldn't fill cells " + e.getLocalizedMessage()); + res = false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("problems geting Property 'isVisible' " + + e.getLocalizedMessage()); + res = false; + } catch (com.sun.star.beans.UnknownPropertyException e) { + log.println("problems geting Property 'isVisible' " + + e.getLocalizedMessage()); + res = false; + } + + tRes.tested("filter()", res); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx.java b/qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx.java new file mode 100644 index 000000000000..afb642290b67 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetFilterableEx.java @@ -0,0 +1,99 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.TableFilterField; +import com.sun.star.sheet.XSheetFilterDescriptor; +import com.sun.star.sheet.XSheetFilterable; +import com.sun.star.sheet.XSheetFilterableEx; +import com.sun.star.uno.UnoRuntime; + + +/** + * Inteface test for XSheetFilterableEx + * + * methods: + * + * createFilterDescriptorByObject + * + */ +public class _XSheetFilterableEx extends MultiMethodTest { + public XSheetFilterableEx oObj = null; + + /** + * queries a XSheetFilterable from the parent Object and then creates + * a XSheetFilterDescriptor with it. + * Returns OK if the Descriptor isn't null and checkFilterDescriptor returns true + */ + + public void _createFilterDescriptorByObject() { + boolean res = true; + Object parent = tEnv.getTestObject(); + XSheetFilterable aFilterable = (XSheetFilterable) UnoRuntime.queryInterface( + XSheetFilterable.class, parent); + XSheetFilterDescriptor desc = oObj.createFilterDescriptorByObject( + aFilterable); + + if (desc != null) { + res &= checkFilterDescriptor(desc); + } else { + log.println("gained XSheetFilterDescriptor is null"); + res &= false; + } + tRes.tested("createFilterDescriptorByObject()",res); + } + + /** + * returns true if the Method getFilterFields() returns a non empty array + * and all Fields can be gained without exception + */ + + public boolean checkFilterDescriptor(XSheetFilterDescriptor desc) { + TableFilterField[] fields = desc.getFilterFields(); + boolean res = true; + + if (fields.length == 0) { + log.println("The gained Descriptor is empty"); + res &= false; + } else { + log.println("Found "+fields.length+" TableFields"); + } + + for (int k = 0; k < fields.length; k++) { + log.println("StringValue(" + k + "): " + fields[k].StringValue); + log.println("IsNumeric(" + k + "): " + fields[k].IsNumeric); + log.println("NumericValue(" + k + "): " + fields[k].NumericValue); + log.println("Field(" + k + "): " + fields[k].Field); + log.println("Connection(" + k + "): " + fields[k].Connection); + log.println("Operator(" + k + "): " + fields[k].Operator); + } + + return res; + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetLinkable.java b/qadevOOo/tests/java/ifc/sheet/_XSheetLinkable.java new file mode 100644 index 000000000000..4972ef7bcc94 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetLinkable.java @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.SheetLinkMode; +import com.sun.star.sheet.XSheetLinkable; +import lib.MultiMethodTest; +import util.utils; + +/** + * + */ +public class _XSheetLinkable extends MultiMethodTest { + public XSheetLinkable oObj = null; + SheetLinkMode slm = null; + String linkSheetName = null; + String linkUrl = null; + String linkUrl2 = null; + + public void before() { + // get a document for linking. + linkUrl = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet"); + linkUrl = utils.getFullTestURL(linkUrl); + + // get a second sheet for changing the link url: if it's not set, + // this part of the test is omitted. + linkUrl2 = (String)tEnv.getObjRelation("XSheetLinkable.LinkSheet2"); + if (linkUrl2 != null) + linkUrl = utils.getFullTestURL(linkUrl); + + // set a name for the sheet. + linkSheetName = "Sheet1"; + } + + public void _getLinkMode() { + requiredMethod("link()"); + slm = oObj.getLinkMode(); + tRes.tested("getLinkMode()", slm == SheetLinkMode.VALUE); + } + + public void _getLinkSheetName() { + requiredMethod("link()"); + String lSheetName = oObj.getLinkSheetName(); + tRes.tested("getLinkSheetName()", linkSheetName.equals(lSheetName)); + } + + public void _getLinkUrl() { + requiredMethod("link()"); + String lUrl = oObj.getLinkUrl(); + System.out.println("URL: " + lUrl); + tRes.tested("getLinkUrl()", lUrl.equals(linkUrl)); + } + + public void _link() { + oObj.link(linkUrl, linkSheetName, "", "", SheetLinkMode.VALUE); + tRes.tested("link()", true); + } + + public void _setLinkMode() { + requiredMethod("getLinkMode()"); + oObj.setLinkMode(SheetLinkMode.NONE); + slm = oObj.getLinkMode(); + tRes.tested("setLinkMode()", slm == SheetLinkMode.NONE); + } + + public void _setLinkSheetName() { + requiredMethod("getLinkSheetName()"); + oObj.setLinkSheetName("Sheet2"); + linkSheetName = oObj.getLinkSheetName(); + tRes.tested("setLinkSheetName()", linkSheetName.equals("Sheet2")); + } + + public void _setLinkUrl() { + requiredMethod("getLinkUrl()"); + boolean result = false; + if (linkUrl2 == null) { + // set back to the original value + oObj.setLinkUrl(linkUrl); + result = true; + } + else { + oObj.setLinkUrl(linkUrl2); + linkUrl = oObj.getLinkUrl(); + result = linkUrl.equals(linkUrl2); + } + tRes.tested("setLinkUrl()", result); + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetOperation.java b/qadevOOo/tests/java/ifc/sheet/_XSheetOperation.java new file mode 100644 index 000000000000..e57c50c00714 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetOperation.java @@ -0,0 +1,104 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.CellFlags; +import com.sun.star.sheet.GeneralFunction; +import com.sun.star.sheet.XSheetOperation; + +/** +* Testing <code>com.sun.star.sheet.XSheetOperation</code> +* interface methods : +* <ul> +* <li><code> computeFunction()</code></li> +* <li><code> clearContents()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetOperation +*/ +public class _XSheetOperation extends MultiMethodTest { + + public XSheetOperation oObj = null; + + /** + * Test clears formula and value contents, calls the method + * <code>computeFunction</code> and checks returned value. <p> + * Has <b> OK </b> status if returned value is equal to zero + * and no exceptions were thrown. <p> + */ + public void _clearContents() { + boolean result = true; + double resultVal = -1; + + log.println("Testing clearContents() ..."); + + int allFlags; + allFlags = CellFlags.VALUE | CellFlags.FORMULA; + + oObj.clearContents (allFlags) ; + + try { + resultVal = oObj.computeFunction(GeneralFunction.SUM); + result &= (resultVal == 0.0) || (resultVal == 0); + } catch (com.sun.star.uno.Exception e) { + result &= false ; + log.println( + "Exception occured while checking results of method"); + e.printStackTrace(log); + } + + tRes.tested("clearContents()", result); + + } // finished clearContents + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is equal or greate than zero + * and no exceptions were thrown. <p> + */ + public void _computeFunction() { + + log.println("Testing computeFunction() ..."); + double resultVal = -1; + boolean result = true; + + try { + resultVal = oObj.computeFunction (GeneralFunction.COUNT) ; + result = resultVal >= 0; + } catch (com.sun.star.uno.Exception e) { + result = false; + log.println("Exception occured in method computeFunction."); + e.printStackTrace(log); + } + + tRes.tested("computeFunction()", result); + } // finished computeFunction + +} // finished class _XSheetOperation + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetOutline.java b/qadevOOo/tests/java/ifc/sheet/_XSheetOutline.java new file mode 100644 index 000000000000..2a69cb7e0404 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetOutline.java @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XCellRangesQuery; +import com.sun.star.sheet.XSheetCellRanges; +import lib.MultiMethodTest; + +import com.sun.star.sheet.XSheetOutline; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.table.TableOrientation; +import com.sun.star.uno.UnoRuntime; +import lib.Status; +import lib.StatusException; + +/** + * + */ +public class _XSheetOutline extends MultiMethodTest { + public XSheetOutline oObj = null; + CellRangeAddress address = null; + CellRangeAddress subaddress = null; + + public void before() { + address = (CellRangeAddress)tEnv.getObjRelation("CellRangeAddress"); + subaddress = (CellRangeAddress)tEnv.getObjRelation("CellRangeSubAddress"); + if (address == null) + throw new StatusException(Status.failed("Object relation CellRangeAddress not found")); + if (subaddress == null) + throw new StatusException(Status.failed("Object relation CellRangeSubAddress not found")); + } + + public void _autoOutline() { + executeMethod("ungroup()"); + boolean result = false; + oObj.autoOutline(address); + // initially the range is grouped and shown + result = isCellShown(subaddress); + oObj.hideDetail(address); + // here only a part of the address is hidden: subaddress must be that part + result &= !isCellShown(subaddress); + tRes.tested("autoOutline()", result); + } + + public void _clearOutline() { + executeMethod("autoOutline()"); + boolean result = false; + oObj.clearOutline(); + result = isCellShown(subaddress); + oObj.hideDetail(address); + result &= isCellShown(subaddress); + tRes.tested("clearOutline()", result); + } + + public void _group() { + oObj.group(address, TableOrientation.COLUMNS); + oObj.group(address, TableOrientation.ROWS); + tRes.tested("group()", true); + } + + public void _ungroup() { + executeMethod("showDetail()"); + oObj.ungroup(address, TableOrientation.COLUMNS); + oObj.ungroup(address, TableOrientation.ROWS); + oObj.hideDetail(address); + tRes.tested("ungroup()", isCellShown(address)); + } + + public void _hideDetail() { + requiredMethod("group()"); + oObj.hideDetail(address); + tRes.tested("hideDetail()", !isCellShown(address)); + } + + public void _showDetail() { + executeMethod("showLevel()"); + oObj.showDetail(address); + tRes.tested("showDetail()", isCellShown(address)); + } + + public void _showLevel() { + executeMethod("hideDetail()"); + boolean result = false; + oObj.showLevel((short)2, TableOrientation.COLUMNS); + oObj.showLevel((short)2, TableOrientation.ROWS); + result = isCellShown(address); + oObj.showLevel((short)0, TableOrientation.COLUMNS); + oObj.showLevel((short)0, TableOrientation.ROWS); + + result &= !isCellShown(address); + tRes.tested("showLevel()", result); + } + + private boolean isCellShown(CellRangeAddress range) { + boolean isNotShown = true; + XCellRangesQuery xCellRangesQuery = (XCellRangesQuery)UnoRuntime.queryInterface(XCellRangesQuery.class, oObj); + if (xCellRangesQuery != null) { + XSheetCellRanges xRanges = xCellRangesQuery.queryVisibleCells(); + CellRangeAddress[] visibleRanges = xRanges.getRangeAddresses(); + for (int i=0; i<visibleRanges.length; i++) { + isNotShown &= dotIsOutsideRange(range.StartRow, range.StartColumn, visibleRanges[i]); + isNotShown &= dotIsOutsideRange(range.StartRow, range.EndColumn, visibleRanges[i]); + isNotShown &= dotIsOutsideRange(range.EndRow, range.StartColumn, visibleRanges[i]); + isNotShown &= dotIsOutsideRange(range.EndRow, range.EndColumn, visibleRanges[i]); + log.println(isNotShown?"\tisOutSide":"\tisInside"); + } + } + return !isNotShown; + } + + private boolean dotIsOutsideRange(int dotRow, int dotColumn, CellRangeAddress range) { + log.println("Checking dot(" + dotRow + "," + dotColumn + ") against row[" + + range.StartRow + ":" + range.EndRow + "] column[" + + range.StartColumn + ":" + range.EndColumn + "]"); + boolean isInside = true; + if (dotRow >= range.StartRow && dotRow <= range.EndRow) + if (dotColumn >= range.StartColumn && dotColumn <= range.EndColumn) + isInside = false; + return isInside; + } +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XSheetPageBreak.java b/qadevOOo/tests/java/ifc/sheet/_XSheetPageBreak.java new file mode 100644 index 000000000000..bcd47dbc861f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSheetPageBreak.java @@ -0,0 +1,93 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.TablePageBreakData; +import com.sun.star.sheet.XSheetPageBreak; + +/** +* Testing <code>com.sun.star.sheet.XSheetPageBreak</code> +* interface methods : +* <ul> +* <li><code> getColumnPageBreaks()</code></li> +* <li><code> getRowPageBreaks()</code></li> +* <li><code> removeAllManualPageBreaks()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSheetPageBreak +*/ +public class _XSheetPageBreak extends MultiMethodTest { + + public XSheetPageBreak oObj = null; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getColumnPageBreaks() { + TablePageBreakData[] breakArr = oObj.getColumnPageBreaks(); + tRes.tested("getColumnPageBreaks()", breakArr != null); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getRowPageBreaks() { + TablePageBreakData[] breakArr = oObj.getRowPageBreaks(); + tRes.tested("getRowPageBreaks()", breakArr != null); + } + + /** + * Test calls the method and checks that all breaks gone. <p> + * Has <b> OK </b> status if number of column breaks and number of row breaks + * are equal to zero. <p> + */ + public void _removeAllManualPageBreaks() { + oObj.removeAllManualPageBreaks(); + + int manualRowPageBreaks = 0; + int manualColumnPageBreaks = 0; + + log.println("Check if all breaks are gone"); + + TablePageBreakData[] breakArr = oObj.getColumnPageBreaks(); + for (int i = 0; i < breakArr.length; i++) + if (breakArr[i].ManualBreak) manualColumnPageBreaks++; + + breakArr = oObj.getRowPageBreaks(); + for (int i = 0; i < breakArr.length; i++) + if (breakArr[i].ManualBreak) manualRowPageBreaks++ ; + + tRes.tested( + "removeAllManualPageBreaks()", + manualColumnPageBreaks == 0 && manualRowPageBreaks == 0); + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSpreadsheet.java b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheet.java new file mode 100644 index 000000000000..8e1f6c044513 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheet.java @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XSheetCellCursor; +import com.sun.star.sheet.XSheetCellRange; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.table.XCellRange; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XSpreadsheet</code> +* interface methods : +* <ul> +* <li><code> createCursor()</code></li> +* <li><code> createCursorByRange()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSpreadsheet +*/ +public class _XSpreadsheet extends MultiMethodTest { + + // oObj filled by MultiMethodTest + public XSpreadsheet oObj = null; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _createCursor() { + log.println("Testing createCursor"); + XSheetCellCursor oCursor = oObj.createCursor() ; + tRes.tested("createCursor()", oCursor != null); + } + + /** + * Test gets a cell range, call method using this cell range + * and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null + * and no exceptions were thrown. <p> + */ + public void _createCursorByRange() { + log.println("Testing createCursorByRange"); + + log.println("getting cellrange"); + XCellRange oRange = null; + try { + oRange = oObj.getCellRangeByPosition (1, 1, 2, 3); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Can't get cell range by address"); + e.printStackTrace(log); + tRes.tested("createCursorByRange()", false); + } + + XSheetCellRange oSheetRange = (XSheetCellRange) + UnoRuntime.queryInterface(XSheetCellRange.class, oRange) ; + log.println("getting Cursor"); + XSheetCellCursor oCursor = oObj.createCursorByRange(oSheetRange); + tRes.tested("createCursorByRange()", oCursor != null); + } + +} // finisch class _XSpreadsheet + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSpreadsheetDocument.java b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheetDocument.java new file mode 100644 index 000000000000..c3d667deccf8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheetDocument.java @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XSpreadsheetDocument; +import com.sun.star.sheet.XSpreadsheets; + +/** +* Testing <code>com.sun.star.sheet.XSpreadsheetDocument</code> +* interface methods : +* <ul> +* <li><code> getSheets()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSpreadsheetDocument +*/ +public class _XSpreadsheetDocument extends MultiMethodTest { + + public XSpreadsheetDocument oObj = null; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getSheets() { + XSpreadsheets sheets = oObj.getSheets(); + tRes.tested("getSheets()", sheets != null); + } + + +} // finish class _XSpreadsheetDocument + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView.java b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView.java new file mode 100644 index 000000000000..a016214d0cdf --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheetView.java @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSpreadsheetView; + +/** +* Testing <code>com.sun.star.sheet.XSpreadsheetView</code> +* interface methods : +* <ul> +* <li><code> getActiveSheet()</code></li> +* <li><code> setActiveSheet()</code></li> +* </ul> <p> +* This test needs the following object relations : +* <ul> +* <li> <code>'Sheet'</code> (of type <code>XSpreadsheet</code>): +* to set new active spreadsheet </li> +* <ul> <p> +* @see com.sun.star.sheet.XSpreadsheetView +*/ +public class _XSpreadsheetView extends MultiMethodTest { + + public XSpreadsheetView oObj = null; + public XSpreadsheet oSheet = null; + + /** + * Test calls the method, stores and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getActiveSheet() { + oSheet = oObj.getActiveSheet(); + tRes.tested("getActiveSheet()", oSheet != null); + } + + /** + * Test sets new active sheet that was obtained by relation + * <code>'Sheet'</code>, gets the current active sheet and compares + * returned value with value that was stored by method + * <code>getFilterFields()</code>. <p> + * Has <b> OK </b> status if values aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getActiveSheet() </code> : to have the current + * active sheet </li> + * </ul> + */ + public void _setActiveSheet() { + requiredMethod("getActiveSheet()"); + + XSpreadsheet new_Sheet = (XSpreadsheet)tEnv.getObjRelation("Sheet"); + if (new_Sheet == null) throw new StatusException(Status.failed + ("Relation 'Sheet' not found")); + + oObj.setActiveSheet(new_Sheet); + new_Sheet = oObj.getActiveSheet(); + tRes.tested("setActiveSheet()", !oSheet.equals(new_Sheet)); + } + + +} // finish class _XSpreadsheetView + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XSpreadsheets.java b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheets.java new file mode 100644 index 000000000000..1b3682586778 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSpreadsheets.java @@ -0,0 +1,184 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.XSpreadsheets; + +import lib.MultiMethodTest; + + +/** +* Testing <code>com.sun.star.sheet.XSpreadsheets</code> +* interface methods : +* <ul> +* <li><code> insertNewByName()</code></li> +* <li><code> moveByName()</code></li> +* <li><code> copyByName()</code></li> +* </ul> <p> +* Test is multithread compilant. <p> +* @see com.sun.star.sheet.XSpreadsheets +*/ +public class _XSpreadsheets extends MultiMethodTest { + protected static int uniqCount = 0; + public XSpreadsheets oObj = null; + protected int uniqNumber = 0; + + /** + * Sets the unique number for the current test. + */ + protected synchronized void before() { + uniqNumber = uniqCount++; + } + + /** + * Test inserts new sheet using the name returned by the method + * <code>newName</code>, copies inserted sheet with the new name, + * checks existence of the sheet with this name in collection and removes + * the both sheets from the collection. <p> + * Has <b> OK </b> status if the sheet with the name of the copy exists + * in the collection and no exceptions were thrown. <p> + */ + public void _copyByName() { + boolean result = true; + + //first insert one that should be copied + String iS = newName("copyFrom"); + log.println("Inserting sheet '" + iS + "'"); + oObj.insertNewByName(iS, (short) 0); + + String[] eNames = oObj.getElementNames(); + String NewSheet = newName("copyTo"); + log.println("Try to copy " + eNames[0] + " to " + NewSheet); + oObj.copyByName(eNames[0], NewSheet, (short) 0); + result = oObj.hasByName(NewSheet); + + //remove all inserted sheets + try { + oObj.removeByName(NewSheet); + oObj.removeByName(iS); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.print("Can't remove sheet by name"); + e.printStackTrace(log); + result = false; + } catch (com.sun.star.container.NoSuchElementException e) { + log.print("Can't remove sheet by name"); + e.printStackTrace(log); + result = false; + } + + tRes.tested("copyByName()", result); + } // finished _copyByName + + /** + * Test inserts new sheet using the name returned by the method + * <code>newName</code>, moves the inserted sheet to the new position + * in collection, gets all element names in collection and checks the name + * of the sheet in the new position. <p> + * Has <b> OK </b> status if the sheet name in the new position is equal to + * the name of the sheet that was moved. <p> + */ + public void _moveByName() { + //first insert one that should be moved + String iS = newName("move"); + oObj.insertNewByName(iS, (short) 0); + + String[] eNames = oObj.getElementNames(); + String sheetToMove = eNames[0]; + log.println("Try to move " + sheetToMove); + oObj.moveByName(sheetToMove, (short) 2); + eNames = oObj.getElementNames(); + tRes.tested("moveByName()", sheetToMove.equals(eNames[1])); + } // finished _moveByName + + /** + * Test inserts new sheet using the name returned by the method + * <code>newName</code>, checks the existence of the inserted sheet in + * the collection, removes the sheet, tries to insert the sheet with the + * bad name returned by method <code>badName()</code>. <p> + * Has <b> OK </b> status if the inserted sheet exists in the collection + * after first method call and if exception occured during the second call. <p> + */ + public void _insertNewByName() { + boolean result = false; + + String NewSheet = newName("insert"); + log.println("Try to insert " + NewSheet); + oObj.insertNewByName(NewSheet, (short) 0); + result = oObj.hasByName(NewSheet); + + try { + oObj.removeByName(NewSheet); + } catch (com.sun.star.lang.WrappedTargetException e) { + log.print("Can't remove sheet '" + NewSheet + "':"); + e.printStackTrace(log); + result = false; + } catch (com.sun.star.container.NoSuchElementException e) { + log.print("Can't remove sheet '" + NewSheet + "':"); + e.printStackTrace(log); + result = false; + } + + try { + NewSheet = badName(); + log.println("Try to insert " + NewSheet); + oObj.insertNewByName(NewSheet, (short) 0); + log.println( + "No Exception thrown while inserting sheet with invalid name"); + result &= false; + oObj.removeByName(NewSheet); + } catch (com.sun.star.uno.RuntimeException e) { + log.println( + "Expected exception occured during testing 'insertNewByName'"); + result &= true; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.print("Can't remove sheet '" + NewSheet + "':"); + e.printStackTrace(log); + result = false; + } catch (com.sun.star.container.NoSuchElementException e) { + log.print("Can't remove sheet '" + NewSheet + "':"); + e.printStackTrace(log); + result = false; + } + + tRes.tested("insertNewByName()", result); + } // finished _insertByName + + /** + * Method returns unique new name using passed prefix and unique number + * of the current test. + */ + public String newName(String prefix) { + return prefix + uniqNumber; + } // finished newName + + /** + * Method return bad name for a sheet using the name of the current thread. + */ + public String badName() { + return "$%#/?\\"; + } // finished badName +} //finish class _XSpreadsheets diff --git a/qadevOOo/tests/java/ifc/sheet/_XSubTotalCalculatable.java b/qadevOOo/tests/java/ifc/sheet/_XSubTotalCalculatable.java new file mode 100644 index 000000000000..6d68b74919af --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSubTotalCalculatable.java @@ -0,0 +1,125 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import lib.MultiMethodTest; +import lib.Status; +import lib.StatusException; + +import com.sun.star.sheet.SubTotalColumn; +import com.sun.star.sheet.XSpreadsheet; +import com.sun.star.sheet.XSubTotalCalculatable; +import com.sun.star.sheet.XSubTotalDescriptor; +import com.sun.star.uno.UnoRuntime; + + +public class _XSubTotalCalculatable extends MultiMethodTest { + public XSubTotalCalculatable oObj; + protected XSubTotalDescriptor desc; + protected XSpreadsheet oSheet; + + protected void before() { + oSheet = (XSpreadsheet) tEnv.getObjRelation("SHEET"); + + if (oSheet == null) { + log.println("Object relation oSheet is missing"); + log.println("Trying to query the needed Interface"); + oSheet = (XSpreadsheet) UnoRuntime.queryInterface( + XSpreadsheet.class, tEnv.getTestObject()); + + if (oSheet == null) { + throw new StatusException(Status.failed( + "Object relation oSheet is missing")); + } + } + } + + public void _applySubTotals() { + requiredMethod("createSubTotalDescriptor()"); + + boolean res = true; + + try { + oSheet.getCellByPosition(0, 0).setFormula("first"); + oSheet.getCellByPosition(1, 0).setFormula("second"); + oSheet.getCellByPosition(0, 3).setFormula(""); + oSheet.getCellByPosition(0, 1).setValue(5); + oSheet.getCellByPosition(0, 2).setValue(5); + oSheet.getCellByPosition(1, 1).setValue(17); + oSheet.getCellByPosition(1, 2).setValue(25); + oObj.applySubTotals(desc, true); + + String formula = oSheet.getCellByPosition(0, 3).getFormula(); + String expected = "=SUBTOTAL(9;$A$2:$A$3)"; + res = formula.equals(expected); + + if (!res) { + log.println("getting: " + formula); + log.println("expected: " + expected); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't fill cells" + e.getLocalizedMessage()); + res = false; + } + + tRes.tested("applySubTotals()", res); + } + + public void _createSubTotalDescriptor() { + desc = oObj.createSubTotalDescriptor(true); + + SubTotalColumn[] columns = new SubTotalColumn[1]; + columns[0] = new SubTotalColumn(); + columns[0].Column = 0; + columns[0].Function = com.sun.star.sheet.GeneralFunction.SUM; + desc.addNew(columns, 0); + tRes.tested("createSubTotalDescriptor()", true); + } + + public void _removeSubTotals() { + requiredMethod("applySubTotals()"); + + boolean res = true; + + try { + oObj.removeSubTotals(); + + String formula = oSheet.getCellByPosition(0, 3).getFormula(); + String expected = ""; + res = formula.equals(expected); + + if (!res) { + log.println("getting: " + formula); + log.println("expected: " + expected); + } + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Couldn't get cell" + e.getLocalizedMessage()); + } + + tRes.tested("removeSubTotals()", res); + } +}
\ No newline at end of file diff --git a/qadevOOo/tests/java/ifc/sheet/_XSubTotalDescriptor.java b/qadevOOo/tests/java/ifc/sheet/_XSubTotalDescriptor.java new file mode 100644 index 000000000000..19c3eefd721a --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSubTotalDescriptor.java @@ -0,0 +1,77 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +package ifc.sheet; + +import com.sun.star.sheet.GeneralFunction; +import com.sun.star.sheet.SubTotalColumn; +import com.sun.star.sheet.XSubTotalDescriptor; + +import lib.MultiMethodTest; + + +/** +* Testing <code>com.sun.star.sheet.XSubTotalDescriptor</code> +* interface methods : +* <ul> +* <li><code> addNew()</code></li> +* <li><code> clear()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSubTotalDescriptor +*/ +public class _XSubTotalDescriptor extends MultiMethodTest { + public XSubTotalDescriptor oObj = null; + + /** + * Test creates a subtotal field definition and adds it to the descriptor.<p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _addNew() { + SubTotalColumn[] columns = new SubTotalColumn[1]; + SubTotalColumn column = new SubTotalColumn(); + column.Column = 5; + column.Function = GeneralFunction.SUM; + columns[0] = column; + oObj.addNew(columns, 1); + tRes.tested("addNew()", true); + } + + /** + * Test just calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _clear() { + oObj.clear(); + tRes.tested("clear()", true); + } + + /** + * Forces environment recreation. + */ + protected void after() { + disposeEnvironment(); + } +} // finish class _XSubTotalDescriptor diff --git a/qadevOOo/tests/java/ifc/sheet/_XSubTotalField.java b/qadevOOo/tests/java/ifc/sheet/_XSubTotalField.java new file mode 100644 index 000000000000..000239e84117 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XSubTotalField.java @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.GeneralFunction; +import com.sun.star.sheet.SubTotalColumn; +import com.sun.star.sheet.XSubTotalField; + +/** +* Testing <code>com.sun.star.sheet.XSubTotalField</code> +* interface methods : +* <ul> +* <li><code> getGroupColumn()</code></li> +* <li><code> setGroupColumn()</code></li> +* <li><code> getSubTotalColumns()</code></li> +* <li><code> setSubTotalColumns()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XSubTotalField +*/ +public class _XSubTotalField extends MultiMethodTest { + + public XSubTotalField oObj = null; + public int GroupColumn = 0; + public SubTotalColumn[] STColumns = null; + + /** + * Test calls the method, stores and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't equal to zero. <p> + */ + public void _getGroupColumn() { + GroupColumn = oObj.getGroupColumn(); + tRes.tested("getGroupColumn()", GroupColumn != 0); + } // end of getGroupColumn + + /** + * Test calls the method, stores and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't null. <p> + */ + public void _getSubTotalColumns() { + STColumns = oObj.getSubTotalColumns(); + tRes.tested("getSubTotalColumns()", STColumns != null); + } // end of getSubTotalColumns + + /** + * Test sets new value of the column by which entries are grouped, + * gets the current value and compares + * returned value with value that was stored by method + * <code>getGroupColumn()</code>. <p> + * Has <b> OK </b> status if values aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getGroupColumn() </code> : to have the current column by + * which entries are grouped </li> + * </ul> + */ + public void _setGroupColumn() { + requiredMethod("getGroupColumn()"); + oObj.setGroupColumn(2); + tRes.tested("setGroupColumn()", GroupColumn != oObj.getGroupColumn()); + } // end of getGroupColumn + + /** + * Test sets new value using method, gets the current value and compares + * returned value with value that was stored by method + * <code>getSubTotalColumns()</code>. <p> + * Has <b> OK </b> status if values aren't equal. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> getSubTotalColumns() </code> : to have the current value</li> + * </ul> + */ + public void _setSubTotalColumns() { + requiredMethod("getSubTotalColumns()"); + SubTotalColumn[] columns = new SubTotalColumn[2]; + SubTotalColumn column = new SubTotalColumn(); + column.Column=2; + column.Function=GeneralFunction.AVERAGE; + columns[0]=column; + columns[1]=STColumns[0]; + oObj.setSubTotalColumns(columns); + tRes.tested( + "setSubTotalColumns()", + !STColumns.equals(oObj.getSubTotalColumns()) ); + } // end of getSubTotalColumns + +} // finish class _XSubTotalField + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XUniqueCellFormatRangesSupplier.java b/qadevOOo/tests/java/ifc/sheet/_XUniqueCellFormatRangesSupplier.java new file mode 100644 index 000000000000..43bd1f3d5adf --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XUniqueCellFormatRangesSupplier.java @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.sheet.XUniqueCellFormatRangesSupplier; + +public class _XUniqueCellFormatRangesSupplier extends MultiMethodTest { + + public XUniqueCellFormatRangesSupplier oObj; + + /** + * call the method getUniqueCellFormatRanges and returns OK result if + * the gained XIndexAccess isn't null and the method checkIndexAccess + * returns true. + */ + + public void _getUniqueCellFormatRanges() { + boolean res = true; + XIndexAccess xIA = oObj.getUniqueCellFormatRanges(); + if (xIA != null) { + res = checkIndexAccess(xIA); + } else { + log.println("The gained IndexAccess is null"); + res = false; + } + tRes.tested("getUniqueCellFormatRanges()",res); + } + + /** + * calls the method getCount at the IndexAccess, returns true is it is >0 + * and getByIndex() doesn't throw an exception for Indexes between 0 and count + */ + + protected boolean checkIndexAccess(XIndexAccess xIA) { + boolean res = true; + int count = xIA.getCount(); + log.println("Found "+count+" Elements"); + res &= count>0; + for (int k=0; k<count; k++) { + try { + Object element = xIA.getByIndex(k); + log.println("Element "+k+" = "+element); + } catch (com.sun.star.lang.IndexOutOfBoundsException e) { + log.println("Unexpected Exception while getting by Index ("+k+")"+e.getMessage()); + res &=false; + } catch (com.sun.star.lang.WrappedTargetException e) { + log.println("Unexpected Exception while getting by Index ("+k+")"+e.getMessage()); + res &=false; + } + } + return res; + } + + +} diff --git a/qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor.java b/qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor.java new file mode 100644 index 000000000000..6812704fd80f --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XUsedAreaCursor.java @@ -0,0 +1,138 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XCellRangeAddressable; +import com.sun.star.sheet.XSheetCellCursor; +import com.sun.star.sheet.XUsedAreaCursor; +import com.sun.star.table.CellRangeAddress; +import com.sun.star.uno.UnoRuntime; + +/** +* Testing <code>com.sun.star.sheet.XUsedAreaCursor</code> +* interface methods : +* <ul> +* <li><code> gotoStartOfUsedArea()</code></li> +* <li><code> gotoEndOfUsedArea()</code></li> +* </ul> <p> +* Component must also implement the following interfaces : +* <ul> +* <li> <code> com.sun.star.XCellRangeAddressable </code> : to check the current +* position of the cursor </li> +* <ul> <p> +* @see com.sun.star.sheet.XUsedAreaCursor +*/ +public class _XUsedAreaCursor extends MultiMethodTest { + + public XUsedAreaCursor oObj = null; + public XSheetCellCursor oC = null; + CellRangeAddress sAddr = null; + + /** + * Test points the cursor to the start of used area, expands cursor to the + * end of the used area, gets and checks current range address, then + * points the cursor to the end of the used area, gets and checks current + * range address again. <p> + * Has <b> OK </b> status if the range address expands at all used area + * in first case and if the range address just points to the cell at the end + * of the used area in second case. <p> + */ + public void _gotoEndOfUsedArea() { + boolean result = true ; + + XCellRangeAddressable oAddr = (XCellRangeAddressable) + UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ; + + // first with true argument + oObj.gotoStartOfUsedArea(false); + oObj.gotoEndOfUsedArea(true); + sAddr = oAddr.getRangeAddress(); + + result &= (sAddr.StartColumn == 1); + result &= (sAddr.StartRow == 1); + result &= (sAddr.EndColumn == 4); + result &= (sAddr.EndRow == 5); + + oObj.gotoEndOfUsedArea(false); + sAddr = oAddr.getRangeAddress(); + + result &= (sAddr.StartColumn == 4); + result &= (sAddr.StartRow == 5); + result &= (sAddr.EndColumn == 4); + result &= (sAddr.EndRow == 5); + + tRes.tested("gotoEndOfUsedArea()", result) ; + } + + /** + * Test points the cursor to the end of used area, expands cursor to the + * start of the used area, gets and checks current range address, then + * points the cursor to the start of the used area, gets and checks current + * range address again. <p> + * Has <b> OK </b> status if the range address expands at all used area + * in first case and if the range address just points to the cell at the + * start of the used area in second case. <p> + */ + public void _gotoStartOfUsedArea() { + XCellRangeAddressable oAddr = (XCellRangeAddressable) + UnoRuntime.queryInterface (XCellRangeAddressable.class, oObj) ; + + boolean result = true ; + + // with true parameter first + oObj.gotoEndOfUsedArea(false); + oObj.gotoStartOfUsedArea(true); + sAddr = oAddr.getRangeAddress(); + + result &= (sAddr.StartColumn == 1); + result &= (sAddr.StartRow == 1); + result &= (sAddr.EndColumn == 4); + result &= (sAddr.EndRow == 5); + + // now testing with false parameter + oObj.gotoStartOfUsedArea(false); + sAddr = oAddr.getRangeAddress(); + + result &= (sAddr.StartColumn == 1); + result &= (sAddr.StartRow == 1); + result &= (sAddr.EndColumn == 1); + result &= (sAddr.EndRow == 1); + + tRes.tested("gotoStartOfUsedArea()", result) ; + } // finished gotoStartOfUsedArea + + /** + * Forces object environment recreation. + */ + protected void after() { + this.disposeEnvironment(); + } +} // finished class _XUsedAreaCursor + diff --git a/qadevOOo/tests/java/ifc/sheet/_XViewFreezable.java b/qadevOOo/tests/java/ifc/sheet/_XViewFreezable.java new file mode 100644 index 000000000000..ded696dcd0d1 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XViewFreezable.java @@ -0,0 +1,78 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XViewFreezable; + +/** +* Testing <code>com.sun.star.sheet.XViewFreezable</code> +* interface methods : +* <ul> +* <li><code> hasFrozenPanes()</code></li> +* <li><code> freezeAtPosition()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XViewFreezable +*/ +public class _XViewFreezable extends MultiMethodTest { + + public XViewFreezable oObj = null; + + /** + * Test calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _freezeAtPosition() { + oObj.freezeAtPosition(2, 2); + tRes.tested("freezeAtPosition()", true); + } + + /** + * Test calls the method, checks returned value, unfreezes panes, calls the + * method and checks returned value again. <p> + * Has <b> OK </b> status if returned value is true after firts call and + * returned value is false after second. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> freezeAtPosition() </code> : to freeze panes with the + * specified number of columns and rows </li> + * </ul> + */ + public void _hasFrozenPanes() { + requiredMethod("freezeAtPosition()"); + boolean result = oObj.hasFrozenPanes(); + oObj.freezeAtPosition(0,0); + result &= !oObj.hasFrozenPanes(); + tRes.tested("hasFrozenPanes()", result); + } + + +} // finish class _XViewFreezable + + diff --git a/qadevOOo/tests/java/ifc/sheet/_XViewPane.java b/qadevOOo/tests/java/ifc/sheet/_XViewPane.java new file mode 100644 index 000000000000..6fa46876022e --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XViewPane.java @@ -0,0 +1,133 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XViewPane; +import com.sun.star.table.CellRangeAddress; + +/** +* Testing <code>com.sun.star.sheet.XViewPane</code> +* interface methods : +* <ul> +* <li><code> getFirstVisibleColumn()</code></li> +* <li><code> setFirstVisibleColumn()</code></li> +* <li><code> getFirstVisibleRow()</code></li> +* <li><code> setFirstVisibleRow()</code></li> +* <li><code> getVisibleRange()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XViewPane +*/ +public class _XViewPane extends MultiMethodTest { + + public XViewPane oObj = null; + int row = 3; + int col = 5; + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is equal to value that was set + * by method <code>setFirstVisibleColumn()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setFirstVisibleColumn() </code> : to set specific value + * of the first column that is visible in the pane </li> + * </ul> + */ + public void _getFirstVisibleColumn() { + requiredMethod("setFirstVisibleColumn()"); + boolean result = col == oObj.getFirstVisibleColumn(); + tRes.tested("getFirstVisibleColumn()", result); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is equal to value that was set + * by method <code>setFirstVisibleRow()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setFirstVisibleRow() </code> : to set specific value of + * the first row that is visible in the pane </li> + * </ul> + */ + public void _getFirstVisibleRow() { + requiredMethod("setFirstVisibleRow()"); + boolean result = row == oObj.getFirstVisibleRow(); + tRes.tested("getFirstVisibleRow()", result); + } + + /** + * Test just calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _setFirstVisibleColumn() { + oObj.setFirstVisibleColumn(col); + tRes.tested("setFirstVisibleColumn()", true); + } + + /** + * Test just calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _setFirstVisibleRow() { + oObj.setFirstVisibleRow(row); + tRes.tested("setFirstVisibleRow()", true); + } + + /** + * Test calls the method, checks returned value and adds object relation + * 'DATAAREA' to test environment. <p> + * Has <b> OK </b> status if returned value isn't null and if start row and + * start column are equal to values that was set by methods + * <code>setFirstVisibleRow</code> and <code>setFirstVisibleColumn</code>.<p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> setFirstVisibleRow() </code> : to set specific value of + * the first row that is visible in the pane </li> + * <li> <code> setFirstVisibleColumn() </code> : to set specific value of + * the first column that is visible in the pane </li> + * </ul> + */ + public void _getVisibleRange() { + requiredMethod("setFirstVisibleRow()"); + requiredMethod("setFirstVisibleColumn()"); + + CellRangeAddress RA = oObj.getVisibleRange(); + boolean result = RA != null; + if (result) { + result &= RA.Sheet == 0; + result &= RA.StartRow == row; + result &= RA.StartColumn == col; + tEnv.addObjRelation("DATAAREA", RA); + } + + tRes.tested("getVisibleRange()", result); + } +} + diff --git a/qadevOOo/tests/java/ifc/sheet/_XViewSplitable.java b/qadevOOo/tests/java/ifc/sheet/_XViewSplitable.java new file mode 100644 index 000000000000..5fbdce6c7cb8 --- /dev/null +++ b/qadevOOo/tests/java/ifc/sheet/_XViewSplitable.java @@ -0,0 +1,136 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +package ifc.sheet; + +import lib.MultiMethodTest; + +import com.sun.star.sheet.XViewSplitable; + +/** +* Testing <code>com.sun.star.sheet.XViewSplitable</code> +* interface methods : +* <ul> +* <li><code> getIsWindowSplit()</code></li> +* <li><code> getSplitHorizontal()</code></li> +* <li><code> getSplitVertical()</code></li> +* <li><code> getSplitColumn()</code></li> +* <li><code> getSplitRow()</code></li> +* <li><code> splitAtPosition()</code></li> +* </ul> <p> +* @see com.sun.star.sheet.XViewSplitable +*/ +public class _XViewSplitable extends MultiMethodTest { + + public XViewSplitable oObj = null; + protected final int posX = 101, posY = 51; + + /** + * Test just calls the method. <p> + * Has <b> OK </b> status if the method successfully returns. <p> + */ + public void _splitAtPosition(){ + oObj.splitAtPosition(posX, posY); + tRes.tested("splitAtPosition()", true); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value is equal to true. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> splitAtPosition() </code> : that the view was splitted into + * individual panes </li> + * </ul> + */ + public void _getIsWindowSplit(){ + requiredMethod("splitAtPosition()"); + tRes.tested("getIsWindowSplit()", oObj.getIsWindowSplit()); + } + + /** + * Test calls the method and compares returned value with value that was + * set by method <code>splitAtPosition()</code>. <p> + * Has <b> OK </b> status if returned value is equal to value that was + * set by method <code>splitAtPosition()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> splitAtPosition() </code> : to split the view at the + * specified position </li> + * </ul> + */ + public void _getSplitHorizontal() { + requiredMethod("splitAtPosition()"); + tRes.tested("getSplitHorizontal()", oObj.getSplitHorizontal() == posX); + } + + /** + * Test calls the method and compares returned value with value that was + * set by method <code>splitAtPosition()</code>. <p> + * Has <b> OK </b> status if returned value is equal to value that was + * set by method <code>splitAtPosition()</code>. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> splitAtPosition() </code> : to split the view at the + * specified position </li> + * </ul> + */ + public void _getSplitVertical() { + requiredMethod("splitAtPosition()"); + tRes.tested("getSplitVertical()", oObj.getSplitVertical() == posY); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't equal zero. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> splitAtPosition() </code> : to split the view at the + * specified position </li> + * </ul> + */ + public void _getSplitColumn() { + requiredMethod("splitAtPosition()"); + tRes.tested("getSplitColumn()", oObj.getSplitColumn() != 0); + } + + /** + * Test calls the method and checks returned value. <p> + * Has <b> OK </b> status if returned value isn't equal zero. <p> + * The following method tests are to be completed successfully before : + * <ul> + * <li> <code> splitAtPosition() </code> : to split the view at the + * specified position </li> + * </ul> + */ + public void _getSplitRow() { + requiredMethod("splitAtPosition()"); + tRes.tested("getSplitRow()", oObj.getSplitRow() != 0); + } +} // finish class _XViewSplitable + + |