summaryrefslogtreecommitdiffstats
path: root/testtools/source/cliversioning
diff options
context:
space:
mode:
Diffstat (limited to 'testtools/source/cliversioning')
-rw-r--r--testtools/source/cliversioning/makefile.mk134
-rw-r--r--testtools/source/cliversioning/readme.txt93
-rw-r--r--testtools/source/cliversioning/runtests.cs118
-rw-r--r--testtools/source/cliversioning/version.cs599
-rw-r--r--testtools/source/cliversioning/version_libs/readme.txt3
-rw-r--r--testtools/source/cliversioning/version_libs/version_3_0_0.dllbin0 -> 11776 bytes
-rw-r--r--testtools/source/cliversioning/version_libs/version_3_0_1.dllbin0 -> 11776 bytes
-rwxr-xr-xtesttools/source/cliversioning/version_libs/version_3_1.dllbin0 -> 11776 bytes
-rw-r--r--testtools/source/cliversioning/version_libs/version_3_1_1.dllbin0 -> 11776 bytes
-rwxr-xr-xtesttools/source/cliversioning/version_libs/version_3_2.dllbin0 -> 11776 bytes
-rwxr-xr-xtesttools/source/cliversioning/version_libs/version_3_2_1.dllbin0 -> 11776 bytes
-rwxr-xr-xtesttools/source/cliversioning/version_libs/version_3_3.dllbin0 -> 11776 bytes
12 files changed, 947 insertions, 0 deletions
diff --git a/testtools/source/cliversioning/makefile.mk b/testtools/source/cliversioning/makefile.mk
new file mode 100644
index 000000000..aabbeb296
--- /dev/null
+++ b/testtools/source/cliversioning/makefile.mk
@@ -0,0 +1,134 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+# Builds the SpreadSheet examples of the Developers Guide.
+
+PRJ = ..$/..
+PRJNAME = cli_ure
+TARGET := test_climaker
+PACKAGE = cliversion
+
+.INCLUDE: settings.mk
+
+.IF "$(CROSS_COMPILING)"=="YES"
+
+all:
+# nothing
+
+.ENDIF
+
+.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+.IF "$(debug)" != ""
+CSCFLAGS += -checked+ -define:DEBUG -define:TRACE -debug+
+.ELSE
+CSCFLAGS += -optimize+
+.ENDIF
+
+
+EXETARGET2=$(BIN)$/runtests.exe
+
+.IF "$(name)" != ""
+TESTLIB=$(BIN)$/$(name)
+.ELSE
+TESTLIB=$(BIN)$/version_current.dll
+.ENDIF
+VERSIONLIBS=version_libs
+
+CLI_URE = $(SOLARBINDIR)$/cli_ure.dll
+CLI_URETYPES = $(SOLARBINDIR)$/cli_uretypes.dll
+CLI_BASETYPES = $(SOLARBINDIR)$/cli_basetypes.dll
+CLI_CPPUHELPER = $(SOLARBINDIR)$/cli_cppuhelper.dll
+CLI_OOOTYPES = $(SOLARBINDIR)$/cli_oootypes.dll
+
+
+.INCLUDE: target.mk
+
+.IF "$(BUILD_FOR_CLI)" == ""
+ALLTAR:
+
+.ELSE
+ALLTAR: \
+ $(EXETARGET2) \
+ $(TESTLIB) \
+ $(MISC)$/copyassemblies.done \
+ COPYVERSIONLIBS \
+ RUNINSTRUCTIONS
+
+.ENDIF
+
+
+COPYVERSIONLIBS:
+ -$(GNUCOPY) $(VERSIONLIBS)$/* $(BIN)
+
+
+$(MISC)$/copyassemblies.done .ERRREMOVE:
+ $(GNUCOPY) $(CLI_CPPUHELPER) $(BIN)$/$(CLI_CPPUHELPER:f)
+ $(GNUCOPY) $(CLI_BASETYPES) $(BIN)$/$(CLI_BASETYPES:f)
+ $(GNUCOPY) $(CLI_URETYPES) $(BIN)$/$(CLI_URETYPES:f)
+ $(GNUCOPY) $(CLI_URE) $(BIN)$/$(CLI_URE:f)
+ $(GNUCOPY) $(CLI_OOOTYPES) $(BIN)$/$(CLI_OOOTYPES:f)
+ $(TOUCH) $@
+
+CSFILES2 = runtests.cs
+
+.IF "$(CCNUMVER)" >= "001399999999"
+CSCPLATFORMX86 = -platform:x86
+.ELSE
+CSCPLATFORMX86 =
+.ENDIF
+
+$(EXETARGET2): $(CSFILES2)
+ $(CSC) $(CSCFLAGS) -target:exe -out:$(EXETARGET2) $(CSCPLATFORMX86)\
+ $(CSFILES2)
+
+CSFILESLIB = version.cs
+$(TESTLIB): $(CSFILESLIB) $(SOLARBINDIR)$/cliureversion.mk
+ $(CSC) $(CSCFLAGS) -target:library -out:$(TESTLIB) \
+ -reference:$(SOLARBINDIR)$/cli_ure.dll \
+ -reference:$(SOLARBINDIR)$/cli_uretypes.dll \
+ -reference:$(SOLARBINDIR)$/cli_basetypes.dll \
+ -reference:$(SOLARBINDIR)$/cli_cppuhelper.dll \
+ -reference:$(SOLARBINDIR)$/cli_oootypes.dll \
+ $(CSFILESLIB)
+
+
+
+RUNINSTRUCTIONS :
+ @echo .
+ @echo ########################### N O T E ######################################
+ @echo .
+ @echo To run the test go to qa\cliversioning, run dmake and follow instructions.
+ @echo .
+ @echo Or install an office with full system integration and run $(BIN)$/runtests.exe
+ @echo in a console without build environment.
+ @echo .
+ @echo Or install an office with setup /a. Expand PATH with the bin folder of the URE.
+ @echo Set UNO_PATH=system_path_to_program_folder
+ @echo This must be the program folder of the brand layer.
+ @echo For example, c:\staroffice\Sun\staroffice 9\program
+ @echo Run runtests.exe.
+ @echo .
+ @echo To build a test library with run.
+ @echo
+ @echo dmake name=version_10_10_10.dll
+ @echo
+ @echo The name must always start with 'version_'.
+ @echo ########################### N O T E ######################################
+ @echo .
+ @echo .
diff --git a/testtools/source/cliversioning/readme.txt b/testtools/source/cliversioning/readme.txt
new file mode 100644
index 000000000..c2878c383
--- /dev/null
+++ b/testtools/source/cliversioning/readme.txt
@@ -0,0 +1,93 @@
+#
+# This file is part of the LibreOffice project.
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+# This file incorporates work covered by the following license notice:
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed
+# with this work for additional information regarding copyright
+# ownership. The ASF licenses this file to you under the Apache
+# License, Version 2.0 (the "License"); you may not use this file
+# except in compliance with the License. You may obtain a copy of
+# the License at http://www.apache.org/licenses/LICENSE-2.0 .
+#
+
+
+WINDOWS ONLY, no other platforms
+
+
+This test checks if the cli assemblies and their policy files are installed in the
+GAC and if the policy files are correct. The office must be installed with complete
+system integration. That is, one does not use setup /a for starting the
+installation.
+
+In OOo 3.0 there was a breaking change so that the test created for previous
+version do not work anymore. To use these old tests one needs to install a
+version of OOo less than v 3.0. Then one needs to check out the cli_ure module
+for that version. The tests are contained in cli_ure/qa/versioning.
+
+In the sub directory version_libs are libraries which are linked with (referencing)
+cli_cppuhelper
+cli_basetypes
+cli_ure
+cli_uretypes
+cli_oootypes
+
+They are named version_3_0_0 etc, where the name indicates the version of the
+office for which they were initially build. If there are only the assemblies
+for example OOo2.0.2 installed and a client was build with the assemblies from
+OOo2 then the policy assemblies must make the correct redirection.
+
+When calling dmake then the executable runtest.exe and version_current.dll are
+build. When runtest runs then it loads all dlls, which names start with
+"version", from the same directory and tries to run a particular test code
+which is only available in the version_xxx.dll s. The code in the
+version_xxx.dlls uses the cli default bootstrap mechanism to find the office
+installation and start the office. When running runtest in a build environment
+then it may use the wrong libraries for bootstrapping in which case the test
+fails. Then one has to set PATH which must point to the program directory of
+the office installation. For example:
+
+set PATH=d:\office\program
+
+runtest stops when a test failed to run. It writes error information to the
+console which shows which version_xxx.dll failed to run and if this was due to
+a referenced assembly that could not be loaded. This would be the case if such
+an assembly or the policy assembly is not properly installed or the redirection
+in the policy assembly is wrong.
+
+The version_current.dll references the assemblies in the current build
+environment. version_current.dll is also executed when runtest is started.
+
+To run the whole test one can either
+1. start testools/wntmsci11.pro/bin/runtests.exe in a console where no
+environment is set.
+2. Call dmake run in testools/qa/cliversions
+
+For a limited test one can call in this directory
+dmake run office=d:\office
+There must not be an office installed in the system (the assemblies from the GAC
+would then be used). Only the test with the version_current.dll will succeed
+because there are no policy files installed. This test requires that all
+assemblies are copied next to runtests.exe - the makefile will do that.
+
+The parameter office must be a system path to the office installation
+directory. The java code calls runtest and also sets PATH so that the test
+works in the build environment. It also sets UNO_PATH so that the office will be
+found. If the test says that it failed, then one should run runtest directly
+because it puts out more information.
+
+
+
+Creating a new version_xxx.dll
+==============================
+When a version of our assemblies changes then one should provide a new version dll which test exactly the assemblies with the changed version. This is easily done:
+1. set the build environment in which the new versions are effective.
+2 call: dmake name=version_xxx.dll
+3. copy the new version dll from the output tree into qa/versioning/version_libs
+4. commit the new version.dll using the -kb switch (only when creating the new file : cvs new -kb version_3_1_0.dll)
+
diff --git a/testtools/source/cliversioning/runtests.cs b/testtools/source/cliversioning/runtests.cs
new file mode 100644
index 000000000..40cccefc6
--- /dev/null
+++ b/testtools/source/cliversioning/runtests.cs
@@ -0,0 +1,118 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+using System;
+using System.Reflection;
+using System.IO;
+
+// __________ implementation ____________________________________
+
+/** Create and modify a spreadsheet document.
+ */
+namespace cliversion
+{
+public class RunTests
+{
+
+ public static int Main(String[] args)
+ {
+// System.Diagnostics.Debugger.Launch();
+ //get the path to the directory
+ string sLocation = Assembly.GetExecutingAssembly().Location;
+ sLocation = sLocation.Substring(0, sLocation.LastIndexOf('\\'));
+ // Create a reference to the current directory.
+ DirectoryInfo di = new DirectoryInfo(sLocation);
+ // Create an array representing the files in the current directory.
+ FileInfo[] fi = di.GetFiles();
+
+ //For every found dll try to figure out if it contains a
+ //cliversion.Version class
+ foreach (FileInfo fiTemp in fi)
+ {
+ if (fiTemp.Extension != ".dll"
+ || ! fiTemp.Name.StartsWith("version"))
+ continue;
+
+ Assembly ass = null;
+ Object objVersion = null;
+ try
+ {
+ string sName = fiTemp.Name.Substring(0, fiTemp.Name.LastIndexOf(".dll"));
+ ass = Assembly.Load(sName);
+ }
+ catch (BadImageFormatException)
+ {
+ continue;
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("#Unexpected Exception");
+ Console.WriteLine(e.Message);
+ return -1;
+ }
+
+ //Assembly is loaded, instantiate cliversion.Version
+ try
+ {
+ //This runs the test
+ objVersion = ass.CreateInstance("cliversion.Version");
+ if (objVersion == null)
+ continue;
+ Console.WriteLine("#Tested successfully " + fiTemp.Name);
+ //Starting the office the second time may fail without this pause
+ System.Threading.Thread.Sleep(2000);
+ }
+ catch (Exception e)
+ {
+ TargetInvocationException te = e as TargetInvocationException;
+ if (te != null)
+ {
+ FileNotFoundException fe = e.InnerException as FileNotFoundException;
+ if (fe != null)
+ {
+ Console.WriteLine(fiTemp.Name + " did not find " + fe.FileName +
+ ". Maybe the " + fe.FileName + " is not installed or does not match the referenced version." +
+ "Original message: " + fe.Message + "\n\n FusionLog: \n" + fe.FusionLog );
+ return -1;
+ }
+ FileLoadException fl = e.InnerException as FileLoadException;
+ if (fl != null)
+ {
+ Console.WriteLine(fiTemp.Name + " could not load " + fl.FileName +
+ ". Maybe the version of " + fl.FileName + " does not match the referenced version. " +
+ "Original message: " + fl.Message + "\n\n FusionLog: \n" + fl.FusionLog );
+ return -1;
+ }
+
+ if (e.InnerException != null)
+ {
+ Console.WriteLine(e.InnerException);
+ }
+ }
+ Console.WriteLine("#Unexpected Exception");
+ Console.WriteLine(e.Message);
+ return -1;
+ }
+ }
+ //For some unknown reason this program hangs sometimes when started from java. This is
+ //a workaround that makes the problem disappear.
+ System.Threading.Thread.Sleep(1000);
+ return 0;
+ }
+}
+}
diff --git a/testtools/source/cliversioning/version.cs b/testtools/source/cliversioning/version.cs
new file mode 100644
index 000000000..b1717148d
--- /dev/null
+++ b/testtools/source/cliversioning/version.cs
@@ -0,0 +1,599 @@
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+
+using System;
+using unoidl.com.sun.star.lang;
+using unoidl.com.sun.star.uno;
+using unoidl.com.sun.star.frame;
+using unoidl.com.sun.star.util;
+
+namespace cliversion
+{
+public class Version
+{
+ public Version()
+ {
+ try
+ {
+// System.Diagnostics.Debugger.Launch();
+
+ //link with cli_ure.dll
+ uno.util.WeakBase wb = new uno.util.WeakBase();
+ using ( SpreadsheetSample aSample = new SpreadsheetSample() )
+ {
+ aSample.doCellRangeSamples();
+ aSample.terminate();
+ }
+ }
+ catch (System.Exception )
+ {
+ //This exception is thrown if we link with a library which is not
+ //available
+ throw;
+ }
+ }
+}
+
+class SpreadsheetSample: SpreadsheetDocHelper
+{
+ public SpreadsheetSample()
+ {
+ }
+ /** All samples regarding the service com.sun.star.sheet.SheetCellRange. */
+ public void doCellRangeSamples()
+ {
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet = getSpreadsheet( 0 );
+ unoidl.com.sun.star.table.XCellRange xCellRange = null;
+ unoidl.com.sun.star.beans.XPropertySet xPropSet = null;
+ unoidl.com.sun.star.table.CellRangeAddress aRangeAddress = null;
+
+ // Preparation
+ setFormula( xSheet, "B5", "First cell" );
+ setFormula( xSheet, "B6", "Second cell" );
+ // Get cell range B5:B6 by position - (column, row, column, row)
+ xCellRange = xSheet.getCellRangeByPosition( 1, 4, 1, 5 );
+
+
+ // --- Change cell range properties. ---
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ // from com.sun.star.styles.CharacterProperties
+ xPropSet.setPropertyValue(
+ "CharColor", new uno.Any( (Int32) 0x003399 ) );
+ xPropSet.setPropertyValue(
+ "CharHeight", new uno.Any( (Single) 20.0 ) );
+ // from com.sun.star.styles.ParagraphProperties
+ xPropSet.setPropertyValue(
+ "ParaLeftMargin", new uno.Any( (Int32) 500 ) );
+ // from com.sun.star.table.CellProperties
+ xPropSet.setPropertyValue(
+ "IsCellBackgroundTransparent", new uno.Any( false ) );
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0x99CCFF ) );
+
+
+ // --- Replace text in all cells. ---
+ unoidl.com.sun.star.util.XReplaceable xReplace =
+ (unoidl.com.sun.star.util.XReplaceable) xCellRange;
+ unoidl.com.sun.star.util.XReplaceDescriptor xReplaceDesc =
+ xReplace.createReplaceDescriptor();
+ xReplaceDesc.setSearchString( "cell" );
+ xReplaceDesc.setReplaceString( "text" );
+ // property SearchWords searches for whole cells!
+ xReplaceDesc.setPropertyValue( "SearchWords", new uno.Any( false ) );
+ int nCount = xReplace.replaceAll( xReplaceDesc );
+
+ // --- Merge cells. ---
+ xCellRange = xSheet.getCellRangeByName( "F3:G6" );
+ prepareRange( xSheet, "E1:H7", "XMergeable" );
+ unoidl.com.sun.star.util.XMergeable xMerge =
+ (unoidl.com.sun.star.util.XMergeable) xCellRange;
+ xMerge.merge( true );
+
+
+ // --- Column properties. ---
+ xCellRange = xSheet.getCellRangeByName( "B1" );
+ unoidl.com.sun.star.table.XColumnRowRange xColRowRange =
+ (unoidl.com.sun.star.table.XColumnRowRange) xCellRange;
+ unoidl.com.sun.star.table.XTableColumns xColumns =
+ xColRowRange.getColumns();
+
+ uno.Any aColumnObj = xColumns.getByIndex( 0 );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) aColumnObj.Value;
+ xPropSet.setPropertyValue( "Width", new uno.Any( (Int32) 6000 ) );
+
+ unoidl.com.sun.star.container.XNamed xNamed =
+ (unoidl.com.sun.star.container.XNamed) aColumnObj.Value;
+
+ // --- Cell range data ---
+ prepareRange( xSheet, "A9:C30", "XCellRangeData" );
+
+ xCellRange = xSheet.getCellRangeByName( "A10:C30" );
+ unoidl.com.sun.star.sheet.XCellRangeData xData =
+ (unoidl.com.sun.star.sheet.XCellRangeData) xCellRange;
+ uno.Any [][] aValues =
+ {
+ new uno.Any [] { new uno.Any( "Name" ),
+ new uno.Any( "Fruit" ),
+ new uno.Any( "Quantity" ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 7.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 9.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 5.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 6.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 2.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 7.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 8.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 7.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 1.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 9.0 ) },
+ new uno.Any [] { new uno.Any( "Bob" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 3.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Oranges" ),
+ new uno.Any( (Double) 4.0 ) },
+ new uno.Any [] { new uno.Any( "Alice" ),
+ new uno.Any( "Apples" ),
+ new uno.Any( (Double) 9.0 ) }
+ };
+ xData.setDataArray( aValues );
+
+
+ // --- Get cell range address. ---
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xRangeAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange;
+ aRangeAddress = xRangeAddr.getRangeAddress();
+
+ // --- Sheet operation. ---
+ // uses the range filled with XCellRangeData
+ unoidl.com.sun.star.sheet.XSheetOperation xSheetOp =
+ (unoidl.com.sun.star.sheet.XSheetOperation) xData;
+ double fResult = xSheetOp.computeFunction(
+ unoidl.com.sun.star.sheet.GeneralFunction.AVERAGE );
+
+ // --- Fill series ---
+ // Prepare the example
+ setValue( xSheet, "E10", 1 );
+ setValue( xSheet, "E11", 4 );
+ setDate( xSheet, "E12", 30, 1, 2002 );
+ setFormula( xSheet, "I13", "Text 10" );
+ setFormula( xSheet, "E14", "Jan" );
+ setValue( xSheet, "K14", 10 );
+ setValue( xSheet, "E16", 1 );
+ setValue( xSheet, "F16", 2 );
+ setDate( xSheet, "E17", 28, 2, 2002 );
+ setDate( xSheet, "F17", 28, 1, 2002 );
+ setValue( xSheet, "E18", 6 );
+ setValue( xSheet, "F18", 4 );
+
+ }
+
+ /** Returns the XCellSeries interface of a cell range.
+ @param xSheet The spreadsheet containing the cell range.
+ @param aRange The address of the cell range.
+ @return The XCellSeries interface. */
+ private unoidl.com.sun.star.sheet.XCellSeries getCellSeries(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange )
+ {
+ return (unoidl.com.sun.star.sheet.XCellSeries)
+ xSheet.getCellRangeByName( aRange );
+ }
+
+}
+
+/** This is a helper class for the spreadsheet and table samples.
+ It connects to a running office and creates a spreadsheet document.
+ Additionally it contains various helper functions.
+ */
+class SpreadsheetDocHelper : System.IDisposable
+{
+
+// __ private members ___________________________________________
+
+ private const String msDataSheetName = "Data";
+
+ private unoidl.com.sun.star.uno.XComponentContext m_xContext;
+ private unoidl.com.sun.star.lang.XMultiServiceFactory mxMSFactory;
+ private unoidl.com.sun.star.sheet.XSpreadsheetDocument mxDocument;
+
+
+
+ public SpreadsheetDocHelper()
+ {
+// System.Diagnostics.Debugger.Launch();
+ // Connect to a running office and get the service manager
+ mxMSFactory = connect();
+ // Create a new spreadsheet document
+ mxDocument = initDocument();
+ }
+
+// __ helper methods ____________________________________________
+
+ /** Returns the service manager.
+ @return XMultiServiceFactory interface of the service manager. */
+ public unoidl.com.sun.star.lang.XMultiServiceFactory getServiceManager()
+ {
+ return mxMSFactory;
+ }
+
+ /** Returns the whole spreadsheet document.
+ @return XSpreadsheetDocument interface of the document. */
+ public unoidl.com.sun.star.sheet.XSpreadsheetDocument getDocument()
+ {
+ return mxDocument;
+ }
+
+ /** Returns the spreadsheet with the specified index (0-based).
+ @param nIndex The index of the sheet.
+ @return XSpreadsheet interface of the sheet. */
+ public unoidl.com.sun.star.sheet.XSpreadsheet getSpreadsheet( int nIndex )
+ {
+ // Collection of sheets
+ unoidl.com.sun.star.sheet.XSpreadsheets xSheets =
+ mxDocument.getSheets();
+
+ unoidl.com.sun.star.container.XIndexAccess xSheetsIA =
+ (unoidl.com.sun.star.container.XIndexAccess) xSheets;
+
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet =
+ (unoidl.com.sun.star.sheet.XSpreadsheet)
+ xSheetsIA.getByIndex( nIndex ).Value;
+
+ return xSheet;
+ }
+
+ /** Inserts a new empty spreadsheet with the specified name.
+ @param aName The name of the new sheet.
+ @param nIndex The insertion index.
+ @return The XSpreadsheet interface of the new sheet. */
+ public unoidl.com.sun.star.sheet.XSpreadsheet insertSpreadsheet(
+ String aName, short nIndex )
+ {
+ // Collection of sheets
+ unoidl.com.sun.star.sheet.XSpreadsheets xSheets =
+ mxDocument.getSheets();
+
+ xSheets.insertNewByName( aName, nIndex );
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet =
+ (unoidl.com.sun.star.sheet.XSpreadsheet)
+ xSheets.getByName( aName ).Value;
+
+ return xSheet;
+ }
+
+
+// Methods to fill values into cells.
+
+ /** Writes a double value into a spreadsheet.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aCellName The address of the cell (or a named range).
+ @param fValue The value to write into the cell. */
+ public void setValue(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ double fValue )
+ {
+ xSheet.getCellRangeByName( aCellName ).getCellByPosition(
+ 0, 0 ).setValue( fValue );
+ }
+
+ /** Writes a formula into a spreadsheet.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aCellName The address of the cell (or a named range).
+ @param aFormula The formula to write into the cell. */
+ public void setFormula(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ String aFormula )
+ {
+ xSheet.getCellRangeByName( aCellName ).getCellByPosition(
+ 0, 0 ).setFormula( aFormula );
+ }
+
+ /** Writes a date with standard date format into a spreadsheet.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aCellName The address of the cell (or a named range).
+ @param nDay The day of the date.
+ @param nMonth The month of the date.
+ @param nYear The year of the date. */
+ public void setDate(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCellName,
+ int nDay, int nMonth, int nYear )
+ {
+ // Set the date value.
+ unoidl.com.sun.star.table.XCell xCell =
+ xSheet.getCellRangeByName( aCellName ).getCellByPosition( 0, 0 );
+ String aDateStr = nMonth + "/" + nDay + "/" + nYear;
+ xCell.setFormula( aDateStr );
+
+ // Set standard date format.
+ unoidl.com.sun.star.util.XNumberFormatsSupplier xFormatsSupplier =
+ (unoidl.com.sun.star.util.XNumberFormatsSupplier) getDocument();
+ unoidl.com.sun.star.util.XNumberFormatTypes xFormatTypes =
+ (unoidl.com.sun.star.util.XNumberFormatTypes)
+ xFormatsSupplier.getNumberFormats();
+ int nFormat = xFormatTypes.getStandardFormat(
+ unoidl.com.sun.star.util.NumberFormat.DATE,
+ new unoidl.com.sun.star.lang.Locale() );
+
+ unoidl.com.sun.star.beans.XPropertySet xPropSet =
+ (unoidl.com.sun.star.beans.XPropertySet) xCell;
+ xPropSet.setPropertyValue(
+ "NumberFormat",
+ new uno.Any( (Int32) nFormat ) );
+ }
+
+ /** Draws a colored border around the range and writes the headline
+ in the first cell.
+
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aRange The address of the cell range (or a named range).
+ @param aHeadline The headline text. */
+ public void prepareRange(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aRange, String aHeadline )
+ {
+ unoidl.com.sun.star.beans.XPropertySet xPropSet = null;
+ unoidl.com.sun.star.table.XCellRange xCellRange = null;
+
+ // draw border
+ xCellRange = xSheet.getCellRangeByName( aRange );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ unoidl.com.sun.star.table.BorderLine aLine =
+ new unoidl.com.sun.star.table.BorderLine();
+ aLine.Color = 0x99CCFF;
+ aLine.InnerLineWidth = aLine.LineDistance = 0;
+ aLine.OuterLineWidth = 100;
+ unoidl.com.sun.star.table.TableBorder aBorder =
+ new unoidl.com.sun.star.table.TableBorder();
+ aBorder.TopLine = aBorder.BottomLine = aBorder.LeftLine =
+ aBorder.RightLine = aLine;
+ aBorder.IsTopLineValid = aBorder.IsBottomLineValid = true;
+ aBorder.IsLeftLineValid = aBorder.IsRightLineValid = true;
+ xPropSet.setPropertyValue(
+ "TableBorder",
+ new uno.Any(
+ typeof (unoidl.com.sun.star.table.TableBorder), aBorder ) );
+
+ // draw headline
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange;
+ unoidl.com.sun.star.table.CellRangeAddress aAddr =
+ xAddr.getRangeAddress();
+
+ xCellRange = xSheet.getCellRangeByPosition(
+ aAddr.StartColumn,
+ aAddr.StartRow, aAddr.EndColumn, aAddr.StartRow );
+
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCellRange;
+ xPropSet.setPropertyValue(
+ "CellBackColor", new uno.Any( (Int32) 0x99CCFF ) );
+ // write headline
+ unoidl.com.sun.star.table.XCell xCell =
+ xCellRange.getCellByPosition( 0, 0 );
+ xCell.setFormula( aHeadline );
+ xPropSet = (unoidl.com.sun.star.beans.XPropertySet) xCell;
+ xPropSet.setPropertyValue(
+ "CharColor", new uno.Any( (Int32) 0x003399 ) );
+ xPropSet.setPropertyValue(
+ "CharWeight",
+ new uno.Any( (Single) unoidl.com.sun.star.awt.FontWeight.BOLD ) );
+ }
+
+
+// Methods to create cell addresses and range addresses.
+
+ /** Creates a unoidl.com.sun.star.table.CellAddress and initializes it
+ with the given range.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aCell The address of the cell (or a named cell). */
+ public unoidl.com.sun.star.table.CellAddress createCellAddress(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet,
+ String aCell )
+ {
+ unoidl.com.sun.star.sheet.XCellAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellAddressable)
+ xSheet.getCellRangeByName( aCell ).getCellByPosition( 0, 0 );
+ return xAddr.getCellAddress();
+ }
+
+ /** Creates a unoidl.com.sun.star.table.CellRangeAddress and initializes
+ it with the given range.
+ @param xSheet The XSpreadsheet interface of the spreadsheet.
+ @param aRange The address of the cell range (or a named range). */
+ public unoidl.com.sun.star.table.CellRangeAddress createCellRangeAddress(
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet, String aRange )
+ {
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable)
+ xSheet.getCellRangeByName( aRange );
+ return xAddr.getRangeAddress();
+ }
+
+
+// Methods to convert cell addresses and range addresses to strings.
+
+ /** Returns the text address of the cell.
+ @param nColumn The column index.
+ @param nRow The row index.
+ @return A string containing the cell address. */
+ public String getCellAddressString( int nColumn, int nRow )
+ {
+ String aStr = "";
+ if (nColumn > 25)
+ aStr += (char) ('A' + nColumn / 26 - 1);
+ aStr += (char) ('A' + nColumn % 26);
+ aStr += (nRow + 1);
+ return aStr;
+ }
+
+ /** Returns the text address of the cell range.
+ @param aCellRange The cell range address.
+ @return A string containing the cell range address. */
+ public String getCellRangeAddressString(
+ unoidl.com.sun.star.table.CellRangeAddress aCellRange )
+ {
+ return
+ getCellAddressString( aCellRange.StartColumn, aCellRange.StartRow )
+ + ":"
+ + getCellAddressString( aCellRange.EndColumn, aCellRange.EndRow );
+ }
+
+ /** Returns the text address of the cell range.
+ @param xCellRange The XSheetCellRange interface of the cell range.
+ @param bWithSheet true = Include sheet name.
+ @return A string containing the cell range address. */
+ public String getCellRangeAddressString(
+ unoidl.com.sun.star.sheet.XSheetCellRange xCellRange, bool bWithSheet )
+ {
+ String aStr = "";
+ if (bWithSheet)
+ {
+ unoidl.com.sun.star.sheet.XSpreadsheet xSheet =
+ xCellRange.getSpreadsheet();
+ unoidl.com.sun.star.container.XNamed xNamed =
+ (unoidl.com.sun.star.container.XNamed) xSheet;
+ aStr += xNamed.getName() + ".";
+ }
+ unoidl.com.sun.star.sheet.XCellRangeAddressable xAddr =
+ (unoidl.com.sun.star.sheet.XCellRangeAddressable) xCellRange;
+ aStr += getCellRangeAddressString( xAddr.getRangeAddress() );
+ return aStr;
+ }
+
+ /** Returns a list of addresses of all cell ranges contained in the
+ collection.
+
+ @param xRangesIA The XIndexAccess interface of the collection.
+ @return A string containing the cell range address list. */
+ public String getCellRangeListString(
+ unoidl.com.sun.star.container.XIndexAccess xRangesIA )
+ {
+ String aStr = "";
+ int nCount = xRangesIA.getCount();
+ for (int nIndex = 0; nIndex < nCount; ++nIndex)
+ {
+ if (nIndex > 0)
+ aStr += " ";
+ uno.Any aRangeObj = xRangesIA.getByIndex( nIndex );
+ unoidl.com.sun.star.sheet.XSheetCellRange xCellRange =
+ (unoidl.com.sun.star.sheet.XSheetCellRange) aRangeObj.Value;
+ aStr += getCellRangeAddressString( xCellRange, false );
+ }
+ return aStr;
+ }
+
+
+
+ /** Connect to a running office that is accepting connections.
+ @return The ServiceManager to instantiate office components. */
+ private XMultiServiceFactory connect()
+ {
+
+ m_xContext = uno.util.Bootstrap.bootstrap();
+
+ return (XMultiServiceFactory) m_xContext.getServiceManager();
+ }
+
+ public void Dispose()
+ {
+
+ }
+
+ /** Creates an empty spreadsheet document.
+ @return The XSpreadsheetDocument interface of the document. */
+ private unoidl.com.sun.star.sheet.XSpreadsheetDocument initDocument()
+ {
+ XComponentLoader aLoader = (XComponentLoader)
+ mxMSFactory.createInstance( "com.sun.star.frame.Desktop" );
+
+ XComponent xComponent = aLoader.loadComponentFromURL(
+ "private:factory/scalc", "_blank", 0,
+ new unoidl.com.sun.star.beans.PropertyValue[0] );
+
+ return (unoidl.com.sun.star.sheet.XSpreadsheetDocument) xComponent;
+ }
+
+
+ public void terminate()
+ {
+ XModifiable xMod = (XModifiable) mxDocument;
+ if (xMod != null)
+ xMod.setModified(false);
+ XDesktop aDesktop = (XDesktop)
+ mxMSFactory.createInstance( "com.sun.star.frame.Desktop" );
+ if (aDesktop != null)
+ {
+ try
+ {
+ aDesktop.terminate();
+ }
+ catch (DisposedException d)
+ {
+ //This exception may be thrown because shutting down OOo using
+ //XDesktop terminate does not really work. In the case of the
+ //Exception OOo will still terminate.
+ }
+ }
+ }
+
+
+}
+
+}
diff --git a/testtools/source/cliversioning/version_libs/readme.txt b/testtools/source/cliversioning/version_libs/readme.txt
new file mode 100644
index 000000000..a78c22e1a
--- /dev/null
+++ b/testtools/source/cliversioning/version_libs/readme.txt
@@ -0,0 +1,3 @@
+These binary files are needed for this test. They have been linked with
+earlier versions of the cli libraries, and cannot be build this way again
+in a current version of the build environment. \ No newline at end of file
diff --git a/testtools/source/cliversioning/version_libs/version_3_0_0.dll b/testtools/source/cliversioning/version_libs/version_3_0_0.dll
new file mode 100644
index 000000000..71769a44f
--- /dev/null
+++ b/testtools/source/cliversioning/version_libs/version_3_0_0.dll
Binary files differ
diff --git a/testtools/source/cliversioning/version_libs/version_3_0_1.dll b/testtools/source/cliversioning/version_libs/version_3_0_1.dll
new file mode 100644
index 000000000..823cfc8c8
--- /dev/null
+++ b/testtools/source/cliversioning/version_libs/version_3_0_1.dll
Binary files differ
diff --git a/testtools/source/cliversioning/version_libs/version_3_1.dll b/testtools/source/cliversioning/version_libs/version_3_1.dll
new file mode 100755
index 000000000..b16da2df5
--- /dev/null
+++ b/testtools/source/cliversioning/version_libs/version_3_1.dll
Binary files differ
diff --git a/testtools/source/cliversioning/version_libs/version_3_1_1.dll b/testtools/source/cliversioning/version_libs/version_3_1_1.dll
new file mode 100644
index 000000000..9ff42fc23
--- /dev/null
+++ b/testtools/source/cliversioning/version_libs/version_3_1_1.dll
Binary files differ
diff --git a/testtools/source/cliversioning/version_libs/version_3_2.dll b/testtools/source/cliversioning/version_libs/version_3_2.dll
new file mode 100755
index 000000000..e89232441
--- /dev/null
+++ b/testtools/source/cliversioning/version_libs/version_3_2.dll
Binary files differ
diff --git a/testtools/source/cliversioning/version_libs/version_3_2_1.dll b/testtools/source/cliversioning/version_libs/version_3_2_1.dll
new file mode 100755
index 000000000..037f5ddee
--- /dev/null
+++ b/testtools/source/cliversioning/version_libs/version_3_2_1.dll
Binary files differ
diff --git a/testtools/source/cliversioning/version_libs/version_3_3.dll b/testtools/source/cliversioning/version_libs/version_3_3.dll
new file mode 100755
index 000000000..a63a43632
--- /dev/null
+++ b/testtools/source/cliversioning/version_libs/version_3_3.dll
Binary files differ