[Libreoffice-commits] core.git: Branch 'aoo/trunk' - 2 commits - postprocess/prj sc/JunitTest_sc_complex.mk test/inc test/prj test/source

Damjan Jovanovic damjan at apache.org
Wed Jan 18 12:17:39 UTC 2017


 postprocess/prj/build.lst                                           |    2 
 sc/JunitTest_sc_complex.mk                                          |    2 
 test/inc/makefile.mk                                                |   36 +
 test/inc/pch/precompiled_test.cxx                                   |   24 
 test/inc/pch/precompiled_test.hxx                                   |   28 
 test/inc/test/detail/testdllapi.hxx                                 |   37 +
 test/inc/test/gettestargument.hxx                                   |   42 +
 test/inc/test/officeconnection.hxx                                  |   63 +
 test/inc/test/oustringostreaminserter.hxx                           |   46 +
 test/inc/test/toabsolutefileurl.hxx                                 |   42 +
 test/inc/test/uniquepipename.hxx                                    |   40 +
 test/prj/build.lst                                                  |    6 
 test/prj/d.lst                                                      |   17 
 test/source/cpp/getargument.cxx                                     |   45 +
 test/source/cpp/getargument.hxx                                     |   42 +
 test/source/cpp/gettestargument.cxx                                 |   39 +
 test/source/cpp/makefile.mk                                         |   72 ++
 test/source/cpp/officeconnection.cxx                                |  170 +++++
 test/source/cpp/toabsolutefileurl.cxx                               |   81 ++
 test/source/cpp/uniquepipename.cxx                                  |   44 +
 test/source/cpp/unoexceptionprotector/makefile.mk                   |   67 ++
 test/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx     |   96 ++
 test/source/java/org/openoffice/test/Argument.java                  |   32 
 test/source/java/org/openoffice/test/FileHelper.java                |   56 +
 test/source/java/org/openoffice/test/OfficeConnection.java          |  220 ++++++
 test/source/java/org/openoffice/test/OfficeFileUrl.java             |   38 +
 test/source/java/org/openoffice/test/TestArgument.java              |   35 +
 test/source/java/org/openoffice/test/makefile.mk                    |   53 +
 test/source/java/org/openoffice/test/tools/DocumentType.java        |   60 +
 test/source/java/org/openoffice/test/tools/OfficeDocument.java      |  324 ++++++++++
 test/source/java/org/openoffice/test/tools/OfficeDocumentView.java  |  140 ++++
 test/source/java/org/openoffice/test/tools/SpreadsheetDocument.java |   69 ++
 test/source/java/org/openoffice/test/tools/SpreadsheetView.java     |   68 ++
 test/source/java/org/openoffice/test/tools/makefile.mk              |   47 +
 34 files changed, 2181 insertions(+), 2 deletions(-)

New commits:
commit b4448f13ef5a8ddece9dd35f4ca749aa203cb976
Author: Damjan Jovanovic <damjan at apache.org>
Date:   Wed Jan 18 05:16:11 2017 +0000

    Fix a main/sc JunitTest typo.
    
    Patch by: me

diff --git a/sc/JunitTest_sc_complex.mk b/sc/JunitTest_sc_complex.mk
index f946a3a..03d34c6 100644
--- a/sc/JunitTest_sc_complex.mk
+++ b/sc/JunitTest_sc_complex.mk
@@ -32,7 +32,7 @@ $(eval $(call gb_JunitTest_add_jars,sc_complex,\
 ))
 
 $(eval $(call gb_JunitTest_add_sourcefiles,sc_complex,\
-	sc/qa/complex/sc/CalcCRTL \
+	sc/qa/complex/sc/CalcRTL \
 ))
 
 $(eval $(call gb_JunitTest_add_classes,sc_complex,\
commit 74dc26ee5acba162d704a5ff4082391fb2953f1e
Author: Damjan Jovanovic <damjan at apache.org>
Date:   Wed Jan 18 04:32:59 2017 +0000

    Resurrect main/test, which was deleted by liuzhe in r1378870, probably
    
    by accident, and which we need for test.jar and test-tools.jar for
    subsequent tests.
    
    I am only bringing back the prj, inc and source subdirectories, as the
    others are unnecessary.
    
    Patch by: me

diff --git a/postprocess/prj/build.lst b/postprocess/prj/build.lst
index 62aa24e..9993021 100644
--- a/postprocess/prj/build.lst
+++ b/postprocess/prj/build.lst
@@ -1,4 +1,4 @@
-po      postprocess     ::      svgio accessibility automation basctl bean chart2 configmgr CRASHREP:crashrep COINMP:coinmp cui dbaccess desktop dtrans embeddedobj embedserv EPM:epm eventattacher extensions extras fileaccess filter forms fpicker helpcontent2 io JAVAINSTALLER2:javainstaller2 lingucomponent MATHMLDTD:MathMLDTD ODK:odk officecfg package padmin psprint_config remotebridges sc scaddins sccomp scp2 scripting sd setup_native slideshow starmath sw sysui testtools ucb UnoControls unoxml ure wizards xmerge xmlsecurity MORE_FONTS:more_fonts OOo:pyuno OOo:readlicense_oo SO:top unodevtools JFREEREPORT:jfreereport REPORTBUILDER:reportbuilder reportdesign sdext SWEXT:swext smoketestdoc uui writerfilter winaccessibility oox MYSQLC:mysqlc LIBXSLT:libxslt NULL
+po      postprocess     ::      svgio accessibility automation basctl bean chart2 configmgr CRASHREP:crashrep COINMP:coinmp cui dbaccess desktop dtrans embeddedobj embedserv EPM:epm eventattacher extensions extras fileaccess filter forms fpicker helpcontent2 io JAVAINSTALLER2:javainstaller2 lingucomponent MATHMLDTD:MathMLDTD ODK:odk officecfg package padmin psprint_config remotebridges sc scaddins sccomp scp2 scripting sd setup_native slideshow starmath sw sysui test testtools ucb UnoControls unoxml ure wizards xmerge xmlsecurity MORE_FONTS:more_fonts OOo:pyuno OOo:readlicense_oo SO:top unodevtools JFREEREPORT:jfreereport REPORTBUILDER:reportbuilder reportdesign sdext SWEXT:swext smoketestdoc uui writerfilter winaccessibility oox MYSQLC:mysqlc LIBXSLT:libxslt NULL
 po	postprocess			    	usr1	-	all	po_mkout NULL
 po	postprocess\checkxml		nmake	-	all	po_checkxml NULL
 po	postprocess\checkdeliver	nmake	-	all	po_checkdlv NULL
diff --git a/test/inc/makefile.mk b/test/inc/makefile.mk
new file mode 100644
index 0000000..872e9f2
--- /dev/null
+++ b/test/inc/makefile.mk
@@ -0,0 +1,36 @@
+#**************************************************************
+#  
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#  
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#  
+#**************************************************************
+
+
+
+PRJ = ..
+PRJNAME = test
+TARGET = inc
+
+ENABLE_EXCEPTIONS = TRUE
+VISIBILITY_HIDDEN = TRUE
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
+
+.IF "$(ENABLE_PCH)" != ""
+ALLTAR: $(SLO)/precompiled.pch $(SLO)/precompiled_ex.pch
+.ENDIF
diff --git a/test/inc/pch/precompiled_test.cxx b/test/inc/pch/precompiled_test.cxx
new file mode 100644
index 0000000..f0fda0b
--- /dev/null
+++ b/test/inc/pch/precompiled_test.cxx
@@ -0,0 +1,24 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#include "precompiled_test.hxx"
diff --git a/test/inc/pch/precompiled_test.hxx b/test/inc/pch/precompiled_test.hxx
new file mode 100644
index 0000000..a6a57fe
--- /dev/null
+++ b/test/inc/pch/precompiled_test.hxx
@@ -0,0 +1,28 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#if defined PRECOMPILED_HEADERS
+
+#include "sal/config.h"
+
+#endif
diff --git a/test/inc/test/detail/testdllapi.hxx b/test/inc/test/detail/testdllapi.hxx
new file mode 100644
index 0000000..9ea3dcc
--- /dev/null
+++ b/test/inc/test/detail/testdllapi.hxx
@@ -0,0 +1,37 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#ifndef INCLUDED_TEST_DETAIL_TESTDLLAPI_HXX
+#define INCLUDED_TEST_DETAIL_TESTDLLAPI_HXX
+
+#include "sal/config.h"
+
+#include "sal/types.h"
+
+#if defined OOO_DLLIMPLEMENTATION_TEST
+#define OOO_DLLPUBLIC_TEST SAL_DLLPUBLIC_EXPORT
+#else
+#define OOO_DLLPUBLIC_TEST SAL_DLLPUBLIC_IMPORT
+#endif
+
+#endif
diff --git a/test/inc/test/gettestargument.hxx b/test/inc/test/gettestargument.hxx
new file mode 100644
index 0000000..c20ce4c
--- /dev/null
+++ b/test/inc/test/gettestargument.hxx
@@ -0,0 +1,42 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#ifndef INCLUDED_TEST_GETTESTARGUMENT_HXX
+#define INCLUDED_TEST_GETTESTARGUMENT_HXX
+
+#include "sal/config.h"
+
+#include "test/detail/testdllapi.hxx"
+
+namespace rtl { class OUString; }
+
+namespace test {
+
+// Obtain the value of a test argument (tunneled in via an "arg-testarg.<name>"
+// bootstrap variable):
+OOO_DLLPUBLIC_TEST bool getTestArgument(
+    rtl::OUString const & name, rtl::OUString * value);
+
+}
+
+#endif
diff --git a/test/inc/test/officeconnection.hxx b/test/inc/test/officeconnection.hxx
new file mode 100644
index 0000000..582f705
--- /dev/null
+++ b/test/inc/test/officeconnection.hxx
@@ -0,0 +1,63 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#ifndef INCLUDED_TEST_OFFICECONNECTION_HXX
+#define INCLUDED_TEST_OFFICECONNECTION_HXX
+
+#include "sal/config.h"
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "osl/process.h"
+#include "test/detail/testdllapi.hxx"
+
+namespace com { namespace sun { namespace star { namespace uno {
+    class XComponentContext;
+} } } }
+
+namespace test {
+
+// Start up and shut down an OOo instance (details about the OOo instance are
+// tunneled in via "arg-..." bootstrap variables):
+class OOO_DLLPUBLIC_TEST OfficeConnection: private boost::noncopyable {
+public:
+    OfficeConnection();
+
+    ~OfficeConnection();
+
+    void setUp();
+
+    void tearDown();
+
+    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+    getComponentContext() const;
+
+private:
+    oslProcess process_;
+    com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >
+        context_;
+};
+
+}
+
+#endif
diff --git a/test/inc/test/oustringostreaminserter.hxx b/test/inc/test/oustringostreaminserter.hxx
new file mode 100644
index 0000000..775dd27
--- /dev/null
+++ b/test/inc/test/oustringostreaminserter.hxx
@@ -0,0 +1,46 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#ifndef INCLUDED_TEST_OUSTRINGOSTREAMINSERTER_HXX
+#define INCLUDED_TEST_OUSTRINGOSTREAMINSERTER_HXX
+
+#include "sal/config.h"
+
+#include <ostream>
+
+#include "osl/thread.h"
+#include "rtl/ustring.hxx"
+
+// Include this header to support rtl::OUString in CPPUNIT_ASSERT macros.
+
+template< typename charT, typename traits > std::basic_ostream<charT, traits> &
+operator <<(
+    std::basic_ostream<charT, traits> & stream, rtl::OUString const & string)
+{
+    return stream <<
+        rtl::OUStringToOString(string, osl_getThreadTextEncoding()).getStr();
+        // best effort; potentially loses data due to conversion failures and
+        // embedded null characters
+}
+
+#endif
diff --git a/test/inc/test/toabsolutefileurl.hxx b/test/inc/test/toabsolutefileurl.hxx
new file mode 100644
index 0000000..ed33416
--- /dev/null
+++ b/test/inc/test/toabsolutefileurl.hxx
@@ -0,0 +1,42 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#ifndef INCLUDED_TEST_TOABSOLUTEFILEURL_HXX
+#define INCLUDED_TEST_TOABSOLUTEFILEURL_HXX
+
+#include "sal/config.h"
+
+#include "test/detail/testdllapi.hxx"
+
+namespace rtl { class OUString; }
+
+namespace test {
+
+// Convert a pathname in system notation, potentially relative to the process's
+// current working directory, to an absolute file URL:
+OOO_DLLPUBLIC_TEST rtl::OUString toAbsoluteFileUrl(
+    rtl::OUString const & relativePathname);
+
+}
+
+#endif
diff --git a/test/inc/test/uniquepipename.hxx b/test/inc/test/uniquepipename.hxx
new file mode 100644
index 0000000..9632d8f
--- /dev/null
+++ b/test/inc/test/uniquepipename.hxx
@@ -0,0 +1,40 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#ifndef INCLUDED_TEST_UNIQUEPIPENAME_HXX
+#define INCLUDED_TEST_UNIQUEPIPENAME_HXX
+
+#include "sal/config.h"
+
+#include "test/detail/testdllapi.hxx"
+
+namespace rtl { class OUString; }
+
+namespace test {
+
+// Create a system-wide unique name (for use with osl::Pipe):
+OOO_DLLPUBLIC_TEST rtl::OUString uniquePipeName(rtl::OUString const & name);
+
+}
+
+#endif
diff --git a/test/prj/build.lst b/test/prj/build.lst
new file mode 100644
index 0000000..0da3c32
--- /dev/null
+++ b/test/prj/build.lst
@@ -0,0 +1,6 @@
+te test : BOOST:boost cppu cppuhelper javaunohelper ridljar sal solenv stlport unoil NULL
+te test\inc nmake - all inc NULL
+te test\source\cpp nmake - all source_cpp inc NULL
+te test\source\cpp\unoexceptionprotector nmake - all source_cpp_unoexceptionprotector inc NULL
+te test\source\java\org\openoffice\test nmake - all source_java NULL
+te test\source\java\org\openoffice\test\tools nmake - all source_java_tools NULL
diff --git a/test/prj/d.lst b/test/prj/d.lst
new file mode 100644
index 0000000..18a599f
--- /dev/null
+++ b/test/prj/d.lst
@@ -0,0 +1,17 @@
+mkdir: %_DEST%\inc%_EXT%\test
+mkdir: %_DEST%\inc%_EXT%\test\detail
+..\%__SRC%\bin\test.dll %_DEST%\bin%_EXT%\test.dll
+..\%__SRC%\bin\unoexceptionprotector.dll %_DEST%\bin%_EXT%\unoexceptionprotector.dll
+..\%__SRC%\lib\itest.lib %_DEST%\lib%_EXT%\itest.lib
+..\%__SRC%\lib\libtest.dylib %_DEST%\lib%_EXT%\libtest.dylib
+..\%__SRC%\lib\libtest.so %_DEST%\lib%_EXT%\libtest.so
+..\%__SRC%\lib\unoexceptionprotector.dylib %_DEST%\lib%_EXT%\unoexceptionprotector.dylib
+..\%__SRC%\lib\unoexceptionprotector.so %_DEST%\lib%_EXT%\unoexceptionprotector.so
+..\inc\test\detail\testdllapi.hxx %_DEST%\inc%_EXT%\test\detail\testdllapi.hxx
+..\inc\test\gettestargument.hxx %_DEST%\inc%_EXT%\test\gettestargument.hxx
+..\inc\test\officeconnection.hxx %_DEST%\inc%_EXT%\test\officeconnection.hxx
+..\inc\test\oustringostreaminserter.hxx %_DEST%\inc%_EXT%\test\oustringostreaminserter.hxx
+..\inc\test\toabsolutefileurl.hxx %_DEST%\inc%_EXT%\test\toabsolutefileurl.hxx
+..\inc\test\uniquepipename.hxx %_DEST%\inc%_EXT%\test\uniquepipename.hxx
+..\%__SRC%\class\test.jar %_DEST%\bin%_EXT%\test.jar
+..\%__SRC%\class\test-tools.jar %_DEST%\bin%_EXT%\test-tools.jar
diff --git a/test/source/cpp/getargument.cxx b/test/source/cpp/getargument.cxx
new file mode 100644
index 0000000..4e30a48
--- /dev/null
+++ b/test/source/cpp/getargument.cxx
@@ -0,0 +1,45 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#include "sal/config.h"
+
+#include "osl/diagnose.h"
+#include "rtl/bootstrap.hxx"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+
+#include "getargument.hxx"
+
+namespace test {
+
+namespace detail {
+
+bool getArgument(rtl::OUString const & name, rtl::OUString * value) {
+    OSL_ASSERT(value != 0);
+    return rtl::Bootstrap::get(
+        rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("arg-")) + name, *value);
+}
+
+}
+
+}
diff --git a/test/source/cpp/getargument.hxx b/test/source/cpp/getargument.hxx
new file mode 100644
index 0000000..7ec6a4a
--- /dev/null
+++ b/test/source/cpp/getargument.hxx
@@ -0,0 +1,42 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#ifndef INCLUDED_TEST_SOURCE_CPP_GETARGUMENT_HXX
+#define INCLUDED_TEST_SOURCE_CPP_GETARGUMENT_HXX
+
+#include "sal/config.h"
+
+namespace test {
+
+namespace detail {
+
+// Obtain the value of an argument tunneled in via an "arg-<name>" bootstrap
+// variable:
+bool getArgument(
+    rtl::OUString const & name, rtl::OUString * value);
+
+}
+
+}
+
+#endif
diff --git a/test/source/cpp/gettestargument.cxx b/test/source/cpp/gettestargument.cxx
new file mode 100644
index 0000000..118cb6e
--- /dev/null
+++ b/test/source/cpp/gettestargument.cxx
@@ -0,0 +1,39 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#include "sal/config.h"
+
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "test/gettestargument.hxx"
+
+#include "getargument.hxx"
+
+namespace test {
+
+bool getTestArgument(rtl::OUString const & name, rtl::OUString * value) {
+    return detail::getArgument(
+        rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("testarg.")) + name, value);
+}
+
+}
diff --git a/test/source/cpp/makefile.mk b/test/source/cpp/makefile.mk
new file mode 100644
index 0000000..5e49d4f
--- /dev/null
+++ b/test/source/cpp/makefile.mk
@@ -0,0 +1,72 @@
+#**************************************************************
+#  
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#  
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#  
+#**************************************************************
+
+
+
+PRJ = ../..
+PRJNAME = test
+TARGET = cpp
+
+ENABLE_EXCEPTIONS = TRUE
+VISIBILITY_HIDDEN = TRUE
+
+.INCLUDE: settings.mk
+
+.IF "$(WITH_CPPUNIT)" != "YES" || "$(GUI)" == "OS2"
+
+ at all:
+.IF "$(GUI)" == "OS2"
+    @echo "Skipping, cppunit broken."
+.ELIF "$(WITH_CPPUNIT)" != "YES"
+    @echo "cppunit disabled. nothing do do."
+.END
+
+.ELSE
+
+CDEFS += -DOOO_DLLIMPLEMENTATION_TEST
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(USE_SYSTEM_STL)" != "YES" && "$(SYSTEM_CPPUNIT)" == "YES"
+CFLAGSCXX += -DADAPT_EXT_STL
+.END
+
+SLOFILES = \
+    $(SLO)/getargument.obj \
+    $(SLO)/gettestargument.obj \
+    $(SLO)/officeconnection.obj \
+    $(SLO)/toabsolutefileurl.obj \
+    $(SLO)/uniquepipename.obj
+
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1OBJS = $(SLOFILES)
+SHL1RPATH = NONE
+SHL1STDLIBS = \
+    $(CPPUHELPERLIB) \
+    $(CPPULIB) \
+    $(CPPUNITLIB) \
+    $(SALLIB)
+SHL1TARGET = test
+SHL1USE_EXPORTS = name
+DEF1NAME = $(SHL1TARGET)
+
+.ENDIF
+
+.INCLUDE: target.mk
diff --git a/test/source/cpp/officeconnection.cxx b/test/source/cpp/officeconnection.cxx
new file mode 100644
index 0000000..c137fbd
--- /dev/null
+++ b/test/source/cpp/officeconnection.cxx
@@ -0,0 +1,170 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#include "sal/config.h"
+
+#include "com/sun/star/bridge/UnoUrlResolver.hpp"
+#include "com/sun/star/bridge/XUnoUrlResolver.hpp"
+#include "com/sun/star/connection/NoConnectException.hpp"
+#include "com/sun/star/frame/XDesktop.hpp"
+#include "com/sun/star/lang/DisposedException.hpp"
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "cppuhelper/bootstrap.hxx"
+#include <preextstl.h>
+#include "cppunit/TestAssert.h"
+#include <postextstl.h>
+#include "osl/process.h"
+#include "osl/time.h"
+#include "sal/types.h"
+#include "test/officeconnection.hxx"
+#include "test/toabsolutefileurl.hxx"
+#include "test/uniquepipename.hxx"
+
+#include "getargument.hxx"
+
+namespace {
+
+namespace css = com::sun::star;
+
+}
+
+namespace test {
+
+OfficeConnection::OfficeConnection(): process_(0) {}
+
+OfficeConnection::~OfficeConnection() {}
+
+void OfficeConnection::setUp() {
+    rtl::OUString desc;
+    rtl::OUString argSoffice;
+    CPPUNIT_ASSERT(
+        detail::getArgument(
+            rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("soffice")),
+            &argSoffice));
+    if (argSoffice.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("path:"))) {
+        desc = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pipe,name=")) +
+            uniquePipeName(
+                rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("oootest")));
+        rtl::OUString noquickArg(
+            RTL_CONSTASCII_USTRINGPARAM("-quickstart=no"));
+        rtl::OUString nofirstArg(
+            RTL_CONSTASCII_USTRINGPARAM("-nofirststartwizard"));
+        rtl::OUString norestoreArg(RTL_CONSTASCII_USTRINGPARAM("-norestore"));
+        rtl::OUString acceptArg(
+            rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("-accept=")) + desc +
+            rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(";urp")));
+        rtl::OUString argUser;
+        CPPUNIT_ASSERT(
+            detail::getArgument(
+                rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("user")), &argUser));
+        rtl::OUString userArg(
+            rtl::OUString(
+                RTL_CONSTASCII_USTRINGPARAM("-env:UserInstallation=")) +
+            toAbsoluteFileUrl(argUser));
+        rtl::OUString jreArg(
+            RTL_CONSTASCII_USTRINGPARAM("-env:UNO_JAVA_JFW_ENV_JREHOME=true"));
+        rtl_uString * args[] = {
+            noquickArg.pData, nofirstArg.pData, norestoreArg.pData,
+            acceptArg.pData, userArg.pData, jreArg.pData };
+        rtl_uString ** envs = 0;
+        rtl::OUString argEnv;
+        if (detail::getArgument(
+                rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("env")), &argEnv))
+        {
+            envs = &argEnv.pData;
+        }
+        CPPUNIT_ASSERT_EQUAL(
+            osl_Process_E_None,
+            osl_executeProcess(
+                toAbsoluteFileUrl(
+                    argSoffice.copy(RTL_CONSTASCII_LENGTH("path:"))).pData,
+                args, sizeof args / sizeof args[0], 0, 0, 0, envs,
+                envs == 0 ? 0 : 1, &process_));
+    } else if (argSoffice.matchAsciiL(RTL_CONSTASCII_STRINGPARAM("connect:"))) {
+        desc = argSoffice.copy(RTL_CONSTASCII_LENGTH("connect:"));
+    } else {
+        CPPUNIT_FAIL(
+            "\"soffice\" argument starts with neither \"path:\" nor"
+            " \"connect:\"");
+    }
+    css::uno::Reference< css::bridge::XUnoUrlResolver > resolver(
+        css::bridge::UnoUrlResolver::create(
+            cppu::defaultBootstrap_InitialComponentContext()));
+    for (;;) {
+        try {
+            context_ =
+                css::uno::Reference< css::uno::XComponentContext >(
+                    resolver->resolve(
+                        rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("uno:")) +
+                        desc +
+                        rtl::OUString(
+                            RTL_CONSTASCII_USTRINGPARAM(
+                                ";urp;StarOffice.ComponentContext"))),
+                    css::uno::UNO_QUERY_THROW);
+            break;
+        } catch (css::connection::NoConnectException &) {}
+        if (process_ != 0) {
+            TimeValue delay = { 1, 0 }; // 1 sec
+            CPPUNIT_ASSERT_EQUAL(
+                osl_Process_E_TimedOut,
+                osl_joinProcessWithTimeout(process_, &delay));
+        }
+    }
+}
+
+void OfficeConnection::tearDown() {
+    if (process_ != 0) {
+        if (context_.is()) {
+            css::uno::Reference< css::frame::XDesktop > desktop(
+                context_->getServiceManager()->createInstanceWithContext(
+                    rtl::OUString(
+                        RTL_CONSTASCII_USTRINGPARAM(
+                            "com.sun.star.frame.Desktop")),
+                    context_),
+                css::uno::UNO_QUERY_THROW);
+            context_.clear();
+            try {
+                CPPUNIT_ASSERT(desktop->terminate());
+                desktop.clear();
+            } catch (css::lang::DisposedException &) {}
+                // it appears that DisposedExceptions can already happen while
+                // receiving the response of the terminate call
+        }
+        CPPUNIT_ASSERT_EQUAL(osl_Process_E_None, osl_joinProcess(process_));
+        oslProcessInfo info;
+        info.Size = sizeof info;
+        CPPUNIT_ASSERT_EQUAL(
+            osl_Process_E_None,
+            osl_getProcessInfo(process_, osl_Process_EXITCODE, &info));
+        CPPUNIT_ASSERT_EQUAL(oslProcessExitCode(0), info.Code);
+        osl_freeProcessHandle(process_);
+    }
+}
+
+css::uno::Reference< css::uno::XComponentContext >
+OfficeConnection::getComponentContext() const {
+    return context_;
+}
+
+}
diff --git a/test/source/cpp/toabsolutefileurl.cxx b/test/source/cpp/toabsolutefileurl.cxx
new file mode 100644
index 0000000..ba521ed
--- /dev/null
+++ b/test/source/cpp/toabsolutefileurl.cxx
@@ -0,0 +1,81 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#include "sal/config.h"
+
+#include "com/sun/star/uno/Reference.hxx"
+#include "com/sun/star/uno/RuntimeException.hpp"
+#include "com/sun/star/uno/XInterface.hpp"
+#include "osl/file.hxx"
+#include "osl/process.h"
+#include "rtl/ustring.hxx"
+#include "test/toabsolutefileurl.hxx"
+
+namespace {
+
+namespace css = com::sun::star;
+
+}
+
+namespace test {
+
+rtl::OUString toAbsoluteFileUrl(rtl::OUString const & relativePathname) {
+    rtl::OUString cwd;
+    oslProcessError e1 = osl_getProcessWorkingDir(&cwd.pData);
+    if (e1 != osl_Process_E_None) {
+        throw css::uno::RuntimeException(
+            (rtl::OUString(
+                RTL_CONSTASCII_USTRINGPARAM(
+                    "osl_getProcessWorkingDir failed with ")) +
+             rtl::OUString::valueOf(static_cast< sal_Int32 >(e1))),
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    rtl::OUString url;
+    osl::FileBase::RC e2 = osl::FileBase::getFileURLFromSystemPath(
+        relativePathname, url);
+    if (e2 != osl::FileBase::E_None) {
+        throw css::uno::RuntimeException(
+            (rtl::OUString(
+                RTL_CONSTASCII_USTRINGPARAM(
+                    "osl::FileBase::getFileURLFromSystemPath(")) +
+             relativePathname +
+             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(") failed with ")) +
+             rtl::OUString::valueOf(static_cast< sal_Int32 >(e2))),
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    rtl::OUString absUrl;
+    e2 = osl::FileBase::getAbsoluteFileURL(cwd, url, absUrl);
+    if (e2 != osl::FileBase::E_None) {
+        throw css::uno::RuntimeException(
+            (rtl::OUString(
+                RTL_CONSTASCII_USTRINGPARAM(
+                    "osl::FileBase::getAbsoluteFileURL(")) +
+             cwd + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(", ")) + url +
+             rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(") failed with ")) +
+             rtl::OUString::valueOf(static_cast< sal_Int32 >(e2))),
+            css::uno::Reference< css::uno::XInterface >());
+    }
+    return absUrl;
+}
+
+}
diff --git a/test/source/cpp/uniquepipename.cxx b/test/source/cpp/uniquepipename.cxx
new file mode 100644
index 0000000..fa0600c
--- /dev/null
+++ b/test/source/cpp/uniquepipename.cxx
@@ -0,0 +1,44 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#include "sal/config.h"
+
+#include "cppunit/TestAssert.h"
+#include "osl/process.h"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+#include "test/uniquepipename.hxx"
+
+namespace test {
+
+rtl::OUString uniquePipeName(rtl::OUString const & name) {
+    oslProcessInfo info;
+    info.Size = sizeof info;
+    CPPUNIT_ASSERT_EQUAL(
+        osl_Process_E_None,
+        osl_getProcessInfo(0, osl_Process_IDENTIFIER, &info));
+    return name + rtl::OUString::valueOf(static_cast< sal_Int64 >(info.Ident));
+}
+
+}
diff --git a/test/source/cpp/unoexceptionprotector/makefile.mk b/test/source/cpp/unoexceptionprotector/makefile.mk
new file mode 100644
index 0000000..de3c021
--- /dev/null
+++ b/test/source/cpp/unoexceptionprotector/makefile.mk
@@ -0,0 +1,67 @@
+#**************************************************************
+#  
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#  
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#  
+#**************************************************************
+
+
+
+PRJ = ../../..
+PRJNAME = test
+TARGET = unoexceptionprotector
+
+ENABLE_EXCEPTIONS = TRUE
+VISIBILITY_HIDDEN = TRUE
+
+.INCLUDE: settings.mk
+
+.IF "$(WITH_CPPUNIT)" != "YES" || "$(GUI)" == "OS2"
+
+ at all:
+.IF "$(GUI)" == "OS2"
+    @echo "Skipping, cppunit broken."
+.ELIF "$(WITH_CPPUNIT)" != "YES"
+    @echo "cppunit disabled. nothing do do."
+.END
+
+.ELSE
+
+DLLPRE =
+
+CFLAGSCXX += $(CPPUNIT_CFLAGS)
+.IF "$(USE_SYSTEM_STL)" != "YES" && "$(SYSTEM_CPPUNIT)" == "YES"
+CFLAGSCXX += -DADAPT_EXT_STL
+.END
+
+SLOFILES = $(SLO)/unoexceptionprotector.obj
+
+SHL1IMPLIB = i$(SHL1TARGET)
+SHL1OBJS = $(SLOFILES)
+SHL1RPATH = NONE
+SHL1STDLIBS = \
+    $(CPPUHELPERLIB) \
+    $(CPPULIB) \
+    $(CPPUNITLIB) \
+    $(SALLIB)
+SHL1TARGET = unoexceptionprotector
+SHL1USE_EXPORTS = name
+DEF1NAME = $(SHL1TARGET)
+
+.INCLUDE: target.mk
+
+.ENDIF
diff --git a/test/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx b/test/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
new file mode 100644
index 0000000..2fc434b
--- /dev/null
+++ b/test/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
@@ -0,0 +1,96 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+#include "precompiled_test.hxx"
+#include "sal/config.h"
+
+#include <limits>
+#include <string>
+
+#include "boost/noncopyable.hpp"
+#include "com/sun/star/uno/Any.hxx"
+#include "com/sun/star/uno/Exception.hpp"
+#include "cppuhelper/exc_hlp.hxx"
+#include "osl/thread.h"
+#include "rtl/string.hxx"
+#include "rtl/ustring.h"
+#include "rtl/ustring.hxx"
+#include "sal/types.h"
+
+#include "preextstl.h"
+#include "cppunit/Message.h"
+#include "cppunit/Protector.h"
+#include "postextstl.h"
+
+namespace {
+
+namespace css = com::sun::star;
+
+// Best effort conversion:
+std::string convert(rtl::OUString const & s16) {
+    rtl::OString s8(rtl::OUStringToOString(s16, osl_getThreadTextEncoding()));
+    return std::string(
+        s8.getStr(),
+        ((static_cast< sal_uInt32 >(s8.getLength())
+          > std::numeric_limits< std::string::size_type >::max())
+         ? std::numeric_limits< std::string::size_type >::max()
+         : static_cast< std::string::size_type >(s8.getLength())));
+}
+
+class Prot: public CppUnit::Protector, private boost::noncopyable {
+public:
+    Prot() {}
+
+    virtual ~Prot() {}
+
+    virtual bool protect(
+        CppUnit::Functor const & functor,
+        CppUnit::ProtectorContext const & context);
+};
+
+bool Prot::protect(
+    CppUnit::Functor const & functor, CppUnit::ProtectorContext const & context)
+{
+    try {
+        return functor();
+    } catch (css::uno::Exception & e) {
+        css::uno::Any a(cppu::getCaughtException());
+        reportError(
+            context,
+            CppUnit::Message(
+                convert(
+                    rtl::OUString(
+                        RTL_CONSTASCII_USTRINGPARAM(
+                            "uncaught exception of type "))
+                    + a.getValueTypeName()),
+                convert(e.Message)));
+    }
+    return false;
+}
+
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT CppUnit::Protector * SAL_CALL
+unoexceptionprotector() {
+    return new Prot;
+}
diff --git a/test/source/java/org/openoffice/test/Argument.java b/test/source/java/org/openoffice/test/Argument.java
new file mode 100644
index 0000000..97f08df
--- /dev/null
+++ b/test/source/java/org/openoffice/test/Argument.java
@@ -0,0 +1,32 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+package org.openoffice.test;
+
+public final class Argument {
+    public static String get(String name) {
+        return System.getProperty("org.openoffice.test.arg." + name);
+    }
+
+    private Argument() {}
+}
diff --git a/test/source/java/org/openoffice/test/FileHelper.java b/test/source/java/org/openoffice/test/FileHelper.java
new file mode 100644
index 0000000..fb2dd27
--- /dev/null
+++ b/test/source/java/org/openoffice/test/FileHelper.java
@@ -0,0 +1,56 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+package org.openoffice.test;
+
+/**
+ * Helper Functions for File handling
+ */
+public class FileHelper
+{
+    public FileHelper()
+        {
+        }
+    /**
+     * Concat a _sRelativePathToAdd to a _sPath and append a '/' to the _sPath only if need.
+     *
+     * @param _sPath
+     * @param _sRelativePathToAdd
+     * @return a right concated path
+     */
+    public static String appendPath(String _sPath, String _sRelativePathToAdd)
+    {
+        String sNewPath = _sPath;
+        String fs = System.getProperty("file.separator");
+        if (_sPath.startsWith("file:"))
+        {
+            fs = "/";                                  // we use a file URL so only '/' is allowed.
+        }
+        if (! (sNewPath.endsWith("/") || sNewPath.endsWith("\\") ) )
+        {
+            sNewPath += fs;
+        }
+        sNewPath += _sRelativePathToAdd;
+        return sNewPath;
+    }
+}
diff --git a/test/source/java/org/openoffice/test/OfficeConnection.java b/test/source/java/org/openoffice/test/OfficeConnection.java
new file mode 100644
index 0000000..f565028
--- /dev/null
+++ b/test/source/java/org/openoffice/test/OfficeConnection.java
@@ -0,0 +1,220 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+package org.openoffice.test;
+
+import com.sun.star.bridge.UnoUrlResolver;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.connection.NoConnectException;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.lang.DisposedException;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.Map;
+import java.util.UUID;
+import static org.junit.Assert.*;
+
+/** Start up and shut down an OOo instance.
+
+    Details about the OOo instance are tunneled in via
+    org.openoffice.test.arg.... system properties.
+*/
+public final class OfficeConnection {
+    /** Start up an OOo instance.
+    */
+    public void setUp() throws Exception {
+        String sofficeArg = Argument.get("soffice");
+        if (sofficeArg.startsWith("path:")) {
+            description = "pipe,name=oootest" + UUID.randomUUID();
+            ProcessBuilder pb = new ProcessBuilder(
+                sofficeArg.substring("path:".length()), "-quickstart=no",
+                "-nofirststartwizard", "-norestore",
+                "-accept=" + description + ";urp",
+                "-env:UserInstallation=" + Argument.get("user"),
+                "-env:UNO_JAVA_JFW_ENV_JREHOME=true");
+            String envArg = Argument.get("env");
+            if (envArg != null) {
+                Map<String, String> env = pb.environment();
+                int i = envArg.indexOf("=");
+                if (i == -1) {
+                    env.remove(envArg);
+                } else {
+                    env.put(envArg.substring(0, i), envArg.substring(i + 1));
+                }
+            }
+            process = pb.start();
+            outForward = new Forward(process.getInputStream(), System.out);
+            outForward.start();
+            errForward = new Forward(process.getErrorStream(), System.err);
+            errForward.start();
+        } else if (sofficeArg.startsWith("connect:")) {
+            description = sofficeArg.substring("connect:".length());
+        } else {
+            fail(
+                "\"soffice\" argument \"" + sofficeArg +
+                " starts with neither \"path:\" nor \"connect:\"");
+        }
+        XUnoUrlResolver resolver = UnoUrlResolver.create(
+            Bootstrap.createInitialComponentContext(null));
+        for (;;) {
+            try {
+                context = UnoRuntime.queryInterface(
+                    XComponentContext.class,
+                    resolver.resolve(
+                        "uno:" + description +
+                        ";urp;StarOffice.ComponentContext"));
+                break;
+            } catch (NoConnectException e) {}
+            if (process != null) {
+                assertNull(waitForProcess(process, 1000)); // 1 sec
+            }
+        }
+    }
+
+    /** Shut down the OOo instance.
+    */
+    public void tearDown()
+        throws InterruptedException, com.sun.star.uno.Exception
+    {
+        boolean desktopTerminated = true;
+        if (process != null) {
+            if (context != null) {
+                XMultiComponentFactory factory = context.getServiceManager();
+                assertNotNull(factory);
+                XDesktop desktop = UnoRuntime.queryInterface(
+                    XDesktop.class,
+                    factory.createInstanceWithContext(
+                        "com.sun.star.frame.Desktop", context));
+                context = null;
+                try {
+                    desktopTerminated = desktop.terminate();
+                } catch (DisposedException e) {}
+                    // it appears that DisposedExceptions can already happen
+                    // while receiving the response of the terminate call
+                desktop = null;
+            } else {
+                process.destroy();
+            }
+        }
+        int code = 0;
+        if (process != null) {
+            code = process.waitFor();
+        }
+        boolean outTerminated = outForward == null || outForward.terminated();
+        boolean errTerminated = errForward == null || errForward.terminated();
+        assertTrue(desktopTerminated);
+        assertEquals(0, code);
+        assertTrue(outTerminated);
+        assertTrue(errTerminated);
+    }
+
+    /** Obtain the component context of the running OOo instance.
+    */
+    public XComponentContext getComponentContext() {
+        return context;
+    }
+
+    //TODO: get rid of this hack for legacy qa/unoapi tests
+    public String getDescription() {
+        return description;
+    }
+
+    private static Integer waitForProcess(Process process, final long millis)
+        throws InterruptedException
+    {
+        final Thread t1 = Thread.currentThread();
+        Thread t2 = new Thread("waitForProcess") {
+                public void run() {
+                    try {
+                        Thread.currentThread().sleep(millis);
+                    } catch (InterruptedException e) {}
+                    t1.interrupt();
+                }
+            };
+        boolean old = Thread.interrupted();
+            // clear interrupted status, get old status
+        t2.start();
+        int n = 0;
+        boolean done = false;
+        try {
+            n = process.waitFor();
+            done = true;
+        } catch (InterruptedException e) {}
+        t2.interrupt();
+        try {
+            t2.join();
+        } catch (InterruptedException e) {
+            t2.join();
+        }
+        Thread.interrupted(); // clear interrupted status
+        if (old) {
+            t1.interrupt(); // reset old status
+        }
+        return done ? new Integer(n) : null;
+    }
+
+    private static final class Forward extends Thread {
+        public Forward(InputStream in, PrintStream out) {
+            super("process output forwarder");
+            this.in = in;
+            this.out = out;
+        }
+
+        public void run() {
+            for (;;) {
+                byte[] buf = new byte[1024];
+                int n;
+                try {
+                    n = in.read(buf);
+                } catch (IOException e) {
+                    throw new RuntimeException("wrapping", e);
+                }
+                if (n == -1) {
+                    break;
+                }
+                out.write(buf, 0, n);
+            }
+            done = true;
+        }
+
+        public boolean terminated() throws InterruptedException {
+            join();
+            return done;
+        }
+
+        private final InputStream in;
+        private final PrintStream out;
+        private boolean done = false;
+    }
+
+    private String description;
+    private Process process = null;
+    private Forward outForward = null;
+    private Forward errForward = null;
+    private XComponentContext context = null;
+}
diff --git a/test/source/java/org/openoffice/test/OfficeFileUrl.java b/test/source/java/org/openoffice/test/OfficeFileUrl.java
new file mode 100644
index 0000000..ed25f42
--- /dev/null
+++ b/test/source/java/org/openoffice/test/OfficeFileUrl.java
@@ -0,0 +1,38 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+package org.openoffice.test;
+
+import java.io.File;
+
+/** Obtain the office-internal absolute file URL of a given file.
+ */
+public final class OfficeFileUrl {
+    public static String getAbsolute(File file) {
+        return file.getAbsoluteFile().toURI().toString().replaceFirst(
+            "\\A[Ff][Ii][Ll][Ee]:/(?=[^/]|\\z)", "file:///");
+            // file:/path -> file:///path
+    }
+
+    private OfficeFileUrl() {}
+}
diff --git a/test/source/java/org/openoffice/test/TestArgument.java b/test/source/java/org/openoffice/test/TestArgument.java
new file mode 100644
index 0000000..c506ec8
--- /dev/null
+++ b/test/source/java/org/openoffice/test/TestArgument.java
@@ -0,0 +1,35 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+package org.openoffice.test;
+
+/** Obtain the value of a test argument (tunneled in via an
+    "org.openoffice.test.arg.testarg.<name>" system property).
+ */
+public final class TestArgument {
+    public static String get(String name) {
+        return Argument.get("testarg." + name);
+    }
+
+    private TestArgument() {}
+}
diff --git a/test/source/java/org/openoffice/test/makefile.mk b/test/source/java/org/openoffice/test/makefile.mk
new file mode 100644
index 0000000..f8c5d25
--- /dev/null
+++ b/test/source/java/org/openoffice/test/makefile.mk
@@ -0,0 +1,53 @@
+#**************************************************************
+#  
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#  
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#  
+#**************************************************************
+
+
+
+PRJ = ../../../../..
+PRJNAME = test
+TARGET = test
+
+.IF "$(OOO_JUNIT_JAR)" != ""
+
+PACKAGE = org/openoffice/test
+JAVAFILES = \
+    Argument.java \
+    FileHelper.java \
+    OfficeConnection.java \
+    OfficeFileUrl.java \
+    TestArgument.java
+JARFILES = juh.jar ridl.jar unoil.jar
+EXTRAJARFILES = $(OOO_JUNIT_JAR)
+
+JARTARGET        = $(TARGET).jar
+JARCLASSDIRS     = $(PACKAGE)
+JARCLASSEXCLUDES = $(PACKAGE)/tools/*
+JARCLASSPATH     = $(JARFILES)
+ # expect $(OOO_JUNIT_JAR) to be on CLASSPATH wherever test.jar is used (also,
+ # on Windows, $(OOO_JUNIT_JAR) could be an absolute pathname with drive letter
+ # like X:/path and some JVMs would refuse to load test.jar if its MANIFEST.MF
+ # Class-Path contained such a pathname that looks like an unknown URL with
+ # scheme X)
+
+.END
+
+.INCLUDE: settings.mk
+.INCLUDE: target.mk
diff --git a/test/source/java/org/openoffice/test/tools/DocumentType.java b/test/source/java/org/openoffice/test/tools/DocumentType.java
new file mode 100644
index 0000000..59db040
--- /dev/null
+++ b/test/source/java/org/openoffice/test/tools/DocumentType.java
@@ -0,0 +1,60 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+package org.openoffice.test.tools;
+
+/** a helper "enumeration class" for classifying a document type
+*/
+public class DocumentType extends com.sun.star.uno.Enum
+{
+    private DocumentType( int value )
+    {
+        super( value );
+    }
+
+    public static DocumentType getDefault()
+    {
+        return WRITER;
+    }
+
+    public static final DocumentType WRITER = new DocumentType(0);
+    public static final DocumentType CALC = new DocumentType(1);
+    public static final DocumentType DRAWING = new DocumentType(2);
+    public static final DocumentType XMLFORM = new DocumentType(3);
+    public static final DocumentType PRESENTATION = new DocumentType(4);
+    public static final DocumentType FORMULA = new DocumentType(5);
+    public static final DocumentType UNKNOWN = new DocumentType(-1);
+
+    public static DocumentType fromInt(int value)
+    {
+        switch(value)
+        {
+            case 0: return WRITER;
+            case 1: return CALC;
+            case 2: return DRAWING;
+            case 3: return XMLFORM;
+            case 4: return PRESENTATION;
+            case 5: return FORMULA;
+            default: return UNKNOWN;
+        }
+    }
+};
diff --git a/test/source/java/org/openoffice/test/tools/OfficeDocument.java b/test/source/java/org/openoffice/test/tools/OfficeDocument.java
new file mode 100644
index 0000000..a554db5
--- /dev/null
+++ b/test/source/java/org/openoffice/test/tools/OfficeDocument.java
@@ -0,0 +1,324 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+package org.openoffice.test.tools;
+
+import com.sun.star.beans.PropertyState;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.document.MacroExecMode;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPageSupplier;
+import com.sun.star.drawing.XDrawPages;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.CloseVetoException;
+import com.sun.star.util.XCloseable;
+import com.sun.star.util.XModifiable;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**************************************************************************/
+
+/**************************************************************************/
+/** provides a small wrapper around a document
+*/
+public class OfficeDocument
+{
+    /* ================================================================== */
+    /* ------------------------------------------------------------------ */
+    public OfficeDocument( XMultiServiceFactory orb, XComponent document )
+    {
+        m_orb = orb;
+        m_documentComponent = document;
+    }
+
+    /* ------------------------------------------------------------------ */
+    protected static XComponent implLoadAsComponent( XMultiServiceFactory orb, String documentOrFactoryURL ) throws com.sun.star.uno.Exception
+    {
+        return implLoadAsComponent( orb, documentOrFactoryURL, new PropertyValue[0] );
+    }
+
+    /* ------------------------------------------------------------------ */
+    protected static XComponent implLoadAsComponent( XMultiServiceFactory orb, String documentOrFactoryURL, final PropertyValue[] i_args ) throws com.sun.star.uno.Exception
+    {
+        XComponentLoader aLoader = UnoRuntime.queryInterface( XComponentLoader.class,
+            orb.createInstance( "com.sun.star.frame.Desktop" ) );
+
+        XComponent document = UnoRuntime.queryInterface( XComponent.class,
+            aLoader.loadComponentFromURL( documentOrFactoryURL, "_blank", 0, i_args )
+        );
+        return document;
+    }
+
+    /* ------------------------------------------------------------------ */
+    private static OfficeDocument implLoadDocument( XMultiServiceFactory orb, String documentOrFactoryURL ) throws com.sun.star.uno.Exception
+    {
+        return implLoadDocument( orb, documentOrFactoryURL, new PropertyValue[0] );
+    }
+
+    /* ------------------------------------------------------------------ */
+    private static OfficeDocument implLoadDocument( XMultiServiceFactory orb, String documentOrFactoryURL, final PropertyValue[] i_args ) throws com.sun.star.uno.Exception
+    {
+        XComponent document = implLoadAsComponent( orb, documentOrFactoryURL, i_args );
+
+        XServiceInfo xSI = UnoRuntime.queryInterface( XServiceInfo.class, document );
+        if ( xSI.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+            return new SpreadsheetDocument( orb, document );
+        return new OfficeDocument( orb, document );
+    }
+
+    /* ------------------------------------------------------------------ */
+    public static OfficeDocument loadDocument( XMultiServiceFactory orb, String documentURL ) throws com.sun.star.uno.Exception
+    {
+        return implLoadDocument( orb, documentURL );
+    }
+
+    /* ------------------------------------------------------------------ */
+    public static OfficeDocument blankTextDocument( XMultiServiceFactory orb ) throws com.sun.star.uno.Exception
+    {
+        return blankDocument( orb, DocumentType.WRITER );
+    }
+
+    /* ------------------------------------------------------------------ */
+    public static OfficeDocument blankXMLForm( XMultiServiceFactory orb ) throws com.sun.star.uno.Exception
+    {
+        return blankDocument( orb, DocumentType.XMLFORM );
+    }
+
+    /* ------------------------------------------------------------------ */
+    public static OfficeDocument blankDocument( XMultiServiceFactory orb, DocumentType eType ) throws com.sun.star.uno.Exception
+    {
+        final PropertyValue[] args = new PropertyValue[] {
+            new PropertyValue( "MacroExecutionMode", -1, MacroExecMode.ALWAYS_EXECUTE, PropertyState.DIRECT_VALUE )
+        };
+        return implLoadDocument( orb, getDocumentFactoryURL( eType ), args );
+    }
+
+    /* ------------------------------------------------------------------ */
+    public boolean close()
+    {
+        try
+        {
+            XCloseable closeDoc = UnoRuntime.queryInterface( XCloseable.class, m_documentComponent );
+            closeDoc.close( true );
+            return true;
+        }
+        catch ( CloseVetoException e )
+        {
+            Logger.getLogger( OfficeDocument.class.getName() ).log( Level.SEVERE, "closing the document was vetoed", e );
+        }
+        return false;
+    }
+
+    /* ================================================================== */
+    /* ------------------------------------------------------------------ */
+    public XComponent getDocument( )
+    {
+        return m_documentComponent;
+    }
+
+    /* ------------------------------------------------------------------ */
+    public boolean isModified()
+    {
+        XModifiable modify = (XModifiable)query( XModifiable.class );
+        return modify.isModified();
+    }
+
+    /* ------------------------------------------------------------------ */
+    public Object query( Class aInterfaceClass )
+    {
+        return UnoRuntime.queryInterface( aInterfaceClass, m_documentComponent );
+    }
+
+    /* ------------------------------------------------------------------ */
+    public XMultiServiceFactory getOrb( )
+    {
+        return m_orb;
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** retrieves the current view of the document
+        @return
+            the view component, queried for the interface described by aInterfaceClass
+    */
+    public OfficeDocumentView getCurrentView( )
+    {
+        // get the model interface for the document
+        XModel xDocModel = UnoRuntime.queryInterface( XModel.class, m_documentComponent );
+        // get the current controller for the document - as a controller is tied to a view,
+        // this gives us the currently active view for the document.
+        XController xController = xDocModel.getCurrentController();
+
+        if ( classify() == DocumentType.CALC )
+            return new SpreadsheetView( m_orb, this, xController );
+
+        return new OfficeDocumentView( m_orb, this, xController );
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** reloads the document
+     *
+     *  The reload is done by dispatching the respective URL at a frame of the document.
+     *  As a consequence, if you have references to a view of the document, or any interface
+     *  of the document, they will become invalid.
+     *  The Model instance itself, at which you called reload, will still be valid, it will
+     *  automatically update its internal state after the reload.
+     *
+     *  Another consequence is that if the document does not have a view at all, it cannot
+     *  be reloaded.
+     */
+    public void reload() throws Exception
+    {
+        OfficeDocumentView view = getCurrentView();
+        XFrame frame = view.getController().getFrame();
+        XModel oldModel = frame.getController().getModel();
+
+        getCurrentView().dispatch( ".uno:Reload" );
+
+        m_documentComponent = UnoRuntime.queryInterface( XComponent.class, frame.getController().getModel() );
+
+        XModel newModel = getCurrentView().getController().getModel();
+        if ( UnoRuntime.areSame( oldModel, newModel ) )
+            throw new java.lang.IllegalStateException( "reload failed" );
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** returns a URL which can be used to create a document of a certain type
+    */
+    public static String getDocumentFactoryURL( DocumentType eType )
+    {
+        if ( eType == DocumentType.WRITER )
+            return "private:factory/swriter";
+        if ( eType == DocumentType.CALC )
+            return "private:factory/scalc";
+        if ( eType == DocumentType.DRAWING )
+            return "private:factory/sdraw";
+        if ( eType == DocumentType.XMLFORM )
+            return "private:factory/swriter?slot=21053";
+        if ( eType == DocumentType.PRESENTATION )
+            return "private:factory/simpress";
+        if ( eType == DocumentType.FORMULA )
+            return "private:factory/smath";
+        return "private:factory/swriter";
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** classifies a document
+    */
+    public DocumentType classify( )
+    {
+        XServiceInfo xSI = UnoRuntime.queryInterface( XServiceInfo.class, m_documentComponent );
+
+        if ( xSI.supportsService( "com.sun.star.text.TextDocument" ) )
+            return DocumentType.WRITER;
+        else if ( xSI.supportsService( "com.sun.star.sheet.SpreadsheetDocument" ) )
+            return DocumentType.CALC;
+        else if ( xSI.supportsService( "com.sun.star.drawing.DrawingDocument" ) )
+            return DocumentType.DRAWING;
+        else if ( xSI.supportsService( "com.sun.star.presentation.PresentationDocument" ) )
+            return DocumentType.PRESENTATION;
+        else if ( xSI.supportsService( "com.sun.star.formula.FormulaProperties" ) )
+            return DocumentType.FORMULA;
+
+        return DocumentType.UNKNOWN;
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** retrieves a com.sun.star.drawing.DrawPage of the document, denoted by index
+     *  @param index
+     *      the index of the draw page
+     *  @throws
+     *      com.sun.star.lang.IndexOutOfBoundsException
+     *      com.sun.star.lang.WrappedTargetException
+     */
+    protected XDrawPage getDrawPage( int index ) throws com.sun.star.lang.IndexOutOfBoundsException, com.sun.star.lang.WrappedTargetException
+    {
+        XDrawPagesSupplier xSuppPages = UnoRuntime.queryInterface( XDrawPagesSupplier.class, getDocument() );
+        XDrawPages xPages = xSuppPages.getDrawPages();
+
+        return UnoRuntime.queryInterface( XDrawPage.class, xPages.getByIndex( index ) );
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** retrieves the <type scope="com.sun.star.drawing">DrawPage</type> of the document
+    */
+    protected XDrawPage getMainDrawPage( ) throws com.sun.star.uno.Exception
+    {
+        XDrawPage xReturn;
+
+        // in case of a Writer document, this is rather easy: simply ask the XDrawPageSupplier
+        XDrawPageSupplier xSuppPage = UnoRuntime.queryInterface( XDrawPageSupplier.class, getDocument() );
+        if ( null != xSuppPage )
+            xReturn = xSuppPage.getDrawPage();
+        else
+        {   // the model itself is no draw page supplier - okay, it may be a Writer or Calc document
+            // (or any other multi-page document)
+            XDrawPagesSupplier xSuppPages = UnoRuntime.queryInterface( XDrawPagesSupplier.class, getDocument() );
+            XDrawPages xPages = xSuppPages.getDrawPages();
+
+            xReturn = UnoRuntime.queryInterface( XDrawPage.class, xPages.getByIndex( 0 ) );
+
+            // Note that this is no really error-proof code: If the document model does not support the
+            // XDrawPagesSupplier interface, or if the pages collection returned is empty, this will break.
+        }
+
+        return xReturn;
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** creates a component at the service factory provided by the document
+    */
+    public XInterface createInstance( String serviceSpecifier ) throws com.sun.star.uno.Exception
+    {
+        XMultiServiceFactory xORB = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_documentComponent );
+        return (XInterface)xORB.createInstance( serviceSpecifier );
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** creates a component at the service factory provided by the document, queried for a given interface type
+    */
+    public <T> T createInstance( String i_serviceSpecifier, Class<T> i_interfaceClass ) throws com.sun.star.uno.Exception
+    {
+        return UnoRuntime.queryInterface( i_interfaceClass, createInstance( i_serviceSpecifier ) );
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** creates a component at the service factory provided by the document
+    */
+    public XInterface createInstanceWithArguments( String serviceSpecifier, Object[] arguments ) throws com.sun.star.uno.Exception
+    {
+        XMultiServiceFactory xORB = UnoRuntime.queryInterface( XMultiServiceFactory.class, m_documentComponent );
+        return (XInterface) xORB.createInstanceWithArguments( serviceSpecifier, arguments );
+    }
+
+    private XMultiServiceFactory    m_orb;
+    private XComponent              m_documentComponent;
+};
+
diff --git a/test/source/java/org/openoffice/test/tools/OfficeDocumentView.java b/test/source/java/org/openoffice/test/tools/OfficeDocumentView.java
new file mode 100644
index 0000000..d572dd9
--- /dev/null
+++ b/test/source/java/org/openoffice/test/tools/OfficeDocumentView.java
@@ -0,0 +1,140 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+package org.openoffice.test.tools;
+
+/**************************************************************************/
+
+import com.sun.star.beans.NamedValue;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.URL;
+import com.sun.star.util.XURLTransformer;
+
+/**************************************************************************/
+/** provides a small wrapper around a document view
+*/
+public class OfficeDocumentView
+{
+    private     XMultiServiceFactory    m_orb;
+    private     XController             m_controller;
+    private     OfficeDocument          m_document;
+
+    /* ------------------------------------------------------------------ */
+    final public XController getController()
+    {
+        return m_controller;
+    }
+
+    /* ------------------------------------------------------------------ */
+    final protected OfficeDocument getDocument()
+    {
+        return m_document;
+    }
+
+    /* ------------------------------------------------------------------ */
+    public OfficeDocumentView( XMultiServiceFactory orb, OfficeDocument document, XController controller )
+    {
+        m_orb = orb;
+        m_document = document;
+        m_controller = controller;
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** retrieves a dispatcher for the given URL, obtained at the current view of the document
+        @param aURL
+            a one-element array. The first element must contain a valid
+            <member scope="com.sun.star.util">URL::Complete</member> value. Upon return, the URL is correctly
+            parsed.
+        @return
+            the dispatcher for the URL in question
+    */
+    public XDispatch getDispatcher( URL[] aURL ) throws com.sun.star.uno.Exception
+    {
+        XDispatch xReturn = null;
+
+        // go get the dispatch provider of it's frame
+        XDispatchProvider xProvider = UnoRuntime.queryInterface( XDispatchProvider.class, m_controller.getFrame() );
+        if ( null != xProvider )
+        {
+            // need an URLTransformer
+            XURLTransformer xTransformer = UnoRuntime.queryInterface( XURLTransformer.class,
+                m_orb.createInstance( "com.sun.star.util.URLTransformer" ) );
+            xTransformer.parseStrict( aURL );
+
+            xReturn = xProvider.queryDispatch( aURL[0], new String( ), 0 );
+        }
+        return xReturn;
+    }
+
+
+    /* ------------------------------------------------------------------ */
+    /** retrieves a dispatcher for the given URL, obtained at the current view of the document
+    */
+    public XDispatch getDispatcher( String url ) throws com.sun.star.uno.Exception
+    {
+        URL[] aURL = new URL[] { new URL() };
+        aURL[0].Complete = url;
+        return getDispatcher( aURL );
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** dispatches the given URL into the view, if there's a dispatcher for it
+
+        @return
+            <TRUE/> if the URL was successfully dispatched
+    */
+    public boolean dispatch( String i_url ) throws com.sun.star.uno.Exception
+    {
+        return dispatch( i_url, new PropertyValue[0] );
+    }
+
+    /* ------------------------------------------------------------------ */
+    public boolean dispatch( final String i_url, final PropertyValue[] i_arguments ) throws com.sun.star.uno.Exception
+    {
+        URL[] completeURL = new URL[] { new URL() };
+        completeURL[0].Complete = i_url;
+        XDispatch dispatcher = getDispatcher( completeURL );
+        if ( dispatcher == null )
+            return false;
+
+        dispatcher.dispatch( completeURL[0], i_arguments );
+        return true;
+    }
+
+    /* ------------------------------------------------------------------ */
+    public boolean dispatch( final String i_url, final NamedValue[] i_arguments ) throws com.sun.star.uno.Exception
+    {
+        final PropertyValue[] dispatchArgs = new PropertyValue[ i_arguments.length ];
+        for ( int i=0; i<i_arguments.length; ++i )
+        {
+            dispatchArgs[i] = new PropertyValue( i_arguments[i].Name, -1, i_arguments[i].Value, PropertyState.DIRECT_VALUE );
+        }
+        return dispatch( i_url, dispatchArgs );
+    }
+};
+
diff --git a/test/source/java/org/openoffice/test/tools/SpreadsheetDocument.java b/test/source/java/org/openoffice/test/tools/SpreadsheetDocument.java
new file mode 100644
index 0000000..c10a438
--- /dev/null
+++ b/test/source/java/org/openoffice/test/tools/SpreadsheetDocument.java
@@ -0,0 +1,69 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+
+package org.openoffice.test.tools;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.table.XCellRange;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheets;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * @author  frank.schoenheit at oracle.com
+ */
+public class SpreadsheetDocument extends OfficeDocument
+{
+    /** Creates a new blank spreadsheet document */
+    /* ------------------------------------------------------------------ */
+    public SpreadsheetDocument( XMultiServiceFactory orb ) throws com.sun.star.uno.Exception
+    {
+        super( orb, implLoadAsComponent( orb, "private:factory/scalc" ) );
+    }
+
+    /* ------------------------------------------------------------------ */
+    public SpreadsheetDocument( XMultiServiceFactory orb, XComponent document ) throws com.sun.star.uno.Exception
+    {
+        super( orb, document );
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** returns the sheets collection
+    */
+    public XSpreadsheets getSheets() throws com.sun.star.uno.Exception
+    {
+        XSpreadsheetDocument spreadsheetDoc = UnoRuntime.queryInterface( XSpreadsheetDocument.class, getDocument() );
+        return spreadsheetDoc.getSheets();
+    }
+
+    /* ------------------------------------------------------------------ */
+    /** returns the sheet with the given index
+    */
+    public XCellRange getSheet( int index ) throws com.sun.star.uno.Exception
+    {
+        XIndexAccess sheets = UnoRuntime.queryInterface( XIndexAccess.class, getSheets() );
+        return UnoRuntime.queryInterface( XCellRange.class, sheets.getByIndex( index ) );
+    }
+}
diff --git a/test/source/java/org/openoffice/test/tools/SpreadsheetView.java b/test/source/java/org/openoffice/test/tools/SpreadsheetView.java
new file mode 100644
index 0000000..940eecb
--- /dev/null
+++ b/test/source/java/org/openoffice/test/tools/SpreadsheetView.java
@@ -0,0 +1,68 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+
+package org.openoffice.test.tools;
+
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.frame.XController;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sheet.XSpreadsheet;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.sheet.XSpreadsheetView;
+import com.sun.star.uno.UnoRuntime;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author frank.schoenheit at oracle.com
+ */
+public class SpreadsheetView extends OfficeDocumentView
+{
+
+    /** Creates a new instance of SpreadsheetView */
+    public SpreadsheetView( XMultiServiceFactory orb, OfficeDocument document, XController controller )
+    {
+        super( orb, document, controller );
+    }
+
+    /** activates the sheet with the given index
+     */
+    void activateSheet( int sheetIndex )
+    {
+        try
+        {
+            // get the sheet to activate
+            XSpreadsheetDocument doc = UnoRuntime.queryInterface( XSpreadsheetDocument.class, getDocument().getDocument() );
+            XIndexAccess sheets = UnoRuntime.queryInterface( XIndexAccess.class, doc.getSheets() );
+
+            XSpreadsheet sheet = UnoRuntime.queryInterface( XSpreadsheet.class, sheets.getByIndex( sheetIndex ) );
+
+            // activate
+            XSpreadsheetView view = UnoRuntime.queryInterface( XSpreadsheetView.class, getController() );
+            view.setActiveSheet( sheet );
+        }
+        catch( com.sun.star.uno.Exception e )
+        {
+            Logger.getLogger( SpreadsheetView.class.getName() ).log( Level.SEVERE, "unable to activate the given sheet", e );
+        }
+    }
+}
diff --git a/test/source/java/org/openoffice/test/tools/makefile.mk b/test/source/java/org/openoffice/test/tools/makefile.mk
new file mode 100644
index 0000000..4e93b58
--- /dev/null
+++ b/test/source/java/org/openoffice/test/tools/makefile.mk
@@ -0,0 +1,47 @@
+#**************************************************************
+#  
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#  
+#    http://www.apache.org/licenses/LICENSE-2.0
+#  
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#  
+#**************************************************************
+
+
+
+PRJ = ../../../../../..
+PRJNAME = test
+TARGET = test-tools
+
+PACKAGE = org/openoffice/test/tools
+
+.INCLUDE: settings.mk
+
+JARFILES = juh.jar ridl.jar unoil.jar
+JAVAFILES = \
+    OfficeDocument.java \
+    OfficeDocumentView.java \
+    DocumentType.java \
+    SpreadsheetDocument.java \
+    SpreadsheetView.java \
+
+JARTARGET = $(TARGET).jar
+JARCLASSDIRS = $(PACKAGE)
+JARCLASSPATH = $(JARFILES)
+
+.INCLUDE: target.mk
+
+test:
+    echo $(JAVACLASSFILES)


More information about the Libreoffice-commits mailing list