summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli_ure/qa/versioning/VersionTestCase.java109
-rw-r--r--cli_ure/qa/versioning/makefile.mk162
-rw-r--r--cli_ure/qa/versioning/runtests.cs125
-rw-r--r--cli_ure/qa/versioning/version.cs600
-rw-r--r--cli_ure/source/native/makefile.mk3
-rw-r--r--cli_ure/source/native/native_bootstrap.cxx288
-rw-r--r--cli_ure/source/native/path.cxx221
-rw-r--r--cli_ure/version/version.txt24
-rw-r--r--unoil/climaker/version.txt6
9 files changed, 439 insertions, 1099 deletions
diff --git a/cli_ure/qa/versioning/VersionTestCase.java b/cli_ure/qa/versioning/VersionTestCase.java
deleted file mode 100644
index a156af986c83..000000000000
--- a/cli_ure/qa/versioning/VersionTestCase.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: VersionTestCase.java,v $
- * $Revision: 1.4 $
- *
- * 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 cliversion;
-
-
-import complexlib.ComplexTestCase;
-
-
-public class VersionTestCase extends ComplexTestCase
-{
- public String[] getTestMethodNames()
- {
- return new String[]
- {
- "checkVersion"
- };
- }
-
- public void checkVersion()
- {
- int retVal = 0;
- try
- {
- String testProgram = System.getProperty("cli_test_program");
- if (testProgram == null || testProgram.length() == 0)
- failed("Check the make file. Java must be called with -Dcli_ure_test=pathtoexe");
- String unoPath = System.getProperty("uno_path");
- if (unoPath == null || unoPath.length() == 0)
- failed("Check the make file. Java must be called with -Duno_path=path_to_program_directory");
- String sSystemRoot = System.getProperty("SystemRoot");
- if (sSystemRoot == null || sSystemRoot.length() == 0)
- failed("Check the make file. Java must be called with -DSystemRoot=%SystemRoot%.");
-
-// System.out.println("UNO_PATH="+unoPath);
- //We need to set the PATH because otherwise it appears that runtests inherits the PATH
- //from build environment. Then the bootstrapping fails because the libraries
- //are not used from the office.
- //.NET 2 requires SystemRoot being set.
- String[] arEnv = new String[] {
- "PATH=" + unoPath, "SystemRoot=" + sSystemRoot};
- Process proc = null;
-
- proc = Runtime.getRuntime().exec(testProgram, arEnv);
- Reader outReader = new Reader(proc.getInputStream());
- Reader errReader = new Reader(proc.getErrorStream());
- proc.waitFor();
- retVal = proc.exitValue();
- } catch(Exception e)
- {
- e.printStackTrace();
- System.out.println(e.getMessage());
- failed("Unexpected exception.");
- }
- if (retVal != 0)
- failed("Tests for library versioning failed.");
- }
-}
-
-
-/* This reads reads from an InputStream and discards the data.
- */
-class Reader extends Thread
-{
- java.io.InputStream is;
- public Reader(java.io.InputStream stream)
- {
- is = stream;
- start();
- }
-
- public void run()
- {
- try
- {
- byte[] buf = new byte[1024];
- while (-1 != is.read(buf));
- }
- catch (java.io.IOException exc)
- {
- }
- }
-}
diff --git a/cli_ure/qa/versioning/makefile.mk b/cli_ure/qa/versioning/makefile.mk
deleted file mode 100644
index ce32ac6555a5..000000000000
--- a/cli_ure/qa/versioning/makefile.mk
+++ /dev/null
@@ -1,162 +0,0 @@
-#*************************************************************************
-#
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# Copyright 2008 by Sun Microsystems, Inc.
-#
-# OpenOffice.org - a multi-platform office productivity suite
-#
-# $RCSfile: makefile.mk,v $
-#
-# $Revision: 1.7.14.1 $
-#
-# 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.
-#
-#*************************************************************************
-
-
-# Builds the SpreadSheet examples of the Developers Guide.
-
-PRJ = ..$/..
-PRJNAME = cli_ure
-TARGET := test_climaker
-PACKAGE = cliversion
-
-.INCLUDE: settings.mk
-
-#----- compile .java files -----------------------------------------
-
-JARFILES = sandbox.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar
-JAVAFILES = VersionTestCase.java
-JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
-
-#----- make a jar from compiled files ------------------------------
-
-MAXLINELENGTH = 100000
-
-JARCLASSDIRS = $(PACKAGE)
-JARTARGET = $(TARGET).jar
-JARCOMPRESS = TRUE
-
-CSCFLAGS = -incr
-.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
-
-.IF "$(GUI)"=="WNT"
-ALLTAR: $(EXETARGET2) \
- $(TESTLIB) \
- COPYVERSIONLIBS \
- RUNINSTRUCTIONS
-.ELSE
-ALLTAR:
-.ENDIF
-
-
-COPYVERSIONLIBS:
- -$(GNUCOPY) -p $(VERSIONLIBS)$/* $(BIN)
-
-CSFILES2 = runtests.cs
-$(EXETARGET2): $(CSFILES2)
- $(CSC) $(CSCFLAGS) -target:exe -out:$(EXETARGET2) \
- $(CSFILES2)
-
-
-CSFILESLIB = version.cs
-$(TESTLIB): $(CSFILESLIB) $(BIN)$/cliureversion.mk
- $(CSC) $(CSCFLAGS) -target:library -out:$(TESTLIB) \
- -reference:$(BIN)$/cli_ure.dll \
- -reference:$(BIN)$/cli_types.dll \
- -reference:$(BIN)$/cli_basetypes.dll \
- -reference:$(BIN)$/cli_cppuhelper.dll \
- $(CSFILESLIB)
-
-#This target only checks if the the office/program/assembly directory
-#contains the proper libraries.
-$(BIN)$/buildwithofficelibs.dll:
- $(CSC) $(CSCFLAGS) -target:library -out:$@ \
- -reference:"$(office)"$/program$/assembly$/cli_ure.dll \
- -reference:"$(office)"$/program$/assembly$/cli_types.dll \
- -reference:"$(office)"$/program$/assembly$/cli_basetypes.dll \
- -reference:"$(office)"$/program$/assembly$/cli_cppuhelper.dll \
- $(CSFILESLIB)
-
-
-#-----------------------------------------------------------------------------
-CLIMAKERFLAGS =
-.IF "$(debug)" != ""
-CLIMAKERFLAGS += --verbose
-.ENDIF
-
-
-.IF "$(depend)" == ""
-ALL: ALLTAR
-.ELSE
-ALL: ALLDEP
-.ENDIF
-
-.INCLUDE: target.mk
-
-
-RUNINSTRUCTIONS :
- @echo .
- @echo ########################### N O T E ######################################
- @echo .
- @echo To run the test you have to provide the path to the office location.
- @echo Example:
- @echo dmake run office="d:\myOffice"
- @echo .
- @echo To build a test library with a particular name run. The namese must start with "version".
- @echo For example:
- @echo "dmake name=version_10_10_10.dll"
- @echo ########################### N O T E ######################################
- @echo .
- @echo .
-
-# --- Parameters for the test --------------------------------------
-
-# test base is java complex
-CT_TESTBASE = -TestBase java_complex
-
-# test looks something like the.full.package.TestName
-CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b)
-
-# start the runner application
-CT_APP = org.openoffice.Runner
-
-CT_NOOFFICE = -NoOffice
-# --- Targets ------------------------------------------------------
-
-RUN: $(BIN)$/buildwithofficelibs.dll
- java -cp $(CLASSPATH) -DSystemRoot=$(SystemRoot) -Dcli_test_program=$(EXETARGET2) -Duno_path="$(office)"\program $(CT_APP) $(CT_NOOFFICE) $(CT_TESTBASE) $(CT_TEST)
-
-run: RUN
-
diff --git a/cli_ure/qa/versioning/runtests.cs b/cli_ure/qa/versioning/runtests.cs
deleted file mode 100644
index 5d165c39bb78..000000000000
--- a/cli_ure/qa/versioning/runtests.cs
+++ /dev/null
@@ -1,125 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: runtests.cs,v $
- * $Revision: 1.5 $
- *
- * 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.
- *
- ************************************************************************/
-
-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;
- }
- }
- 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/cli_ure/qa/versioning/version.cs b/cli_ure/qa/versioning/version.cs
deleted file mode 100644
index 5983c136b898..000000000000
--- a/cli_ure/qa/versioning/version.cs
+++ /dev/null
@@ -1,600 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: version.cs,v $
- * $Revision: 1.4 $
- *
- * 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.
- *
- ************************************************************************/
-
-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)
- aDesktop.terminate();
- }
-
-// ________________________________________________________________
-}
-
-}
diff --git a/cli_ure/source/native/makefile.mk b/cli_ure/source/native/makefile.mk
index db27cc02fc45..a5e3731e114c 100644
--- a/cli_ure/source/native/makefile.mk
+++ b/cli_ure/source/native/makefile.mk
@@ -7,7 +7,7 @@
# OpenOffice.org - a multi-platform office productivity suite
#
# $RCSfile: makefile.mk,v $
-# $Revision: 1.26 $
+# $Revision: 1.26.8.1 $
#
# This file is part of OpenOffice.org.
#
@@ -100,6 +100,7 @@ LINKFLAGS += -NOENTRY -NODEFAULTLIB:nochkclr.obj -INCLUDE:__DllMainCRTStartup@12
SLOFILES = \
$(SLO)$/native_bootstrap.obj \
+ $(SLO)$/path.obj \
$(SLO)$/assembly_cppuhelper.obj
diff --git a/cli_ure/source/native/native_bootstrap.cxx b/cli_ure/source/native/native_bootstrap.cxx
index 60c5c783dc8d..fb7c2f21dcdf 100644
--- a/cli_ure/source/native/native_bootstrap.cxx
+++ b/cli_ure/source/native/native_bootstrap.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: native_bootstrap.cxx,v $
- * $Revision: 1.14 $
+ * $Revision: 1.14.12.5 $
*
* This file is part of OpenOffice.org.
*
@@ -28,7 +28,7 @@
*
************************************************************************/
-// We are using the Windows UNICODE API
+// Use UNICODE Windows and C API.
#define _UNICODE
#define UNICODE
@@ -55,157 +55,271 @@ using namespace ::rtl;
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
-#define OFFICE_LOCATION_REGISTRY_KEY L"Software\\OpenOffice.org\\Layer\\URE\\1"
-#define UREINSTALLLOCATION L"UREINSTALLLOCATION"
+namespace cli_ure {
+ WCHAR * resolveLink(WCHAR * path);
+}
+
+#define INSTALL_PATH L"Software\\OpenOffice.org\\UNO\\InstallPath"
+#define BASIS_LINK L"\\basis-link"
+#define URE_LINK L"\\ure-link"
#define URE_BIN L"\\bin"
+#define UNO_PATH L"UNO_PATH"
namespace
{
+ /*
+ * Gets the installation path from the Windows Registry for the specified
+ * registry key.
+ *
+ * @param hroot open handle to predefined root registry key
+ * @param subKeyName name of the subkey to open
+ *
+ * @return the installation path or NULL, if no installation was found or
+ * if an error occured
+ */
+WCHAR* getPathFromRegistryKey( HKEY hroot, LPCWSTR subKeyName )
+{
+ HKEY hkey;
+ DWORD type;
+ TCHAR* data = NULL;
+ DWORD size;
+
+ /* open the specified registry key */
+ if ( RegOpenKeyEx( hroot, subKeyName, 0, KEY_READ, &hkey ) != ERROR_SUCCESS )
+ {
+ return NULL;
+ }
+
+ /* find the type and size of the default value */
+ if ( RegQueryValueEx( hkey, NULL, NULL, &type, NULL, &size) != ERROR_SUCCESS )
+ {
+ RegCloseKey( hkey );
+ return NULL;
+ }
+
+ /* get memory to hold the default value */
+ data = new WCHAR[size];
+
+ /* read the default value */
+ if ( RegQueryValueEx( hkey, NULL, NULL, &type, (LPBYTE) data, &size ) != ERROR_SUCCESS )
+ {
+ RegCloseKey( hkey );
+ return NULL;
+ }
+
+ /* release registry key handle */
+ RegCloseKey( hkey );
+
+ return data;
+}
+
+/* If the path does not end with '\' the las segment will be removed.
+ path: C:\a\b
+ -> C:\a
+ @param io_path
+ in/out parameter. The string is not reallocated. Simply a '\0'
+ will be inserted to shorten the string.
+*/
+void oneDirUp(LPTSTR io_path)
+{
+ WCHAR * pEnd = io_path + lstrlen(io_path) - 1;
+ while (pEnd > io_path //prevent crashing if provided string does not contain a backslash
+ && *pEnd != L'\\')
+ pEnd --;
+ *pEnd = L'\0';
+}
+
-//Returns the path to the URE/bin folder.
-//The caller must free the returned string with delete[]
-wchar_t * getUnoPath()
+/* Returns the path to the program folder of the brand layer,
+ for example c:/openoffice.org 3/program
+ This path is either obtained from the environment variable UNO_PATH
+ or the registry item
+ "Software\\OpenOffice.org\\UNO\\InstallPath"
+ either in HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE
+ The return value must be freed with delete[]
+*/
+WCHAR * getInstallPath()
{
- wchar_t * theUnoPath = NULL;
- bool failed = false;
- HKEY hKey = 0;
- if (RegOpenKeyEx(HKEY_CURRENT_USER,OFFICE_LOCATION_REGISTRY_KEY,
- 0, KEY_READ, &hKey) != ERROR_SUCCESS)
+ WCHAR * szInstallPath = NULL;
+
+ DWORD cChars = GetEnvironmentVariable(UNO_PATH, NULL, 0);
+ if (cChars > 0)
{
- if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, OFFICE_LOCATION_REGISTRY_KEY,
- 0, KEY_READ, &hKey) != ERROR_SUCCESS)
+ szInstallPath = new WCHAR[cChars];
+ cChars = GetEnvironmentVariable(UNO_PATH, szInstallPath, cChars);
+ //If PATH is not set then it is no error
+ if (cChars == 0)
{
-#if OSL_DEBUG_LEVEL >= 2
- fprintf(stderr, "cli_cppuhelper: Office not properly installed. "
- "Could not open registry keys.");
-#endif
- failed = true;
+ delete[] szInstallPath;
+ return NULL;
}
}
- if (! failed)
+
+ if (! szInstallPath)
{
- DWORD dwType = 0;
- DWORD dwLen = 0;
- wchar_t *arData = NULL;
- //get the length for the path to office
- if (RegQueryValueEx(hKey, UREINSTALLLOCATION, NULL, &dwType, NULL,
- &dwLen) == ERROR_SUCCESS)
+ szInstallPath = getPathFromRegistryKey( HKEY_CURRENT_USER, INSTALL_PATH );
+ if ( szInstallPath == NULL )
{
- arData = new wchar_t[dwLen];
- arData[0] = '\0';
- if (RegQueryValueEx(hKey, UREINSTALLLOCATION, NULL, &dwType, (LPBYTE) arData,
- & dwLen) == ERROR_SUCCESS)
- {
- int test = lstrlen(URE_BIN);
- //attach the bin directory to the URE path
- int sizePath = lstrlen(arData) + lstrlen(URE_BIN) + 1;
- theUnoPath = new wchar_t[sizePath];
- theUnoPath[0] = '\0';
- lstrcat(theUnoPath, arData);
- lstrcat(theUnoPath, URE_BIN);
- delete[] arData;
-#if OSL_DEBUG_LEVEL >=2
- fprintf(stdout,"[cli_cppuhelper]: Using path %S to load office libraries.", theUnoPath);
-#endif
- }
+ /* read the key's default value from HKEY_LOCAL_MACHINE */
+ szInstallPath = getPathFromRegistryKey( HKEY_LOCAL_MACHINE, INSTALL_PATH );
}
- RegCloseKey(hKey);
}
- return theUnoPath;
+ return szInstallPath;
}
-
-//Returns the path to the Ure/bin directory and expands the PATH by inserting the
-// ure/bin path at the front.
-wchar_t const * getUreBinPathAndSetPath()
+/* Returns the path to the URE/bin path, where cppuhelper lib resides.
+ The returned string must be freed with delete[]
+*/
+WCHAR* getUnoPath()
{
- static wchar_t * theBinPath = NULL;
+ WCHAR * szLinkPath = NULL;
+ WCHAR * szUrePath = NULL;
+ WCHAR * szUreBin = NULL; //the return value
- if (theBinPath)
- return theBinPath;
+ WCHAR * szInstallPath = getInstallPath();
+ if (szInstallPath)
+ {
+ //build the path tho the basis-link file
+ oneDirUp(szInstallPath);
+ int sizeLinkPath = lstrlen(szInstallPath) + lstrlen(INSTALL_PATH) + 1;
+ if (sizeLinkPath < MAX_PATH)
+ sizeLinkPath = MAX_PATH;
+ szLinkPath = new WCHAR[sizeLinkPath];
+ szLinkPath[0] = L'\0';
+ lstrcat(szLinkPath, szInstallPath);
+ lstrcat(szLinkPath, BASIS_LINK);
+
+ //get the path to the actual Basis folder
+ if (cli_ure::resolveLink(szLinkPath))
+ {
+ //build the path to the ure-link file
+ int sizeUrePath = lstrlen(szLinkPath) + lstrlen(URE_LINK) + 1;
+ if (sizeUrePath < MAX_PATH)
+ sizeUrePath = MAX_PATH;
+ szUrePath = new WCHAR[sizeUrePath];
+ szUrePath[0] = L'\0';
+ lstrcat(szUrePath, szLinkPath);
+ lstrcat(szUrePath, URE_LINK);
+
+ //get the path to the actual Ure folder
+ if (cli_ure::resolveLink(szUrePath))
+ {
+ //build the path to the URE/bin directory
+ szUreBin = new WCHAR[lstrlen(szUrePath) + lstrlen(URE_BIN) + 1];
+ szUreBin[0] = L'\0';
+ lstrcat(szUreBin, szUrePath);
+ lstrcat(szUreBin, URE_BIN);
+ }
+ }
+ }
+#if OSL_DEBUG_LEVEL >=2
+ if (szUreBin)
+ {
+ fwprintf(stdout,L"[cli_cppuhelper]: Path to URE libraries:\n %s \n", szUreBin);
+ }
+ else
+ {
+ fwprintf(stdout,L"[cli_cppuhelper]: Failed to determine location of URE.\n");
+ }
+#endif
+ delete[] szInstallPath;
+ delete[] szLinkPath;
+ delete[] szUrePath;
+ return szUreBin;
+}
- wchar_t * unoPath = getUnoPath();
- if (!unoPath)
- return NULL;
- //We extend the path to contain the program directory of the office,
- //so that components can use osl_loadModule with arguments, such as
- //"reg3.dll". That is, the arguments are only the library names.
+/*We extend the path to contain the Ure/bin folder,
+ so that components can use osl_loadModule with arguments, such as
+ "reg3.dll". That is, the arguments are only the library names.
+*/
+void extendPath(LPCWSTR szUreBinPath)
+{
+ if (!szUreBinPath)
+ return;
- wchar_t * sEnvPath = NULL;
+ WCHAR * sEnvPath = NULL;
DWORD cChars = GetEnvironmentVariable(L"PATH", sEnvPath, 0);
if (cChars > 0)
{
- sEnvPath = new wchar_t[cChars];
+ sEnvPath = new WCHAR[cChars];
cChars = GetEnvironmentVariable(L"PATH", sEnvPath, cChars);
//If PATH is not set then it is no error
if (cChars == 0 && GetLastError() != ERROR_ENVVAR_NOT_FOUND)
{
delete[] sEnvPath;
- return NULL;
+ return;
}
}
- //prepare the new PATH. Add the Ure/bin directory at the front
- wchar_t * sNewPath = new wchar_t[lstrlen(sEnvPath) + lstrlen(unoPath) + 2];
- sNewPath[0] = '\0';
- lstrcat(sNewPath, unoPath);
+ //prepare the new PATH. Add the Ure/bin directory at the front.
+ //note also adding ';'
+ WCHAR * sNewPath = new WCHAR[lstrlen(sEnvPath) + lstrlen(szUreBinPath) + 2];
+ sNewPath[0] = L'\0';
+ lstrcat(sNewPath, szUreBinPath);
if (lstrlen(sEnvPath))
{
lstrcat(sNewPath, L";");
lstrcat(sNewPath, sEnvPath);
}
-
BOOL bSet = SetEnvironmentVariable(L"PATH", sNewPath);
- theBinPath = unoPath;
delete[] sEnvPath;
delete[] sNewPath;
-
- return theBinPath;
}
-HMODULE loadFromPath(wchar_t const * sLibName)
+
+HMODULE loadFromPath(LPCWSTR sLibName)
{
if (sLibName == NULL)
return NULL;
- wchar_t const * binPath = getUreBinPathAndSetPath();
- if (!binPath)
+ WCHAR * szUreBinPath = getUnoPath();
+ if (!szUreBinPath)
return NULL;
+ extendPath(szUreBinPath);
- wchar_t* sFullPath = new wchar_t[lstrlen(sLibName) + lstrlen(binPath) + 2];
- sFullPath[0] = '\0';
- sFullPath = lstrcat(sFullPath, binPath);
- sFullPath = lstrcat(sFullPath, L"\\");
- sFullPath = lstrcat(sFullPath, sLibName);
- HMODULE handle = LoadLibraryEx(sFullPath, NULL,
+ WCHAR* szFullPath = new WCHAR[lstrlen(sLibName) + lstrlen(szUreBinPath) + 2];
+ szFullPath[0] = L'\0';
+ lstrcat(szFullPath, szUreBinPath);
+ lstrcat(szFullPath, L"\\");
+ lstrcat(szFullPath, sLibName);
+ HMODULE handle = LoadLibraryEx(szFullPath, NULL,
LOAD_WITH_ALTERED_SEARCH_PATH);
- delete[] sFullPath;
- return handle;
+ delete[] szFullPath;
+ delete[] szUreBinPath;
+ return handle;
}
-//Hook for delayed loading of libraries which this library is linked with.
-extern "C" FARPROC WINAPI delayLoadHook(
+/*Hook for delayed loading of libraries which this library is linked with.
+ This is a failure hook. That is, it is only called when the loading of
+ a library failed. It will be called when loading of cppuhelper failed.
+ Because we extend the PATH to the URE/bin folder while this function is
+ executed (see extendPath), all other libraries are found.
+*/
+extern "C" FARPROC WINAPI delayLoadHook(
unsigned dliNotify,
PDelayLoadInfo pdli
)
{
if (dliNotify == dliFailLoadLib)
{
- //Convert the ansi file name to wchar_t*
+ LPWSTR szLibName = NULL;
+ //Convert the ansi file name to wchar_t*
int size = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pdli->szDll, -1, NULL, 0);
if (size > 0)
{
- wchar_t * buf = new wchar_t[size];
- if (MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pdli->szDll, -1, buf, size))
+ szLibName = new WCHAR[size];
+ if (! MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, pdli->szDll, -1, szLibName, size))
{
- HMODULE handle = NULL;
- return (FARPROC) loadFromPath(buf);
+ return 0;
}
}
+ HANDLE h = loadFromPath(szLibName);
+ delete[] szLibName;
+ return (FARPROC) h;
}
return 0;
}
diff --git a/cli_ure/source/native/path.cxx b/cli_ure/source/native/path.cxx
new file mode 100644
index 000000000000..075a3cdb75bd
--- /dev/null
+++ b/cli_ure/source/native/path.cxx
@@ -0,0 +1,221 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: path.cxx,v $
+ * $Revision: 1.1.2.1 $
+ *
+ * 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.
+ *
+ ************************************************************************/
+
+#include "sal/config.h"
+
+#if defined WNT
+
+#include <cstddef>
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+#include "sal/types.h"
+#include "tools/pathutils.hxx"
+
+namespace cli_ure {
+
+WCHAR * filename(WCHAR * path) {
+ WCHAR * f = path;
+ for (WCHAR * p = path;;) {
+ switch (*p++) {
+ case L'\0':
+ return f;
+ case L'\\':
+ f = p;
+ break;
+ }
+ }
+}
+
+WCHAR * buildPath(
+ WCHAR * path, WCHAR const * frontBegin, WCHAR const * frontEnd,
+ WCHAR const * backBegin, std::size_t backLength)
+{
+ // Remove leading ".." segments in the second path together with matching
+ // segments in the first path that are neither empty nor "." nor ".." nor
+ // end in ":" (which is not foolprove, as it can erroneously erase the start
+ // of a UNC path, but only if the input is bad data):
+ while (backLength >= 2 && backBegin[0] == L'.' && backBegin[1] == L'.' &&
+ (backLength == 2 || backBegin[2] == L'\\'))
+ {
+ if (frontEnd - frontBegin < 2 || frontEnd[-1] != L'\\' ||
+ frontEnd[-2] == L'\\' || frontEnd[-2] == L':' ||
+ (frontEnd[-2] == L'.' &&
+ (frontEnd - frontBegin < 3 || frontEnd[-3] == L'\\' ||
+ (frontEnd[-3] == L'.' &&
+ (frontEnd - frontBegin < 4 || frontEnd[-4] == L'\\')))))
+ {
+ break;
+ }
+ WCHAR const * p = frontEnd - 1;
+ while (p != frontBegin && p[-1] != L'\\') {
+ --p;
+ }
+ if (p == frontBegin) {
+ break;
+ }
+ frontEnd = p;
+ if (backLength == 2) {
+ backBegin += 2;
+ backLength -= 2;
+ } else {
+ backBegin += 3;
+ backLength -= 3;
+ }
+ }
+ if (backLength <
+ static_cast< std::size_t >(MAX_PATH - (frontEnd - frontBegin)))
+ // hopefully std::size_t is large enough
+ {
+ WCHAR * p;
+ if (frontBegin == path) {
+ p = const_cast< WCHAR * >(frontEnd);
+ } else {
+ p = path;
+ while (frontBegin != frontEnd) {
+ *p++ = *frontBegin++;
+ }
+ }
+ for (; backLength > 0; --backLength) {
+ *p++ = *backBegin++;
+ }
+ *p = L'\0';
+ return p;
+ } else {
+ SetLastError(ERROR_FILENAME_EXCED_RANGE);
+ return NULL;
+ }
+}
+
+WCHAR * resolveLink(WCHAR * path) {
+ HANDLE h = CreateFileW(
+ path, FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
+ if (h == INVALID_HANDLE_VALUE) {
+ return NULL;
+ }
+ char p1[MAX_PATH];
+ DWORD n;
+ BOOL ok = ReadFile(h, p1, MAX_PATH, &n, NULL);
+ CloseHandle(h);
+ if (!ok) {
+ return NULL;
+ }
+ WCHAR p2[MAX_PATH];
+ std::size_t n2 = 0;
+ bool colon = false;
+ for (DWORD i = 0; i < n;) {
+ unsigned char c = static_cast< unsigned char >(p1[i++]);
+ switch (c) {
+ case '\0':
+ SetLastError(ERROR_BAD_PATHNAME);
+ return NULL;
+ case '\x0A':
+ case '\x0D':
+ if (n2 == MAX_PATH) {
+ SetLastError(ERROR_FILENAME_EXCED_RANGE);
+ return NULL;
+ }
+ p2[n2] = L'\0';
+ break;
+ case ':':
+ colon = true;
+ // fall through
+ default:
+ // Convert from UTF-8 to UTF-16:
+ if (c <= 0x7F) {
+ p2[n2++] = c;
+ } else if (c >= 0xC2 && c <= 0xDF && i < n &&
+ static_cast< unsigned char >(p1[i]) >= 0x80 &&
+ static_cast< unsigned char >(p1[i]) <= 0xBF)
+ {
+ p2[n2++] = ((c & 0x1F) << 6) |
+ (static_cast< unsigned char >(p1[i++]) & 0x3F);
+ } else if (n - i > 1 &&
+ ((c == 0xE0 &&
+ static_cast< unsigned char >(p1[i]) >= 0xA0 &&
+ static_cast< unsigned char >(p1[i]) <= 0xBF) ||
+ ((c >= 0xE1 && c <= 0xEC || c >= 0xEE && c <= 0xEF) &&
+ static_cast< unsigned char >(p1[i]) >= 0x80 &&
+ static_cast< unsigned char >(p1[i]) <= 0xBF) ||
+ (c == 0xED &&
+ static_cast< unsigned char >(p1[i]) >= 0x80 &&
+ static_cast< unsigned char >(p1[i]) <= 0x9F)) &&
+ static_cast< unsigned char >(p1[i + 1]) >= 0x80 &&
+ static_cast< unsigned char >(p1[i + 1]) <= 0xBF)
+ {
+ p2[n2++] = ((c & 0x0F) << 12) |
+ ((static_cast< unsigned char >(p1[i]) & 0x3F) << 6) |
+ (static_cast< unsigned char >(p1[i + 1]) & 0x3F);
+ i += 2;
+ } else if (n - 2 > 1 &&
+ ((c == 0xF0 &&
+ static_cast< unsigned char >(p1[i]) >= 0x90 &&
+ static_cast< unsigned char >(p1[i]) <= 0xBF) ||
+ (c >= 0xF1 && c <= 0xF3 &&
+ static_cast< unsigned char >(p1[i]) >= 0x80 &&
+ static_cast< unsigned char >(p1[i]) <= 0xBF) ||
+ (c == 0xF4 &&
+ static_cast< unsigned char >(p1[i]) >= 0x80 &&
+ static_cast< unsigned char >(p1[i]) <= 0x8F)) &&
+ static_cast< unsigned char >(p1[i + 1]) >= 0x80 &&
+ static_cast< unsigned char >(p1[i + 1]) <= 0xBF &&
+ static_cast< unsigned char >(p1[i + 2]) >= 0x80 &&
+ static_cast< unsigned char >(p1[i + 2]) <= 0xBF)
+ {
+ sal_Int32 u = ((c & 0x07) << 18) |
+ ((static_cast< unsigned char >(p1[i]) & 0x3F) << 12) |
+ ((static_cast< unsigned char >(p1[i + 1]) & 0x3F) << 6) |
+ (static_cast< unsigned char >(p1[i + 2]) & 0x3F);
+ i += 3;
+ p2[n2++] = static_cast< WCHAR >(((u - 0x10000) >> 10) | 0xD800);
+ p2[n2++] = static_cast< WCHAR >(
+ ((u - 0x10000) & 0x3FF) | 0xDC00);
+ } else {
+ SetLastError(ERROR_BAD_PATHNAME);
+ return NULL;
+ }
+ break;
+ }
+ }
+ WCHAR * end;
+ if (colon || p2[0] == L'\\') {
+ // Interpret p2 as an absolute path:
+ end = path;
+ } else {
+ // Interpret p2 as a relative path:
+ end = filename(path);
+ }
+ return buildPath(path, path, end, p2, n2);
+}
+
+}
+
+#endif
diff --git a/cli_ure/version/version.txt b/cli_ure/version/version.txt
index 97229d15781a..7e81c58e3277 100644
--- a/cli_ure/version/version.txt
+++ b/cli_ure/version/version.txt
@@ -8,7 +8,7 @@
#
# $RCSfile: version.txt,v $
#
-# $Revision: 1.12 $
+# $Revision: 1.12.12.1 $
#
# This file is part of OpenOffice.org.
#
@@ -29,23 +29,23 @@
#
#*************************************************************************
-CLI_URETYPES_NEW_VERSION=1.0.0.0
+CLI_URETYPES_NEW_VERSION=1.0.1.0
CLI_URETYPES_OLD_VERSION=1.0.0.0-1.0.0.0
-CLI_URETYPES_POLICY_VERSION=1.0.0.0
+CLI_URETYPES_POLICY_VERSION=1.1.0.0
CLI_URETYPES_POLICY_ASSEMBLY=policy.1.0.cli_uretypes
-CLI_BASETYPES_NEW_VERSION=1.0.11.0
-CLI_BASETYPES_OLD_VERSION=1.0.0.0-1.0.10.0
-CLI_BASETYPES_POLICY_VERSION=11.0.0.0
+CLI_BASETYPES_NEW_VERSION=1.0.12.0
+CLI_BASETYPES_OLD_VERSION=1.0.0.0-1.0.11.0
+CLI_BASETYPES_POLICY_VERSION=12.0.0.0
CLI_BASETYPES_POLICY_ASSEMBLY=policy.1.0.cli_basetypes
-CLI_URE_NEW_VERSION=1.0.14.0
-CLI_URE_OLD_VERSION=1.0.0.0-1.0.13.0
-CLI_URE_POLICY_VERSION=14.0.0.0
+CLI_URE_NEW_VERSION=1.0.15.0
+CLI_URE_OLD_VERSION=1.0.0.0-1.0.14.0
+CLI_URE_POLICY_VERSION=15.0.0.0
CLI_URE_POLICY_ASSEMBLY=policy.1.0.cli_ure
-CLI_CPPUHELPER_NEW_VERSION=1.0.14.0
-CLI_CPPUHELPER_OLD_VERSION=1.0.0.0-1.0.13.0
-CLI_CPPUHELPER_POLICY_VERSION=14.0.0.0
+CLI_CPPUHELPER_NEW_VERSION=1.0.15.0
+CLI_CPPUHELPER_OLD_VERSION=1.0.0.0-1.0.14.0
+CLI_CPPUHELPER_POLICY_VERSION=15.0.0.0
CLI_CPPUHELPER_POLICY_ASSEMBLY=policy.1.0.cli_cppuhelper
diff --git a/unoil/climaker/version.txt b/unoil/climaker/version.txt
index 2a56b0372d1e..86d9998af42d 100644
--- a/unoil/climaker/version.txt
+++ b/unoil/climaker/version.txt
@@ -8,7 +8,7 @@
#
# $RCSfile: version.txt,v $
#
-# $Revision: 1.2 $
+# $Revision: 1.2.18.1 $
#
# This file is part of OpenOffice.org.
#
@@ -29,8 +29,8 @@
#
#*************************************************************************
-CLI_OOOTYPES_NEW_VERSION=1.0.0.0
+CLI_OOOTYPES_NEW_VERSION=1.0.1.0
CLI_OOOTYPES_OLD_VERSION=1.0.0.0-1.0.0.0
-CLI_OOOTYPES_POLICY_VERSION=1.0.0.0
+CLI_OOOTYPES_POLICY_VERSION=1.1.0.0
CLI_OOOTYPES_POLICY_ASSEMBLY=policy.1.0.cli_oootypes