diff options
439 files changed, 16837 insertions, 18236 deletions
diff --git a/binaryurp/prj/build.lst b/binaryurp/prj/build.lst new file mode 100644 index 000000000000..230b323f0a35 --- /dev/null +++ b/binaryurp/prj/build.lst @@ -0,0 +1,3 @@ +bu binaryurp : BOOST:boost LIBXSLT:libxslt cppu cppuhelper offuh sal salhelper stlport NULL +bu binaryurp\source nmake - all bu_source NULL +bu binaryurp\qa nmake - all bu_qa bu_source NULL diff --git a/binaryurp/prj/d.lst b/binaryurp/prj/d.lst new file mode 100644 index 000000000000..48ebd3be806f --- /dev/null +++ b/binaryurp/prj/d.lst @@ -0,0 +1,4 @@ +..\%__SRC%\bin\binaryurp.uno.dll %_DEST%\bin%_EXT%\binaryurp.uno.dll +..\%__SRC%\lib\binaryurp.uno.dylib %_DEST%\lib%_EXT%\binaryurp.uno.dylib +..\%__SRC%\lib\binaryurp.uno.so %_DEST%\lib%_EXT%\binaryurp.uno.so +..\%__SRC%\misc\binaryurp.component %_DEST%\xml%_EXT%\binaryurp.component diff --git a/binaryurp/qa/makefile.mk b/binaryurp/qa/makefile.mk new file mode 100644 index 000000000000..14b80c86cfaf --- /dev/null +++ b/binaryurp/qa/makefile.mk @@ -0,0 +1,77 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#***********************************************************************/ + +PRJ = .. +PRJNAME = binaryurp +TARGET = qa + +ENABLE_EXCEPTIONS = TRUE + +.INCLUDE: settings.mk + +CFLAGSCXX += $(CPPUNIT_CFLAGS) + +DLLPRE = + +SLOFILES = $(SLO)/test-cache.obj $(SLO)/test-unmarshal.obj + +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLO)/test-cache.obj +SHL1RPATH = NONE +SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) +SHL1TARGET = test-cache +SHL1VERSIONMAP = version.map +DEF1NAME = $(SHL1TARGET) + +SHL2IMPLIB = i$(SHL2TARGET) +SHL2OBJS = \ + $(SLO)/test-unmarshal.obj \ + $(SLO)/binaryany.obj \ + $(SLO)/bridge.obj \ + $(SLO)/bridgefactory.obj \ + $(SLO)/currentcontext.obj \ + $(SLO)/incomingrequest.obj \ + $(SLO)/lessoperators.obj \ + $(SLO)/marshal.obj \ + $(SLO)/outgoingrequests.obj \ + $(SLO)/proxy.obj \ + $(SLO)/reader.obj \ + $(SLO)/unmarshal.obj \ + $(SLO)/writer.obj +SHL2RPATH = NONE +SHL2STDLIBS = \ + $(CPPUHELPERLIB) \ + $(CPPULIB) \ + $(CPPUNITLIB) \ + $(SALHELPERLIB) \ + $(SALLIB) +SHL2TARGET = test-unmarshal +SHL2VERSIONMAP = version.map +DEF2NAME = $(SHL2TARGET) + +.INCLUDE: target.mk +.INCLUDE: _cppunit.mk diff --git a/binaryurp/qa/test-cache.cxx b/binaryurp/qa/test-cache.cxx new file mode 100644 index 000000000000..f9a3946c0df9 --- /dev/null +++ b/binaryurp/qa/test-cache.cxx @@ -0,0 +1,84 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" + +#include "../source/cache.hxx" + +namespace { + +class Test: public CppUnit::TestFixture { +private: + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testNothingLostFromLruList); + CPPUNIT_TEST_SUITE_END(); + + void testNothingLostFromLruList(); +}; + +// cf. jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java: +void Test::testNothingLostFromLruList() { + int a[8]; + for (int i = 0; i != sizeof a / sizeof a[0]; ++i) { + for (int j = 0; j != i; ++j) { + a[j] = 0; + } + for (;;) { + binaryurp::Cache< int > c(4); + for (int k = 0; k != i; ++k) { + bool f; + c.add(a[k], &f); + } + bool f; + CPPUNIT_ASSERT_EQUAL( + 6, + c.add(-1, &f) + c.add(-2, &f) + c.add(-3, &f) + c.add(-4, &f)); + int j = i - 1; + while (j >= 0 && a[j] == 3) { + --j; + } + if (j < 0) { + break; + } + ++a[j]; + for (int k = j + 1; k != i; ++k) { + a[k] = 0; + } + } + } +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/binaryurp/qa/test-unmarshal.cxx b/binaryurp/qa/test-unmarshal.cxx new file mode 100644 index 000000000000..3d3c1795a724 --- /dev/null +++ b/binaryurp/qa/test-unmarshal.cxx @@ -0,0 +1,112 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include "com/sun/star/io/IOException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "cppu/unotype.hxx" +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "rtl/ref.hxx" +#include "rtl/string.h" +#include "sal/types.h" +#include "typelib/typedescription.hxx" + +#include "../source/bridge.hxx" +#include "../source/cache.hxx" +#include "../source/readerstate.hxx" +#include "../source/unmarshal.hxx" + +namespace { + +namespace css = com::sun::star; + +class Test: public CppUnit::TestFixture { +private: + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(testTypeOfBooleanSequence); + CPPUNIT_TEST(testTypeOfVoidSequence); + CPPUNIT_TEST_SUITE_END(); + + void testTypeOfBooleanSequence(); + + void testTypeOfVoidSequence(); +}; + +void Test::testTypeOfBooleanSequence() { + binaryurp::ReaderState state; + css::uno::Sequence< sal_Int8 > buf(13); + buf[0] = static_cast< sal_Int8 >(20 | 0x80); // sequence type | cache flag + buf[1] = static_cast< sal_Int8 >(binaryurp::cache::ignore >> 8); + buf[2] = static_cast< sal_Int8 >(binaryurp::cache::ignore & 0xFF); + buf[3] = RTL_CONSTASCII_LENGTH("[]boolean"); + buf[4] = '['; + buf[5] = ']'; + buf[6] = 'b'; + buf[7] = 'o'; + buf[8] = 'o'; + buf[9] = 'l'; + buf[10] = 'e'; + buf[11] = 'a'; + buf[12] = 'n'; + binaryurp::Unmarshal m(rtl::Reference< binaryurp::Bridge >(), state, buf); + css::uno::TypeDescription t(m.readType()); + CPPUNIT_ASSERT( + t.equals( + css::uno::TypeDescription( + cppu::UnoType< css::uno::Sequence< bool > >::get()))); + m.done(); +} + +void Test::testTypeOfVoidSequence() { + binaryurp::ReaderState state; + css::uno::Sequence< sal_Int8 > buf(10); + buf[0] = static_cast< sal_Int8 >(20 | 0x80); // sequence type | cache flag + buf[1] = static_cast< sal_Int8 >(binaryurp::cache::ignore >> 8); + buf[2] = static_cast< sal_Int8 >(binaryurp::cache::ignore & 0xFF); + buf[3] = RTL_CONSTASCII_LENGTH("[]void"); + buf[4] = '['; + buf[5] = ']'; + buf[6] = 'v'; + buf[7] = 'o'; + buf[8] = 'i'; + buf[9] = 'd'; + binaryurp::Unmarshal m(rtl::Reference< binaryurp::Bridge >(), state, buf); + try { + m.readType(); + CPPUNIT_FAIL("exception expected"); + } catch (css::io::IOException &) {} +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/binaryurp/qa/version.map b/binaryurp/qa/version.map new file mode 100644 index 000000000000..ef2ab497cb5e --- /dev/null +++ b/binaryurp/qa/version.map @@ -0,0 +1,34 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#***********************************************************************/ + +UDK_3_0_0 { + global: + cppunitTestPlugIn; + + local: + *; +}; diff --git a/binaryurp/source/binaryany.cxx b/binaryurp/source/binaryany.cxx new file mode 100644 index 000000000000..c5b8b1a3cb3d --- /dev/null +++ b/binaryurp/source/binaryany.cxx @@ -0,0 +1,98 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include "osl/diagnose.h" +#include "typelib/typeclass.h" +#include "typelib/typedescription.hxx" +#include "uno/any2.h" + +#include "binaryany.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +} + +BinaryAny::BinaryAny() throw () { + uno_any_construct(&data_, 0, 0, 0); +} + +BinaryAny::BinaryAny(css::uno::TypeDescription const & type, void * value) + throw () +{ + OSL_ASSERT(type.is()); + uno_any_construct(&data_, value, type.get(), 0); +} + +BinaryAny::BinaryAny(uno_Any const & raw) throw () { + OSL_ASSERT(raw.pType != 0); + data_.pType = raw.pType; + typelib_typedescriptionreference_acquire(data_.pType); + data_.pData = raw.pData == &raw.pReserved ? &data_.pReserved : raw.pData; + data_.pReserved = raw.pReserved; +} + +BinaryAny::BinaryAny(BinaryAny const & other) throw () { + uno_type_any_construct(&data_, other.data_.pData, other.data_.pType, 0); +} + +BinaryAny::~BinaryAny() throw () { + uno_any_destruct(&data_, 0); +} + +BinaryAny & BinaryAny::operator =(BinaryAny const & other) throw () { + if (&other != this) { + uno_type_any_assign(&data_, other.data_.pData, other.data_.pType, 0, 0); + } + return *this; +} + +uno_Any * BinaryAny::get() throw () { + return &data_; +} + +css::uno::TypeDescription BinaryAny::getType() const throw () { + return css::uno::TypeDescription(data_.pType); +} + +void * BinaryAny::getValue(css::uno::TypeDescription const & type) const + throw () +{ + OSL_ASSERT( + type.is() && + (type.get()->eTypeClass == typelib_TypeClass_ANY || + type.equals(css::uno::TypeDescription(data_.pType)))); + return type.get()->eTypeClass == typelib_TypeClass_ANY + ? &data_ : data_.pData; +} + +} diff --git a/binaryurp/source/binaryany.hxx b/binaryurp/source/binaryany.hxx new file mode 100644 index 000000000000..4dd6112b5c57 --- /dev/null +++ b/binaryurp/source/binaryany.hxx @@ -0,0 +1,73 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_BINARYANY_HXX +#define INCLUDED_BINARYURP_SOURCE_BINARYANY_HXX + +#include "sal/config.h" + +#include "uno/any2.h" + +namespace com { namespace sun { namespace star { namespace uno { + class TypeDescription; +} } } } + +namespace binaryurp { + +class BinaryAny { +public: + BinaryAny() throw (); + + BinaryAny(com::sun::star::uno::TypeDescription const & type, void * value) + throw (); + + explicit BinaryAny(uno_Any const & raw) throw (); + // takes over raw.pData (but copies raw.pType); raw must not be passed + // to uno_any_destruct + + BinaryAny(BinaryAny const & other) throw (); + + ~BinaryAny() throw (); + + BinaryAny & operator =(BinaryAny const & other) throw (); + + uno_Any * get() throw (); + + com::sun::star::uno::TypeDescription getType() const throw (); + + void * getValue(com::sun::star::uno::TypeDescription const & type) const + throw (); + +private: + mutable uno_Any data_; + // mutable so that getValue() can return a non-const void *, as in turn + // required at various places in binary UNO +}; + +} + +#endif diff --git a/binaryurp/source/binaryurp.component b/binaryurp/source/binaryurp.component new file mode 100644 index 000000000000..19554bcc088b --- /dev/null +++ b/binaryurp/source/binaryurp.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.bridge.BridgeFactory"> + <service name="com.sun.star.bridge.BridgeFactory"/> + </implementation> +</component> diff --git a/binaryurp/source/bridge.cxx b/binaryurp/source/bridge.cxx new file mode 100644 index 000000000000..dcf77662c56d --- /dev/null +++ b/binaryurp/source/bridge.cxx @@ -0,0 +1,978 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <algorithm> +#include <cstddef> +#include <limits> +#include <memory> +#include <vector> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/bridge/InvalidProtocolChangeException.hpp" +#include "com/sun/star/bridge/XBridge.hpp" +#include "com/sun/star/bridge/XInstanceProvider.hpp" +#include "com/sun/star/bridge/XProtocolProperties.hpp" +#include "com/sun/star/connection/XConnection.hpp" +#include "com/sun/star/io/IOException.hpp" +#include "com/sun/star/lang/DisposedException.hpp" +#include "com/sun/star/lang/EventObject.hpp" +#include "com/sun/star/lang/XEventListener.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/exc_hlp.hxx" +#include "cppuhelper/weak.hxx" +#include "osl/diagnose.h" +#include "osl/mutex.hxx" +#include "osl/thread.hxx" +#include "rtl/byteseq.hxx" +#include "rtl/random.h" +#include "rtl/ref.hxx" +#include "rtl/textenc.h" +#include "rtl/ustrbuf.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typeclass.h" +#include "typelib/typedescription.h" +#include "typelib/typedescription.hxx" +#include "uno/dispatcher.hxx" +#include "uno/environment.hxx" +#include "uno/lbnames.h" + +#include "binaryany.hxx" +#include "bridge.hxx" +#include "bridgefactory.hxx" +#include "incomingreply.hxx" +#include "lessoperators.hxx" +#include "outgoingrequest.hxx" +#include "outgoingrequests.hxx" +#include "proxy.hxx" +#include "reader.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +sal_Int32 random() { + sal_Int32 n; + rtlRandomPool pool = rtl_random_createPool(); + rtl_random_getBytes(pool, &n, sizeof n); + rtl_random_destroyPool(pool); + return n; +} + +extern "C" void SAL_CALL freeProxyCallback(uno_ExtEnvironment *, void * pProxy) +{ + OSL_ASSERT(pProxy != 0); + static_cast< Proxy * >(pProxy)->do_free(); +} + +void joinThread(osl::Thread * thread) { + OSL_ASSERT(thread != 0); + if (thread->getIdentifier() != osl::Thread::getCurrentIdentifier()) { + thread->join(); + } +} + +class AttachThread: private boost::noncopyable { +public: + explicit AttachThread(uno_ThreadPool threadPool); + + ~AttachThread(); + + rtl::ByteSequence getTid() throw (); + +private: + uno_ThreadPool threadPool_; + rtl::ByteSequence tid_; +}; + +AttachThread::AttachThread(uno_ThreadPool threadPool): threadPool_(threadPool) { + sal_Sequence * s = 0; + uno_getIdOfCurrentThread(&s); + tid_ = rtl::ByteSequence(s, rtl::BYTESEQ_NOACQUIRE); + uno_threadpool_attach(threadPool_); +} + +AttachThread::~AttachThread() { + uno_threadpool_detach(threadPool_); + uno_releaseIdFromCurrentThread(); +} + +rtl::ByteSequence AttachThread::getTid() throw () { + return tid_; +} + +class PopOutgoingRequest: private boost::noncopyable { +public: + PopOutgoingRequest( + OutgoingRequests & requests, rtl::ByteSequence const & tid, + OutgoingRequest const & request); + + ~PopOutgoingRequest(); + + void clear(); + +private: + OutgoingRequests & requests_; + rtl::ByteSequence tid_; + bool cleared_; +}; + +PopOutgoingRequest::PopOutgoingRequest( + OutgoingRequests & requests, rtl::ByteSequence const & tid, + OutgoingRequest const & request): + requests_(requests), tid_(tid), cleared_(false) +{ + requests_.push(tid_, request); +} + +PopOutgoingRequest::~PopOutgoingRequest() { + if (!cleared_) { + requests_.pop(tid_); + } +} + +void PopOutgoingRequest::clear() { + cleared_ = true; +} + +} + +struct Bridge::SubStub { + com::sun::star::uno::UnoInterfaceReference object; + + sal_uInt32 references; +}; + +Bridge::Bridge( + rtl::Reference< BridgeFactory > const & factory, rtl::OUString const & name, + css::uno::Reference< css::connection::XConnection > const & connection, + css::uno::Reference< css::bridge::XInstanceProvider > const & provider): + factory_(factory), name_(name), connection_(connection), + provider_(provider), + binaryUno_(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO))), + cppToBinaryMapping_( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME)), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO))), + binaryToCppMapping_( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)), + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM(CPPU_CURRENT_LANGUAGE_BINDING_NAME))), + protPropTid_( + reinterpret_cast< sal_Int8 const * >(".UrpProtocolPropertiesTid"), + RTL_CONSTASCII_LENGTH(".UrpProtocolPropertiesTid")), + protPropOid_(RTL_CONSTASCII_USTRINGPARAM("UrpProtocolProperties")), + protPropType_( + cppu::UnoType< + css::uno::Reference< css::bridge::XProtocolProperties > >::get()), + protPropRequest_( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.bridge.XProtocolProperties::requestChange"))), + protPropCommit_( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.bridge.XProtocolProperties::commitChange"))), + threadPool_(0), currentContextMode_(false), proxies_(0), calls_(0), + normalCall_(false), activeCalls_(0), terminated_(false), + mode_(MODE_REQUESTED) +{ + OSL_ASSERT(factory.is() && connection.is()); + if (!binaryUno_.is()) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("URP: no binary UNO environment")), + css::uno::Reference< css::uno::XInterface >()); + } + if (!(cppToBinaryMapping_.is() && binaryToCppMapping_.is())) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("URP: no C++ UNO mapping")), + css::uno::Reference< css::uno::XInterface >()); + } + passive_.set(); +} + +void Bridge::start() { + OSL_ASSERT(threadPool_ == 0 && !writer_.is() && !reader_.is()); + threadPool_ = uno_threadpool_create(); + OSL_ASSERT(threadPool_ != 0); + writer_.set(new Writer(this)); + writer_->create(); + reader_.set(new Reader(this)); + reader_->create(); +} + +void Bridge::terminate() { + rtl::Reference< Reader > r; + rtl::Reference< Writer > w; + Listeners ls; + { + osl::MutexGuard g(mutex_); + if (terminated_) { + return; + } + std::swap(reader_, r); + std::swap(writer_, w); + ls.swap(listeners_); + terminated_ = true; + } + try { + connection_->close(); + } catch (css::io::IOException & e) { + OSL_TRACE( + OSL_LOG_PREFIX "caught IO exception '%s'", + rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); + } + OSL_ASSERT(w.is()); + w->stop(); + joinThread(r.get()); + joinThread(w.get()); + OSL_ASSERT(threadPool_ != 0); + uno_threadpool_dispose(threadPool_); + Stubs s; + { + osl::MutexGuard g(mutex_); + s.swap(stubs_); + } + for (Stubs::iterator i(s.begin()); i != s.end(); ++i) { + for (Stub::iterator j(i->second.begin()); j != i->second.end(); ++j) { + binaryUno_.get()->pExtEnv->revokeInterface( + binaryUno_.get()->pExtEnv, j->second.object.get()); + } + } + factory_->removeBridge(this); + for (Listeners::iterator i(ls.begin()); i != ls.end(); ++i) { + try { + (*i)->disposing( + css::lang::EventObject( + static_cast< cppu::OWeakObject * >(this))); + } catch (css::uno::RuntimeException & e) { + OSL_TRACE( + OSL_LOG_PREFIX "caught runtime exception '%s'", + rtl::OUStringToOString( + e.Message, RTL_TEXTENCODING_UTF8).getStr()); + } + } +} + +css::uno::Reference< css::connection::XConnection > Bridge::getConnection() + const +{ + return connection_; +} + +css::uno::Reference< css::bridge::XInstanceProvider > Bridge::getProvider() + const +{ + return provider_; +} + +css::uno::Mapping & Bridge::getCppToBinaryMapping() { + return cppToBinaryMapping_; +} + +BinaryAny Bridge::mapCppToBinaryAny(css::uno::Any const & cppAny) { + css::uno::Any in(cppAny); + BinaryAny out; + out.~BinaryAny(); + uno_copyAndConvertData( + out.get(), &in, + css::uno::TypeDescription(cppu::UnoType< css::uno::Any >::get()).get(), + cppToBinaryMapping_.get()); + return out; +} + +uno_ThreadPool Bridge::getThreadPool() const { + OSL_ASSERT(threadPool_ != 0); + return threadPool_; +} + +rtl::Reference< Writer > Bridge::getWriter() { + osl::MutexGuard g(mutex_); + if (terminated_) { + throw css::lang::DisposedException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "Binary URP bridge already disposed")), + static_cast< cppu::OWeakObject * >(this)); + } + OSL_ASSERT(writer_.is()); + return writer_; +} + +css::uno::UnoInterfaceReference Bridge::registerIncomingInterface( + rtl::OUString const & oid, css::uno::TypeDescription const & type) +{ + OSL_ASSERT(type.is()); + if (oid.getLength() == 0) { + return css::uno::UnoInterfaceReference(); + } + css::uno::UnoInterfaceReference obj(findStub(oid, type)); + if (!obj.is()) { + binaryUno_.get()->pExtEnv->getRegisteredInterface( + binaryUno_.get()->pExtEnv, + reinterpret_cast< void ** >(&obj.m_pUnoI), oid.pData, + reinterpret_cast< typelib_InterfaceTypeDescription * >(type.get())); + if (obj.is()) { + makeReleaseCall(oid, type); + } else { + obj.set(new Proxy(this, oid, type), SAL_NO_ACQUIRE); + { + osl::MutexGuard g(mutex_); + OSL_ASSERT( + proxies_ < std::numeric_limits< std::size_t >::max()); + ++proxies_; + } + binaryUno_.get()->pExtEnv->registerProxyInterface( + binaryUno_.get()->pExtEnv, + reinterpret_cast< void ** >(&obj.m_pUnoI), &freeProxyCallback, + oid.pData, + reinterpret_cast< typelib_InterfaceTypeDescription * >( + type.get())); + } + } + return obj; +} + +rtl::OUString Bridge::registerOutgoingInterface( + css::uno::UnoInterfaceReference const & object, + css::uno::TypeDescription const & type) +{ + OSL_ASSERT(type.is()); + if (!object.is()) { + return rtl::OUString(); + } + rtl::OUString oid; + if (!Proxy::isProxy(this, object, &oid)) { + binaryUno_.get()->pExtEnv->getObjectIdentifier( + binaryUno_.get()->pExtEnv, &oid.pData, object.get()); + osl::MutexGuard g(mutex_); + Stubs::iterator i(stubs_.find(oid)); + Stub newStub; + Stub * stub = i == stubs_.end() ? &newStub : &i->second; + Stub::iterator j(stub->find(type)); + //TODO: Release sub-stub if it is not successfully sent to remote side + // (otherwise, stub will leak until terminate()): + if (j == stub->end()) { + j = stub->insert(Stub::value_type(type, SubStub())).first; + if (stub == &newStub) { + i = stubs_.insert(Stubs::value_type(oid, Stub())).first; + std::swap(i->second, newStub); + j = i->second.find(type); + OSL_ASSERT(j != i->second.end()); + } + j->second.object = object; + j->second.references = 1; + binaryUno_.get()->pExtEnv->registerInterface( + binaryUno_.get()->pExtEnv, + reinterpret_cast< void ** >(&j->second.object.m_pUnoI), + oid.pData, + reinterpret_cast< typelib_InterfaceTypeDescription * >( + type.get())); + } else { + OSL_ASSERT(stub != &newStub); + if (j->second.references == SAL_MAX_UINT32) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: stub reference count overflow")), + css::uno::Reference< css::uno::XInterface >()); + } + ++j->second.references; + } + } + return oid; +} + +css::uno::UnoInterfaceReference Bridge::findStub( + rtl::OUString const & oid, css::uno::TypeDescription const & type) +{ + OSL_ASSERT(oid.getLength() != 0 && type.is()); + osl::MutexGuard g(mutex_); + Stubs::iterator i(stubs_.find(oid)); + if (i != stubs_.end()) { + Stub::iterator j(i->second.find(type)); + if (j != i->second.end()) { + return j->second.object; + } + for (j = i->second.begin(); j != i->second.end(); ++j) { + if (typelib_typedescription_isAssignableFrom( + type.get(), j->first.get())) + { + return j->second.object; + } + } + } + return css::uno::UnoInterfaceReference(); +} + +void Bridge::releaseStub( + rtl::OUString const & oid, css::uno::TypeDescription const & type) +{ + OSL_ASSERT(oid.getLength() != 0 && type.is()); + css::uno::UnoInterfaceReference obj; + bool unused; + { + osl::MutexGuard g(mutex_); + Stubs::iterator i(stubs_.find(oid)); + if (i == stubs_.end()) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("URP: release unknown stub")), + css::uno::Reference< css::uno::XInterface >()); + } + Stub::iterator j(i->second.find(type)); + if (j == i->second.end()) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("URP: release unknown stub")), + css::uno::Reference< css::uno::XInterface >()); + } + OSL_ASSERT(j->second.references > 0); + --j->second.references; + if (j->second.references == 0) { + obj = j->second.object; + i->second.erase(j); + if (i->second.empty()) { + stubs_.erase(i); + } + } + unused = becameUnused(); + } + if (obj.is()) { + binaryUno_.get()->pExtEnv->revokeInterface( + binaryUno_.get()->pExtEnv, obj.get()); + } + terminateWhenUnused(unused); +} + +void Bridge::resurrectProxy(Proxy & proxy) { + uno_Interface * p = &proxy; + binaryUno_.get()->pExtEnv->registerProxyInterface( + binaryUno_.get()->pExtEnv, + reinterpret_cast< void ** >(&p), &freeProxyCallback, + proxy.getOid().pData, + reinterpret_cast< typelib_InterfaceTypeDescription * >( + proxy.getType().get())); + OSL_ASSERT(p == &proxy); +} + +void Bridge::revokeProxy(Proxy & proxy) { + binaryUno_.get()->pExtEnv->revokeInterface( + binaryUno_.get()->pExtEnv, &proxy); +} + +void Bridge::freeProxy(Proxy & proxy) { + try { + makeReleaseCall(proxy.getOid(), proxy.getType()); + } catch (css::uno::RuntimeException & e) { + OSL_TRACE( + OSL_LOG_PREFIX "caught runtime exception '%s'", + rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); + } catch (std::exception & e) { + OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what()); + } + bool unused; + { + osl::MutexGuard g(mutex_); + OSL_ASSERT(proxies_ > 0); + --proxies_; + unused = becameUnused(); + } + terminateWhenUnused(unused); +} + +void Bridge::incrementCalls(bool normalCall) throw () { + osl::MutexGuard g(mutex_); + OSL_ASSERT(calls_ < std::numeric_limits< std::size_t >::max()); + ++calls_; + normalCall_ |= normalCall; +} + +void Bridge::decrementCalls() { + bool unused; + { + osl::MutexGuard g(mutex_); + OSL_ASSERT(calls_ > 0); + --calls_; + unused = becameUnused(); + } + terminateWhenUnused(unused); +} + +void Bridge::incrementActiveCalls() throw () { + osl::MutexGuard g(mutex_); + OSL_ASSERT( + activeCalls_ <= calls_ && + activeCalls_ < std::numeric_limits< std::size_t >::max()); + ++activeCalls_; + passive_.reset(); +} + +void Bridge::decrementActiveCalls() throw () { + osl::MutexGuard g(mutex_); + OSL_ASSERT(activeCalls_ <= calls_ && activeCalls_ > 0); + --activeCalls_; + if (activeCalls_ == 0) { + passive_.set(); + } +} + +bool Bridge::makeCall( + rtl::OUString const & oid, css::uno::TypeDescription const & member, + bool setter, std::vector< BinaryAny > const & inArguments, + BinaryAny * returnValue, std::vector< BinaryAny > * outArguments) +{ + std::auto_ptr< IncomingReply > resp; + { + AttachThread att(threadPool_); + PopOutgoingRequest pop( + outgoingRequests_, att.getTid(), + OutgoingRequest(OutgoingRequest::KIND_NORMAL, member, setter)); + sendRequest( + att.getTid(), oid, css::uno::TypeDescription(), member, + inArguments); + pop.clear(); + incrementCalls(true); + incrementActiveCalls(); + void * job; + uno_threadpool_enter(threadPool_, &job); + resp.reset(static_cast< IncomingReply * >(job)); + decrementActiveCalls(); + decrementCalls(); + } + if (resp.get() == 0) { + throw css::lang::DisposedException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "Binary URP bridge disposed during call")), + static_cast< cppu::OWeakObject * >(this)); + } + *returnValue = resp->returnValue; + if (!resp->exception) { + *outArguments = resp->outArguments; + } + return resp->exception; +} + +void Bridge::sendRequestChangeRequest() { + OSL_ASSERT(mode_ == MODE_REQUESTED); + random_ = random(); + std::vector< BinaryAny > a; + a.push_back( + BinaryAny( + css::uno::TypeDescription(cppu::UnoType< sal_Int32 >::get()), + &random_)); + sendProtPropRequest(OutgoingRequest::KIND_REQUEST_CHANGE, a); +} + +void Bridge::handleRequestChangeReply( + bool exception, BinaryAny const & returnValue) +{ + throwException(exception, returnValue); + sal_Int32 n = *static_cast< sal_Int32 * >( + returnValue.getValue( + css::uno::TypeDescription(cppu::UnoType< sal_Int32 >::get()))); + sal_Int32 exp = 0; + switch (mode_) { + case MODE_REQUESTED: + case MODE_REPLY_1: + exp = 1; + break; + case MODE_REPLY_MINUS1: + exp = -1; + mode_ = MODE_REQUESTED; + break; + case MODE_REPLY_0: + exp = 0; + mode_ = MODE_WAIT; + break; + default: + OSL_ASSERT(false); // this cannot happen + break; + } + if (n != exp) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: requestChange reply with unexpected return value" + " received")), + static_cast< cppu::OWeakObject * >(this)); + } + decrementCalls(); + switch (exp) { + case -1: + sendRequestChangeRequest(); + break; + case 0: + break; + case 1: + sendCommitChangeRequest(); + break; + default: + OSL_ASSERT(false); // this cannot happen + break; + } +} + +void Bridge::handleCommitChangeReply( + bool exception, BinaryAny const & returnValue) +{ + bool ccMode = true; + try { + throwException(exception, returnValue); + } catch (css::bridge::InvalidProtocolChangeException &) { + ccMode = false; + } + if (ccMode) { + setCurrentContextMode(); + } + OSL_ASSERT(mode_ == MODE_REQUESTED || mode_ == MODE_REPLY_1); + mode_ = MODE_NORMAL; + getWriter()->unblock(); + decrementCalls(); +} + +void Bridge::handleRequestChangeRequest( + rtl::ByteSequence const & tid, std::vector< BinaryAny > const & inArguments) +{ + OSL_ASSERT(inArguments.size() == 1); + switch (mode_) { + case MODE_REQUESTED: + { + sal_Int32 n2 = *static_cast< sal_Int32 * >( + inArguments[0].getValue( + css::uno::TypeDescription( + cppu::UnoType< sal_Int32 >::get()))); + sal_Int32 ret; + if (n2 > random_) { + ret = 1; + mode_ = MODE_REPLY_0; + } else if (n2 == random_) { + ret = -1; + mode_ = MODE_REPLY_MINUS1; + } else { + ret = 0; + mode_ = MODE_REPLY_1; + } + getWriter()->sendDirectReply( + tid, protPropRequest_, false, + BinaryAny( + css::uno::TypeDescription( + cppu::UnoType< sal_Int32 >::get()), + &ret), + std::vector< BinaryAny >()); + break; + } + case MODE_NORMAL: + { + mode_ = MODE_NORMAL_WAIT; + sal_Int32 ret = 1; + getWriter()->queueReply( + tid, protPropRequest_, false, false, + BinaryAny( + css::uno::TypeDescription( + cppu::UnoType< sal_Int32 >::get()), + &ret), + std::vector< BinaryAny >(), false); + break; + } + default: + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: unexpected requestChange request received")), + static_cast< cppu::OWeakObject * >(this)); + } +} + +void Bridge::handleCommitChangeRequest( + rtl::ByteSequence const & tid, std::vector< BinaryAny > const & inArguments) +{ + bool ccMode = false; + bool exc = false; + BinaryAny ret; + OSL_ASSERT(inArguments.size() == 1); + css::uno::Sequence< css::bridge::ProtocolProperty > s; + OSL_VERIFY(mapBinaryToCppAny(inArguments[0]) >>= s); + for (sal_Int32 i = 0; i != s.getLength(); ++i) { + if (s[i].Name.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("CurrentContext"))) + { + ccMode = true; + } else { + ccMode = false; + exc = true; + ret = mapCppToBinaryAny( + css::uno::makeAny( + css::bridge::InvalidProtocolChangeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "InvalidProtocolChangeException")), + css::uno::Reference< css::uno::XInterface >(), s[i], + 1))); + break; + } + } + switch (mode_) { + case MODE_WAIT: + getWriter()->sendDirectReply( + tid, protPropCommit_, exc, ret, std::vector< BinaryAny >()); + if (ccMode) { + setCurrentContextMode(); + mode_ = MODE_NORMAL; + getWriter()->unblock(); + } else { + mode_ = MODE_REQUESTED; + sendRequestChangeRequest(); + } + break; + case MODE_NORMAL_WAIT: + getWriter()->queueReply( + tid, protPropCommit_, false, false, ret, std::vector< BinaryAny >(), + ccMode); + mode_ = MODE_NORMAL; + break; + default: + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: unexpected commitChange request received")), + static_cast< cppu::OWeakObject * >(this)); + } +} + +OutgoingRequest Bridge::lastOutgoingRequest(rtl::ByteSequence const & tid) { + OutgoingRequest req(outgoingRequests_.top(tid)); + outgoingRequests_.pop(tid); + return req; +} + +bool Bridge::isProtocolPropertiesRequest( + rtl::OUString const & oid, css::uno::TypeDescription const & type) const +{ + return oid == protPropOid_ && type.equals(protPropType_); +} + +void Bridge::setCurrentContextMode() { + osl::MutexGuard g(mutex_); + currentContextMode_ = true; +} + +bool Bridge::isCurrentContextMode() { + osl::MutexGuard g(mutex_); + return currentContextMode_; +} + +Bridge::~Bridge() { + if (threadPool_ != 0) { + uno_threadpool_destroy(threadPool_); + } +} + +css::uno::Reference< css::uno::XInterface > Bridge::getInstance( + rtl::OUString const & sInstanceName) throw (css::uno::RuntimeException) +{ + if (sInstanceName.getLength() == 0) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "XBridge::getInstance sInstanceName must be non-empty")), + static_cast< cppu::OWeakObject * >(this)); + } + for (sal_Int32 i = 0; i != sInstanceName.getLength(); ++i) { + if (sInstanceName[i] > 0x7F) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "XBridge::getInstance sInstanceName contains non-ASCII" + " character")), + css::uno::Reference< css::uno::XInterface >()); + } + } + css::uno::TypeDescription ifc( + cppu::UnoType< css::uno::Reference< css::uno::XInterface > >::get()); + typelib_TypeDescription * p = ifc.get(); + std::vector< BinaryAny > inArgs; + inArgs.push_back( + BinaryAny( + css::uno::TypeDescription(cppu::UnoType< css::uno::Type >::get()), + &p)); + BinaryAny ret; + std::vector< BinaryAny> outArgs; + bool exc = makeCall( + sInstanceName, + css::uno::TypeDescription( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.uno.XInterface::queryInterface"))), + false, inArgs, &ret, &outArgs); + throwException(exc, ret); + return css::uno::Reference< css::uno::XInterface >( + static_cast< css::uno::XInterface * >( + binaryToCppMapping_.mapInterface( + *static_cast< uno_Interface ** >(ret.getValue(ifc)), + ifc.get())), + css::uno::UNO_REF_NO_ACQUIRE); +} + +rtl::OUString Bridge::getName() throw (css::uno::RuntimeException) { + return name_; +} + +rtl::OUString Bridge::getDescription() throw (css::uno::RuntimeException) { + rtl::OUStringBuffer b(name_); + b.append(sal_Unicode(':')); + b.append(connection_->getDescription()); + return b.makeStringAndClear(); +} + +void Bridge::dispose() throw (css::uno::RuntimeException) { + terminate(); + // OOo expects dispose to not return while there are still remote calls in + // progress; an external protocol must ensure that dispose is not called + // from within an incoming or outgoing remote call, as passive_.wait() would + // otherwise deadlock: + passive_.wait(); +} + +void Bridge::addEventListener( + css::uno::Reference< css::lang::XEventListener > const & xListener) + throw (css::uno::RuntimeException) +{ + OSL_ASSERT(xListener.is()); + { + osl::MutexGuard g(mutex_); + if (!terminated_) { + listeners_.push_back(xListener); + return; + } + } + xListener->disposing( + css::lang::EventObject(static_cast< cppu::OWeakObject * >(this))); +} + +void Bridge::removeEventListener( + css::uno::Reference< css::lang::XEventListener > const & aListener) + throw (css::uno::RuntimeException) +{ + osl::MutexGuard g(mutex_); + Listeners::iterator i( + std::find(listeners_.begin(), listeners_.end(), aListener)); + if (i != listeners_.end()) { + listeners_.erase(i); + } +} + +void Bridge::sendCommitChangeRequest() { + OSL_ASSERT(mode_ == MODE_REQUESTED || mode_ == MODE_REPLY_1); + css::uno::Sequence< css::bridge::ProtocolProperty > s(1); + s[0].Name = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CurrentContext")); + std::vector< BinaryAny > a; + a.push_back(mapCppToBinaryAny(css::uno::makeAny(s))); + sendProtPropRequest(OutgoingRequest::KIND_COMMIT_CHANGE, a); +} + +void Bridge::sendProtPropRequest( + OutgoingRequest::Kind kind, std::vector< BinaryAny > const & inArguments) +{ + OSL_ASSERT( + kind == OutgoingRequest::KIND_REQUEST_CHANGE || + kind == OutgoingRequest::KIND_COMMIT_CHANGE); + incrementCalls(false); + css::uno::TypeDescription member( + kind == OutgoingRequest::KIND_REQUEST_CHANGE + ? protPropRequest_ : protPropCommit_); + PopOutgoingRequest pop( + outgoingRequests_, protPropTid_, OutgoingRequest(kind, member, false)); + getWriter()->sendDirectRequest( + protPropTid_, protPropOid_, protPropType_, member, inArguments); + pop.clear(); +} + +void Bridge::makeReleaseCall( + rtl::OUString const & oid, css::uno::TypeDescription const & type) +{ + AttachThread att(threadPool_); + sendRequest( + att.getTid(), oid, type, + css::uno::TypeDescription( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.uno.XInterface::release"))), + std::vector< BinaryAny >()); +} + +void Bridge::sendRequest( + rtl::ByteSequence const & tid, rtl::OUString const & oid, + css::uno::TypeDescription const & type, + css::uno::TypeDescription const & member, + std::vector< BinaryAny > const & inArguments) +{ + getWriter()->queueRequest(tid, oid, type, member, inArguments); +} + +void Bridge::throwException(bool exception, BinaryAny const & value) { + if (exception) { + cppu::throwException(mapBinaryToCppAny(value)); + } +} + +css::uno::Any Bridge::mapBinaryToCppAny(BinaryAny const & binaryAny) { + BinaryAny in(binaryAny); + css::uno::Any out; + out.~Any(); + uno_copyAndConvertData( + &out, in.get(), + css::uno::TypeDescription(cppu::UnoType< css::uno::Any >::get()).get(), + binaryToCppMapping_.get()); + return out; +} + +bool Bridge::becameUnused() const { + return stubs_.empty() && proxies_ == 0 && calls_ == 0 && normalCall_; +} + +void Bridge::terminateWhenUnused(bool unused) { + if (unused) { + // That the current thread considers the bridge unused implies that it + // is not within an incoming or outgoing remote call (so calling + // terminate cannot lead to deadlock): + terminate(); + } +} + +} diff --git a/binaryurp/source/bridge.hxx b/binaryurp/source/bridge.hxx new file mode 100644 index 000000000000..73e32aac0cac --- /dev/null +++ b/binaryurp/source/bridge.hxx @@ -0,0 +1,287 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_BRIDGE_HXX +#define INCLUDED_BINARYURP_SOURCE_BRIDGE_HXX + +#include "sal/config.h" + +#include <cstddef> +#include <list> +#include <map> +#include <vector> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/bridge/XBridge.hpp" +#include "com/sun/star/lang/XComponent.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "cppuhelper/implbase2.hxx" +#include "osl/conditn.hxx" +#include "osl/mutex.hxx" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "uno/environment.hxx" +#include "uno/mapping.hxx" +#include "uno/threadpool.h" + +#include "outgoingrequest.hxx" +#include "outgoingrequests.hxx" +#include "writer.hxx" + +namespace binaryurp { + class BinaryAny; + class BridgeFactory; + class Proxy; + class Reader; +} +namespace com { namespace sun { namespace star { + namespace bridge { class XInstanceProvider; } + namespace connection { class XConnection; } + namespace lang { class XEventListener; } + namespace uno { + class Any; + class TypeDescription; + class UnoInterfaceReference; + class XInterface; + } +} } } +namespace rtl { class ByteSequence; } + +namespace binaryurp { + +class Bridge: + public cppu::WeakImplHelper2< + com::sun::star::bridge::XBridge, com::sun::star::lang::XComponent >, + private boost::noncopyable +{ +public: + Bridge( + rtl::Reference< BridgeFactory > const & factory, + rtl::OUString const & name, + com::sun::star::uno::Reference< + com::sun::star::connection::XConnection > const & connection, + com::sun::star::uno::Reference< + com::sun::star::bridge::XInstanceProvider > const & provider); + + void start(); + + // Internally waits for all incoming and outgoing remote calls to terminate, + // so must not be called from within such a call: + void terminate(); + + com::sun::star::uno::Reference< com::sun::star::connection::XConnection > + getConnection() const; + + com::sun::star::uno::Reference< com::sun::star::bridge::XInstanceProvider > + getProvider() const; + + com::sun::star::uno::Mapping & getCppToBinaryMapping(); + + BinaryAny mapCppToBinaryAny(com::sun::star::uno::Any const & cppAny); + + uno_ThreadPool getThreadPool() const; + + rtl::Reference< Writer > getWriter(); + + com::sun::star::uno::UnoInterfaceReference registerIncomingInterface( + rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type); + + rtl::OUString registerOutgoingInterface( + com::sun::star::uno::UnoInterfaceReference const & object, + com::sun::star::uno::TypeDescription const & type); + + com::sun::star::uno::UnoInterfaceReference findStub( + rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type); + + void releaseStub( + rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type); + + void resurrectProxy(Proxy & proxy); + + void revokeProxy(Proxy & proxy); + + void freeProxy(Proxy & proxy); + + void incrementCalls(bool normalCall) throw (); + + void decrementCalls(); + + void incrementActiveCalls() throw (); + + void decrementActiveCalls() throw (); + + bool makeCall( + rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & member, bool setter, + std::vector< BinaryAny > const & inArguments, BinaryAny * returnValue, + std::vector< BinaryAny > * outArguments); + + // Only called from reader_ thread: + void sendRequestChangeRequest(); + + // Only called from reader_ thread: + void handleRequestChangeReply( + bool exception, BinaryAny const & returnValue); + + // Only called from reader_ thread: + void handleCommitChangeReply(bool exception, BinaryAny const & returnValue); + + // Only called from reader_ thread: + void handleRequestChangeRequest( + rtl::ByteSequence const & tid, + std::vector< BinaryAny > const & inArguments); + + // Only called from reader_ thread: + void handleCommitChangeRequest( + rtl::ByteSequence const & tid, + std::vector< BinaryAny > const & inArguments); + + OutgoingRequest lastOutgoingRequest(rtl::ByteSequence const & tid); + + bool isProtocolPropertiesRequest( + rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type) const; + + void setCurrentContextMode(); + + bool isCurrentContextMode(); + +private: + virtual ~Bridge(); + + virtual com::sun::star::uno::Reference< com::sun::star::uno::XInterface > + SAL_CALL getInstance(rtl::OUString const & sInstanceName) + throw (com::sun::star::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getName() + throw (com::sun::star::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getDescription() + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL dispose() + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL addEventListener( + com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > + const & xListener) + throw (com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL removeEventListener( + com::sun::star::uno::Reference< com::sun::star::lang::XEventListener > + const & aListener) + throw (com::sun::star::uno::RuntimeException); + + // Only called from reader_ thread: + void sendCommitChangeRequest(); + + // Only called from reader_ thread: + void sendProtPropRequest( + OutgoingRequest::Kind kind, + std::vector< BinaryAny > const & inArguments); + + void makeReleaseCall( + rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type); + + void sendRequest( + rtl::ByteSequence const & tid, rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type, + com::sun::star::uno::TypeDescription const & member, + std::vector< BinaryAny > const & inArguments); + + void throwException(bool exception, BinaryAny const & value); + + com::sun::star::uno::Any mapBinaryToCppAny(BinaryAny const & binaryAny); + + bool becameUnused() const; + + void terminateWhenUnused(bool unused); + + typedef + std::list< + com::sun::star::uno::Reference< + com::sun::star::lang::XEventListener > > + Listeners; + + struct SubStub; + + typedef std::map< com::sun::star::uno::TypeDescription, SubStub > Stub; + + typedef std::map< rtl::OUString, Stub > Stubs; + + enum Mode { + MODE_REQUESTED, MODE_REPLY_MINUS1, MODE_REPLY_0, MODE_REPLY_1, + MODE_WAIT, MODE_NORMAL, MODE_NORMAL_WAIT }; + + rtl::Reference< BridgeFactory > factory_; + rtl::OUString name_; + com::sun::star::uno::Reference< com::sun::star::connection::XConnection > + connection_; + com::sun::star::uno::Reference< com::sun::star::bridge::XInstanceProvider > + provider_; + com::sun::star::uno::Environment binaryUno_; + com::sun::star::uno::Mapping cppToBinaryMapping_; + com::sun::star::uno::Mapping binaryToCppMapping_; + rtl::ByteSequence protPropTid_; + rtl::OUString protPropOid_; + com::sun::star::uno::TypeDescription protPropType_; + com::sun::star::uno::TypeDescription protPropRequest_; + com::sun::star::uno::TypeDescription protPropCommit_; + uno_ThreadPool threadPool_; + OutgoingRequests outgoingRequests_; + + osl::Mutex mutex_; + Listeners listeners_; + rtl::Reference< Writer > writer_; + rtl::Reference< Reader > reader_; + bool currentContextMode_; + Stubs stubs_; + std::size_t proxies_; + std::size_t calls_; + bool normalCall_; + std::size_t activeCalls_; + osl::Condition passive_; + // to guarantee that passive_ is eventually set (to avoid deadlock, see + // dispose), activeCalls_ only counts those calls for which it can be + // guaranteed that incrementActiveCalls is indeed followed by + // decrementActiveCalls, without an intervening exception + bool terminated_; + + // Only accessed from reader_ thread: + Mode mode_; + sal_Int32 random_; +}; + +} + +#endif diff --git a/binaryurp/source/bridgefactory.cxx b/binaryurp/source/bridgefactory.cxx new file mode 100644 index 000000000000..16bd9cf1b6f3 --- /dev/null +++ b/binaryurp/source/bridgefactory.cxx @@ -0,0 +1,232 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <algorithm> + +#include "com/sun/star/connection/XConnection.hpp" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/factory.hxx" +#include "cppuhelper/implementationentry.hxx" +#include "osl/diagnose.h" +#include "rtl/ref.hxx" +#include "sal/types.h" +#include "uno/lbnames.h" + +#include "bridge.hxx" +#include "bridgefactory.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +} + +css::uno::Reference< css::uno::XInterface > BridgeFactory::static_create( + css::uno::Reference< css::uno::XComponentContext > const & xContext) + SAL_THROW((css::uno::Exception)) +{ + return static_cast< cppu::OWeakObject * >(new BridgeFactory(xContext)); +} + +rtl::OUString BridgeFactory::static_getImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.bridge.BridgeFactory")); +} + +css::uno::Sequence< rtl::OUString > +BridgeFactory::static_getSupportedServiceNames() { + rtl::OUString name( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.BridgeFactory")); + return css::uno::Sequence< rtl::OUString >(&name, 1); +} + +void BridgeFactory::removeBridge( + css::uno::Reference< css::bridge::XBridge > const & bridge) +{ + OSL_ASSERT(bridge.is()); + rtl::OUString n(bridge->getName()); + osl::MutexGuard g(*this); + if (n.getLength() == 0) { + BridgeList::iterator i( + std::find(unnamed_.begin(), unnamed_.end(), bridge)); + if (i != unnamed_.end()) { + unnamed_.erase(i); + } + } else { + BridgeMap::iterator i(named_.find(n)); + if (i != named_.end() && i->second == bridge) { + named_.erase(i); + } + } +} + +BridgeFactory::BridgeFactory( + css::uno::Reference< css::uno::XComponentContext > const & context): + BridgeFactoryBase(*static_cast< osl::Mutex * >(this)), context_(context) +{ + OSL_ASSERT(context.is()); +} + +BridgeFactory::~BridgeFactory() {} + +rtl::OUString BridgeFactory::getImplementationName() + throw (css::uno::RuntimeException) +{ + return static_getImplementationName(); +} + +sal_Bool BridgeFactory::supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) +{ + css::uno::Sequence< rtl::OUString > s(getSupportedServiceNames()); + for (sal_Int32 i = 0; i != s.getLength(); ++i) { + if (ServiceName == s[i]) { + return true; + } + } + return false; +} + +css::uno::Sequence< rtl::OUString > BridgeFactory::getSupportedServiceNames() + throw (css::uno::RuntimeException) +{ + return static_getSupportedServiceNames(); +} + +css::uno::Reference< css::bridge::XBridge > BridgeFactory::createBridge( + rtl::OUString const & sName, rtl::OUString const & sProtocol, + css::uno::Reference< css::connection::XConnection > const & aConnection, + css::uno::Reference< css::bridge::XInstanceProvider > const & + anInstanceProvider) + throw ( + css::bridge::BridgeExistsException, css::lang::IllegalArgumentException, + css::uno::RuntimeException) +{ + rtl::Reference< Bridge > b; + { + osl::MutexGuard g(*this); + if (named_.find(sName) != named_.end()) { + throw css::bridge::BridgeExistsException( + sName, static_cast< cppu::OWeakObject * >(this)); + } + if (!(sProtocol.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("urp")) && + aConnection.is())) + { + throw css::lang::IllegalArgumentException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "BridgeFactory::createBridge: sProtocol != urp ||" + " aConnection == null")), + static_cast< cppu::OWeakObject * >(this), -1); + } + b.set(new Bridge(this, sName, aConnection, anInstanceProvider)); + if (sName.getLength() == 0) { + unnamed_.push_back( + css::uno::Reference< css::bridge::XBridge >(b.get())); + } else { + named_[sName] = b.get(); + } + } + b->start(); + return css::uno::Reference< css::bridge::XBridge >(b.get()); +} + +css::uno::Reference< css::bridge::XBridge > BridgeFactory::getBridge( + rtl::OUString const & sName) throw (css::uno::RuntimeException) +{ + osl::MutexGuard g(*this); + BridgeMap::iterator i(named_.find(sName)); + return i == named_.end() + ? css::uno::Reference< css::bridge::XBridge >() : i->second; +} + +css::uno::Sequence< css::uno::Reference< css::bridge::XBridge > > +BridgeFactory::getExistingBridges() throw (css::uno::RuntimeException) { + osl::MutexGuard g(*this); + if (unnamed_.size() > SAL_MAX_INT32) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "BridgeFactory::getExistingBridges: too many")), + static_cast< cppu::OWeakObject * >(this)); + } + sal_Int32 n = static_cast< sal_Int32 >(unnamed_.size()); + if (named_.size() > static_cast< sal_uInt32 >(SAL_MAX_INT32 - n)) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "BridgeFactory::getExistingBridges: too many")), + static_cast< cppu::OWeakObject * >(this)); + } + n = static_cast< sal_Int32 >(n + named_.size()); + css::uno::Sequence< css::uno::Reference< css::bridge::XBridge > > s(n); + sal_Int32 i = 0; + for (BridgeList::iterator j(unnamed_.begin()); j != unnamed_.end(); ++j) { + s[i++] = *j; + } + for (BridgeMap::iterator j(named_.begin()); j != named_.end(); ++j) { + s[i++] = j->second; + } + return s; +} + +} + +namespace { + +static cppu::ImplementationEntry const services[] = { + { &binaryurp::BridgeFactory::static_create, + &binaryurp::BridgeFactory::static_getImplementationName, + &binaryurp::BridgeFactory::static_getSupportedServiceNames, + &cppu::createSingleComponentFactory, 0, 0 }, + { 0, 0, 0, 0, 0, 0 } +}; + +} + +extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + char const * pImplName, void * pServiceManager, void * pRegistryKey) +{ + return cppu::component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey, services); +} + +extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL +component_getImplementationEnvironment( + char const ** ppEnvTypeName, uno_Environment **) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} diff --git a/binaryurp/source/bridgefactory.hxx b/binaryurp/source/bridgefactory.hxx new file mode 100755 index 000000000000..af6499d61bd0 --- /dev/null +++ b/binaryurp/source/bridgefactory.hxx @@ -0,0 +1,144 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_BRIDGEFACTORY_HXX +#define INCLUDED_BINARYURP_SOURCE_BRIDGEFACTORY_HXX + +#include "sal/config.h" + +#include <list> +#include <map> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/bridge/XBridgeFactory.hpp" +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "cppuhelper/compbase2.hxx" +#include "sal/types.h" + +namespace com { namespace sun { namespace star { + namespace connection { class XConnection; } + namespace uno { + class XComponentContext; + class XInterface; + } +} } } + +namespace binaryurp { + +// That BridgeFactory derives from XComponent appears to be a historic mistake; +// the implementation does not care about a disposed state: + +typedef + cppu::WeakComponentImplHelper2< + com::sun::star::lang::XServiceInfo, + com::sun::star::bridge::XBridgeFactory > + BridgeFactoryBase; + +class BridgeFactory: + private osl::Mutex, public BridgeFactoryBase, private boost::noncopyable +{ +public: + static com::sun::star::uno::Reference< com::sun::star::uno::XInterface > + SAL_CALL static_create( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & xContext) + SAL_THROW((com::sun::star::uno::Exception)); + + static rtl::OUString SAL_CALL static_getImplementationName(); + + static com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL + static_getSupportedServiceNames(); + + void removeBridge( + com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > + const & bridge); + + using BridgeFactoryBase::acquire; + using BridgeFactoryBase::release; + +private: + explicit BridgeFactory( + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + const & context); + + virtual ~BridgeFactory(); + + virtual rtl::OUString SAL_CALL getImplementationName() + throw (com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > + SAL_CALL createBridge( + rtl::OUString const & sName, rtl::OUString const & sProtocol, + com::sun::star::uno::Reference< + com::sun::star::connection::XConnection > const & aConnection, + com::sun::star::uno::Reference< + com::sun::star::bridge::XInstanceProvider > const & + anInstanceProvider) + throw ( + com::sun::star::bridge::BridgeExistsException, + com::sun::star::lang::IllegalArgumentException, + com::sun::star::uno::RuntimeException); + + virtual com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > + SAL_CALL getBridge( + rtl::OUString const & sName) + throw (com::sun::star::uno::RuntimeException); + + virtual + com::sun::star::uno::Sequence< + com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > > + SAL_CALL getExistingBridges() throw (com::sun::star::uno::RuntimeException); + + typedef + std::list< + com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > > + BridgeList; + + typedef + std::map< + rtl::OUString, + com::sun::star::uno::Reference< com::sun::star::bridge::XBridge > > + BridgeMap; + + com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext > + context_; + BridgeList unnamed_; + BridgeMap named_; +}; + +} + +#endif diff --git a/binaryurp/source/cache.hxx b/binaryurp/source/cache.hxx new file mode 100755 index 000000000000..118b8a07b98d --- /dev/null +++ b/binaryurp/source/cache.hxx @@ -0,0 +1,134 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_CACHE_HXX +#define INCLUDED_BINARYURP_SOURCE_CACHE_HXX + +#include "sal/config.h" + +#include <cstddef> +#include <map> + +#include "boost/noncopyable.hpp" +#include "osl/diagnose.h" +#include "sal/types.h" + +namespace binaryurp { + +namespace cache { + +enum { size = 256, ignore = 0xFFFF }; + +} + +template< typename T > class Cache: private boost::noncopyable { +public: + explicit Cache(std::size_t size): + size_(size), first_(map_.end()), last_(map_.end()) + { + OSL_ASSERT(size < cache::ignore); + } + + sal_uInt16 add(T const & content, bool * found) { + OSL_ASSERT(found != 0); + typename Map::iterator i(map_.find(content)); + *found = i != map_.end(); + if (i == map_.end()) { + typename Map::size_type n = map_.size(); + if (n < size_) { + i = + (map_.insert( + typename Map::value_type( + content, + Entry( + static_cast< sal_uInt16 >(n), map_.end(), + first_)))). + first; + if (first_ == map_.end()) { + last_ = i; + } else { + first_->second.prev = i; + } + first_ = i; + } else if (last_ != map_.end()) { + i = + (map_.insert( + typename Map::value_type( + content, + Entry(last_->second.index, map_.end(), first_)))). + first; + first_->second.prev = i; + first_ = i; + typename Map::iterator j(last_); + last_ = last_->second.prev; + last_->second.next = map_.end(); + map_.erase(j); + } else { + // Reached iff size_ == 0: + return cache::ignore; + } + } else if (i != first_) { + // Move to front (reached only if size_ > 1): + i->second.prev->second.next = i->second.next; + if (i->second.next == map_.end()) { + last_ = i->second.prev; + } else { + i->second.next->second.prev = i->second.prev; + } + i->second.prev = map_.end(); + i->second.next = first_; + first_->second.prev = i; + first_ = i; + } + return i->second.index; + } + +private: + struct Entry; + + typedef std::map< T, Entry > Map; + + struct Entry { + sal_uInt16 index; + typename Map::iterator prev; + typename Map::iterator next; + + Entry( + sal_uInt16 theIndex, typename Map::iterator thePrev, + typename Map::iterator theNext): + index(theIndex), prev(thePrev), next(theNext) {} + }; + + std::size_t size_; + Map map_; + typename Map::iterator first_; + typename Map::iterator last_; +}; + +} + +#endif diff --git a/binaryurp/source/currentcontext.cxx b/binaryurp/source/currentcontext.cxx new file mode 100644 index 000000000000..aed9640d84a0 --- /dev/null +++ b/binaryurp/source/currentcontext.cxx @@ -0,0 +1,80 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#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 "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "uno/current_context.h" +#include "uno/dispatcher.hxx" +#include "uno/lbnames.h" + +#include "currentcontext.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +} + +namespace current_context { + +css::uno::UnoInterfaceReference get() { + css::uno::UnoInterfaceReference cc; + if (!uno_getCurrentContext( + reinterpret_cast< void ** >(&cc.m_pUnoI), + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)).pData, 0)) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("uno_getCurrentContext failed")), + css::uno::Reference< css::uno::XInterface >()); + } + return cc; +} + +void set(css::uno::UnoInterfaceReference const & value) { + css::uno::UnoInterfaceReference cc(value); + if (!uno_setCurrentContext( + cc.m_pUnoI, + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)).pData, 0)) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("uno_setCurrentContext failed")), + css::uno::Reference< css::uno::XInterface >()); + } +} + +} + +} diff --git a/binaryurp/source/currentcontext.hxx b/binaryurp/source/currentcontext.hxx new file mode 100644 index 000000000000..558d9ac04d5c --- /dev/null +++ b/binaryurp/source/currentcontext.hxx @@ -0,0 +1,49 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_CURRENTCONTEXT_HXX +#define INCLUDED_BINARYURP_SOURCE_CURRENTCONTEXT_HXX + +#include "sal/config.h" + +namespace com { namespace sun { namespace star { namespace uno { + class UnoInterfaceReference; +} } } } + +namespace binaryurp { + +namespace current_context { + +com::sun::star::uno::UnoInterfaceReference get(); + +void set(com::sun::star::uno::UnoInterfaceReference const & value); + +} + +} + +#endif diff --git a/binaryurp/source/incomingreply.hxx b/binaryurp/source/incomingreply.hxx new file mode 100644 index 000000000000..654542f701fa --- /dev/null +++ b/binaryurp/source/incomingreply.hxx @@ -0,0 +1,58 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_INCOMINGREPLY_HXX +#define INCLUDED_BINARYURP_SOURCE_INCOMINGREPLY_HXX + +#include "sal/config.h" + +#include <vector> + +#include "boost/noncopyable.hpp" + +#include "binaryany.hxx" + +namespace binaryurp { + +struct IncomingReply: private boost::noncopyable { + IncomingReply( + bool theException, BinaryAny const & theReturnValue, + std::vector< BinaryAny > const & theOutArguments): + exception(theException), returnValue(theReturnValue), + outArguments(theOutArguments) + {} + + bool exception; + + BinaryAny returnValue; + + std::vector< BinaryAny > outArguments; +}; + +} + +#endif diff --git a/binaryurp/source/incomingrequest.cxx b/binaryurp/source/incomingrequest.cxx new file mode 100644 index 000000000000..646a868f66fd --- /dev/null +++ b/binaryurp/source/incomingrequest.cxx @@ -0,0 +1,300 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <list> +#include <vector> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/bridge/XInstanceProvider.hpp" +#include "cppuhelper/exc_hlp.hxx" +#include "rtl/byteseq.hxx" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typedescription.hxx" +#include "uno/dispatcher.hxx" + +#include "binaryany.hxx" +#include "bridge.hxx" +#include "currentcontext.hxx" +#include "incomingrequest.hxx" +#include "specialfunctionids.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +} + +IncomingRequest::IncomingRequest( + rtl::Reference< Bridge > const & bridge, rtl::ByteSequence const & tid, + rtl::OUString const & oid, css::uno::UnoInterfaceReference const & object, + css::uno::TypeDescription const & type, sal_uInt16 functionId, + bool synchronous, css::uno::TypeDescription const & member, bool setter, + std::vector< BinaryAny > const & inArguments, bool currentContextMode, + css::uno::UnoInterfaceReference const & currentContext): + bridge_(bridge), tid_(tid), oid_(oid), object_(object), type_(type), + functionId_(functionId), synchronous_(synchronous), member_(member), + setter_(setter), inArguments_(inArguments), + currentContextMode_(currentContextMode), currentContext_(currentContext) +{ + OSL_ASSERT(bridge.is() && member.is() && member.get()->bComplete); +} + +IncomingRequest::~IncomingRequest() {} + +void IncomingRequest::execute() const { + BinaryAny ret; + std::vector< BinaryAny > outArgs; + bool isExc; + try { + bool resetCc = false; + css::uno::UnoInterfaceReference oldCc; + if (currentContextMode_) { + oldCc = current_context::get(); + current_context::set(currentContext_); + resetCc = true; + } + try { + try { + isExc = !execute_throw(&ret, &outArgs); + } catch (std::exception & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("caught C++ exception: ")) + + rtl::OStringToOUString( + rtl::OString(e.what()), RTL_TEXTENCODING_ASCII_US)), + css::uno::Reference< css::uno::XInterface >()); + // best-effort string conversion + } + } catch (css::uno::RuntimeException &) { + css::uno::Any exc(cppu::getCaughtException()); + ret = bridge_->mapCppToBinaryAny(exc); + isExc = true; + } + if (resetCc) { + current_context::set(oldCc); + } + } catch (css::uno::RuntimeException &) { + css::uno::Any exc(cppu::getCaughtException()); + ret = bridge_->mapCppToBinaryAny(exc); + isExc = true; + } + if (synchronous_) { + bridge_->decrementActiveCalls(); + try { + bridge_->getWriter()->queueReply( + tid_, member_, setter_, isExc, ret, outArgs, false); + return; + } catch (css::uno::RuntimeException & e) { + OSL_TRACE( + OSL_LOG_PREFIX "caught UNO runtime exception '%s'", + (rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8). + getStr())); + } catch (std::exception & e) { + OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what()); + } + bridge_->terminate(); + } else { + if (isExc) { + OSL_TRACE(OSL_LOG_PREFIX "oneway method raised exception"); + } + bridge_->decrementCalls(); + } +} + +bool IncomingRequest::execute_throw( + BinaryAny * returnValue, std::vector< BinaryAny > * outArguments) const +{ + OSL_ASSERT( + returnValue != 0 && + returnValue->getType().equals( + css::uno::TypeDescription( + cppu::UnoType< cppu::UnoVoidType >::get())) && + outArguments != 0 && outArguments->empty()); + bool isExc = false; + switch (functionId_) { + case SPECIAL_FUNCTION_ID_RESERVED: + OSL_ASSERT(false); // this cannot happen + break; + case SPECIAL_FUNCTION_ID_RELEASE: + bridge_->releaseStub(oid_, type_); + break; + case SPECIAL_FUNCTION_ID_QUERY_INTERFACE: + if (!object_.is()) { + css::uno::Reference< css::uno::XInterface > ifc; + css::uno::Reference< css::bridge::XInstanceProvider > prov( + bridge_->getProvider()); + if (prov.is()) { + try { + ifc = prov->getInstance(oid_); + } catch (css::container::NoSuchElementException & e) { + OSL_TRACE( + (OSL_LOG_PREFIX "initial element '%s':" + " NoSuchElementException '%s'"), + (rtl::OUStringToOString(oid_, RTL_TEXTENCODING_UTF8). + getStr()), + (rtl::OUStringToOString( + e.Message, RTL_TEXTENCODING_UTF8). + getStr())); + } + } + if (ifc.is()) { + css::uno::UnoInterfaceReference unoIfc( + static_cast< uno_Interface * >( + bridge_->getCppToBinaryMapping().mapInterface( + ifc.get(), + (css::uno::TypeDescription( + cppu::UnoType< + css::uno::Reference< + css::uno::XInterface > >::get()). + get()))), + SAL_NO_ACQUIRE); + *returnValue = BinaryAny( + css::uno::TypeDescription( + cppu::UnoType< + css::uno::Reference< + css::uno::XInterface > >::get()), + &unoIfc.m_pUnoI); + } + break; + } + // fall through + default: + { + OSL_ASSERT(object_.is()); + css::uno::TypeDescription retType; + std::list< std::vector< char > > outBufs; + std::vector< void * > args; + switch (member_.get()->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + { + css::uno::TypeDescription t( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + member_.get())-> + pAttributeTypeRef); + if (setter_) { + OSL_ASSERT(inArguments_.size() == 1); + args.push_back(inArguments_[0].getValue(t)); + } else { + OSL_ASSERT(inArguments_.empty()); + retType = t; + } + break; + } + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription * mtd = + reinterpret_cast< + typelib_InterfaceMethodTypeDescription * >( + member_.get()); + retType = css::uno::TypeDescription(mtd->pReturnTypeRef); + std::vector< BinaryAny >::const_iterator i( + inArguments_.begin()); + for (sal_Int32 j = 0; j != mtd->nParams; ++j) { + void * p; + if (mtd->pParams[j].bIn) { + p = i++->getValue( + css::uno::TypeDescription( + mtd->pParams[j].pTypeRef)); + } else { + outBufs.push_back( + std::vector< char >( + css::uno::TypeDescription( + mtd->pParams[j].pTypeRef). + get()->nSize)); + p = &outBufs.back()[0]; + } + args.push_back(p); + if (mtd->pParams[j].bOut) { + outArguments->push_back(BinaryAny()); + } + } + OSL_ASSERT(i == inArguments_.end()); + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + std::vector< char > retBuf(retType.is() ? retType.get()->nSize : 0); + uno_Any exc; + uno_Any * pexc = &exc; + (*object_.get()->pDispatcher)( + object_.get(), member_.get(), retBuf.empty() ? 0 : &retBuf[0], + args.empty() ? 0 : &args[0], &pexc); + isExc = pexc != 0; + if (isExc) { + *returnValue = BinaryAny( + css::uno::TypeDescription( + cppu::UnoType< css::uno::Any >::get()), + &exc); + uno_any_destruct(&exc, 0); + } else { + if (!retBuf.empty()) { + *returnValue = BinaryAny(retType, &retBuf[0]); + uno_destructData(&retBuf[0], retType.get(), 0); + } + if (!outArguments->empty()) { + OSL_ASSERT( + member_.get()->eTypeClass == + typelib_TypeClass_INTERFACE_METHOD); + typelib_InterfaceMethodTypeDescription * mtd = + reinterpret_cast< + typelib_InterfaceMethodTypeDescription * >( + member_.get()); + std::vector< BinaryAny >::iterator i(outArguments->begin()); + std::list< std::vector< char > >::iterator j( + outBufs.begin()); + for (sal_Int32 k = 0; k != mtd->nParams; ++k) { + if (mtd->pParams[k].bOut) { + *i++ = BinaryAny( + css::uno::TypeDescription( + mtd->pParams[k].pTypeRef), + args[k]); + } + if (!mtd->pParams[k].bIn) { + uno_type_destructData( + &(*j++)[0], mtd->pParams[k].pTypeRef, 0); + } + } + OSL_ASSERT(i == outArguments->end()); + OSL_ASSERT(j == outBufs.end()); + } + } + break; + } + } + return !isExc; +} + +} diff --git a/binaryurp/source/incomingrequest.hxx b/binaryurp/source/incomingrequest.hxx new file mode 100644 index 000000000000..ead7067f8ae9 --- /dev/null +++ b/binaryurp/source/incomingrequest.hxx @@ -0,0 +1,86 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_INCOMINGREQUEST_HXX +#define INCLUDED_BINARYURP_SOURCE_INCOMINGREQUEST_HXX + +#include "sal/config.h" + +#include <vector> + +#include "boost/noncopyable.hpp" +#include "rtl/byteseq.hxx" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typedescription.hxx" +#include "uno/dispatcher.hxx" + +namespace binaryurp { + class BinaryAny; + class Bridge; +} + +namespace binaryurp { + +class IncomingRequest: private boost::noncopyable { +public: + IncomingRequest( + rtl::Reference< Bridge > const & bridge, rtl::ByteSequence const & tid, + rtl::OUString const & oid, + com::sun::star::uno::UnoInterfaceReference const & object, + com::sun::star::uno::TypeDescription const & type, + sal_uInt16 functionId, bool synchronous, + com::sun::star::uno::TypeDescription const & member, bool setter, + std::vector< BinaryAny > const & inArguments, bool currentContextMode, + com::sun::star::uno::UnoInterfaceReference const & currentContext); + + ~IncomingRequest(); + + void execute() const; + +private: + bool execute_throw( + BinaryAny * returnValue, std::vector< BinaryAny > * outArguments) const; + + rtl::Reference< Bridge > bridge_; + rtl::ByteSequence tid_; + rtl::OUString oid_; // initial object queryInterface; release + com::sun::star::uno::UnoInterfaceReference object_; + com::sun::star::uno::TypeDescription type_; + sal_uInt16 functionId_; + bool synchronous_; + com::sun::star::uno::TypeDescription member_; + bool setter_; + std::vector< BinaryAny > inArguments_; + bool currentContextMode_; + com::sun::star::uno::UnoInterfaceReference currentContext_; +}; + +} + +#endif diff --git a/binaryurp/source/lessoperators.cxx b/binaryurp/source/lessoperators.cxx new file mode 100644 index 000000000000..354118625ce8 --- /dev/null +++ b/binaryurp/source/lessoperators.cxx @@ -0,0 +1,71 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <algorithm> + +#include "osl/diagnose.h" +#include "rtl/byteseq.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typeclass.h" +#include "typelib/typedescription.hxx" + +#include "lessoperators.hxx" + +namespace com { namespace sun { namespace star { namespace uno { + +bool operator <(TypeDescription const & left, TypeDescription const & right) { + OSL_ASSERT(left.is() && right.is()); + typelib_TypeClass tc1 = left.get()->eTypeClass; + typelib_TypeClass tc2 = right.get()->eTypeClass; + return tc1 < tc2 || + (tc1 == tc2 && + (rtl::OUString(left.get()->pTypeName) < + rtl::OUString(right.get()->pTypeName))); +} + +} } } } + +namespace rtl { + +bool operator <(ByteSequence const & left, ByteSequence const & right) { + for (sal_Int32 i = 0; i != std::min(left.getLength(), right.getLength()); + ++i) + { + if (left[i] < right[i]) { + return true; + } + if (right[i] < left[i]) { + return false; + } + } + return left.getLength() < right.getLength(); +} + +} diff --git a/binaryurp/source/lessoperators.hxx b/binaryurp/source/lessoperators.hxx new file mode 100644 index 000000000000..014f0f4d56bf --- /dev/null +++ b/binaryurp/source/lessoperators.hxx @@ -0,0 +1,50 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_LESSOPERATORS_HXX +#define INCLUDED_BINARYURP_SOURCE_LESSOPERATORS_HXX + +#include "sal/config.h" + +namespace com { namespace sun { namespace star { namespace uno { + class TypeDescription; +} } } } +namespace rtl { class ByteSequence; } + +namespace com { namespace sun { namespace star { namespace uno { + +bool operator <(TypeDescription const & left, TypeDescription const & right); + +} } } } + +namespace rtl { + +bool operator <(ByteSequence const & left, ByteSequence const & right); + +} + +#endif diff --git a/binaryurp/source/makefile.mk b/binaryurp/source/makefile.mk new file mode 100644 index 000000000000..ca9e7c72b65d --- /dev/null +++ b/binaryurp/source/makefile.mk @@ -0,0 +1,69 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#***********************************************************************/ + +PRJ = .. +PRJNAME = binaryurp +TARGET = binaryurp + +ENABLE_EXCEPTIONS = TRUE +VISIBILITY_HIDDEN = TRUE + +.INCLUDE: settings.mk + +DLLPRE = + +SLOFILES = \ + $(SLO)/binaryany.obj \ + $(SLO)/bridge.obj \ + $(SLO)/bridgefactory.obj \ + $(SLO)/currentcontext.obj \ + $(SLO)/incomingrequest.obj \ + $(SLO)/lessoperators.obj \ + $(SLO)/marshal.obj \ + $(SLO)/outgoingrequests.obj \ + $(SLO)/proxy.obj \ + $(SLO)/reader.obj \ + $(SLO)/unmarshal.obj \ + $(SLO)/writer.obj + +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLOFILES) +SHL1RPATH = URELIB +SHL1STDLIBS = $(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) +SHL1TARGET = binaryurp.uno +SHL1USE_EXPORTS = name +DEF1NAME = $(SHL1TARGET) + +.INCLUDE: target.mk + +ALLTAR : $(MISC)/binaryurp.component + +$(MISC)/binaryurp.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + binaryurp.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt binaryurp.component diff --git a/binaryurp/source/marshal.cxx b/binaryurp/source/marshal.cxx new file mode 100644 index 000000000000..ce520382efac --- /dev/null +++ b/binaryurp/source/marshal.cxx @@ -0,0 +1,314 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <vector> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppu/unotype.hxx" +#include "osl/diagnose.h" +#include "rtl/byteseq.hxx" +#include "rtl/string.hxx" +#include "rtl/textcvt.h" +#include "rtl/textenc.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typeclass.h" +#include "typelib/typedescription.h" +#include "typelib/typedescription.hxx" +#include "uno/dispatcher.hxx" + +#include "binaryany.hxx" +#include "bridge.hxx" +#include "cache.hxx" +#include "lessoperators.hxx" +#include "marshal.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +void write64(std::vector< unsigned char > * buffer, sal_uInt64 value) { + Marshal::write8(buffer, value >> 56); + Marshal::write8(buffer, (value >> 48) & 0xFF); + Marshal::write8(buffer, (value >> 40) & 0xFF); + Marshal::write8(buffer, (value >> 32) & 0xFF); + Marshal::write8(buffer, (value >> 24) & 0xFF); + Marshal::write8(buffer, (value >> 16) & 0xFF); + Marshal::write8(buffer, (value >> 8) & 0xFF); + Marshal::write8(buffer, value & 0xFF); +} + +void writeCompressed(std::vector< unsigned char > * buffer, sal_uInt32 value) { + if (value < 0xFF) { + Marshal::write8(buffer, static_cast< sal_uInt8 >(value)); + } else { + Marshal::write8(buffer, 0xFF); + Marshal::write32(buffer, value); + } +} + +void writeString( + std::vector< unsigned char > * buffer, rtl::OUString const & value) +{ + OSL_ASSERT(buffer != 0); + rtl::OString v; + if (!value.convertToString( + &v, RTL_TEXTENCODING_UTF8, + (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | + RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "UNO string contains invalid UTF-16 sequence")), + css::uno::Reference< css::uno::XInterface >()); + } + writeCompressed(buffer, static_cast< sal_uInt32 >(v.getLength())); + buffer->insert(buffer->end(), v.getStr(), v.getStr() + v.getLength()); +} + +} + +Marshal::Marshal(rtl::Reference< Bridge > const & bridge, WriterState & state): + bridge_(bridge), state_(state) +{ + OSL_ASSERT(bridge.is()); +} + +Marshal::~Marshal() {} + +void Marshal::write8(std::vector< unsigned char > * buffer, sal_uInt8 value) { + OSL_ASSERT(buffer != 0); + buffer->push_back(value); +} + +void Marshal::write16(std::vector< unsigned char > * buffer, sal_uInt16 value) { + write8(buffer, value >> 8); + write8(buffer, value & 0xFF); +} + +void Marshal::write32(std::vector< unsigned char > * buffer, sal_uInt32 value) { + write8(buffer, value >> 24); + write8(buffer, (value >> 16) & 0xFF); + write8(buffer, (value >> 8) & 0xFF); + write8(buffer, value & 0xFF); +} + +void Marshal::writeValue( + std::vector< unsigned char > * buffer, + css::uno::TypeDescription const & type, BinaryAny const & value) +{ + OSL_ASSERT( + type.is() && + (type.get()->eTypeClass == typelib_TypeClass_ANY || + value.getType().equals(type))); + writeValue(buffer, type, value.getValue(type)); +} + +void Marshal::writeType( + std::vector< unsigned char > * buffer, + css::uno::TypeDescription const & value) +{ + value.makeComplete(); + OSL_ASSERT(value.is()); + typelib_TypeClass tc = value.get()->eTypeClass; + if (tc <= typelib_TypeClass_ANY) { + write8(buffer, static_cast< sal_uInt8 >(tc)); + } else { + bool found; + sal_uInt16 idx = state_.typeCache.add(value, &found); + if (found) { + write8(buffer, static_cast< sal_uInt8 >(tc)); + write16(buffer, idx); + } else { + write8(buffer, static_cast< sal_uInt8 >(tc) | 0x80); + write16(buffer, idx); + writeString(buffer, rtl::OUString(value.get()->pTypeName)); + } + } +} + +void Marshal::writeOid( + std::vector< unsigned char > * buffer, rtl::OUString const & oid) +{ + bool found; + sal_uInt16 idx; + if (oid.getLength() == 0) { + found = true; + idx = cache::ignore; + } else { + idx = state_.oidCache.add(oid, &found); + } + if (found) { + write8(buffer, 0); + } else { + writeString(buffer, oid); + } + write16(buffer, idx); +} + +void Marshal::writeTid( + std::vector< unsigned char > * buffer, rtl::ByteSequence const & tid) +{ + bool found; + sal_uInt16 idx = state_.tidCache.add(tid, &found); + if (found) { + write8(buffer, 0); + } else { + sal_Sequence * p = tid.getHandle(); + writeValue( + buffer, + css::uno::TypeDescription( + cppu::UnoType< css::uno::Sequence< sal_Int8 > >::get()), &p); + } + write16(buffer, idx); +} + +void Marshal::writeValue( + std::vector< unsigned char > * buffer, + css::uno::TypeDescription const & type, void const * value) +{ + OSL_ASSERT(buffer != 0 && type.is()); + type.makeComplete(); + switch (type.get()->eTypeClass) { + case typelib_TypeClass_VOID: + break; + case typelib_TypeClass_BOOLEAN: + OSL_ASSERT(*static_cast< sal_uInt8 const * >(value) <= 1); + // fall through + case typelib_TypeClass_BYTE: + write8(buffer, *static_cast< sal_uInt8 const * >(value)); + break; + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_CHAR: + write16(buffer, *static_cast< sal_uInt16 const * >(value)); + break; + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_FLOAT: + case typelib_TypeClass_ENUM: + write32(buffer, *static_cast< sal_uInt32 const * >(value)); + break; + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + case typelib_TypeClass_DOUBLE: + write64(buffer, *static_cast< sal_uInt64 const * >(value)); + break; + case typelib_TypeClass_STRING: + writeString( + buffer, + rtl::OUString(*static_cast< rtl_uString * const * >(value))); + break; + case typelib_TypeClass_TYPE: + writeType( + buffer, + css::uno::TypeDescription( + *static_cast< typelib_TypeDescriptionReference * const * >( + value))); + break; + case typelib_TypeClass_ANY: + { + uno_Any const * p = static_cast< uno_Any const * >(value); + css::uno::TypeDescription t(p->pType); + writeType(buffer, t); + writeValue(buffer, t, p->pData); + break; + } + case typelib_TypeClass_SEQUENCE: + { + sal_Sequence * p = *static_cast< sal_Sequence * const * >(value); + writeCompressed(buffer, static_cast< sal_uInt32 >(p->nElements)); + css::uno::TypeDescription ctd( + reinterpret_cast< typelib_IndirectTypeDescription * >( + type.get())-> + pType); + OSL_ASSERT(ctd.is()); + if (ctd.get()->eTypeClass == typelib_TypeClass_BYTE) { + buffer->insert( + buffer->end(), p->elements, p->elements + p->nElements); + } else { + for (sal_Int32 i = 0; i != p->nElements; ++i) { + writeValue(buffer, ctd, p->elements + i * ctd.get()->nSize); + } + } + break; + } + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + writeMemberValues(buffer, type, value); + break; + case typelib_TypeClass_INTERFACE: + writeOid( + buffer, + bridge_->registerOutgoingInterface( + css::uno::UnoInterfaceReference( + *static_cast< uno_Interface * const * >(value)), + type)); + break; + default: + OSL_ASSERT(false); // this cannot happen + break; + } +} + +void Marshal::writeMemberValues( + std::vector< unsigned char > * buffer, + css::uno::TypeDescription const & type, void const * aggregateValue) +{ + OSL_ASSERT( + type.is() && + (type.get()->eTypeClass == typelib_TypeClass_STRUCT || + type.get()->eTypeClass == typelib_TypeClass_EXCEPTION) && + aggregateValue != 0); + type.makeComplete(); + typelib_CompoundTypeDescription * ctd = + reinterpret_cast< typelib_CompoundTypeDescription * >(type.get()); + if (ctd->pBaseTypeDescription != 0) { + writeMemberValues( + buffer, + css::uno::TypeDescription(&ctd->pBaseTypeDescription->aBase), + aggregateValue); + } + for (sal_Int32 i = 0; i != ctd->nMembers; ++i) { + writeValue( + buffer, css::uno::TypeDescription(ctd->ppTypeRefs[i]), + (static_cast< char const * >(aggregateValue) + + ctd->pMemberOffsets[i])); + } +} + +} diff --git a/binaryurp/source/marshal.hxx b/binaryurp/source/marshal.hxx new file mode 100755 index 000000000000..a922ec1008f6 --- /dev/null +++ b/binaryurp/source/marshal.hxx @@ -0,0 +1,95 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_MARSHAL_HXX +#define INCLUDED_BINARYURP_SOURCE_MARSHAL_HXX + +#include "sal/config.h" + +#include <vector> + +#include "boost/noncopyable.hpp" +#include "rtl/byteseq.hxx" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typedescription.hxx" + +namespace binaryurp { + class BinaryAny; + class Bridge; + struct WriterState; +} + +namespace binaryurp { + +class Marshal: private boost::noncopyable { +public: + Marshal(rtl::Reference< Bridge > const & bridge, WriterState & state); + + ~Marshal(); + + static void write8(std::vector< unsigned char > * buffer, sal_uInt8 value); + + static void write16( + std::vector< unsigned char > * buffer, sal_uInt16 value); + + static void write32( + std::vector< unsigned char > * buffer, sal_uInt32 value); + + void writeValue( + std::vector< unsigned char > * buffer, + com::sun::star::uno::TypeDescription const & type, + BinaryAny const & value); + + void writeType( + std::vector< unsigned char > * buffer, + com::sun::star::uno::TypeDescription const & value); + + void writeOid( + std::vector< unsigned char > * buffer, rtl::OUString const & oid); + + void writeTid( + std::vector< unsigned char > * buffer, rtl::ByteSequence const & tid); + +private: + void writeValue( + std::vector< unsigned char > * buffer, + com::sun::star::uno::TypeDescription const & type, void const * value); + + void writeMemberValues( + std::vector< unsigned char > * buffer, + com::sun::star::uno::TypeDescription const & type, + void const * aggregateValue); + + rtl::Reference< Bridge > bridge_; + WriterState & state_; +}; + +} + +#endif diff --git a/binaryurp/source/outgoingrequest.hxx b/binaryurp/source/outgoingrequest.hxx new file mode 100644 index 000000000000..7fe67bf96a3b --- /dev/null +++ b/binaryurp/source/outgoingrequest.hxx @@ -0,0 +1,55 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_OUTGOINGREQUEST_HXX +#define INCLUDED_BINARYURP_SOURCE_OUTGOINGREQUEST_HXX + +#include "sal/config.h" + +#include "typelib/typedescription.hxx" + +namespace binaryurp { + +struct OutgoingRequest { + enum Kind { KIND_NORMAL, KIND_REQUEST_CHANGE, KIND_COMMIT_CHANGE }; + + OutgoingRequest( + Kind theKind, com::sun::star::uno::TypeDescription const & theMember, + bool theSetter): + kind(theKind), member(theMember), setter(theSetter) + {} + + Kind kind; + + com::sun::star::uno::TypeDescription member; + + bool setter; +}; + +} + +#endif diff --git a/binaryurp/source/outgoingrequests.cxx b/binaryurp/source/outgoingrequests.cxx new file mode 100644 index 000000000000..388b7755466f --- /dev/null +++ b/binaryurp/source/outgoingrequests.cxx @@ -0,0 +1,80 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include "com/sun/star/uno/RuntimeException.hpp" +#include "rtl/byteseq.hxx" +#include "osl/mutex.hxx" + +#include "lessoperators.hxx" +#include "outgoingrequest.hxx" +#include "outgoingrequests.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +} + +OutgoingRequests::OutgoingRequests() {} + +OutgoingRequests::~OutgoingRequests() {} + +void OutgoingRequests::push( + rtl::ByteSequence const & tid, OutgoingRequest const & request) +{ + osl::MutexGuard g(mutex_); + map_[tid].push_back(request); +} + +OutgoingRequest OutgoingRequests::top(rtl::ByteSequence const & tid) { + osl::MutexGuard g(mutex_); + Map::iterator i(map_.find(tid)); + if (i == map_.end()) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("URP: reply for unknown TID")), + css::uno::Reference< css::uno::XInterface >()); + } + OSL_ASSERT(!i->second.empty()); + return i->second.back(); +} + +void OutgoingRequests::pop(rtl::ByteSequence const & tid) throw () { + osl::MutexGuard g(mutex_); + Map::iterator i(map_.find(tid)); + OSL_ASSERT(i != map_.end()); + i->second.pop_back(); + if (i->second.empty()) { + map_.erase(i); + } +} + +} diff --git a/binaryurp/source/outgoingrequests.hxx b/binaryurp/source/outgoingrequests.hxx new file mode 100644 index 000000000000..92ee622bf682 --- /dev/null +++ b/binaryurp/source/outgoingrequests.hxx @@ -0,0 +1,65 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_OUTGOINGREQUESTS_HXX +#define INCLUDED_BINARYURP_SOURCE_OUTGOINGREQUESTS_HXX + +#include "sal/config.h" + +#include <map> +#include <vector> + +#include "boost/noncopyable.hpp" +#include "osl/mutex.hxx" + +namespace binaryurp { struct OutgoingRequest; } +namespace rtl { class ByteSequence; } + +namespace binaryurp { + +class OutgoingRequests: private boost::noncopyable { +public: + OutgoingRequests(); + + ~OutgoingRequests(); + + void push(rtl::ByteSequence const & tid, OutgoingRequest const & request); + + OutgoingRequest top(rtl::ByteSequence const & tid); + + void pop(rtl::ByteSequence const & tid) throw (); + +private: + typedef std::map< rtl::ByteSequence, std::vector< OutgoingRequest > > Map; + + osl::Mutex mutex_; + Map map_; +}; + +} + +#endif diff --git a/binaryurp/source/proxy.cxx b/binaryurp/source/proxy.cxx new file mode 100644 index 000000000000..876199e7bc17 --- /dev/null +++ b/binaryurp/source/proxy.cxx @@ -0,0 +1,260 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <exception> +#include <vector> + +#include "cppuhelper/exc_hlp.hxx" +#include "osl/diagnose.h" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typedescription.h" +#include "typelib/typedescription.hxx" +#include "uno/any2.h" +#include "uno/dispatcher.h" +#include "uno/dispatcher.hxx" + +#include "binaryany.hxx" +#include "bridge.hxx" +#include "proxy.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +extern "C" void SAL_CALL proxy_acquireInterface(uno_Interface * pInterface) { + OSL_ASSERT(pInterface != 0); + static_cast< Proxy * >(pInterface)->do_acquire(); +} + +extern "C" void SAL_CALL proxy_releaseInterface(uno_Interface * pInterface) { + OSL_ASSERT(pInterface != 0); + static_cast< Proxy * >(pInterface)->do_release(); +} + +extern "C" void SAL_CALL proxy_dispatchInterface( + uno_Interface * pUnoI, typelib_TypeDescription const * pMemberType, + void * pReturn, void ** pArgs, uno_Any ** ppException) +{ + OSL_ASSERT(pUnoI != 0); + static_cast< Proxy * >(pUnoI)->do_dispatch( + pMemberType, pReturn, pArgs, ppException); +} + +} + +Proxy::Proxy( + rtl::Reference< Bridge > const & bridge, rtl::OUString const & oid, + css::uno::TypeDescription const & type): + bridge_(bridge), oid_(oid), type_(type), references_(1) +{ + OSL_ASSERT(bridge.is()); + acquire = &proxy_acquireInterface; + release = &proxy_releaseInterface; + pDispatcher = &proxy_dispatchInterface; +} + +rtl::OUString Proxy::getOid() const { + return oid_; +} + +css::uno::TypeDescription Proxy::getType() const { + return type_; +} + +void Proxy::do_acquire() { + if (osl_incrementInterlockedCount(&references_) == 1) { + bridge_->resurrectProxy(*this); + } +} + +void Proxy::do_release() { + if (osl_decrementInterlockedCount(&references_) == 0) { + bridge_->revokeProxy(*this); + } +} + +void Proxy::do_free() { + bridge_->freeProxy(*this); + delete this; +} + +void Proxy::do_dispatch( + typelib_TypeDescription const * member, void * returnValue, + void ** arguments, uno_Any ** exception) const +{ + try { + try { + do_dispatch_throw(member, returnValue, arguments, exception); + } catch (std::exception & e) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("caught C++ exception: ")) + + rtl::OStringToOUString( + rtl::OString(e.what()), RTL_TEXTENCODING_ASCII_US)), + css::uno::Reference< css::uno::XInterface >()); + // best-effort string conversion + } + } catch (css::uno::RuntimeException &) { + css::uno::Any exc(cppu::getCaughtException()); + uno_copyAndConvertData( + *exception, &exc, + (css::uno::TypeDescription(cppu::UnoType< css::uno::Any >::get()). + get()), + bridge_->getCppToBinaryMapping().get()); + } +} + +bool Proxy::isProxy( + rtl::Reference< Bridge > const & bridge, + css::uno::UnoInterfaceReference const & object, rtl::OUString * oid) +{ + OSL_ASSERT(object.is()); + return object.m_pUnoI->acquire == &proxy_acquireInterface && + static_cast< Proxy * >(object.m_pUnoI)->isProxy(bridge, oid); +} + +Proxy::~Proxy() {} + +void Proxy::do_dispatch_throw( + typelib_TypeDescription const * member, void * returnValue, + void ** arguments, uno_Any ** exception) const +{ + //TODO: Optimize queryInterface: + OSL_ASSERT(member != 0); + bool setter = false; + std::vector< BinaryAny > inArgs; + switch (member->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + setter = returnValue == 0; + if (setter) { + inArgs.push_back( + BinaryAny( + css::uno::TypeDescription( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription const * >( + member)-> + pAttributeTypeRef), + arguments[0])); + } + break; + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription const * mtd = + reinterpret_cast< + typelib_InterfaceMethodTypeDescription const * >(member); + for (sal_Int32 i = 0; i != mtd->nParams; ++i) { + if (mtd->pParams[i].bIn) { + inArgs.push_back( + BinaryAny( + css::uno::TypeDescription(mtd->pParams[i].pTypeRef), + arguments[i])); + } + } + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + BinaryAny ret; + std::vector< BinaryAny > outArgs; + if (bridge_->makeCall( + oid_, + css::uno::TypeDescription( + const_cast< typelib_TypeDescription * >(member)), + setter, inArgs, &ret, &outArgs)) + { + OSL_ASSERT( + ret.getType().get()->eTypeClass == typelib_TypeClass_EXCEPTION); + uno_any_construct( + *exception, ret.getValue(ret.getType()), ret.getType().get(), 0); + } else { + switch (member->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + if (!setter) { + css::uno::TypeDescription t( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription const * >( + member)-> + pAttributeTypeRef); + uno_copyData(returnValue, ret.getValue(t), t.get(), 0); + } + break; + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription const * mtd = + reinterpret_cast< + typelib_InterfaceMethodTypeDescription const * >( + member); + css::uno::TypeDescription t(mtd->pReturnTypeRef); + if (t.get()->eTypeClass != typelib_TypeClass_VOID) { + uno_copyData(returnValue, ret.getValue(t), t.get(), 0); + } + std::vector< BinaryAny >::iterator i(outArgs.begin()); + for (sal_Int32 j = 0; j != mtd->nParams; ++j) { + if (mtd->pParams[j].bOut) { + css::uno::TypeDescription pt(mtd->pParams[j].pTypeRef); + if (mtd->pParams[j].bIn) { + uno_assignData( + arguments[j], pt.get(), i++->getValue(pt), + pt.get(), 0, 0, 0); + } else { + uno_copyData( + arguments[j], i++->getValue(pt), pt.get(), 0); + } + } + } + OSL_ASSERT(i == outArgs.end()); + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + *exception = 0; + } +} + +bool Proxy::isProxy( + rtl::Reference< Bridge > const & bridge, rtl::OUString * oid) const +{ + OSL_ASSERT(oid != 0); + if (bridge == bridge_) { + *oid = oid_; + return true; + } else { + return false; + } +} + +} diff --git a/binaryurp/source/proxy.hxx b/binaryurp/source/proxy.hxx new file mode 100644 index 000000000000..c67ab4eb522a --- /dev/null +++ b/binaryurp/source/proxy.hxx @@ -0,0 +1,92 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_PROXY_HXX +#define INCLUDED_BINARYURP_SOURCE_PROXY_HXX + +#include "sal/config.h" + +#include "boost/noncopyable.hpp" +#include "osl/interlck.h" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" +#include "typelib/typedescription.h" +#include "typelib/typedescription.hxx" +#include "uno/any2.h" +#include "uno/dispatcher.h" + +namespace binaryurp { class Bridge; } +namespace com { namespace sun { namespace star { namespace uno { + class UnoInterfaceReference; +} } } } + +namespace binaryurp { + +class Proxy: public uno_Interface, private boost::noncopyable { +public: + Proxy( + rtl::Reference< Bridge > const & bridge, rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type); + + rtl::OUString getOid() const; + + com::sun::star::uno::TypeDescription getType() const; + + void do_acquire(); + + void do_release(); + + void do_free(); + + void do_dispatch( + typelib_TypeDescription const * member, void * returnValue, + void ** arguments, uno_Any ** exception) const; + + static bool isProxy( + rtl::Reference< Bridge > const & bridge, + com::sun::star::uno::UnoInterfaceReference const & object, + rtl::OUString * oid); + +private: + ~Proxy(); + + void do_dispatch_throw( + typelib_TypeDescription const * member, void * returnValue, + void ** arguments, uno_Any ** exception) const; + + bool isProxy(rtl::Reference< Bridge > const & bridge, rtl::OUString * oid) + const; + + rtl::Reference< Bridge > bridge_; + rtl::OUString oid_; + com::sun::star::uno::TypeDescription type_; + oslInterlockedCount references_; +}; + +} + +#endif diff --git a/binaryurp/source/reader.cxx b/binaryurp/source/reader.cxx new file mode 100755 index 000000000000..f622fb5b0c42 --- /dev/null +++ b/binaryurp/source/reader.cxx @@ -0,0 +1,553 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <exception> +#include <memory> +#include <vector> + +#include "com/sun/star/connection/XConnection.hpp" +#include "com/sun/star/io/IOException.hpp" +#include "com/sun/star/uno/Any.hxx" +#include "com/sun/star/uno/Exception.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/Type.hxx" +#include "com/sun/star/uno/XCurrentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppu/unotype.hxx" +#include "osl/diagnose.h" +#include "rtl/byteseq.h" +#include "rtl/string.h" +#include "rtl/textenc.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typeclass.h" +#include "typelib/typedescription.h" +#include "typelib/typedescription.hxx" +#include "uno/lbnames.h" + +#include "binaryany.hxx" +#include "bridge.hxx" +#include "incomingreply.hxx" +#include "incomingrequest.hxx" +#include "outgoingrequest.hxx" +#include "reader.hxx" +#include "specialfunctionids.hxx" +#include "unmarshal.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +css::uno::Sequence< sal_Int8 > read( + css::uno::Reference< css::connection::XConnection > const & connection, + sal_uInt32 size, bool eofOk) +{ + OSL_ASSERT(connection.is()); + if (size > SAL_MAX_INT32) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Reader: block size too large")), + css::uno::Reference< css::uno::XInterface >()); + } + css::uno::Sequence< sal_Int8 > buf; + sal_Int32 n = connection->read(buf, static_cast< sal_Int32 >(size)); + if (n == 0 && eofOk) { + return css::uno::Sequence< sal_Int8 >(); + } + if (n != static_cast< sal_Int32 >(size)) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Reader: premature end of input")), + css::uno::Reference< css::uno::XInterface >()); + } + OSL_ASSERT(buf.getLength() == static_cast< sal_Int32 >(size)); + return buf; +} + +extern "C" void SAL_CALL request(void * pThreadSpecificData) { + OSL_ASSERT(pThreadSpecificData != 0); + std::auto_ptr< IncomingRequest >( + static_cast< IncomingRequest * >(pThreadSpecificData))-> + execute(); +} + +} + +Reader::Reader(rtl::Reference< Bridge > const & bridge): bridge_(bridge) { + OSL_ASSERT(bridge.is()); + acquire(); +} + +Reader::~Reader() {} + +void Reader::run() { + setName("binaryurpReader"); + try { + bridge_->sendRequestChangeRequest(); + css::uno::Reference< css::connection::XConnection > con( + bridge_->getConnection()); + for (;;) { + css::uno::Sequence< sal_Int8 > s(read(con, 8, true)); + if (s.getLength() == 0) { + break; + } + Unmarshal header(bridge_, state_, s); + sal_uInt32 size = header.read32(); + sal_uInt32 count = header.read32(); + header.done(); + if (count == 0) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Reader: block with zero message count" + " received")), + css::uno::Reference< css::uno::XInterface >()); + } + Unmarshal block(bridge_, state_, read(con, size, false)); + for (sal_uInt32 i = 0; i != count; ++i) { + readMessage(block); + } + block.done(); + } + } catch (css::uno::Exception & e) { + OSL_TRACE( + OSL_LOG_PREFIX "caught UNO exception '%s'", + rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); + } catch (std::exception & e) { + OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what()); + } + bridge_->terminate(); +} + +void Reader::onTerminated() { + release(); +} + +void Reader::readMessage(Unmarshal & unmarshal) { + sal_uInt8 flags1 = unmarshal.read8(); + bool newType; + bool newOid; + bool newTid; + bool forceSynchronous; + sal_uInt16 functionId; + if ((flags1 & 0x80) != 0) { // bit 7: LONGHEADER + if ((flags1 & 0x40) == 0) { // bit 6: REQUEST + readReplyMessage(unmarshal, flags1); + return; + } + newType = (flags1 & 0x20) != 0; // bit 5: NEWTYPE + newOid = (flags1 & 0x10) != 0; // bit 4: NEWOID + newTid = (flags1 & 0x08) != 0; // bit 3: NEWTID + if ((flags1 & 0x01) != 0) { // bit 0: MOREFLAGSS + sal_uInt8 flags2 = unmarshal.read8(); + forceSynchronous = (flags2 & 0x80) != 0; // bit 7: MUSTREPLY + if (((flags2 & 0x40) != 0) != forceSynchronous) { + // bit 6: SYNCHRONOUS + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: request message with MUSTREPLY != SYNCHRONOUS" + " received")), + css::uno::Reference< css::uno::XInterface >()); + } + } else { + forceSynchronous = false; + } + functionId = ((flags1 & 0x04) != 0) // bit 2: FUNCTIONID16 + ? unmarshal.read16() : unmarshal.read8(); + } else { + newType = false; + newOid = false; + newTid = false; + forceSynchronous = false; + functionId = ((flags1 & 0x40) != 0) // bit 6: FUNCTIONID14 + ? ((flags1 & 0x3F) << 8) | unmarshal.read8() : flags1 & 0x3F; + } + css::uno::TypeDescription type; + if (newType) { + type = unmarshal.readType(); + lastType_ = type; + } else { + if (!lastType_.is()) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: request message with NEWTYPE received when last" + " interface type has not yet been set")), + css::uno::Reference< css::uno::XInterface >()); + } + type = lastType_; + } + rtl::OUString oid; + if (newOid) { + oid = unmarshal.readOid(); + if (oid.getLength() == 0) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: emtpy OID")), + css::uno::Reference< css::uno::XInterface >()); + } + lastOid_ = oid; + } else { + if (lastOid_.getLength() == 0) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: request message with NEWOID received when last" + " OID has not yet been set")), + css::uno::Reference< css::uno::XInterface >()); + } + oid = lastOid_; + } + rtl::ByteSequence tid(getTid(unmarshal, newTid)); + lastTid_ = tid; + type.makeComplete(); + if (type.get()->eTypeClass != typelib_TypeClass_INTERFACE) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: request message with non-interface interface type" + " received")), + css::uno::Reference< css::uno::XInterface >()); + } + typelib_InterfaceTypeDescription * itd = + reinterpret_cast< typelib_InterfaceTypeDescription * >(type.get()); + if (functionId >= itd->nMapFunctionIndexToMemberIndex) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: request message with unknown function ID received")), + css::uno::Reference< css::uno::XInterface >()); + } + sal_Int32 memberId = itd->pMapFunctionIndexToMemberIndex[functionId]; + css::uno::TypeDescription memberTd(itd->ppAllMembers[memberId]); + memberTd.makeComplete(); + OSL_ASSERT(memberTd.is()); + bool protProps = bridge_->isProtocolPropertiesRequest(oid, type); + bool ccMode = !protProps && functionId != SPECIAL_FUNCTION_ID_RELEASE && + bridge_->isCurrentContextMode(); + css::uno::UnoInterfaceReference cc; + if (ccMode) { + css::uno::TypeDescription t( + cppu::UnoType< css::uno::Reference< css::uno::XCurrentContext > >:: + get()); + cc.set( + *static_cast< uno_Interface ** >( + unmarshal.readValue(t).getValue(t))); + } + bool synchronous; + if (memberTd.get()->eTypeClass == typelib_TypeClass_INTERFACE_METHOD && + (reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( + memberTd.get())-> + bOneWay)) + { + synchronous = forceSynchronous; + } else { + if (forceSynchronous) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: synchronous request message with non-oneway" + " function ID received")), + css::uno::Reference< css::uno::XInterface >()); + } + synchronous = true; + } + bool setter = false; + std::vector< BinaryAny > inArgs; + switch (memberTd.get()->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + setter = itd->pMapMemberIndexToFunctionIndex[memberId] != functionId; + // pMapMemberIndexToFunctionIndex contains function index of + // attribute getter + if (setter) { + inArgs.push_back( + unmarshal.readValue( + css::uno::TypeDescription( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + memberTd.get())-> + pAttributeTypeRef))); + } + break; + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription * mtd = + reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( + memberTd.get()); + for (sal_Int32 i = 0; i != mtd->nParams; ++i) { + if (mtd->pParams[i].bIn) { + inArgs.push_back( + unmarshal.readValue( + css::uno::TypeDescription( + mtd->pParams[i].pTypeRef))); + } + } + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + bridge_->incrementCalls( + !protProps && functionId != SPECIAL_FUNCTION_ID_RELEASE); + if (protProps) { + switch (functionId) { + case SPECIAL_FUNCTION_ID_REQUEST_CHANGE: + bridge_->handleRequestChangeRequest(tid, inArgs); + break; + case SPECIAL_FUNCTION_ID_COMMIT_CHANGE: + bridge_->handleCommitChangeRequest(tid, inArgs); + break; + default: + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: request message with UrpProtocolProperties OID" + " and unknown function ID received")), + css::uno::Reference< css::uno::XInterface >()); + } + } else { + css::uno::UnoInterfaceReference obj; + switch (functionId) { + case SPECIAL_FUNCTION_ID_QUERY_INTERFACE: + obj = bridge_->findStub(oid, type); + if (!obj.is()) { + OSL_ASSERT( + inArgs.size() == 1 + && inArgs[0].getType().equals( + css::uno::TypeDescription( + cppu::UnoType< css::uno::Type >::get()))); + if (!(type.equals( + css::uno::TypeDescription( + cppu::UnoType< + css::uno::Reference< + css::uno::XInterface > >::get())) + && (css::uno::TypeDescription( + *static_cast< + typelib_TypeDescriptionReference ** >( + inArgs[0].getValue(inArgs[0].getType()))). + equals( + css::uno::TypeDescription( + cppu::UnoType< + css::uno::Reference< + css::uno::XInterface > >::get()))))) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: queryInterface request message with" + " unknown OID received")), + css::uno::Reference< css::uno::XInterface >()); + } + } + break; + case SPECIAL_FUNCTION_ID_RESERVED: + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: request message with unknown function ID 1" + " received")), + css::uno::Reference< css::uno::XInterface >()); + case SPECIAL_FUNCTION_ID_RELEASE: + break; + default: + obj = bridge_->findStub(oid, type); + if (!obj.is()) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: request message with unknown OID received")), + css::uno::Reference< css::uno::XInterface >()); + } + break; + } + std::auto_ptr< IncomingRequest > req( + new IncomingRequest( + bridge_, tid, oid, obj, type, functionId, synchronous, memberTd, + setter, inArgs, ccMode, cc)); + if (synchronous) { + bridge_->incrementActiveCalls(); + } + uno_threadpool_putJob( + bridge_->getThreadPool(), tid.getHandle(), req.get(), &request, + !synchronous); + req.release(); + } +} + +void Reader::readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1) { + rtl::ByteSequence tid(getTid(unmarshal, (flags1 & 0x08) != 0)); + // bit 3: NEWTID + lastTid_ = tid; + OutgoingRequest req(bridge_->lastOutgoingRequest(tid)); + bool exc = (flags1 & 0x20) != 0; // bit 5: EXCEPTION + BinaryAny ret; + std::vector< BinaryAny > outArgs; + if (exc) { + ret = unmarshal.readValue( + css::uno::TypeDescription(cppu::UnoType< css::uno::Any >::get())); + if (!typelib_typedescription_isAssignableFrom( + (css::uno::TypeDescription( + cppu::UnoType< css::uno::RuntimeException >::get()). + get()), + ret.getType().get())) + { + sal_Int32 n = 0; + typelib_TypeDescriptionReference ** p = 0; + switch (req.member.get()->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + { + typelib_InterfaceAttributeTypeDescription * atd = + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + req.member.get()); + n = req.setter ? atd->nSetExceptions : atd->nGetExceptions; + p = req.setter + ? atd->ppSetExceptions : atd->ppGetExceptions; + break; + } + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription * mtd = + reinterpret_cast< + typelib_InterfaceMethodTypeDescription * >( + req.member.get()); + n = mtd->nExceptions; + p = mtd->ppExceptions; + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + bool ok = false; + for (sal_Int32 i = 0; i != n; ++i) { + if (typelib_typedescriptionreference_isAssignableFrom( + p[i], + reinterpret_cast< typelib_TypeDescriptionReference * >( + ret.getType().get()))) + { + ok = true; + break; + } + } + if (!ok) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: reply message with bad exception type" + " received")), + css::uno::Reference< css::uno::XInterface >()); + } + } + } else { + switch (req.member.get()->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + if (!req.setter) { + ret = unmarshal.readValue( + css::uno::TypeDescription( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + req.member.get())-> + pAttributeTypeRef)); + } + break; + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription * mtd = + reinterpret_cast< + typelib_InterfaceMethodTypeDescription * >( + req.member.get()); + ret = unmarshal.readValue( + css::uno::TypeDescription(mtd->pReturnTypeRef)); + for (sal_Int32 i = 0; i != mtd->nParams; ++i) { + if (mtd->pParams[i].bOut) { + outArgs.push_back( + unmarshal.readValue( + css::uno::TypeDescription( + mtd->pParams[i].pTypeRef))); + } + } + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + } + switch (req.kind) { + case OutgoingRequest::KIND_NORMAL: + { + std::auto_ptr< IncomingReply > resp( + new IncomingReply(exc, ret, outArgs)); + uno_threadpool_putJob( + bridge_->getThreadPool(), tid.getHandle(), resp.get(), 0, + false); + resp.release(); + break; + } + case OutgoingRequest::KIND_REQUEST_CHANGE: + OSL_ASSERT(outArgs.empty()); + bridge_->handleRequestChangeReply(exc, ret); + break; + case OutgoingRequest::KIND_COMMIT_CHANGE: + OSL_ASSERT(outArgs.empty()); + bridge_->handleCommitChangeReply(exc, ret); + break; + default: + OSL_ASSERT(false); // this cannot happen + break; + } +} + +rtl::ByteSequence Reader::getTid(Unmarshal & unmarshal, bool newTid) const { + if (newTid) { + return unmarshal.readTid(); + } + if (lastTid_.getLength() == 0) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "URP: message with NEWTID received when last TID has not" + " yet been set")), + css::uno::Reference< css::uno::XInterface >()); + } + return lastTid_; +} + +} diff --git a/binaryurp/source/reader.hxx b/binaryurp/source/reader.hxx new file mode 100644 index 000000000000..37d0b9462ae4 --- /dev/null +++ b/binaryurp/source/reader.hxx @@ -0,0 +1,89 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_READER_HXX +#define INCLUDED_BINARYURP_SOURCE_READER_HXX + +#include "sal/config.h" + +#include <cstddef> + +#include "boost/noncopyable.hpp" +#include "osl/thread.hxx" +#include "rtl/byteseq.hxx" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "salhelper/simplereferenceobject.hxx" +#include "typelib/typedescription.hxx" + +#include "readerstate.hxx" + +namespace binaryurp { + class BinaryAny; + class Bridge; + class Unmarshal; +} + +namespace binaryurp { + +class Reader: + public osl::Thread, public salhelper::SimpleReferenceObject, + private boost::noncopyable +{ +public: + static void * operator new(std::size_t size) + { return Thread::operator new(size); } + + static void operator delete(void * pointer) + { Thread::operator delete(pointer); } + + explicit Reader(rtl::Reference< Bridge > const & bridge); + +private: + virtual ~Reader(); + + virtual void SAL_CALL run(); + + virtual void SAL_CALL onTerminated(); + + void readMessage(Unmarshal & unmarshal); + + void readReplyMessage(Unmarshal & unmarshal, sal_uInt8 flags1); + + rtl::ByteSequence getTid(Unmarshal & unmarshal, bool newTid) const; + + rtl::Reference< Bridge > bridge_; + com::sun::star::uno::TypeDescription lastType_; + rtl::OUString lastOid_; + rtl::ByteSequence lastTid_; + ReaderState state_; +}; + +} + +#endif diff --git a/binaryurp/source/readerstate.hxx b/binaryurp/source/readerstate.hxx new file mode 100644 index 000000000000..ef7ed4d7196f --- /dev/null +++ b/binaryurp/source/readerstate.hxx @@ -0,0 +1,52 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_READERSTATE_HXX +#define INCLUDED_BINARYURP_SOURCE_READERSTATE_HXX + +#include "sal/config.h" + +#include "boost/noncopyable.hpp" +#include "rtl/byteseq.hxx" +#include "rtl/ustring.hxx" +#include "typelib/typedescription.hxx" + +#include "cache.hxx" + +namespace binaryurp { + +struct ReaderState: private boost::noncopyable { + com::sun::star::uno::TypeDescription typeCache[cache::size]; + + rtl::OUString oidCache[cache::size]; + + rtl::ByteSequence tidCache[cache::size]; +}; + +} + +#endif diff --git a/binaryurp/source/specialfunctionids.hxx b/binaryurp/source/specialfunctionids.hxx new file mode 100644 index 000000000000..a2a59791ba09 --- /dev/null +++ b/binaryurp/source/specialfunctionids.hxx @@ -0,0 +1,49 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_SPECIALFUNCTIONIDS_HXX +#define INCLUDED_BINARYURP_SOURCE_SPECIALFUNCTIONIDS_HXX + +#include "sal/config.h" + +namespace binaryurp { + +enum SpecialFunctionIds { + SPECIAL_FUNCTION_ID_QUERY_INTERFACE = 0, + + SPECIAL_FUNCTION_ID_RESERVED = 1, + + SPECIAL_FUNCTION_ID_RELEASE = 2, + + SPECIAL_FUNCTION_ID_REQUEST_CHANGE = 4, + + SPECIAL_FUNCTION_ID_COMMIT_CHANGE = 5 +}; + +} + +#endif diff --git a/binaryurp/source/unmarshal.cxx b/binaryurp/source/unmarshal.cxx new file mode 100755 index 000000000000..62f8683e33ad --- /dev/null +++ b/binaryurp/source/unmarshal.cxx @@ -0,0 +1,563 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <cstdlib> +#include <new> +#include <vector> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/io/IOException.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppu/unotype.hxx" +#include "osl/diagnose.h" +#include "rtl/byteseq.hxx" +#include "rtl/ref.hxx" +#include "rtl/textcvt.h" +#include "rtl/textenc.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "typelib/typeclass.h" +#include "typelib/typedescription.h" +#include "typelib/typedescription.hxx" +#include "uno/any2.h" +#include "uno/data.h" +#include "uno/dispatcher.hxx" + +#include "binaryany.hxx" +#include "bridge.hxx" +#include "cache.hxx" +#include "readerstate.hxx" +#include "unmarshal.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +void * allocate(sal_Size size) { + void * p = rtl_allocateMemory(size); + if (p == 0) { + throw std::bad_alloc(); + } + return p; +} + +std::vector< BinaryAny >::iterator copyMemberValues( + css::uno::TypeDescription const & type, + std::vector< BinaryAny >::iterator const & it, void * buffer) throw () +{ + OSL_ASSERT( + type.is() && + (type.get()->eTypeClass == typelib_TypeClass_STRUCT || + type.get()->eTypeClass == typelib_TypeClass_EXCEPTION) && + buffer != 0); + type.makeComplete(); + std::vector< BinaryAny >::iterator i(it); + typelib_CompoundTypeDescription * ctd = + reinterpret_cast< typelib_CompoundTypeDescription * >(type.get()); + if (ctd->pBaseTypeDescription != 0) { + i = copyMemberValues( + css::uno::TypeDescription(&ctd->pBaseTypeDescription->aBase), i, + buffer); + } + for (sal_Int32 j = 0; j != ctd->nMembers; ++j) { + uno_type_copyData( + static_cast< char * >(buffer) + ctd->pMemberOffsets[j], + const_cast< void * >( + i++->getValue(css::uno::TypeDescription(ctd->ppTypeRefs[j]))), + ctd->ppTypeRefs[j], 0); + } + return i; +} + +} + +Unmarshal::Unmarshal( + rtl::Reference< Bridge > const & bridge, ReaderState & state, + css::uno::Sequence< sal_Int8 > const & buffer): + bridge_(bridge), state_(state), buffer_(buffer) +{ + data_ = reinterpret_cast< sal_uInt8 const * >(buffer_.getConstArray()); + end_ = data_ + buffer_.getLength(); +} + +Unmarshal::~Unmarshal() {} + +sal_uInt8 Unmarshal::read8() { + check(1); + return *data_++; +} + +sal_uInt16 Unmarshal::read16() { + check(2); + sal_uInt16 n = static_cast< sal_uInt16 >(*data_++) << 8; + return n | *data_++; +} + +sal_uInt32 Unmarshal::read32() { + check(4); + sal_uInt32 n = static_cast< sal_uInt32 >(*data_++) << 24; + n |= static_cast< sal_uInt32 >(*data_++) << 16; + n |= static_cast< sal_uInt32 >(*data_++) << 8; + return n | *data_++; +} + +css::uno::TypeDescription Unmarshal::readType() { + sal_uInt8 flags = read8(); + typelib_TypeClass tc = static_cast< typelib_TypeClass >(flags & 0x7F); + switch (tc) { + case typelib_TypeClass_VOID: + case typelib_TypeClass_BOOLEAN: + case typelib_TypeClass_BYTE: + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + case typelib_TypeClass_FLOAT: + case typelib_TypeClass_DOUBLE: + case typelib_TypeClass_CHAR: + case typelib_TypeClass_STRING: + case typelib_TypeClass_TYPE: + case typelib_TypeClass_ANY: + if ((flags & 0x80) != 0) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: cache flag of simple type is" + " set")), + css::uno::Reference< css::uno::XInterface >()); + } + return css::uno::TypeDescription( + *typelib_static_type_getByTypeClass( + static_cast< typelib_TypeClass >(tc))); + case typelib_TypeClass_SEQUENCE: + case typelib_TypeClass_ENUM: + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + case typelib_TypeClass_INTERFACE: + { + sal_uInt16 idx = readCacheIndex(); + if ((flags & 0x80) == 0) { + if (idx == cache::ignore || !state_.typeCache[idx].is()) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: unknown type cache" + " index")), + css::uno::Reference< css::uno::XInterface >()); + } + return state_.typeCache[idx]; + } else { + css::uno::TypeDescription t(readString()); + if (!t.is() || + t.get()->eTypeClass != static_cast< typelib_TypeClass >(tc)) + { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: type with unknown" + " name")), + css::uno::Reference< css::uno::XInterface >()); + } + for (css::uno::TypeDescription t2(t); + t2.get()->eTypeClass == typelib_TypeClass_SEQUENCE;) + { + t2.makeComplete(); + t2 = css::uno::TypeDescription( + reinterpret_cast< typelib_IndirectTypeDescription * >( + t2.get())->pType); + if (!t2.is()) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: sequence type with" + " unknown component type")), + css::uno::Reference< css::uno::XInterface >()); + } + switch (t2.get()->eTypeClass) { + case typelib_TypeClass_VOID: + case typelib_TypeClass_EXCEPTION: + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: sequence type with" + " bad component type")), + css::uno::Reference< css::uno::XInterface >()); + default: + break; + } + } + if (idx != cache::ignore) { + state_.typeCache[idx] = t; + } + return t; + } + } + default: + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: type of unknown type class")), + css::uno::Reference< css::uno::XInterface >()); + } +} + +rtl::OUString Unmarshal::readOid() { + rtl::OUString oid(readString()); + for (sal_Int32 i = 0; i != oid.getLength(); ++i) { + if (oid[i] > 0x7F) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: OID contains non-ASCII" + " character")), + css::uno::Reference< css::uno::XInterface >()); + } + } + sal_uInt16 idx = readCacheIndex(); + if (oid.getLength() == 0 && idx != cache::ignore) { + if (state_.oidCache[idx].getLength() == 0) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: unknown OID cache index")), + css::uno::Reference< css::uno::XInterface >()); + } + return state_.oidCache[idx]; + } + if (idx != cache::ignore) { + state_.oidCache[idx] = oid; + } + return oid; +} + +rtl::ByteSequence Unmarshal::readTid() { + rtl::ByteSequence tid( + *static_cast< sal_Sequence * const * >( + readSequence( + css::uno::TypeDescription( + cppu::UnoType< css::uno::Sequence< sal_Int8 > >::get())). + getValue( + css::uno::TypeDescription( + cppu::UnoType< css::uno::Sequence< sal_Int8 > >::get())))); + sal_uInt16 idx = readCacheIndex(); + if (tid.getLength() == 0) { + if (idx == cache::ignore || state_.tidCache[idx].getLength() == 0) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: unknown TID cache index")), + css::uno::Reference< css::uno::XInterface >()); + } + return state_.tidCache[idx]; + } + if (idx != cache::ignore) { + state_.tidCache[idx] = tid; + } + return tid; +} + +BinaryAny Unmarshal::readValue(css::uno::TypeDescription const & type) { + OSL_ASSERT(type.is()); + switch (type.get()->eTypeClass) { + default: + std::abort(); // this cannot happen + // pseudo fall-through to avoid compiler warnings + case typelib_TypeClass_VOID: + return BinaryAny(); + case typelib_TypeClass_BOOLEAN: + { + sal_uInt8 v = read8(); + if (v > 1) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: boolean of unknown value")), + css::uno::Reference< css::uno::XInterface >()); + } + return BinaryAny(type, &v); + } + case typelib_TypeClass_BYTE: + { + sal_uInt8 v = read8(); + return BinaryAny(type, &v); + } + case typelib_TypeClass_SHORT: + case typelib_TypeClass_UNSIGNED_SHORT: + case typelib_TypeClass_CHAR: + { + sal_uInt16 v = read16(); + return BinaryAny(type, &v); + } + case typelib_TypeClass_LONG: + case typelib_TypeClass_UNSIGNED_LONG: + case typelib_TypeClass_FLOAT: + { + sal_uInt32 v = read32(); + return BinaryAny(type, &v); + } + case typelib_TypeClass_HYPER: + case typelib_TypeClass_UNSIGNED_HYPER: + case typelib_TypeClass_DOUBLE: + { + sal_uInt64 v = read64(); + return BinaryAny(type, &v); + } + case typelib_TypeClass_STRING: + { + rtl::OUString v(readString()); + return BinaryAny(type, &v.pData); + } + case typelib_TypeClass_TYPE: + { + css::uno::TypeDescription v(readType()); + typelib_TypeDescription * p = v.get(); + return BinaryAny(type, &p); + } + case typelib_TypeClass_ANY: + { + css::uno::TypeDescription t(readType()); + if (t.get()->eTypeClass == typelib_TypeClass_ANY) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: any of type ANY")), + css::uno::Reference< css::uno::XInterface >()); + } + return readValue(t); + } + case typelib_TypeClass_SEQUENCE: + type.makeComplete(); + return readSequence(type); + case typelib_TypeClass_ENUM: + { + sal_Int32 v = static_cast< sal_Int32 >(read32()); + type.makeComplete(); + typelib_EnumTypeDescription * etd = + reinterpret_cast< typelib_EnumTypeDescription * >(type.get()); + bool found = false; + for (sal_Int32 i = 0; i != etd->nEnumValues; ++i) { + if (etd->pEnumValues[i] == v) { + found = true; + break; + } + } + if (!found) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: unknown enum value")), + css::uno::Reference< css::uno::XInterface >()); + } + return BinaryAny(type, &v); + } + case typelib_TypeClass_STRUCT: + case typelib_TypeClass_EXCEPTION: + { + std::vector< BinaryAny > as; + readMemberValues(type, &as); + void * buf = allocate(type.get()->nSize); + copyMemberValues(type, as.begin(), buf); + uno_Any raw; + raw.pType = reinterpret_cast< typelib_TypeDescriptionReference * >( + type.get()); + raw.pData = buf; + raw.pReserved = 0; + return BinaryAny(raw); + } + case typelib_TypeClass_INTERFACE: + { + css::uno::UnoInterfaceReference obj( + bridge_->registerIncomingInterface(readOid(), type)); + return BinaryAny(type, &obj.m_pUnoI); + } + } +} + +void Unmarshal::done() const { + if (data_ != end_) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: block contains excess data")), + css::uno::Reference< css::uno::XInterface >()); + } +} + +void Unmarshal::check(sal_Int32 size) const { + if (end_ - data_ < size) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: trying to read past end of block")), + css::uno::Reference< css::uno::XInterface >()); + } +} + +sal_uInt32 Unmarshal::readCompressed() { + sal_uInt8 n = read8(); + return n == 0xFF ? read32() : n; +} + +sal_uInt16 Unmarshal::readCacheIndex() { + sal_uInt16 idx = read16(); + if (idx >= cache::size && idx != cache::ignore) { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: cache index out of range")), + css::uno::Reference< css::uno::XInterface >()); + } + return idx; +} + +sal_uInt64 Unmarshal::read64() { + check(8); + sal_uInt64 n = static_cast< sal_uInt64 >(*data_++) << 56; + n |= static_cast< sal_uInt64 >(*data_++) << 48; + n |= static_cast< sal_uInt64 >(*data_++) << 40; + n |= static_cast< sal_uInt64 >(*data_++) << 32; + n |= static_cast< sal_uInt64 >(*data_++) << 24; + n |= static_cast< sal_uInt64 >(*data_++) << 16; + n |= static_cast< sal_uInt64 >(*data_++) << 8; + return n | *data_++; +} + +rtl::OUString Unmarshal::readString() { + sal_uInt32 n = readCompressed(); + if (n > SAL_MAX_INT32) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: string size too large")), + css::uno::Reference< css::uno::XInterface >()); + } + check(static_cast< sal_Int32 >(n)); + rtl::OUString s; + if (!rtl_convertStringToUString( + &s.pData, reinterpret_cast< char const * >(data_), + static_cast< sal_Int32 >(n), RTL_TEXTENCODING_UTF8, + (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))) + { + throw css::io::IOException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: string does not contain UTF-8")), + css::uno::Reference< css::uno::XInterface >()); + } + data_ += n; + return s; +} + +BinaryAny Unmarshal::readSequence(css::uno::TypeDescription const & type) { + OSL_ASSERT( + type.is() && type.get()->eTypeClass == typelib_TypeClass_SEQUENCE); + sal_uInt32 n = readCompressed(); + if (n > SAL_MAX_INT32) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: sequence size too large")), + css::uno::Reference< css::uno::XInterface >()); + } + if (n == 0) { + return BinaryAny(type, 0); + } + css::uno::TypeDescription ctd( + reinterpret_cast< typelib_IndirectTypeDescription * >( + type.get())->pType); + if (ctd.get()->eTypeClass == typelib_TypeClass_BYTE) { + check(static_cast< sal_Int32 >(n)); + rtl::ByteSequence s( + reinterpret_cast< sal_Int8 const * >(data_), + static_cast< sal_Int32 >(n)); + data_ += n; + sal_Sequence * p = s.getHandle(); + return BinaryAny(type, &p); + } + std::vector< BinaryAny > as; + for (sal_uInt32 i = 0; i != n; ++i) { + as.push_back(readValue(ctd)); + } + OSL_ASSERT(ctd.get()->nSize >= 0); + sal_uInt64 size = static_cast< sal_uInt64 >(n) * + static_cast< sal_uInt64 >(ctd.get()->nSize); + // sal_uInt32 * sal_Int32 -> sal_uInt64 cannot overflow + if (size > SAL_MAX_SIZE - SAL_SEQUENCE_HEADER_SIZE) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "binaryurp::Unmarshal: sequence size too large")), + css::uno::Reference< css::uno::XInterface >()); + } + void * buf = allocate( + SAL_SEQUENCE_HEADER_SIZE + static_cast< sal_Size >(size)); + static_cast< sal_Sequence * >(buf)->nRefCount = 0; + static_cast< sal_Sequence * >(buf)->nElements = + static_cast< sal_Int32 >(n); + for (sal_uInt32 i = 0; i != n; ++i) { + uno_copyData( + static_cast< sal_Sequence * >(buf)->elements + i * ctd.get()->nSize, + const_cast< void * >(as[i].getValue(ctd)), ctd.get(), 0); + } + return BinaryAny(type, reinterpret_cast< sal_Sequence ** >(&buf)); +} + +void Unmarshal::readMemberValues( + css::uno::TypeDescription const & type, std::vector< BinaryAny > * values) +{ + OSL_ASSERT( + type.is() && + (type.get()->eTypeClass == typelib_TypeClass_STRUCT || + type.get()->eTypeClass == typelib_TypeClass_EXCEPTION) && + values != 0); + type.makeComplete(); + typelib_CompoundTypeDescription * ctd = + reinterpret_cast< typelib_CompoundTypeDescription * >(type.get()); + if (ctd->pBaseTypeDescription != 0) { + readMemberValues( + css::uno::TypeDescription(&ctd->pBaseTypeDescription->aBase), + values); + } + for (sal_Int32 i = 0; i != ctd->nMembers; ++i) { + values->push_back( + readValue(css::uno::TypeDescription(ctd->ppTypeRefs[i]))); + } +} + +} diff --git a/binaryurp/source/unmarshal.hxx b/binaryurp/source/unmarshal.hxx new file mode 100644 index 000000000000..33a4aafec75e --- /dev/null +++ b/binaryurp/source/unmarshal.hxx @@ -0,0 +1,106 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_UNMARSHAL_HXX +#define INCLUDED_BINARYURP_SOURCE_UNMARSHAL_HXX + +#include "sal/config.h" + +#include <vector> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "rtl/ref.hxx" +#include "sal/types.h" +#include "typelib/typedescription.hxx" + +namespace binaryurp { + class BinaryAny; + class Bridge; + struct ReaderState; +} +namespace com { namespace sun { namespace star { namespace uno { + class TypeDescription; +} } } } +namespace rtl { + class ByteSequecne; + class OUString; +} + +namespace binaryurp { + +class Unmarshal: private boost::noncopyable { +public: + Unmarshal( + rtl::Reference< Bridge > const & bridge, ReaderState & state, + com::sun::star::uno::Sequence< sal_Int8 > const & buffer); + + ~Unmarshal(); + + sal_uInt8 read8(); + + sal_uInt16 read16(); + + sal_uInt32 read32(); + + com::sun::star::uno::TypeDescription readType(); + + rtl::OUString readOid(); + + rtl::ByteSequence readTid(); + + BinaryAny readValue(com::sun::star::uno::TypeDescription const & type); + + void done() const; + +private: + void check(sal_Int32 size) const; + + sal_uInt32 readCompressed(); + + sal_uInt16 readCacheIndex(); + + sal_uInt64 read64(); + + rtl::OUString readString(); + + BinaryAny readSequence(com::sun::star::uno::TypeDescription const & type); + + void readMemberValues( + com::sun::star::uno::TypeDescription const & type, + std::vector< BinaryAny > * values); + + rtl::Reference< Bridge > bridge_; + ReaderState & state_; + com::sun::star::uno::Sequence< sal_Int8 > buffer_; + sal_uInt8 const * data_; + sal_uInt8 const * end_; +}; + +} + +#endif diff --git a/binaryurp/source/writer.cxx b/binaryurp/source/writer.cxx new file mode 100755 index 000000000000..97a60157eb6f --- /dev/null +++ b/binaryurp/source/writer.cxx @@ -0,0 +1,476 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "sal/config.h" + +#include <exception> +#include <vector> + +#include "com/sun/star/connection/XConnection.hpp" +#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" +#include "com/sun/star/uno/XCurrentContext.hpp" +#include "cppuhelper/exc_hlp.hxx" +#include "osl/mutex.hxx" +#include "rtl/memory.h" +#include "uno/dispatcher.hxx" + +#include "binaryany.hxx" +#include "bridge.hxx" +#include "currentcontext.hxx" +#include "specialfunctionids.hxx" +#include "writer.hxx" + +namespace binaryurp { + +namespace { + +namespace css = com::sun::star; + +bool isProtocolPropertyMessage(rtl::OUString const & oid) { + return oid.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("UrpProtocolProperties")); +} + +} + +Writer::Item::Item() {} + +Writer::Item::Item( + rtl::ByteSequence const & theTid, rtl::OUString const & theOid, + css::uno::TypeDescription const & theType, + css::uno::TypeDescription const & theMember, + std::vector< BinaryAny > const & inArguments, + css::uno::UnoInterfaceReference const & theCurrentContext): + request(true), tid(theTid), oid(theOid), type(theType), member(theMember), + arguments(inArguments), currentContext(theCurrentContext) +{} + +Writer::Item::Item( + rtl::ByteSequence const & theTid, + css::uno::TypeDescription const & theMember, bool theSetter, + bool theException, BinaryAny const & theReturnValue, + std::vector< BinaryAny > const & outArguments, + bool theSetCurrentContextMode): + request(false), tid(theTid), member(theMember), setter(theSetter), + arguments(outArguments), exception(theException), + returnValue(theReturnValue), setCurrentContextMode(theSetCurrentContextMode) +{} + +Writer::Writer(rtl::Reference< Bridge > const & bridge): + bridge_(bridge), marshal_(bridge, state_), stop_(false) +{ + OSL_ASSERT(bridge.is()); + acquire(); +} + +void Writer::sendDirectRequest( + rtl::ByteSequence const & tid, rtl::OUString const & oid, + css::uno::TypeDescription const & type, + css::uno::TypeDescription const & member, + std::vector< BinaryAny > const & inArguments) +{ + OSL_ASSERT(!unblocked_.check()); + sendRequest( + tid, oid, type, member, inArguments, false, + css::uno::UnoInterfaceReference()); +} + +void Writer::sendDirectReply( + rtl::ByteSequence const & tid, css::uno::TypeDescription const & member, + bool exception, BinaryAny const & returnValue, + std::vector< BinaryAny > const & outArguments) +{ + OSL_ASSERT(!unblocked_.check()); + sendReply(tid, member, false, exception, returnValue,outArguments); +} + +void Writer::queueRequest( + rtl::ByteSequence const & tid, rtl::OUString const & oid, + css::uno::TypeDescription const & type, + css::uno::TypeDescription const & member, + std::vector< BinaryAny > const & inArguments) +{ + css::uno::UnoInterfaceReference cc(current_context::get()); + osl::MutexGuard g(mutex_); + queue_.push_back(Item(tid, oid, type, member, inArguments, cc)); + items_.set(); +} + +void Writer::queueReply( + rtl::ByteSequence const & tid, + com::sun::star::uno::TypeDescription const & member, bool setter, + bool exception, BinaryAny const & returnValue, + std::vector< BinaryAny > const & outArguments, bool setCurrentContextMode) +{ + osl::MutexGuard g(mutex_); + queue_.push_back( + Item( + tid, member, setter, exception, returnValue, outArguments, + setCurrentContextMode)); + items_.set(); +} + +void Writer::unblock() { + // Assumes that osl::Condition::set works as a memory barrier, so that + // changes made by preceeding sendDirectRequest/Reply calls are visible to + // subsequent sendRequest/Reply calls: + unblocked_.set(); +} + +void Writer::stop() { + { + osl::MutexGuard g(mutex_); + stop_ = true; + } + unblocked_.set(); + items_.set(); +} + +Writer::~Writer() {} + +void Writer::run() { + setName("binaryurpWriter"); + try { + unblocked_.wait(); + for (;;) { + items_.wait(); + Item item; + { + osl::MutexGuard g(mutex_); + if (stop_) { + return; + } + OSL_ASSERT(!queue_.empty()); + item = queue_.front(); + queue_.pop_front(); + if (queue_.empty()) { + items_.reset(); + } + } + if (item.request) { + sendRequest( + item.tid, item.oid, item.type, item.member, item.arguments, + (!item.oid.equalsAsciiL( + RTL_CONSTASCII_STRINGPARAM("UrpProtocolProperties")) && + !item.member.equals( + css::uno::TypeDescription( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.uno.XInterface::" + "release")))) && + bridge_->isCurrentContextMode()), + item.currentContext); + } else { + sendReply( + item.tid, item.member, item.setter, item.exception, + item.returnValue, item.arguments); + if (item.setCurrentContextMode) { + bridge_->setCurrentContextMode(); + } + } + } + } catch (css::uno::Exception & e) { + OSL_TRACE( + OSL_LOG_PREFIX "caught UNO exception '%s'", + rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8).getStr()); + } catch (std::exception & e) { + OSL_TRACE(OSL_LOG_PREFIX "caught C++ exception '%s'", e.what()); + } + bridge_->terminate(); +} + +void Writer::onTerminated() { + release(); +} + +void Writer::sendRequest( + rtl::ByteSequence const & tid, rtl::OUString const & oid, + css::uno::TypeDescription const & type, + css::uno::TypeDescription const & member, + std::vector< BinaryAny > const & inArguments, bool currentContextMode, + css::uno::UnoInterfaceReference const & currentContext) +{ + OSL_ASSERT(tid.getLength() != 0 && oid.getLength() != 0 && member.is()); + css::uno::TypeDescription t(type); + sal_Int32 functionId = 0; + bool forceSynchronous = false; + member.makeComplete(); + switch (member.get()->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + { + typelib_InterfaceAttributeTypeDescription * atd = + reinterpret_cast< typelib_InterfaceAttributeTypeDescription * >( + member.get()); + OSL_ASSERT(atd->pInterface != 0); + if (!t.is()) { + t = css::uno::TypeDescription(&atd->pInterface->aBase); + } + t.makeComplete(); + functionId = atd->pInterface->pMapMemberIndexToFunctionIndex[ + atd->aBase.nPosition]; + if (!inArguments.empty()) { // setter + ++functionId; + } + break; + } + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription * mtd = + reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( + member.get()); + OSL_ASSERT(mtd->pInterface != 0); + if (!t.is()) { + t = css::uno::TypeDescription(&mtd->pInterface->aBase); + } + t.makeComplete(); + functionId = mtd->pInterface->pMapMemberIndexToFunctionIndex[ + mtd->aBase.nPosition]; + forceSynchronous = mtd->bOneWay && + functionId != SPECIAL_FUNCTION_ID_RELEASE; + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + OSL_ASSERT(functionId >= 0); + if (functionId > SAL_MAX_UINT16) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("function ID too large for URP")), + css::uno::Reference< css::uno::XInterface >()); + } + std::vector< unsigned char > buf; + bool newType = !(lastType_.is() && t.equals(lastType_)); + bool newOid = oid != lastOid_; + bool newTid = tid != lastTid_; + if (newType || newOid || newTid || forceSynchronous || functionId > 0x3FFF) + // > 14 bit function ID + { + Marshal::write8( + &buf, + (0xC0 | (newType ? 0x20 : 0) | (newOid ? 0x10 : 0) | + (newTid ? 0x08 : 0) | (functionId > 0xFF ? 0x04 : 0) | + (forceSynchronous ? 0x01 : 0))); + // bit 7: LONGHEADER, bit 6: REQUEST, bit 5: NEWTYPE, bit 4: NEWOID, + // bit 3: NEWTID, bit 2: FUNCTIONID16, bit 0: MOREFLAGS + if (forceSynchronous) { + Marshal::write8(&buf, 0xC0); // bit 7: MUSTREPLY, bit 6: SYNCHRONOUS + } + if (functionId <= 0xFF) { + Marshal::write8(&buf, static_cast< sal_uInt8 >(functionId)); + } else { + Marshal::write16(&buf, static_cast< sal_uInt16 >(functionId)); + } + if (newType) { + marshal_.writeType(&buf, t); + } + if (newOid) { + marshal_.writeOid(&buf, oid); + } + if (newTid) { + marshal_.writeTid(&buf, tid); + } + } else if (functionId <= 0x3F) { // <= 6 bit function ID + Marshal::write8(&buf, static_cast< sal_uInt8 >(functionId)); + // bit 7: !LONGHEADER, bit 6: !FUNCTIONID14 + } else { + Marshal::write8( + &buf, static_cast< sal_uInt8 >(0x40 | (functionId >> 8))); + // bit 7: !LONGHEADER, bit 6: FUNCTIONID14 + Marshal::write8(&buf, functionId & 0xFF); + } + if (currentContextMode) { + css::uno::UnoInterfaceReference cc(currentContext); + marshal_.writeValue( + &buf, + css::uno::TypeDescription( + cppu::UnoType< + css::uno::Reference< css::uno::XCurrentContext > >::get()), + BinaryAny( + css::uno::TypeDescription( + cppu::UnoType< + css::uno::Reference< + css::uno::XCurrentContext > >::get()), + &cc.m_pUnoI)); + } + switch (member.get()->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + if (!inArguments.empty()) { // setter + OSL_ASSERT(inArguments.size() == 1); + marshal_.writeValue( + &buf, + css::uno::TypeDescription( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + member.get())-> + pAttributeTypeRef), + inArguments.front()); + } + break; + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription * mtd = + reinterpret_cast< typelib_InterfaceMethodTypeDescription * >( + member.get()); + std::vector< BinaryAny >::const_iterator i(inArguments.begin()); + for (sal_Int32 j = 0; j != mtd->nParams; ++j) { + if (mtd->pParams[j].bIn) { + marshal_.writeValue( + &buf, + css::uno::TypeDescription(mtd->pParams[j].pTypeRef), + *i++); + } + } + OSL_ASSERT(i == inArguments.end()); + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + sendMessage(buf); + lastType_ = t; + lastOid_ = oid; + lastTid_ = tid; +} + +void Writer::sendReply( + rtl::ByteSequence const & tid, + com::sun::star::uno::TypeDescription const & member, bool setter, + bool exception, BinaryAny const & returnValue, + std::vector< BinaryAny > const & outArguments) +{ + OSL_ASSERT(tid.getLength() != 0 && member.is() && member.get()->bComplete); + std::vector< unsigned char > buf; + bool newTid = tid != lastTid_; + Marshal::write8(&buf, 0x80 | (exception ? 0x20 : 0) | (newTid ? 0x08 : 0)); + // bit 7: LONGHEADER; bit 6: !REQUEST; bit 5: EXCEPTION; bit 3: NEWTID + if (newTid) { + marshal_.writeTid(&buf, tid); + } + if (exception) { + marshal_.writeValue( + &buf, + css::uno::TypeDescription(cppu::UnoType< css::uno::Any >::get()), + returnValue); + } else { + switch (member.get()->eTypeClass) { + case typelib_TypeClass_INTERFACE_ATTRIBUTE: + if (!setter) { + marshal_.writeValue( + &buf, + css::uno::TypeDescription( + reinterpret_cast< + typelib_InterfaceAttributeTypeDescription * >( + member.get())-> + pAttributeTypeRef), + returnValue); + } + break; + case typelib_TypeClass_INTERFACE_METHOD: + { + typelib_InterfaceMethodTypeDescription * mtd = + reinterpret_cast< + typelib_InterfaceMethodTypeDescription * >( + member.get()); + marshal_.writeValue( + &buf, css::uno::TypeDescription(mtd->pReturnTypeRef), + returnValue); + std::vector< BinaryAny >::const_iterator i( + outArguments.begin()); + for (sal_Int32 j = 0; j != mtd->nParams; ++j) { + if (mtd->pParams[j].bOut) { + marshal_.writeValue( + &buf, + css::uno::TypeDescription(mtd->pParams[j].pTypeRef), + *i++); + } + } + OSL_ASSERT(i == outArguments.end()); + break; + } + default: + OSL_ASSERT(false); // this cannot happen + break; + } + } + sendMessage(buf); + lastTid_ = tid; + bridge_->decrementCalls(); +} + +void Writer::sendMessage(std::vector< unsigned char > const & buffer) { + std::vector< unsigned char > header; + if (buffer.size() > SAL_MAX_UINT32) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("message too large for URP")), + css::uno::Reference< css::uno::XInterface >()); + } + Marshal::write32(&header, static_cast< sal_uInt32 >(buffer.size())); + Marshal::write32(&header, 1); + OSL_ASSERT(!buffer.empty()); + unsigned char const * p = &buffer[0]; + std::vector< unsigned char >::size_type n = buffer.size(); + OSL_ASSERT(header.size() <= SAL_MAX_INT32 && SAL_MAX_INT32 <= SAL_MAX_SIZE); + sal_Size k = SAL_MAX_INT32 - header.size(); + if (n < k) { + k = static_cast< sal_Size >(n); + } + css::uno::Sequence< sal_Int8 > s( + static_cast< sal_Int32 >(header.size() + k)); + OSL_ASSERT(!header.empty()); + rtl_copyMemory( + s.getArray(), &header[0], static_cast< sal_Size >(header.size())); + for (;;) { + rtl_copyMemory(s.getArray() + s.getLength() - k, p, k); + try { + bridge_->getConnection()->write(s); + } catch (css::io::IOException & e) { + css::uno::Any exc(cppu::getCaughtException()); + throw css::lang::WrappedTargetRuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "Binary URP write raised IO exception: ")) + + e.Message), + css::uno::Reference< css::uno::XInterface >(), exc); + } + n = static_cast< std::vector< unsigned char >::size_type >(n - k); + if (n == 0) { + break; + } + p += k; + k = SAL_MAX_INT32; + if (n < k) { + k = static_cast< sal_Size >(n); + } + s.realloc(k); + } +} + +} diff --git a/binaryurp/source/writer.hxx b/binaryurp/source/writer.hxx new file mode 100644 index 000000000000..fe5dba2cc1d9 --- /dev/null +++ b/binaryurp/source/writer.hxx @@ -0,0 +1,185 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_WRITER_HXX +#define INCLUDED_BINARYURP_SOURCE_WRITER_HXX + +#include "sal/config.h" + +#include <cstddef> +#include <deque> +#include <vector> + +#include "boost/noncopyable.hpp" +#include "osl/conditn.hxx" +#include "osl/mutex.hxx" +#include "osl/thread.hxx" +#include "rtl/byteseq.hxx" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "salhelper/simplereferenceobject.hxx" +#include "typelib/typedescription.hxx" +#include "uno/dispatcher.hxx" + +#include "binaryany.hxx" +#include "marshal.hxx" +#include "writerstate.hxx" + +namespace binaryurp { class Bridge; } + +namespace binaryurp { + +class Writer: + public osl::Thread, public salhelper::SimpleReferenceObject, + private boost::noncopyable +{ +public: + static void * operator new(std::size_t size) + { return Thread::operator new(size); } + + static void operator delete(void * pointer) + { Thread::operator delete(pointer); } + + explicit Writer(rtl::Reference< Bridge > const & bridge); + + // Only called from Bridge::reader_ thread, and only before Bridge::writer_ + // thread is unblocked: + void sendDirectRequest( + rtl::ByteSequence const & tid, rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type, + com::sun::star::uno::TypeDescription const & member, + std::vector< BinaryAny > const & inArguments); + + // Only called from Bridge::reader_ thread, and only before Bridge::writer_ + // thread is unblocked: + void sendDirectReply( + rtl::ByteSequence const & tid, + com::sun::star::uno::TypeDescription const & member, + bool exception, BinaryAny const & returnValue, + std::vector< BinaryAny > const & outArguments); + + void queueRequest( + rtl::ByteSequence const & tid, rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type, + com::sun::star::uno::TypeDescription const & member, + std::vector< BinaryAny > const & inArguments); + + void queueReply( + rtl::ByteSequence const & tid, + com::sun::star::uno::TypeDescription const & member, bool setter, + bool exception, BinaryAny const & returnValue, + std::vector< BinaryAny > const & outArguments, + bool setCurrentContextMode); + + void unblock(); + + void stop(); + +private: + virtual ~Writer(); + + virtual void SAL_CALL run(); + + virtual void SAL_CALL onTerminated(); + + void sendRequest( + rtl::ByteSequence const & tid, rtl::OUString const & oid, + com::sun::star::uno::TypeDescription const & type, + com::sun::star::uno::TypeDescription const & member, + std::vector< BinaryAny > const & inArguments, bool currentContextMode, + com::sun::star::uno::UnoInterfaceReference const & currentContext); + + void sendReply( + rtl::ByteSequence const & tid, + com::sun::star::uno::TypeDescription const & member, bool setter, + bool exception, BinaryAny const & returnValue, + std::vector< BinaryAny > const & outArguments); + + void sendMessage(std::vector< unsigned char > const & buffer); + + struct Item { + Item(); + + // Request: + Item( + rtl::ByteSequence const & theTid, rtl::OUString const & theOid, + com::sun::star::uno::TypeDescription const & theType, + com::sun::star::uno::TypeDescription const & theMember, + std::vector< BinaryAny > const & inArguments, + com::sun::star::uno::UnoInterfaceReference const & + theCurrentContext); + + // Reply: + Item( + rtl::ByteSequence const & theTid, + com::sun::star::uno::TypeDescription const & theMember, + bool theSetter, bool theException, BinaryAny const & theReturnValue, + std::vector< BinaryAny > const & outArguments, + bool theSetCurrentContextMode); + + bool request; + + rtl::ByteSequence tid; // request + reply + + rtl::OUString oid; // request + + com::sun::star::uno::TypeDescription type; // request + + com::sun::star::uno::TypeDescription member; // request + reply + + bool setter; // reply + + std::vector< BinaryAny > arguments; + // request: inArguments; reply: outArguments + + bool exception; // reply + + BinaryAny returnValue; // reply + + com::sun::star::uno::UnoInterfaceReference currentContext; // request + + bool setCurrentContextMode; // reply + }; + + rtl::Reference< Bridge > bridge_; + WriterState state_; + Marshal marshal_; + com::sun::star::uno::TypeDescription lastType_; + rtl::OUString lastOid_; + rtl::ByteSequence lastTid_; + osl::Condition unblocked_; + osl::Condition items_; + + osl::Mutex mutex_; + std::deque< Item > queue_; + bool stop_; +}; + +} + +#endif diff --git a/binaryurp/source/writerstate.hxx b/binaryurp/source/writerstate.hxx new file mode 100644 index 000000000000..cbb0208ba019 --- /dev/null +++ b/binaryurp/source/writerstate.hxx @@ -0,0 +1,55 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_BINARYURP_SOURCE_WRITERSTATE_HXX +#define INCLUDED_BINARYURP_SOURCE_WRITERSTATE_HXX + +#include "sal/config.h" + +#include "boost/noncopyable.hpp" +#include "rtl/byteseq.hxx" +#include "rtl/ustring.hxx" +#include "typelib/typedescription.hxx" + +#include "cache.hxx" + +namespace binaryurp { + +struct WriterState: private boost::noncopyable { + WriterState(): + typeCache(cache::size), oidCache(cache::size), tidCache(cache::size) {} + + Cache< com::sun::star::uno::TypeDescription > typeCache; + + Cache< rtl::OUString > oidCache; + + Cache< rtl::ByteSequence > tidCache; +}; + +} + +#endif diff --git a/bridges/inc/bridges/remote/bridgeimpl.hxx b/bridges/inc/bridges/remote/bridgeimpl.hxx deleted file mode 100644 index bb166d50a153..000000000000 --- a/bridges/inc/bridges/remote/bridgeimpl.hxx +++ /dev/null @@ -1,97 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _BRIDGES_REMOTE_BRIDGEIMPL_HXX_ -#define _BRIDGES_REMOTE_BRIDGEIMPL_HXX_ -#include <osl/interlck.h> - -#include <uno/environment.h> - -#include <bridges/remote/context.h> -#include <bridges/remote/remote.h> - - -struct remote_BridgeImpl -{ - void (SAL_CALL * m_allThreadsAreGone ) ( uno_Environment * ); - requestClientSideDispatcher m_sendRequest; - oslInterlockedCount m_nRemoteThreads; - sal_Bool m_bDisposed; - sal_Bool m_bReleaseStubsCalled; -}; - -namespace bridges_remote { - - enum RemoteThreadCounter_HoldEnvWeak - { - RTC_HOLDENVWEAK = 0x1 - }; - - class RemoteThreadCounter - { - public: - // performance optimization. In some cases, it is not necessary to acquire the - // environment. - RemoteThreadCounter( uno_Environment *pEnvRemote, RemoteThreadCounter_HoldEnvWeak ) - : m_bReleaseEnvironment( sal_False ) - , m_pEnvRemote( pEnvRemote ) - { - remote_Context *pContext = ((remote_Context *) m_pEnvRemote->pContext ); - osl_incrementInterlockedCount( &( pContext->m_pBridgeImpl->m_nRemoteThreads ) ); - } - - RemoteThreadCounter( uno_Environment *pEnvRemote ) - : m_bReleaseEnvironment( sal_True ) - , m_pEnvRemote( pEnvRemote ) - { - m_pEnvRemote->acquire( m_pEnvRemote ); - - remote_Context *pContext = ((remote_Context *) m_pEnvRemote->pContext ); - osl_incrementInterlockedCount( &( pContext->m_pBridgeImpl->m_nRemoteThreads ) ); - } - - ~RemoteThreadCounter( ) - { - remote_Context *pContext = ((remote_Context *) m_pEnvRemote->pContext ); - if( 0 == osl_decrementInterlockedCount( &( pContext->m_pBridgeImpl->m_nRemoteThreads)) && - pContext->m_pBridgeImpl->m_bDisposed && - ! pContext->m_pBridgeImpl->m_bReleaseStubsCalled ) - { - pContext->m_pBridgeImpl->m_allThreadsAreGone( m_pEnvRemote ); - } - if( m_bReleaseEnvironment ) - m_pEnvRemote->release( m_pEnvRemote ); - } - - sal_Bool m_bReleaseEnvironment; - uno_Environment *m_pEnvRemote; - }; -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/bridges/remote/connection.h b/bridges/inc/bridges/remote/connection.h deleted file mode 100644 index 1e173944f242..000000000000 --- a/bridges/inc/bridges/remote/connection.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _BRIDGES_REMOTE_CONNECTION_H_ -#define _BRIDGES_REMOTE_CONNECTION_H_ -#include <sal/types.h> - -/** Specfies a C-interface for a bidirectional bytestream, - which is used by a UNO remote environment. - */ -struct remote_Connection -{ - void ( SAL_CALL * acquire ) ( remote_Connection *); - - void ( SAL_CALL * release ) ( remote_Connection *); - - /** - reads nSize bytes from the connection. This method blocks, until - all bytes are available or an error occurs. - @return Number of bytes read. - If the return value is less than nSize, an unrecoverable - i/o error has occurred or the connection was closed. - - */ - sal_Int32 (SAL_CALL * read)(remote_Connection *, sal_Int8 *pDest, sal_Int32 nSize ); - - /** - @return Number of bytes written. - if the return value is less than nSize an unrecoverable - i/o error has occurred or the connection was closed. - */ - sal_Int32 (SAL_CALL * write)(remote_Connection *, const sal_Int8 *pSource, sal_Int32 nSize ); - - void ( SAL_CALL * flush ) ( remote_Connection * ); - - /** closes the connection. - Any read or write operation after this call shall not be served - anymore. Any ongoing read or write operation must return immeadiatly after this call. - The implementation should cope with multiple calls to this method. - */ - void (SAL_CALL * close) ( remote_Connection * ); -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/bridges/remote/context.h b/bridges/inc/bridges/remote/context.h deleted file mode 100644 index 8ff83adfb128..000000000000 --- a/bridges/inc/bridges/remote/context.h +++ /dev/null @@ -1,262 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _BRIDGES_REMOTE_CONTEXT_H_ -#define _BRIDGES_REMOTE_CONTEXT_H_ -#include <osl/interlck.h> -#include <osl/conditn.h> - -#include <typelib/typedescription.h> - -#include <uno/environment.h> -#include <uno/any2.h> - - -/** Interface for refcounted contexts of uno-environments. - - Not all uno_Contexts need to be refcounted, in case they are, - they should be 'derived' from this struct. - This is used as a base class for the remote_Context. - @see uno_Environment - @see uno_getEnvironment() - @see remote_Context - */ -struct uno_Context -{ - /** increase the refcount of the context - */ - void (SAL_CALL * acquire)( uno_Context *pContext ); - - /** decrements the recount of the context. In case the recount drops to zero, - the context gets destroye. - */ - void (SAL_CALL * release)( uno_Context *pContext); - - /** Allows to query for a different interface of the uno_Context. - The result of the void pointer is unspecified and depends on the concrete context. - */ - void * (SAL_CALL *query ) ( uno_Context *pContext , rtl_uString *pId); -}; - -struct remote_Connection; -struct remote_Context; -struct remote_Interface; - - - -/** performs a query-interface for a certain interface via the remote connection ! - - @param pEnvRemote The environment, that shall perform the call. - @param ppRemoteI in/out parameter contains the interface returned by queryInterface - @param pOid the oid of the 'ghost' object on which the call must be done. - ***/ -typedef void ( SAL_CALL * remote_getInstanceFunc ) ( - uno_Environment *pEnvRemote, - remote_Interface **ppRemoteI, - rtl_uString *pOid, - typelib_TypeDescriptionReference *pInterfaceTypeRef, - uno_Any **ppException ); - - -/** refcounted C-interface, which provides object by name. - */ -struct remote_InstanceProvider -{ - void (SAL_CALL * acquire ) ( remote_InstanceProvider * pProvider ); - void (SAL_CALL * release ) ( remote_InstanceProvider * pProvider ); - void (SAL_CALL * getInstance ) ( remote_InstanceProvider * pProvider , - uno_Environment *pEnvRemote, - remote_Interface **ppRemoteI, - rtl_uString *pInstanceName, - typelib_InterfaceTypeDescription *pType, - uno_Any **ppException ); -}; - -/** refcounted C-interface, which allows to register a listener to an - remote bridge to be informed when the bridge gets disposed. - - @see remote_Context - */ -struct remote_DisposingListener -{ - void (SAL_CALL * acquire ) ( remote_DisposingListener * pProvider ); - void (SAL_CALL * release ) ( remote_DisposingListener * pProvider ); - void (SAL_CALL * disposing ) ( remote_DisposingListener * pProvider, - rtl_uString *pBridgeName ); -}; - - -/** - Try to get an existing context characterized by the pIdString. Each ID-String must - uniquely charcterize a certain connection. The context can't be retrieved via this - function anymore, after it got disposed. - - @return 0 when such a context does not exist, otherwise - a pointer to an acquired remote_Context. - **/ -extern "C" remote_Context * SAL_CALL -remote_getContext( rtl_uString *pIdString ); - -/** - Create an acquired remote context. The Context is weakly held by the context administration - and can be accessed later through remote_getContext() (using the same id-string). - - @param pIdString A string, that uniquely describes the connection. For e.g. a socket connection, - host and port of the local and remote host should be in the string. - - @param pDescription - Description of the connection, that may brought up to the user. - - @param pProtocol - The protocol, that the environment uses for - communicating with the remote process. - The format of the protocol string is : "protocolname,para1=para1value,..." - @return 0, when a context with this name already exists. - - @see remote_getContext() - @see remote_Context - */ -extern "C" remote_Context * SAL_CALL -remote_createContext( remote_Connection *pConnection, - rtl_uString *pIdStr, - rtl_uString *pDescription, - rtl_uString *pProtocol, - remote_InstanceProvider *); - -const sal_Int32 REMOTE_CONTEXT_CREATE = 1; -const sal_Int32 REMOTE_CONTEXT_DESTROY = 2; - -typedef void ( SAL_CALL * remote_contextListenerFunc ) ( - void *pThis, - sal_Int32 nRemoteContextMode, - rtl_uString *sName, - rtl_uString *sDescription - ); - -/** Registers a listener at the context administration, which allows to keep - track of existing remote connections. - @param pObject object which is handed to the listener function, when called. - */ -extern "C" void SAL_CALL -remote_addContextListener( remote_contextListenerFunc listener, void *pObject ); - - -/** Removes a listener from the context administration. - */ -extern "C" void SAL_CALL -remote_removeContextListener( remote_contextListenerFunc listener , void *pObject ); - -/** Allows to retrieve all existing context strings. - - @param pnStringCount out parameter. Contains the number of rtl_uStrings in the array - @param memAlloc a memory allocation function for the array of pointers to rtl_uStrings - - @return array of rtl strings. The caller must call release on all rtl_uString s and must free - the pointer array. - */ -extern "C" rtl_uString ** SAL_CALL -remote_getContextList( - sal_Int32 *pnStringCount, - void * ( SAL_CALL * memAlloc ) ( sal_Size nBytesToAlloc ) ); - - -struct remote_BridgeImpl; - -/** The context structure for a remote bridge. - - @see uno_getEnvironment() - */ -struct remote_Context -{ - struct uno_Context aBase; - - /** - These methods are implemented by context administration - */ - void ( SAL_CALL * addDisposingListener ) ( remote_Context *, - remote_DisposingListener * ); - void ( SAL_CALL * removeDisposingListener ) ( remote_Context *, - remote_DisposingListener * ); - /** - will be called by the environment when it gets disposed - */ - void ( SAL_CALL * dispose ) ( remote_Context * ); - - /** The method is set by the remote-environment during environment initialization. - @see remote_getInstanceFunc - */ - remote_getInstanceFunc getRemoteInstance; - - /** - The protocol, that the environment uses for communicating with the remote process. - The format of the protocol string is : "protocolname,para1=para1value,..." - The parameters are protocol dependend - */ - rtl_uString *m_pProtocol; - - /** - It may be the same as m_pName. - Livetime is handled by the context administration. - */ - rtl_uString *m_pDescription; - - /** - The name of this context at context administration. - A string, that uniquely describes this environment. - Livetime is handled by the context administration. - */ - rtl_uString *m_pName; - - /** The instance-provider, which is used to look up unknown object identifiers. - Is usually called on server side, when the first client request comes in. - Maybe 0. Livetime is handled by the context administration. - */ - remote_InstanceProvider *m_pInstanceProvider; - - /** - The connection of this context. - Livetime is handled by the context administration. - */ - remote_Connection *m_pConnection; - - /** - Here arbitrary data may be stored. It may be used by a connection - service to store environment specific data. The bridge does not - use it. - */ - void *m_pAdditionalInformation; - - /** - here the bridge stores its private per environment data. - */ - struct remote_BridgeImpl *m_pBridgeImpl; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/bridges/remote/helper.hxx b/bridges/inc/bridges/remote/helper.hxx deleted file mode 100644 index 56de06b7d8c8..000000000000 --- a/bridges/inc/bridges/remote/helper.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <bridges/remote/bridgeimpl.hxx> - -typedef void ( SAL_CALL * ReleaseRemoteCallbackFunc ) ( - remote_Interface *ppRemoteI, - rtl_uString *pOid, - typelib_TypeDescriptionReference *pTypeRef, - uno_Environment *pEnvRemote - ); - -typedef void ( SAL_CALL * remote_createStubFunc ) ( - remote_Interface **ppRemoteI, - rtl_uString *pOid , - typelib_TypeDescriptionReference *pTypeRef, - uno_Environment *pEnvRemote, - ReleaseRemoteCallbackFunc callback - ); -namespace bridges_remote -{ - - /** @param callback If the bridge implementation wants to handle the remote release call, - it can do it giving this callback. If callback == 0, the releaseRemote - method of the stub is called. - */ - void SAL_CALL remote_createStub ( - remote_Interface **ppRemoteI, - rtl_uString *pOid , - typelib_TypeDescriptionReference *pType, - uno_Environment *pEnvRemote, - ReleaseRemoteCallbackFunc callback ); - - void SAL_CALL remote_retrieveOidFromProxy( - remote_Interface *pRemtoeI, - rtl_uString **ppOid ); - - void SAL_CALL remote_sendQueryInterface( - uno_Environment *pEnvRemote, - remote_Interface **ppRemoteI, - rtl_uString *pOid , - typelib_TypeDescriptionReference *pType, - uno_Any **ppException - ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/bridges/remote/mapping.hxx b/bridges/inc/bridges/remote/mapping.hxx deleted file mode 100644 index 28903eff8ac2..000000000000 --- a/bridges/inc/bridges/remote/mapping.hxx +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _BRIDGES_REMOTE_MAPPING_HXX_ -#define _BRIDGES_REMOTE_MAPPING_HXX_ - -#include <osl/interlck.h> -#include <rtl/ustring.hxx> - -#include <typelib/typedescription.h> - -#include <bridges/remote/remote.h> - -typedef struct _uno_Environment uno_Environment; - -namespace bridges_remote -{ - extern "C" typedef void SAL_CALL RemoteToUno( - uno_Mapping *pMapping, void **ppOut, void *pInterface, - typelib_InterfaceTypeDescription *pInterfaceTypeDescr ); - RemoteToUno remoteToUno; - - extern "C" typedef void SAL_CALL UnoToRemote( - uno_Mapping *pMapping, void **ppOut, void *pInterface, - typelib_InterfaceTypeDescription *pInterfaceTypeDescr ); - UnoToRemote unoToRemote; - - extern "C" typedef void SAL_CALL FreeRemoteMapping(uno_Mapping * mapping); - FreeRemoteMapping freeRemoteMapping; - - class RemoteMapping : - public remote_Mapping - { - public: - RemoteMapping( uno_Environment *pEnvUno , - uno_Environment *pEnvRemote, - uno_MapInterfaceFunc func , - const ::rtl::OUString sPurpose); - ~RemoteMapping(); - - oslInterlockedCount m_nRef; - ::rtl::OUString m_sPurpose; - }; - -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/bridges/remote/proxy.hxx b/bridges/inc/bridges/remote/proxy.hxx deleted file mode 100644 index 25afecca6c13..000000000000 --- a/bridges/inc/bridges/remote/proxy.hxx +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <osl/interlck.h> - -#include <uno/environment.h> -#include <uno/dispatcher.h> -#include <uno/mapping.hxx> - -#include <bridges/remote/remote.h> - -namespace bridges_remote { - -extern "C" typedef void SAL_CALL FreeRemote2UnoProxy( - uno_ExtEnvironment * environment, void * proxy); -FreeRemote2UnoProxy freeRemote2UnoProxy; - -// private: -extern "C" typedef void SAL_CALL AcquireRemote2UnoProxy(uno_Interface *); -AcquireRemote2UnoProxy acquireRemote2UnoProxy; - -// private: -extern "C" typedef void SAL_CALL ReleaseRemote2UnoProxy(uno_Interface *); -ReleaseRemote2UnoProxy releaseRemote2UnoProxy; - -// private: -extern "C" typedef void SAL_CALL DispatchRemote2UnoProxy( - uno_Interface *, typelib_TypeDescription const *, void *, void **, - uno_Any **); -DispatchRemote2UnoProxy dispatchRemote2UnoProxy; - -extern "C" void SAL_CALL remote_release( void * ); - -class Remote2UnoProxy : - public uno_Interface -{ -public: - Remote2UnoProxy( - remote_Interface *pRemoteI, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pType , - uno_Environment *pEnvUno, - uno_Environment *pEnvRemote - ); - - ~Remote2UnoProxy(); - -private: - ::rtl::OUString m_sOid; - typelib_InterfaceTypeDescription *m_pType; - remote_Interface *m_pRemoteI; - uno_Environment *m_pEnvUno; - uno_Environment *m_pEnvRemote; - ::com::sun::star::uno::Mapping m_mapRemote2Uno; - ::com::sun::star::uno::Mapping m_mapUno2Remote; - - oslInterlockedCount m_nRef; - - friend void SAL_CALL acquireRemote2UnoProxy(uno_Interface *); - - friend void SAL_CALL releaseRemote2UnoProxy(uno_Interface *); - - friend void SAL_CALL dispatchRemote2UnoProxy( - uno_Interface *, typelib_TypeDescription const *, void *, void **, - uno_Any **); -}; - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/bridges/remote/remote.h b/bridges/inc/bridges/remote/remote.h deleted file mode 100644 index 1e8ebabf2b93..000000000000 --- a/bridges/inc/bridges/remote/remote.h +++ /dev/null @@ -1,96 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _BRIDGES_REMOTE_REMOTE_H -#define _BRIDGES_REMOTE_REMOTE_H -#include <uno/mapping.h> -#include <uno/any2.h> - -#include <typelib/typedescription.h> -#include <uno/environment.h> - -#define CORBA_STRING8_NAME "com.sun.star.corba.CorbaString8" -#define CORBA_STRING8_NAME_LENGTH (sizeof(CORBA_STRING8_NAME)-1) - -#define CORBA_UNION_NAME "com.sun.star.corba.CorbaUnion" -#define CORBA_UNION_NAME_LENGTH (sizeof(CORBA_UNION_NAME)-1) - -#define REMOTE_MARSHALED_MSGHDR_SIZE 12 -#define REMOTE_RELEASE_METHOD_INDEX 2 -#define REMOTE_RELEASE_METHOD_NAME "release" - -#define CURRENT_IIOP_PROTOCOL_MAJOR 1 -#define CURRENT_IIOP_PROTOCOL_MINOR 2 - -extern "C" { - -struct remote_Interface; - -/** @internal - */ -typedef void (SAL_CALL * remote_DispatchMethod)( - remote_Interface * pRemoteI, typelib_TypeDescription const * pMemberType, - void * pReturn, void * pArgs[], uno_Any ** ppException ); - -/** - @internal - */ -typedef void ( SAL_CALL * requestClientSideDispatcher ) ( - uno_Environment *pEnvRemote, - typelib_TypeDescription const * pMemberType, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pInterfaceType, - void *pReturn, - void *ppArgs[], - uno_Any **ppException ); - -/** The base class of an UNO interface in a remote environment. - */ -struct remote_Interface -{ - void (SAL_CALL * acquire)( remote_Interface * pInterface ); - - void (SAL_CALL * release)( remote_Interface * pInterface ); - - remote_DispatchMethod pDispatcher; -}; - -/** The mapping between an binary-c-uno and a remote environment. - @internal - */ -struct remote_Mapping -{ - uno_Mapping aBase; - uno_Environment *pEnvRemote; - uno_Environment *pEnvUno; -}; - -} - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/bridges/remote/remote.hxx b/bridges/inc/bridges/remote/remote.hxx deleted file mode 100644 index a4fcac21f1c8..000000000000 --- a/bridges/inc/bridges/remote/remote.hxx +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _BRIDGES_REMOTE_REMOTE_HXX_ -#define _BRIDGES_REMOTE_REMOTE_HXX_ -#include <list> - -#include <osl/mutex.hxx> -#include <osl/conditn.h> -#include <osl/interlck.h> - -#include <uno/environment.h> - -#include <bridges/remote/remote.h> -#include <bridges/remote/connection.h> - -#include <com/sun/star/uno/Sequence.hxx> - -namespace bridges_remote { - -extern "C" typedef void SAL_CALL AcquireRemote2RemoteStub( - remote_Interface * pThis); -AcquireRemote2RemoteStub acquireRemote2RemoteStub; - -extern "C" typedef void SAL_CALL FreeRemote2RemoteStub( - uno_ExtEnvironment * environment, void * stub); -FreeRemote2RemoteStub freeRemote2RemoteStub; - -class Remote2RemoteStub : - public remote_Interface -{ -public: - Remote2RemoteStub(rtl_uString *pOid, - typelib_InterfaceTypeDescription *pType, - uno_Environment *pEnvRemote, - requestClientSideDispatcher dispatch ); - ~Remote2RemoteStub(); - - void releaseRemote(); -public: - ::rtl::OUString m_sOid; - typelib_InterfaceTypeDescription *m_pType; - oslInterlockedCount m_nRef; - uno_Environment *m_pEnvRemote; - requestClientSideDispatcher m_dispatch; - oslInterlockedCount m_nReleaseRemote; -}; - -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/bridges/remote/stub.hxx b/bridges/inc/bridges/remote/stub.hxx deleted file mode 100644 index b89389ec50fe..000000000000 --- a/bridges/inc/bridges/remote/stub.hxx +++ /dev/null @@ -1,67 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <bridges/remote/remote.hxx> - -#include <uno/dispatcher.h> -#include <uno/mapping.hxx> - -namespace bridges_remote { - -extern "C" typedef void SAL_CALL AcquireUno2RemoteStub( remote_Interface *pThis ); -AcquireUno2RemoteStub acquireUno2RemoteStub; - -extern "C" typedef void SAL_CALL FreeUno2RemoteStub( - uno_ExtEnvironment * environment, void * stub); -FreeUno2RemoteStub freeUno2RemoteStub; - -class Uno2RemoteStub : - public remote_Interface -{ -public: - Uno2RemoteStub( uno_Interface *pUnoI, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pType, - uno_Environment *pEnvUno, - uno_Environment *pEnvRemote ); - ~Uno2RemoteStub(); - -public: - ::rtl::OUString m_sOid; - typelib_InterfaceTypeDescription *m_pType; - uno_Interface *m_pUnoI; - oslInterlockedCount m_nRef; - - uno_Environment *m_pEnvUno; - uno_Environment *m_pEnvRemote; - ::com::sun::star::uno::Mapping m_mapRemote2Uno; - ::com::sun::star::uno::Mapping m_mapUno2Remote; -}; - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/inc/pch/precompiled_bridges.hxx b/bridges/inc/pch/precompiled_bridges.hxx index 3116a130f7ed..e0396ac9b835 100644 --- a/bridges/inc/pch/precompiled_bridges.hxx +++ b/bridges/inc/pch/precompiled_bridges.hxx @@ -39,8 +39,6 @@ #include "com/sun/star/bridge/XBridge.hpp" #include "com/sun/star/bridge/XBridgeFactory.hpp" #include "com/sun/star/bridge/XInstanceProvider.hpp" -#include "com/sun/star/bridge/XProtocolProperties.hdl" -#include "com/sun/star/bridge/XProtocolProperties.hpp" #include "com/sun/star/bridge/XUnoUrlResolver.hpp" #include "com/sun/star/connection/ConnectionSetupException.hpp" #include "com/sun/star/connection/NoConnectException.hpp" @@ -50,8 +48,6 @@ #include "com/sun/star/frame/XComponentLoader.hpp" #include "com/sun/star/io/XInputStream.hpp" #include "com/sun/star/io/XOutputStream.hpp" -#include "com/sun/star/lang/DisposedException.hdl" -#include "com/sun/star/lang/DisposedException.hpp" #include "com/sun/star/lang/IllegalArgumentException.hpp" #include "com/sun/star/lang/WrappedTargetRuntimeException.hpp" #include "com/sun/star/lang/XComponent.hpp" diff --git a/bridges/prj/build.lst b/bridges/prj/build.lst index 444e8f30c25c..9c7b2f31548f 100644 --- a/bridges/prj/build.lst +++ b/bridges/prj/build.lst @@ -2,9 +2,6 @@ br bridges : cppuhelper jurt jvmaccess salhelper NULL br bridges usr1 - all br_mkout NULL br bridges\inc nmake - all br_inc NULL br bridges\unotypes nmake - all br_unotypes NULL -br bridges\source\remote\static nmake - all br_rem_static br_unotypes br_inc NULL -br bridges\source\remote\urp nmake - all br_rem_urp br_rem_static br_inc NULL -br bridges\source\remote\context nmake - all br_rcon br_unotypes br_inc NULL br bridges\source\cpp_uno\mingw_intel nmake - w br_gcc3i br_cppuno_shared br_unotypes br_inc NULL br bridges\source\cpp_uno\msvc_win32_intel nmake - w br_msci br_cppuno_shared br_unotypes br_inc NULL br bridges\source\cpp_uno\msvc_win32_x86-64 nmake - w br_mscx br_cppuno_shared br_unotypes br_inc NULL diff --git a/bridges/prj/d.lst b/bridges/prj/d.lst index f7d8aef99afb..becaa7283cd8 100644 --- a/bridges/prj/d.lst +++ b/bridges/prj/d.lst @@ -1,16 +1,3 @@ -mkdir: %_DEST%\inc%_EXT%\bridges -mkdir: %_DEST%\inc%_EXT%\bridges\remote - -..\inc\bridges\remote\connection.h %_DEST%\inc%_EXT%\bridges\remote\connection.h -..\inc\bridges\remote\context.h %_DEST%\inc%_EXT%\bridges\remote\context.h -..\inc\bridges\remote\remote.h %_DEST%\inc%_EXT%\bridges\remote\remote.h - -..\%__SRC%\lib\irmcxt* %_DEST%\lib%_EXT%\* -..\%__SRC%\lib\librmcxt.*.* %_DEST%\lib%_EXT%\* -..\%__SRC%\bin\rmcxt*.dll %_DEST%\bin%_EXT%\* - -..\%__SRC%\lib\liburp_uno* %_DEST%\lib%_EXT%\liburp_uno* -..\%__SRC%\bin\urp_uno* %_DEST%\bin%_EXT%\urp_uno* ..\%__SRC%\lib\libjava_uno* %_DEST%\lib%_EXT%\libjava_uno* ..\%__SRC%\bin\java_uno* %_DEST%\bin%_EXT%\java_uno* ..\%__SRC%\class\java_uno*.jar %_DEST%\bin%_EXT%\java_uno*.jar @@ -22,8 +9,3 @@ mkdir: %_DEST%\inc%_EXT%\bridges\remote ..\%__SRC%\lib\libgcc3_uno.* %_DEST%\lib%_EXT%\libgcc3_uno.* ..\%__SRC%\bin\gcc3_uno.* %_DEST%\bin%_EXT%\gcc3_uno.* ..\%__SRC%\lib\libsunpro5_uno.* %_DEST%\lib%_EXT%\libsunpro5_uno.* - -..\%__SRC%\lib\rmcxt3.lib %_DEST%\lib%_EXT%\rmcxt.lib - - -linklib: librmcxt.*.* diff --git a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx index 8cd5356e3dd8..c830f877ccf2 100644 --- a/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx +++ b/bridges/source/cpp_uno/gcc3_linux_x86-64/uno2cpp.cxx @@ -29,10 +29,14 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_bridges.hxx" +#include <exception> +#include <typeinfo> #include <stdio.h> #include <stdlib.h> #include <string.h> -#include <rtl/alloc.h> + +#include "rtl/alloc.h" +#include "rtl/ustrbuf.hxx" #include <com/sun/star/uno/genfunc.hxx> #include "com/sun/star/uno/RuntimeException.hpp" @@ -238,6 +242,18 @@ static void callVirtualMethod(void * pThis, sal_uInt32 nVtableIndex, //================================================================================================== +namespace { + +void appendCString(OUStringBuffer & buffer, char const * text) { + if (text != 0) { + buffer.append( + OStringToOUString(OString(text), RTL_TEXTENCODING_ISO_8859_1)); + // use 8859-1 to avoid conversion failure + } +} + +} + static void cpp_call( bridges::cpp_uno::shared::UnoInterfaceProxy * pThis, bridges::cpp_uno::shared::VtableSlot aVtableSlot, @@ -370,13 +386,31 @@ static void cpp_call( try { - callVirtualMethod( - pAdjustedThisPtr, aVtableSlot.index, - pCppReturn, pReturnTypeRef, bSimpleReturn, - pStackStart, ( pStack - pStackStart ), - pGPR, nGPR, - pFPR, nFPR ); - // NO exception occurred... + try { + callVirtualMethod( + pAdjustedThisPtr, aVtableSlot.index, + pCppReturn, pReturnTypeRef, bSimpleReturn, + pStackStart, ( pStack - pStackStart ), + pGPR, nGPR, + pFPR, nFPR ); + } catch (Exception &) { + throw; + } catch (std::exception & e) { + OUStringBuffer buf; + buf.appendAscii(RTL_CONSTASCII_STRINGPARAM("C++ code threw ")); + appendCString(buf, typeid(e).name()); + buf.appendAscii(RTL_CONSTASCII_STRINGPARAM(": ")); + appendCString(buf, e.what()); + throw RuntimeException( + buf.makeStringAndClear(), Reference< XInterface >()); + } catch (...) { + throw RuntimeException( + OUString( + RTL_CONSTASCII_USTRINGPARAM( + "C++ code threw unknown exception")), + Reference< XInterface >()); + } + *ppUnoExc = 0; // reconvert temporary params diff --git a/bridges/source/jni_uno/makefile.mk b/bridges/source/jni_uno/makefile.mk index da0942cdad29..1474a86cd741 100644 --- a/bridges/source/jni_uno/makefile.mk +++ b/bridges/source/jni_uno/makefile.mk @@ -67,6 +67,7 @@ SHL1STDLIBS= \ SHL1VERSIONMAP=$(TARGET).map +SHL1CREATEJNILIB=TRUE SHL1IMPLIB=i$(TARGET) SHL1LIBS=$(SLB)$/$(TARGET).lib SHL1DEF=$(MISC)$/$(SHL1TARGET).def diff --git a/bridges/source/remote/context/context.cxx b/bridges/source/remote/context/context.cxx deleted file mode 100644 index b7f4930384ad..000000000000 --- a/bridges/source/remote/context/context.cxx +++ /dev/null @@ -1,487 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <stdio.h> -#include <string.h> -#include <list> -#include <boost/unordered_map.hpp> -#include <utility> - -#include <osl/diagnose.h> -#include <osl/interlck.h> -#include <osl/mutex.hxx> - -#include "rtl/ustring.hxx" -#include "rtl/instance.hxx" - -#include <bridges/remote/context.h> -#include <bridges/remote/remote.h> -#include <bridges/remote/connection.h> -#include <bridges/remote/counter.hxx> - -using namespace ::std; -using namespace ::osl; -using namespace ::rtl; - -namespace { - -extern "C" typedef void * (SAL_CALL * MemAlloc)(sal_Size); - -} - -namespace remote_context -{ - -class remote_ContextImpl : - public remote_Context -{ -public: - remote_ContextImpl( remote_Connection *pConnection, - rtl_uString *pIdStr, - rtl_uString *pDescription, - rtl_uString *pProtocol, - remote_InstanceProvider *pProvider ); - ~remote_ContextImpl(); - - static void SAL_CALL thisAcquire( uno_Context * ); - static void SAL_CALL thisRelease( uno_Context * ); - static void * SAL_CALL thisQuery( uno_Context * , rtl_uString * ); - static void SAL_CALL thisAddDisposingListener( remote_Context * , remote_DisposingListener * ); - static void SAL_CALL thisRemoveDisposingListener( remote_Context *, remote_DisposingListener *); - static void SAL_CALL thisDispose( remote_Context *); -public: - oslInterlockedCount m_nRef; - sal_Bool m_bDisposed; - list < remote_DisposingListener * > m_lstListener; - Mutex m_mutex; -}; - - - - -struct equalOUString_Impl -{ - sal_Bool operator()(const OUString & s1, const OUString & s2) const - { return s1 == s2; } -}; - -struct hashOUString_Impl -{ - size_t operator()(const OUString & rName) const - { return rName.hashCode(); } -}; - -typedef boost::unordered_map -< - OUString, - void *, - hashOUString_Impl, - equalOUString_Impl -> -ContextMap; - -#if OSL_DEBUG_LEVEL > 1 -static MyCounter thisCounter( "DEBUG : Context" ); -#endif - -class ContextAdmin -{ -public: - // listener administration - void addContextListener( remote_contextListenerFunc listener , void *pObject ); - void removeContextListener( remote_contextListenerFunc listener , void *pObject ); - - void fire( sal_Int32 nRemoteContextMode, - rtl_uString *sName, - rtl_uString *sDescription ); - - // context administration - uno_Context *createAndRegisterContext( - remote_Connection *pConnection, - rtl_uString *pIdStr, - rtl_uString *pDescription, - rtl_uString *pProtocol, - remote_InstanceProvider *pInstanceProvider ); - - void revokeContext( uno_Context *pRemoteContext ); - - uno_Context *getContext( rtl_uString *pHost ); - - rtl_uString ** getConnectionList( - sal_Int32 *pnStringCount, MemAlloc memAlloc ); - -private: - ::osl::Mutex m_mutex; - - ContextMap m_mapContext; - - typedef std::list< std::pair< remote_contextListenerFunc, void * > > List; - List m_lstListener; -}; - -void ContextAdmin::addContextListener( remote_contextListenerFunc listener , void *pObject ) -{ - ::osl::MutexGuard guard( m_mutex ); - - m_lstListener.push_back( std::make_pair( listener, pObject ) ); -} - -void ContextAdmin::removeContextListener( remote_contextListenerFunc listener , void *pObject ) -{ - ::osl::MutexGuard guard( m_mutex ); - - for (List::iterator ii(m_lstListener.begin()); ii != m_lstListener.end(); - ++ii) - { - if (ii->first == listener && ii->second == pObject) { - m_lstListener.erase( ii ); - break; - } - } -} - -void ContextAdmin::fire( - sal_Int32 nRemoteContextMode, - rtl_uString *pName, - rtl_uString *sDescription ) -{ - List lst; - { - ::osl::MutexGuard guard( m_mutex ); - lst = m_lstListener; - } - for (List::iterator i(lst.begin()); i != lst.end(); ++i) { - (i->first)(i->second, nRemoteContextMode, pName, sDescription); - } -} - -uno_Context *ContextAdmin::createAndRegisterContext( remote_Connection *pConnection, - rtl_uString *pIdStr, - rtl_uString *pDescription, - rtl_uString *pProtocol, - remote_InstanceProvider *pInstanceProvider ) -{ - ::osl::MutexGuard guard( m_mutex ); - - uno_Context *pContext = getContext( pIdStr ); - if( pContext ) - { - pContext->release( pContext ); - return 0; - } - - remote_ContextImpl *p = new remote_ContextImpl( pConnection, - pIdStr, - pDescription, - pProtocol, - pInstanceProvider ); - - p->aBase.acquire( (uno_Context*) p ); - - m_mapContext[ OUString( pIdStr) ] = (void*) p; - - fire( REMOTE_CONTEXT_CREATE , pIdStr , pDescription ); - return ( uno_Context * )p; -} - - -void ContextAdmin::revokeContext( uno_Context *pRemoteContext ) -{ - ::osl::MutexGuard guard( m_mutex ); - - remote_ContextImpl *p = ( remote_ContextImpl * ) pRemoteContext; - - ContextMap::iterator ii = m_mapContext.find( p->m_pName ); - OSL_ASSERT( ii != m_mapContext.end() ); - m_mapContext.erase( ii ); - - fire( REMOTE_CONTEXT_DESTROY , p->m_pName , p->m_pDescription ); - -} - -uno_Context *ContextAdmin::getContext( rtl_uString *pHost ) -{ - ::osl::MutexGuard guard( m_mutex ); - - ContextMap::iterator ii = m_mapContext.find( OUString( (rtl_uString*)pHost ) ); - if( ii == m_mapContext.end() ) - { - return 0; - } - - uno_Context *p = ( uno_Context * ) (*ii).second; - p->acquire( p ); - return p; -} - - -rtl_uString ** ContextAdmin::getConnectionList( - sal_Int32 *pnStringCount, MemAlloc memAlloc ) -{ - ::osl::MutexGuard guard( m_mutex ); - - *pnStringCount = m_mapContext.size(); - - if (*pnStringCount == 0) - return NULL; - - rtl_uString **ppReturn = ( rtl_uString ** ) - memAlloc( sizeof( rtl_uString * ) * m_mapContext.size() ); - memset( ppReturn , 0 , sizeof( rtl_uString * ) * m_mapContext.size() ); - - sal_Int32 i = 0; - for( ContextMap::iterator ii = m_mapContext.begin() ; - ii != m_mapContext.end(); - ++ii, i++ ) - { - rtl_uString_assign( &( ppReturn[i] ), (*ii).first.pData ); - } - - return ppReturn; -} - - -struct theContextAdmin : public rtl::Static<ContextAdmin, theContextAdmin> {}; - -/***************************** - * remote_ContextImpl implementation - ****************************/ - - - -remote_ContextImpl::remote_ContextImpl( remote_Connection *pConnection , - rtl_uString *pIdStr, - rtl_uString *pDescription, - rtl_uString *pProtocol, - remote_InstanceProvider *pProvider ) : - m_nRef( 0 ), - m_bDisposed( sal_False ) -{ - m_pConnection = pConnection; - m_pConnection->acquire( m_pConnection ); - - m_pInstanceProvider = pProvider; - if( m_pInstanceProvider ) - { - m_pInstanceProvider->acquire( pProvider ); - } - - m_pName = pIdStr; - rtl_uString_acquire( m_pName ); - - m_pDescription = pDescription; - rtl_uString_acquire( m_pDescription ); - - m_pProtocol = pProtocol; - rtl_uString_acquire( pProtocol ); - - aBase.acquire = thisAcquire; - aBase.release = thisRelease; - addDisposingListener = thisAddDisposingListener; - removeDisposingListener = thisRemoveDisposingListener; - dispose = thisDispose; -#if OSL_DEBUG_LEVEL > 1 - thisCounter.acquire(); -#endif -} - -remote_ContextImpl::~remote_ContextImpl() -{ - // disposed must have been called - OSL_ASSERT( m_bDisposed ); - - rtl_uString_release( m_pName ); - rtl_uString_release( m_pDescription ); - rtl_uString_release( m_pProtocol ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.release(); -#endif - -} - - -void remote_ContextImpl::thisAddDisposingListener( remote_Context *pRemoteC , - remote_DisposingListener *pListener ) -{ - remote_ContextImpl *pImpl = (remote_ContextImpl * ) pRemoteC; - - ::osl::MutexGuard guard( pImpl->m_mutex ); - - pListener->acquire( pListener ); - pImpl->m_lstListener.push_back( pListener ); -} - -void remote_ContextImpl::thisRemoveDisposingListener( remote_Context *pRemoteC, - remote_DisposingListener *pListener) -{ - remote_ContextImpl *pImpl = (remote_ContextImpl * ) pRemoteC; - MutexGuard guard( pImpl->m_mutex ); - - for( list< remote_DisposingListener * >::iterator ii = pImpl->m_lstListener.begin() ; - ii != pImpl->m_lstListener.end(); - ++ii ) - { - if( (*ii) == pListener ) - { - pImpl->m_lstListener.erase( ii ); - pListener->release( pListener ); - break; - } - } -} - -void remote_ContextImpl::thisDispose( remote_Context *pRemoteC ) -{ - remote_ContextImpl *pImpl = ( remote_ContextImpl * )pRemoteC; - - MutexGuard guard( pImpl->m_mutex ); - if( ! pImpl->m_bDisposed ) - { - pImpl->m_bDisposed = sal_True; - theContextAdmin::get().revokeContext( (uno_Context * ) pRemoteC ); - - if( pImpl->m_pInstanceProvider ) - { - pImpl->m_pInstanceProvider->release( pImpl->m_pInstanceProvider ); - pImpl->m_pInstanceProvider = 0; - } - - pImpl->m_pConnection->release( pImpl->m_pConnection ); - pImpl->m_pConnection = 0; - - list< remote_DisposingListener * > lst = pImpl->m_lstListener; - pImpl->m_lstListener.clear(); - - for( list < remote_DisposingListener * >::iterator ii = lst.begin(); - ii != lst.end(); - ++ii ) - { - (*ii)->disposing( (*ii) , pImpl->m_pName ); - (*ii)->release( (*ii) ); - } - - } -} - - - -void remote_ContextImpl::thisAcquire( uno_Context *pRemoteC ) -{ - remote_ContextImpl *p = SAL_REINTERPRET_CAST(remote_ContextImpl * ,pRemoteC ); - osl_incrementInterlockedCount( &(p->m_nRef) ); -} - -void remote_ContextImpl::thisRelease( uno_Context *pRemoteC ) -{ - remote_ContextImpl *p = SAL_REINTERPRET_CAST( remote_ContextImpl * , pRemoteC ); - if (! osl_decrementInterlockedCount( &(p->m_nRef) )) - { - // enshure, that this piece of code is not reentered - osl_incrementInterlockedCount( &(p->m_nRef) ); - - // dispose, if necessary - p->dispose( p ); - - // restore the counter - osl_decrementInterlockedCount( &(p->m_nRef) ); - - if( 0 == p->m_nRef ) - { - delete p; - } - else - { - // reanimated, but disposed ! - } - } -} - -void *remote_ContextImpl::thisQuery( uno_Context * , rtl_uString * ) -{ - return 0; -} - - -} // end namespace remote_context - - -using namespace remote_context; - -//----------------------- -// -// C-Interface -// -//----------------------- -extern "C" remote_Context * SAL_CALL -remote_getContext( rtl_uString *pIdString ) -{ - return (remote_Context *) theContextAdmin::get().getContext(pIdString); -} - - - -extern "C" remote_Context * SAL_CALL -remote_createContext( remote_Connection *pConnection, - rtl_uString *pIdStr, - rtl_uString *pDescription, - rtl_uString *pProtocol, - remote_InstanceProvider *pProvider ) -{ - remote_ContextImpl *p = (remote_ContextImpl * ) - theContextAdmin::get().createAndRegisterContext( - pConnection , - pIdStr , - pDescription, - pProtocol, - pProvider ); - - return (remote_Context * )p; -} - - -extern "C" void SAL_CALL -remote_addContextListener( remote_contextListenerFunc listener, void *pObject ) -{ - theContextAdmin::get().addContextListener( listener , pObject ); -} - -extern "C" void SAL_CALL -remote_removeContextListener( remote_contextListenerFunc listener , void *pObject ) -{ - theContextAdmin::get().removeContextListener( listener , pObject ); -} - -extern "C" rtl_uString ** SAL_CALL -remote_getContextList( sal_Int32 *pnStringCount, MemAlloc memAlloc ) -{ - return theContextAdmin::get().getConnectionList( pnStringCount , memAlloc ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/context/exports.dxp b/bridges/source/remote/context/exports.dxp deleted file mode 100644 index dcef3c369b10..000000000000 --- a/bridges/source/remote/context/exports.dxp +++ /dev/null @@ -1,5 +0,0 @@ -remote_getContext -remote_createContext -remote_getContextList -remote_removeContextListener -remote_addContextListener
\ No newline at end of file diff --git a/bridges/source/remote/context/rmcxt.map b/bridges/source/remote/context/rmcxt.map deleted file mode 100755 index 182f6495ea9d..000000000000 --- a/bridges/source/remote/context/rmcxt.map +++ /dev/null @@ -1,10 +0,0 @@ -UDK_3_0_0 { - global: - remote_getContext; - remote_createContext; - remote_getContextList; - remote_removeContextListener; - remote_addContextListener; - local: - *; -}; diff --git a/bridges/source/remote/idl/corba.idl b/bridges/source/remote/idl/corba.idl deleted file mode 100644 index b71d16e2eff1..000000000000 --- a/bridges/source/remote/idl/corba.idl +++ /dev/null @@ -1,88 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -module com -{ -module sun -{ -module star -{ - -module corba -{ - - // CosBridging module - typedef unsigned long ObjectSystemID; - typedef sequence< byte > OpaqueData; - - struct OneThreadID - { - ObjectSystemID objSysID; - OpaqueData threadID; - }; - - typedef sequence<OneThreadID> ThreadIDs; - - struct LogicalThreadID // Service context - { - ThreadIDs IDs; - }; - - struct CorbaString8 - { - string theString; - }; - - struct CorbaUnion - { - long dummy; - }; - - struct ObjectKey - { - CorbaString8 sOid; - CorbaString8 sType; - }; - - enum TCKind - { - tk_null, tk_void, - tk_short, tk_long, tk_ushort, tk_ulong, - tk_float, tk_double, tk_boolean, tk_char, - tk_octet, tk_any, tk_TypeCode, tk_Principal, tk_objref, - tk_struct, tk_union, tk_enum, tk_string, - tk_sequence, tk_array, tk_alias, tk_except, - tk_longlong, tk_ulonglong, tk_longdouble, - tk_wchar, tk_wstring, tk_fixed, - tk_value, tk_value_box, - tk_native, - tk_abstract_interface - }; -}; - -}; -}; -}; diff --git a/bridges/source/remote/static/helper.cxx b/bridges/source/remote/static/helper.cxx deleted file mode 100644 index f0fc40106d36..000000000000 --- a/bridges/source/remote/static/helper.cxx +++ /dev/null @@ -1,212 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <rtl/alloc.h> -#include <osl/diagnose.h> - -#include <bridges/remote/helper.hxx> - -#include <bridges/remote/stub.hxx> -#include <bridges/remote/proxy.hxx> -#include <bridges/remote/remote.hxx> - -#include <com/sun/star/uno/Sequence.hxx> - -using namespace ::rtl; -using namespace ::com::sun::star::uno; - -namespace bridges_remote -{ - -void SAL_CALL remote_createStub ( - remote_Interface **ppRemoteI, - rtl_uString *pOid , - typelib_TypeDescriptionReference *pTypeRef, - uno_Environment *pEnvRemote, - ReleaseRemoteCallbackFunc releaseRemoteCallback ) -{ - typelib_TypeDescription *pType = 0; - typelib_typedescriptionreference_getDescription( &pType, pTypeRef ); - - (void) pEnvRemote->pExtEnv->getRegisteredInterface( - pEnvRemote->pExtEnv, - (void **)ppRemoteI, - pOid, - (typelib_InterfaceTypeDescription* )pType ); - - if( *ppRemoteI ) - { - if( (*ppRemoteI)->acquire == acquireRemote2RemoteStub ) { - - if( releaseRemoteCallback ) - { - // use the callback handler, the bridge wants to send the call immeadiatly - releaseRemoteCallback( *ppRemoteI , pOid, pTypeRef , pEnvRemote ); - } - else - { - ((::bridges_remote::Remote2RemoteStub *)*ppRemoteI)->releaseRemote(); - } - } - else - { - // Uno2RemoteStub - // no release necessary - } - } - else - { - remote_BridgeImpl *pImpl = ((remote_Context *)pEnvRemote->pContext)->m_pBridgeImpl; - *ppRemoteI = - new ::bridges_remote::Remote2RemoteStub( - pOid, - (typelib_InterfaceTypeDescription * ) pType, - pEnvRemote, - pImpl->m_sendRequest); - - // ppRemoteI may change during registration - pEnvRemote->pExtEnv->registerProxyInterface( - pEnvRemote->pExtEnv, - (void **) ppRemoteI, - freeRemote2RemoteStub, - pOid, - (typelib_InterfaceTypeDescription * ) pType ); - } - - typelib_typedescription_release( pType ); -} - -void SAL_CALL remote_sendQueryInterface( - uno_Environment *pEnvRemote, - remote_Interface **ppRemoteI, - rtl_uString *pOid , - typelib_TypeDescriptionReference *pTypeRef, - uno_Any **ppException - ) -{ - OSL_ASSERT( ppRemoteI ); - - typelib_InterfaceTypeDescription *pType = 0; - typelib_typedescriptionreference_getDescription( (typelib_TypeDescription ** )&pType, pTypeRef ); - - if( *ppRemoteI ) - { - (*ppRemoteI)->release( *ppRemoteI ); - (*ppRemoteI) = 0; - } - - remote_BridgeImpl *pImpl = ((remote_Context *)pEnvRemote->pContext)->m_pBridgeImpl; - - Type type = ::getCppuType( (Reference < XInterface > *)0 ); - - // get type for queryInterface - OUString sCompleteMethodName = type.getTypeName(); - sCompleteMethodName += OUString(RTL_CONSTASCII_USTRINGPARAM("::queryInterface")); - - typelib_InterfaceMemberTypeDescription *pMemberType = 0; - typelib_typedescription_getByName( - (typelib_TypeDescription **) &pMemberType, - sCompleteMethodName.pData ); - - OSL_ASSERT( pMemberType ); - - uno_Any anyInterface; - anyInterface.pType = 0; - anyInterface.pData = 0; - - void *pReturn = &anyInterface; - void *ppArgs[1]; - - ppArgs[0] = 0; - typelib_TypeDescriptionReference *pRef = 0; - typelib_typedescriptionreference_new( &pRef , - pType->aBase.eTypeClass, - pType->aBase.pTypeName); - - ppArgs[0] = &pRef; - -// uno_Any anyException; -// uno_Any *pAnyException = &anyException; - - // do the queryInterface - pImpl->m_sendRequest( - pEnvRemote, - (typelib_TypeDescription * ) pMemberType, - pOid, - pType, - pReturn, - ppArgs, - ppException ); - - - // now release everything - typelib_typedescriptionreference_release( pRef ); - typelib_typedescription_release( (typelib_TypeDescription * ) pMemberType ); - - if( *ppException ) - { - *ppRemoteI = 0; - } - else - { - // set out parameter - if( typelib_TypeClass_INTERFACE == anyInterface.pType->eTypeClass ) - { - *ppRemoteI = ( remote_Interface * ) anyInterface.pReserved; - } - typelib_typedescriptionreference_release( anyInterface.pType ); - } - - typelib_typedescription_release( (typelib_TypeDescription * ) pType ); -} - - -void SAL_CALL remote_retrieveOidFromProxy( - remote_Interface *pRemoteI, - rtl_uString **ppOid ) -{ - if( pRemoteI->acquire == acquireRemote2RemoteStub ) - { - // Remote2RemoteStub - ::bridges_remote::Remote2RemoteStub *pStub = (::bridges_remote::Remote2RemoteStub * ) pRemoteI; - rtl_uString_newFromString( ppOid , pStub->m_sOid.pData ); - } - else - { - // Uno2RemoteStub - ::bridges_remote::Uno2RemoteStub *pStub = (::bridges_remote::Uno2RemoteStub * ) pRemoteI; - rtl_uString_newFromString( ppOid , pStub->m_sOid.pData ); - pRemoteI->acquire( pRemoteI ); - } -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/static/mapping.cxx b/bridges/source/remote/static/mapping.cxx deleted file mode 100644 index 3402cfe68268..000000000000 --- a/bridges/source/remote/static/mapping.cxx +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <osl/diagnose.h> - -#include <bridges/remote/proxy.hxx> -#include <bridges/remote/stub.hxx> -#include <bridges/remote/counter.hxx> -#include <bridges/remote/mapping.hxx> - -using namespace bridges_remote; - -extern "C" { - -static void SAL_CALL thisAcquire( uno_Mapping *pMap ) -{ - RemoteMapping *p = SAL_REINTERPRET_CAST( RemoteMapping * , pMap ); - if( 1 == osl_incrementInterlockedCount( &(p->m_nRef) ) ) - { - if( remoteToUno == pMap->mapInterface ) - { - uno_registerMapping( &pMap , - freeRemoteMapping, - p->pEnvRemote , - p->pEnvUno , - p->m_sPurpose.pData ); - } - else - { - uno_registerMapping( &pMap , - freeRemoteMapping, - p->pEnvUno , - p->pEnvRemote , - p->m_sPurpose.pData ); - } - - } -} - -static void SAL_CALL thisRelease( uno_Mapping *pMap ) -{ - RemoteMapping *p = SAL_REINTERPRET_CAST( RemoteMapping * , pMap ); - if (! osl_decrementInterlockedCount( &(p->m_nRef) )) - { - uno_revokeMapping( pMap ); - } -} - -} - -namespace bridges_remote { - -void remoteToUno( uno_Mapping *pMapping, void **ppUnoI, void *pRemoteI, - typelib_InterfaceTypeDescription *pTypeDescr ) -{ - remote_Mapping *pRemoteMapping = ( remote_Mapping * ) pMapping; - - OSL_ASSERT( ppUnoI && pTypeDescr ); - if (*ppUnoI) - { - ((uno_Interface *)*ppUnoI)->release( (uno_Interface *)*ppUnoI ); - *ppUnoI = 0; - } - - if (pRemoteI && pTypeDescr) - { - // get object id of interface to be wrapped - rtl_uString * pOid = 0; - pRemoteMapping->pEnvRemote->pExtEnv->getObjectIdentifier( - pRemoteMapping->pEnvRemote->pExtEnv, - &pOid, - pRemoteI ); - - OSL_ASSERT(pOid); - if( ! pOid ) - { - return; - } - - // try to get any known interface from target environment - pRemoteMapping->pEnvUno->pExtEnv->getRegisteredInterface( - pRemoteMapping->pEnvUno->pExtEnv, - ppUnoI, - pOid, - pTypeDescr); - - if ( ! *ppUnoI) // already existing interface - { - // try to publish a new proxy; proxy may be exchanged during registration - *ppUnoI = new Remote2UnoProxy( - ( remote_Interface * ) pRemoteI, - pOid, - pTypeDescr , - pRemoteMapping->pEnvUno, - pRemoteMapping->pEnvRemote); - - pRemoteMapping->pEnvUno->pExtEnv->registerProxyInterface( - pRemoteMapping->pEnvUno->pExtEnv, - ppUnoI, - freeRemote2UnoProxy, - pOid, - pTypeDescr ); - - OSL_ASSERT( *ppUnoI ); - } - rtl_uString_release( pOid ); - } -} - -void unoToRemote( uno_Mapping *pMapping, void **ppRemoteI, void *pUnoI, - typelib_InterfaceTypeDescription *pTypeDescr ) -{ - remote_Mapping *pRemoteMapping = ( remote_Mapping * ) pMapping; - OSL_ASSERT( ppRemoteI && pTypeDescr ); - if (*ppRemoteI) - { - ((remote_Interface *)*ppRemoteI)->release( (remote_Interface *)*ppRemoteI); - *ppRemoteI = 0; - } - if (pUnoI && pTypeDescr) - { - // get object id of interface to be wrapped - rtl_uString * pOid = 0; - pRemoteMapping->pEnvUno->pExtEnv->getObjectIdentifier( - pRemoteMapping->pEnvUno->pExtEnv, - &pOid, - pUnoI ); - - OSL_ASSERT( pOid ); - if( ! pOid ) - { - return; - } - - pRemoteMapping->pEnvRemote->pExtEnv->getRegisteredInterface( - pRemoteMapping->pEnvRemote->pExtEnv, - (void**)ppRemoteI, - pOid, - pTypeDescr ); - - if( !*ppRemoteI ) - { - // try to publish a new proxy; - *ppRemoteI = new Uno2RemoteStub( - ( uno_Interface * ) pUnoI, - pOid, - pTypeDescr, - pRemoteMapping->pEnvUno, - pRemoteMapping->pEnvRemote ); - - // note : ppRemoteI may change during registration - pRemoteMapping->pEnvRemote->pExtEnv->registerProxyInterface( - pRemoteMapping->pEnvRemote->pExtEnv, - (void**) ppRemoteI, - freeUno2RemoteStub, - pOid, - pTypeDescr ); - } - - rtl_uString_release( pOid ); - } -} - -void freeRemoteMapping(uno_Mapping * mapping) { - delete reinterpret_cast< RemoteMapping * >(mapping); -} - -RemoteMapping::RemoteMapping( uno_Environment *pEnvUno_ , - uno_Environment *pEnvRemote_, - uno_MapInterfaceFunc func, - const ::rtl::OUString sPurpose) : - m_nRef( 1 ), - m_sPurpose( sPurpose ) -{ - pEnvUno = pEnvUno_; - pEnvRemote = pEnvRemote_; - - pEnvUno->acquire( pEnvUno ); - pEnvRemote->acquire( pEnvRemote ); - - aBase.mapInterface = func; - aBase.acquire = thisAcquire; - aBase.release = thisRelease; -} - -RemoteMapping::~RemoteMapping( ) -{ - pEnvUno->release( pEnvUno ); - pEnvRemote->release( pEnvRemote ); -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/static/proxy.cxx b/bridges/source/remote/static/proxy.cxx deleted file mode 100644 index 737dda701a28..000000000000 --- a/bridges/source/remote/static/proxy.cxx +++ /dev/null @@ -1,341 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <sal/alloca.h> -#include <bridges/remote/proxy.hxx> -#include <bridges/remote/context.h> - -#include <uno/data.h> -#include <uno/mapping.hxx> -#include <uno/environment.h> - -#include <com/sun/star/uno/Any.hxx> - -#include <bridges/remote/bridgeimpl.hxx> - -#include "remote_types.hxx" - -#if OSL_DEBUG_LEVEL > 1 -#include <bridges/remote/counter.hxx> -static MyCounter thisCounter( "DEBUG : Remote2UnoProxy"); -#endif - -using namespace ::bridges_remote; -using namespace ::com::sun::star::uno; - -extern "C" { - -void SAL_CALL remote_release( void *pRemoteI ) -{ - ((remote_Interface * )pRemoteI)->release( (remote_Interface * ) pRemoteI ); -} - -} - -namespace bridges_remote { - -void freeRemote2UnoProxy(uno_ExtEnvironment *, void * proxy) { - delete static_cast< Remote2UnoProxy * >(proxy); -} - -void acquireRemote2UnoProxy( uno_Interface *pThis ) -{ - Remote2UnoProxy *p = ( Remote2UnoProxy * ) pThis; - if( 1 == osl_incrementInterlockedCount( &(p->m_nRef) ) ) - { - p->m_pEnvUno->pExtEnv->registerProxyInterface( - p->m_pEnvUno->pExtEnv, - (void**)&pThis, - freeRemote2UnoProxy, - p->m_sOid.pData, - p->m_pType ); - OSL_ASSERT( (uno_Interface *)p == pThis ); - } -} - -void releaseRemote2UnoProxy( uno_Interface *pThis ) -{ - Remote2UnoProxy *p = ( Remote2UnoProxy * ) pThis; - if ( 0 == osl_decrementInterlockedCount( &(p->m_nRef) )) - { - p->m_pEnvUno->pExtEnv->revokeInterface( p->m_pEnvUno->pExtEnv, p ); - } -} - -void SAL_CALL dispatchRemote2UnoProxy( - uno_Interface * pUnoI, - typelib_TypeDescription const * pType, - void * pReturn, - void * ppArgs[], - uno_Any ** ppException ) -{ - Remote2UnoProxy *p = ( Remote2UnoProxy * ) pUnoI; - RemoteThreadCounter counter( p->m_pEnvRemote ); - - typelib_InterfaceMethodTypeDescription *pMethodType = 0; - typelib_InterfaceAttributeTypeDescription *pAttributeType = 0; - typelib_TypeDescription *pReturnType = 0; - typelib_TypeDescription **ppArgType = 0; - sal_Int32 nArgCount = 0; - sal_Bool *pbIsIn = 0; - sal_Bool *pbIsOut = 0; - sal_Bool *pbConversionNeeded = 0; - sal_Bool bConversionNeededForReturn = 0; - - //-------------------------------- - // Collect all needed types ! - //-------------------------------- - if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pType->eTypeClass ) - { - pAttributeType = ( typelib_InterfaceAttributeTypeDescription * ) pType; - if( pReturn ) - { - TYPELIB_DANGER_GET( &pReturnType , pAttributeType->pAttributeTypeRef ); - bConversionNeededForReturn = remote_relatesToInterface( pReturnType ); - } - else - { - nArgCount = 1; - ppArgType = (typelib_TypeDescription **) alloca( sizeof( void * ) ); - pbIsIn = ( sal_Bool * ) alloca( sizeof( sal_Bool ) ); - pbIsOut = ( sal_Bool * ) alloca( sizeof( sal_Bool ) ); - pbConversionNeeded = ( sal_Bool *) alloca( sizeof( sal_Bool ) ); - - pbIsIn[0] = sal_True; - pbIsOut[0] = sal_False; - ppArgType[0] = 0; - TYPELIB_DANGER_GET( &( ppArgType[0] ) , pAttributeType->pAttributeTypeRef ); - pbConversionNeeded[0] = remote_relatesToInterface( ppArgType[0] ); - - } - } - if( typelib_TypeClass_INTERFACE_METHOD == pType->eTypeClass ) - { - pMethodType = ( typelib_InterfaceMethodTypeDescription * ) pType; - TYPELIB_DANGER_GET( &pReturnType , pMethodType->pReturnTypeRef ); - bConversionNeededForReturn = remote_relatesToInterface( pReturnType ); - nArgCount = pMethodType->nParams; - ppArgType = (typelib_TypeDescription **) alloca( sizeof( void * ) * nArgCount ); - pbIsIn = (sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount ); - pbIsOut = (sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount ); - pbConversionNeeded = ( sal_Bool *) alloca( sizeof( sal_Bool ) * nArgCount ); - sal_Int32 i; - for( i = 0 ; i < nArgCount ; i ++ ) - { - ppArgType[i] = 0; - TYPELIB_DANGER_GET( & (ppArgType[i]) , pMethodType->pParams[i].pTypeRef ); - pbIsIn[i] = pMethodType->pParams[i].bIn; - pbIsOut[i] = pMethodType->pParams[i].bOut; - pbConversionNeeded[i] = remote_relatesToInterface( ppArgType[i] ); - } - } - - void *pRemoteReturn = 0; - if( pReturnType ) - { - if( bConversionNeededForReturn ) - { - pRemoteReturn = alloca( pReturnType->nSize ); - } - else - { - pRemoteReturn = pReturn; - } - } - - void ** ppRemoteArgs = 0; - if( nArgCount ) - { - ppRemoteArgs = (void**) alloca( sizeof( void * ) * nArgCount ); - } - - sal_Int32 i; - for( i = 0 ; i < nArgCount ; i ++ ) - { - if( pbConversionNeeded[i] ) - { - ppRemoteArgs[i] = alloca( ppArgType[i]->nSize ); - - if( pbIsIn[i] ) { - uno_copyAndConvertData( - ppRemoteArgs[i], - ppArgs[i], - ppArgType[i], - p->m_mapUno2Remote.get() ); - } - } - else - { - ppRemoteArgs[i] = ppArgs[i]; - } - } - - uno_Any any; - uno_Any *pAny = &any; - - p->m_pRemoteI->pDispatcher( p->m_pRemoteI, - pType, - pRemoteReturn, - ppRemoteArgs, - &pAny ); - - if( ! pAny ) - { - if( pReturn && bConversionNeededForReturn ) - { - uno_copyAndConvertData( - pReturn , - pRemoteReturn, - pReturnType, - p->m_mapRemote2Uno.get() ); - uno_destructData( pRemoteReturn , pReturnType , remote_release ); - } - - sal_Int32 j; - for( j = 0 ; j < nArgCount ; j ++ ) - { - if( pbConversionNeeded[j] ) - { - if( pbIsIn[j] ) { - if( pbIsOut[j] ) { - uno_destructData( ppArgs[j] , - ppArgType[j] , - 0 ); - uno_copyAndConvertData( ppArgs[j] , - ppRemoteArgs[j], - ppArgType[j], - p->m_mapRemote2Uno.get() ); - } - } - else // pure out - { - uno_copyAndConvertData( ppArgs[j] , - ppRemoteArgs[j], - ppArgType[j], - p->m_mapRemote2Uno.get() ); - } - uno_destructData( ppRemoteArgs[j], - ppArgType[j], - remote_release ); - } - } - *ppException = 0; - } - else - { - // ----------------------- - // an exception occurred - // ----------------------- - typelib_TypeDescription *pAnyType = 0; - getCppuType( (::com::sun::star::uno::Any*) 0 ).getDescription( &pAnyType ); - uno_copyAndConvertData( *ppException , - pAny , - pAnyType, - p->m_mapRemote2Uno.get() ); - uno_destructData( pAny , pAnyType , remote_release ); - typelib_typedescription_release( pAnyType ); - - // destruct remote in parameters ( out parameters have not been constructed ) - for( i = 0 ; i < nArgCount ; i ++ ) - { - if( pbConversionNeeded[i] && pbIsIn[i] ) - { - uno_destructData( ppRemoteArgs[i], - ppArgType[i], - remote_release ); - } - } - } - - //-------------------------- - // release all acquired types - //-------------------------- - if( pReturnType ) - { - TYPELIB_DANGER_RELEASE( pReturnType ); - } - for( i = 0 ; i < nArgCount ; i ++ ) - { - TYPELIB_DANGER_RELEASE( ppArgType[ i] ); - } - -} - -Remote2UnoProxy::Remote2UnoProxy( remote_Interface *pRemoteI, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pType, - uno_Environment *pEnvUno, - uno_Environment *pEnvRemote ) : - m_sOid( pOid ), - m_pType( pType ), - m_pRemoteI( pRemoteI ), - m_pEnvUno( pEnvUno ), - m_pEnvRemote( pEnvRemote ), - m_mapRemote2Uno( pEnvRemote, pEnvUno ), - m_mapUno2Remote( pEnvUno , pEnvRemote ), - m_nRef( 1 ) -{ - typelib_typedescription_acquire( (typelib_TypeDescription * ) m_pType ); - m_pEnvUno->acquire( m_pEnvUno ); - m_pEnvRemote->acquire( m_pEnvRemote ); - - acquire = acquireRemote2UnoProxy; - release = releaseRemote2UnoProxy; - pDispatcher = dispatchRemote2UnoProxy; - - m_pEnvRemote->pExtEnv->registerInterface( - m_pEnvRemote->pExtEnv, - (void**)&m_pRemoteI, - m_sOid.pData, - m_pType ); - m_pRemoteI->acquire( m_pRemoteI ); - -#if OSL_DEBUG_LEVEL > 1 - thisCounter.acquire(); -#endif -} - -Remote2UnoProxy::~Remote2UnoProxy() -{ - // revoke external ref (oid) - m_pEnvRemote->pExtEnv->revokeInterface( m_pEnvRemote->pExtEnv , m_pRemoteI ); - - typelib_typedescription_release( (typelib_TypeDescription * )m_pType ); - m_pRemoteI->release( m_pRemoteI ); - m_pEnvUno->release( m_pEnvUno ); - m_pEnvRemote->release( m_pEnvRemote ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.release(); -#endif -} - -} // end namespace bridge_remote - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/static/remote.cxx b/bridges/source/remote/static/remote.cxx deleted file mode 100644 index e94743469271..000000000000 --- a/bridges/source/remote/static/remote.cxx +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <bridges/remote/remote.hxx> -#include <bridges/remote/counter.hxx> - -#if OSL_DEBUG_LEVEL > 1 -static MyCounter thisCounter( "DEBUG : Remote2RemoteStub"); -#endif - -using namespace bridges_remote; - -extern "C" { - -static void SAL_CALL thisRelease( remote_Interface *pThis ) -{ - Remote2RemoteStub *p = ( Remote2RemoteStub * ) pThis; - if (! osl_decrementInterlockedCount( &(p->m_nRef) )) - { - p->m_pEnvRemote->pExtEnv->revokeInterface( p->m_pEnvRemote->pExtEnv, pThis ); - - } -} - -static void SAL_CALL thisDispatch( - remote_Interface * pRemoteI, - typelib_TypeDescription const * pMemberType, - void * pReturn, - void * pArgs[], - uno_Any ** ppException ) -{ - Remote2RemoteStub *pThis = ( Remote2RemoteStub * ) pRemoteI; - - pThis->m_dispatch( pThis->m_pEnvRemote, - pMemberType, - pThis->m_sOid.pData, - pThis->m_pType, - pReturn, - pArgs, - ppException ); -} - -} - -namespace bridges_remote { - -void acquireRemote2RemoteStub( remote_Interface *pThis ) -{ - Remote2RemoteStub *p = ( Remote2RemoteStub * ) pThis; - if( 1 == osl_incrementInterlockedCount( &(p->m_nRef) ) ) - { - p->m_pEnvRemote->pExtEnv->registerProxyInterface( - p->m_pEnvRemote->pExtEnv, - (void**)&pThis, - freeRemote2RemoteStub, - p->m_sOid.pData, - p->m_pType ); - OSL_ASSERT( (remote_Interface *)p == pThis ); - } -} - -void freeRemote2RemoteStub(uno_ExtEnvironment *, void * stub) { - delete static_cast< Remote2RemoteStub * >(stub); -} - -Remote2RemoteStub::Remote2RemoteStub( rtl_uString *pOid, - typelib_InterfaceTypeDescription *pType, - uno_Environment *pEnvRemote, - requestClientSideDispatcher dispatch ) : - m_sOid( pOid ), - m_pType( (typelib_InterfaceTypeDescription * ) pType ), - m_nRef( 1 ), - m_pEnvRemote( pEnvRemote ), - m_dispatch( dispatch ), - m_nReleaseRemote( 1 ) -{ - typelib_typedescription_acquire( ( typelib_TypeDescription * ) m_pType ); - m_pEnvRemote->acquire( m_pEnvRemote ); - - acquire = acquireRemote2RemoteStub; - release = thisRelease; - pDispatcher = thisDispatch; -#if OSL_DEBUG_LEVEL > 1 - thisCounter.acquire(); -#endif -} - -Remote2RemoteStub::~Remote2RemoteStub() -{ - - // send a release via the connection ! - sal_Bool bNeedsRelease = sal_False; - if( ! m_pType->aBase.bComplete ) - { - // m_pType may be exchanged during complete, so it needs to be acquired - // (MT : Another thread may use m_pType during e.g. dispatch ! ). - typelib_typedescription_acquire( (typelib_TypeDescription*)m_pType ); - bNeedsRelease = sal_True; - typelib_typedescription_complete( (typelib_TypeDescription **) &m_pType ); - } - - uno_Any any; - uno_Any *pAny = &any; - - typelib_TypeDescription *pReleaseMethod = 0; - typelib_typedescriptionreference_getDescription( - &pReleaseMethod , - m_pType->ppAllMembers[REMOTE_RELEASE_METHOD_INDEX] ); - for( int i = 0 ; i < m_nReleaseRemote ; i ++ ) - { - thisDispatch( this, - pReleaseMethod, - 0, - 0, - &pAny ); - } - typelib_typedescription_release( pReleaseMethod ); - if( bNeedsRelease ) - { - typelib_typedescription_release( (typelib_TypeDescription * ) m_pType ); - } - - typelib_typedescription_release( (typelib_TypeDescription * ) m_pType ); - m_pEnvRemote->release( m_pEnvRemote ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.release(); -#endif -} - -void Remote2RemoteStub::releaseRemote() -{ - osl_incrementInterlockedCount( &m_nReleaseRemote ); -} - -} // end namespace bridges_remote - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/static/remote_types.cxx b/bridges/source/remote/static/remote_types.cxx deleted file mode 100644 index f47580d8da92..000000000000 --- a/bridges/source/remote/static/remote_types.cxx +++ /dev/null @@ -1,99 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include "remote_types.hxx" - -namespace bridges_remote { - -sal_Bool SAL_CALL remote_relatesToInterface2( typelib_TypeDescription * pTypeDescr ) -{ - switch (pTypeDescr->eTypeClass) - { - case typelib_TypeClass_SEQUENCE: - { - switch (((typelib_IndirectTypeDescription *)pTypeDescr)->pType->eTypeClass) - { - case typelib_TypeClass_SEQUENCE: - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: - { - typelib_TypeDescription * pTD = 0; - TYPELIB_DANGER_GET( &pTD, ((typelib_IndirectTypeDescription *)pTypeDescr)->pType ); - sal_Bool bRel = remote_relatesToInterface( pTD ); - TYPELIB_DANGER_RELEASE( pTD ); - return bRel; - } - default: - break; - } - } - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: - { - // ...optimized... to avoid getDescription() calls! - typelib_CompoundTypeDescription * pComp = (typelib_CompoundTypeDescription *)pTypeDescr; - typelib_TypeDescriptionReference ** pTypes = pComp->ppTypeRefs; - for ( sal_Int32 nPos = pComp->nMembers; nPos--; ) - { - switch (pTypes[nPos]->eTypeClass) - { - case typelib_TypeClass_INTERFACE: - case typelib_TypeClass_UNION: // might relate to interface - case typelib_TypeClass_ANY: // might relate to interface - return sal_True; - case typelib_TypeClass_SEQUENCE: - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: - { - typelib_TypeDescription * pTD = 0; - TYPELIB_DANGER_GET( &pTD, pTypes[nPos] ); - sal_Bool bRel = remote_relatesToInterface( pTD ); - TYPELIB_DANGER_RELEASE( pTD ); - if (bRel) - return sal_True; - break; - } - default: - break; - } - } - if (pComp->pBaseTypeDescription) - return remote_relatesToInterface( (typelib_TypeDescription *)pComp->pBaseTypeDescription ); - break; - } - default: - OSL_ASSERT( 0 ); - } - return sal_False; -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/static/remote_types.hxx b/bridges/source/remote/static/remote_types.hxx deleted file mode 100644 index 9325cbc18167..000000000000 --- a/bridges/source/remote/static/remote_types.hxx +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _BRIDGES_REMOTE_TYPES_HXX_ -#define _BRIDGES_REMOTE_TYPES_HXX_ - -#include <osl/diagnose.h> -#include <sal/types.h> -#include <typelib/typedescription.h> - -namespace bridges_remote -{ - -inline sal_Bool SAL_CALL remote_relatesToInterface( typelib_TypeDescription *pTypeDescr ); -sal_Bool SAL_CALL remote_relatesToInterface2( typelib_TypeDescription * pTypeDescr ); - - -/** Determines whether given type might relate or relates to an interface, - i.e. values of this type are interface or may contain interface(s).<br> - @param pTypeDescr type description of type - @return true if type might relate to an interface, false otherwise -*/ -inline sal_Bool SAL_CALL remote_relatesToInterface( typelib_TypeDescription * pTypeDescr ) -{ - switch (pTypeDescr->eTypeClass) - { - case typelib_TypeClass_SEQUENCE: - switch (((typelib_IndirectTypeDescription *)pTypeDescr)->pType->eTypeClass) - { - case typelib_TypeClass_INTERFACE: - case typelib_TypeClass_UNION: // might relate to interface - case typelib_TypeClass_ANY: // might relate to interface - return sal_True; - case typelib_TypeClass_SEQUENCE: - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: - return remote_relatesToInterface2( pTypeDescr ); - default: - return sal_False; - } - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: - return remote_relatesToInterface2( pTypeDescr ); - case typelib_TypeClass_UNION: // might relate to interface - case typelib_TypeClass_ANY: // might relate to interface - case typelib_TypeClass_INTERFACE: - return sal_True; - default: - return sal_False; - } -} - -/** Determines whether given type is a cpp simple type, e.g. int, enum.<br> - @param pTypeDescr type description of type - @return true if type is a cpp simple type, false otherwise -*/ -inline sal_Bool SAL_CALL remote_isSimpleType( typelib_TypeDescription * pTypeDescr ) -{ - return (pTypeDescr->eTypeClass <= typelib_TypeClass_ENUM && - pTypeDescr->eTypeClass != typelib_TypeClass_STRING && - pTypeDescr->eTypeClass != typelib_TypeClass_ANY && - pTypeDescr->eTypeClass != typelib_TypeClass_TYPE); -} - -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/static/stub.cxx b/bridges/source/remote/static/stub.cxx deleted file mode 100644 index 0a1bb3450328..000000000000 --- a/bridges/source/remote/static/stub.cxx +++ /dev/null @@ -1,339 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <sal/alloca.h> -#include <osl/diagnose.h> - -#include <uno/data.h> -#include <uno/mapping.hxx> - -#include <bridges/remote/stub.hxx> -#include <bridges/remote/proxy.hxx> -#include <bridges/remote/context.h> -#include <bridges/remote/bridgeimpl.hxx> - -#include "remote_types.hxx" - -#if OSL_DEBUG_LEVEL > 1 -#include <bridges/remote/counter.hxx> -static MyCounter thisCounter( "DEBUG : Uno2RemoteStub"); -#endif - -using namespace ::com::sun::star::uno; -using namespace bridges_remote; - -extern "C" { - -void SAL_CALL thisRelease( remote_Interface *pThis ) -{ - Uno2RemoteStub *p = ( Uno2RemoteStub * ) pThis; - if (! osl_decrementInterlockedCount( &(p->m_nRef) )) - { - p->m_pEnvRemote->pExtEnv->revokeInterface( p->m_pEnvRemote->pExtEnv, pThis ); - } -} - -void SAL_CALL thisDispatch( - remote_Interface * pRemoteI, - typelib_TypeDescription const * pType, - void * pReturn, - void * ppArgs[], - uno_Any ** ppException ) -{ - Uno2RemoteStub *p = ( Uno2RemoteStub * ) pRemoteI; - - RemoteThreadCounter counter( p->m_pEnvRemote ); - - typelib_InterfaceMethodTypeDescription *pMethodType = 0; - typelib_InterfaceAttributeTypeDescription *pAttributeType = 0; - typelib_TypeDescription *pReturnType = 0; - typelib_TypeDescription **ppArgType = 0; - sal_Int32 nArgCount = 0; - sal_Bool *pbIsIn = 0; - sal_Bool *pbIsOut = 0; - sal_Bool bConversionNeededForReturn = sal_False; - sal_Bool *pbConversionNeeded = 0; - - sal_Int32 i; - //-------------------------------- - // Collect all needed types ! - //-------------------------------- - if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pType->eTypeClass ) - { - pAttributeType = ( typelib_InterfaceAttributeTypeDescription * ) pType; - if( pReturn ) - { - TYPELIB_DANGER_GET( &pReturnType , pAttributeType->pAttributeTypeRef ); - bConversionNeededForReturn = remote_relatesToInterface( pReturnType ); - } - else - { - nArgCount = 1; - ppArgType = (typelib_TypeDescription **) alloca( sizeof( void * ) ); - pbIsIn = ( sal_Bool * ) alloca( sizeof( sal_Bool ) ); - pbIsOut = ( sal_Bool * ) alloca( sizeof( sal_Bool ) ); - pbConversionNeeded = ( sal_Bool * ) alloca( sizeof( sal_Bool ) ); - pbIsIn[0] = sal_True; - pbIsOut[0] = sal_False; - ppArgType[0] = 0; - TYPELIB_DANGER_GET( &( ppArgType[0] ) , pAttributeType->pAttributeTypeRef ); - pbConversionNeeded[0] = remote_relatesToInterface( ppArgType[0] ); - } - } - if( typelib_TypeClass_INTERFACE_METHOD == pType->eTypeClass ) - { - pMethodType = ( typelib_InterfaceMethodTypeDescription * ) pType; - TYPELIB_DANGER_GET( &pReturnType , pMethodType->pReturnTypeRef ); - bConversionNeededForReturn = remote_relatesToInterface( pReturnType ); - nArgCount = pMethodType->nParams; - ppArgType = (typelib_TypeDescription **) alloca( sizeof( void * ) * nArgCount ); - pbIsIn = (sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount ); - pbIsOut = (sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount ); - pbConversionNeeded = ( sal_Bool * ) alloca( sizeof( sal_Bool ) * nArgCount ); - - for( i = 0 ; i < nArgCount ; i ++ ) - { - ppArgType[i] = 0; - TYPELIB_DANGER_GET( & (ppArgType[i]) , pMethodType->pParams[i].pTypeRef ); - pbIsIn[i] = pMethodType->pParams[i].bIn; - pbIsOut[i] = pMethodType->pParams[i].bOut; - pbConversionNeeded[i] = remote_relatesToInterface( ppArgType[i] ); - } - } - - // create Mapping - - void *pUnoReturn = 0; - void **ppUnoArgs = 0; - - if( pReturnType ) - { - if( bConversionNeededForReturn ) - { - pUnoReturn = alloca( pReturnType->nSize ); - } - else - { - pUnoReturn = pReturn; - } - } - - ppUnoArgs = (void **) alloca( nArgCount * sizeof( void * ) ); - for( i = 0 ; i < nArgCount ; i ++ ) - { - if( pbConversionNeeded[i] ) - { - ppUnoArgs[i] = alloca( ppArgType[i]->nSize ); - if( pbIsIn[i] ) - { - uno_copyAndConvertData( - ppUnoArgs[i], - ppArgs[i], - ppArgType[i], - p->m_mapRemote2Uno.get() - ); - } - } - else - { - ppUnoArgs[i] = ppArgs[i]; - } - } - - // do the call - uno_Any any; - uno_Any *pAny = &any; - - p->m_pUnoI->pDispatcher( p->m_pUnoI, - pType, - pUnoReturn, - ppUnoArgs, - &pAny); - - if( ! pAny ) - { - // ------------------ - // No Exception - // ------------------ - - // Map return value - if( pReturnType && bConversionNeededForReturn ) - { - uno_copyAndConvertData( - pReturn , - pUnoReturn, - pReturnType, - p->m_mapUno2Remote.get() ); - uno_destructData( pUnoReturn , pReturnType, 0 ); - } - - // map arguments - for( i = 0 ; i < nArgCount ; i ++ ) - { - if( pbConversionNeeded[i] ) - { - if( pbIsIn[i] ) { - if( pbIsOut[i] ) { - uno_destructData( - ppArgs[i] , - ppArgType[i] , - remote_release ); - uno_copyAndConvertData( ppArgs[i] , - ppUnoArgs[i], - ppArgType[i], - p->m_mapUno2Remote.get() ); - } - } - else // pure out - { - uno_copyAndConvertData( ppArgs[i] , - ppUnoArgs[i], - ppArgType[i], - p->m_mapUno2Remote.get() ); - } - uno_destructData( ppUnoArgs[i], - ppArgType[i], - 0 ); - } - } - *ppException = 0; - } - else - { - // ----------------------- - // an exception occurred - // ----------------------- - typelib_TypeDescription *pAnyType = 0; - getCppuType( (Any*) 0 ).getDescription( &pAnyType ); - uno_copyAndConvertData( *ppException , - pAny , - pAnyType, - p->m_mapUno2Remote.get() ); - uno_destructData( pAny , pAnyType , 0 ); - typelib_typedescription_release( pAnyType ); - - // destruct uno in parameters ( out parameters have not been constructed ) - for( i = 0 ; i < nArgCount ; i ++ ) - { - if( pbConversionNeeded[i] && pbIsIn[i] ) - { - uno_destructData( ppUnoArgs[i], - ppArgType[i], - 0 ); - } - } - } - - //-------------------------- - // release all acquired types - //-------------------------- - if( pReturnType ) - { - TYPELIB_DANGER_RELEASE( pReturnType ); - } - for( i = 0 ; i < nArgCount ; i ++ ) - { - TYPELIB_DANGER_RELEASE( ppArgType[ i] ); - } -} - -} - -namespace bridges_remote { - -void acquireUno2RemoteStub( remote_Interface *pThis ) -{ - Uno2RemoteStub *p = ( Uno2RemoteStub * ) pThis; - if( 1 == osl_incrementInterlockedCount( &(p->m_nRef) ) ) - { - - p->m_pEnvRemote->pExtEnv->registerProxyInterface( - p->m_pEnvRemote->pExtEnv, - (void**)&pThis, - freeUno2RemoteStub, - p->m_sOid.pData, - p->m_pType ); - - OSL_ASSERT( (remote_Interface*) p == pThis ); - } -} - -void freeUno2RemoteStub(uno_ExtEnvironment *, void * stub) { - delete static_cast< Uno2RemoteStub * >(stub); -} - -Uno2RemoteStub::Uno2RemoteStub( uno_Interface *pUnoI, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pType, - uno_Environment *pEnvUno, - uno_Environment *pEnvRemote ) : - m_sOid( pOid ), - m_pType( pType ), - m_pUnoI( pUnoI ), - m_nRef( 1 ), - m_pEnvUno( pEnvUno ), - m_pEnvRemote( pEnvRemote ), - m_mapRemote2Uno( pEnvRemote, pEnvUno ), - m_mapUno2Remote( pEnvUno, pEnvRemote ) -{ - typelib_typedescription_acquire( (typelib_TypeDescription * )m_pType ); - m_pEnvUno->acquire( m_pEnvUno ); - m_pEnvRemote->acquire( m_pEnvRemote ); - - acquire = acquireUno2RemoteStub; - release = thisRelease; - pDispatcher = thisDispatch; - - m_pEnvUno->pExtEnv->registerInterface( m_pEnvUno->pExtEnv, - (void **)&m_pUnoI, - m_sOid.pData, - m_pType ); - m_pUnoI->acquire( m_pUnoI ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.acquire(); -#endif -} - -Uno2RemoteStub::~Uno2RemoteStub() -{ - m_pEnvUno->pExtEnv->revokeInterface( m_pEnvUno->pExtEnv , m_pUnoI ); - - typelib_typedescription_release( (typelib_TypeDescription * )m_pType ); - m_pUnoI->release( m_pUnoI ); - m_pEnvUno->release( m_pEnvUno ); - m_pEnvRemote->release( m_pEnvRemote ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.release(); -#endif -} - -} // end namespace bridges_remote - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/makefile.mk b/bridges/source/remote/urp/makefile.mk deleted file mode 100644 index eaa3f3a6f146..000000000000 --- a/bridges/source/remote/urp/makefile.mk +++ /dev/null @@ -1,78 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/..$/.. - -PRJNAME=bridges -TARGET=urp_uno -ENABLE_EXCEPTIONS=TRUE -USE_DEFFILE=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# ------------------------------------------------------------------ - -SLOFILES= \ - $(SLO)$/urp_environment.obj \ - $(SLO)$/urp_marshal.obj \ - $(SLO)$/urp_unmarshal.obj \ - $(SLO)$/urp_dispatch.obj \ - $(SLO)$/urp_job.obj \ - $(SLO)$/urp_reader.obj \ - $(SLO)$/urp_writer.obj \ - $(SLO)$/urp_log.obj \ - $(SLO)$/urp_bridgeimpl.obj \ - $(SLO)$/urp_propertyobject.obj \ - $(SLO)$/urp_threadid.obj - -.IF "$(COM)"=="GCC" -NOOPTFILES= \ - $(SLO)$/urp_reader.obj -.ENDIF # "$(COM)"=="GCC" - -SHL1TARGET= $(TARGET) - -SHL1DEF=$(MISC)$/$(SHL1TARGET).def -SHL1VERSIONMAP=..$/..$/bridge_exports.map -SHL1RPATH=URELIB - -SHL1STDLIBS=\ - $(SALLIB)\ - $(CPPULIB) - -SHL1LIBS=\ - $(SLB)$/$(TARGET).lib \ - $(SLB)$/bridges_remote_static.lib - -DEF1NAME= $(SHL1TARGET) - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - diff --git a/bridges/source/remote/urp/urp_bridgeimpl.cxx b/bridges/source/remote/urp/urp_bridgeimpl.cxx deleted file mode 100644 index 0e25746f0a42..000000000000 --- a/bridges/source/remote/urp/urp_bridgeimpl.cxx +++ /dev/null @@ -1,253 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <osl/thread.h> -#include <bridges/remote/helper.hxx> - -#include <algorithm> - -#include "urp_bridgeimpl.hxx" - -using namespace ::rtl; -using namespace ::osl; -using namespace ::com::sun::star::uno; -namespace bridges_urp -{ - -template < class t > -inline t mymin( const t & val1, const t & val2 ) -{ - return val1 < val2 ? val1 : val2; -} - -/*********** - * urp_BridgeImpl - ***********/ -urp_BridgeImpl::urp_BridgeImpl( sal_Int32 nCacheSize , sal_uInt32 nInitialMarshalerSize ) : - m_blockMarshaler( this , nInitialMarshalerSize , ::bridges_remote::remote_retrieveOidFromProxy), - m_nMarshaledMessages( 0 ), - m_oidCacheOut( (sal_uInt16)nCacheSize ), - m_tidCacheOut( (sal_uInt16)nCacheSize ), - m_typeCacheOut( (sal_uInt16)nCacheSize ) -{ - m_pOidIn = new OUString[ nCacheSize ]; - m_pTidIn = new ByteSequence[ nCacheSize ]; - m_pTypeIn = new Type[ nCacheSize ]; - m_nRemoteThreads = 0; -} - -urp_BridgeImpl::~urp_BridgeImpl() -{ - delete [] m_pOidIn; - delete [] m_pTidIn; - delete [] m_pTypeIn; -} - - -void urp_BridgeImpl::applyProtocolChanges( const Properties &props ) -{ - if( m_properties.nTypeCacheSize != props.nTypeCacheSize ) - { - if( props.nTypeCacheSize == 0 ) - { - delete [] m_pTypeIn; - m_pTypeIn = 0; - } - else - { - Type *pNew = new Type[props.nTypeCacheSize]; - sal_Int32 i; - sal_Int32 iMin = mymin( m_properties.nTypeCacheSize , props.nTypeCacheSize ); - for( i = 0; i < iMin ; i ++ ) - { - pNew[i] = m_pTypeIn[i]; - } - delete [] m_pTypeIn; - m_pTypeIn = pNew; - } - OSL_ASSERT( props.nTypeCacheSize <= 0xffff ); - m_properties.nTypeCacheSize = props.nTypeCacheSize; - m_typeCacheOut.resize( (sal_uInt16)props.nTypeCacheSize ); - } - - if( m_properties.nOidCacheSize != props.nOidCacheSize ) - { - if( 0 == props.nOidCacheSize ) - { - delete [] m_pOidIn; - m_pOidIn = 0; - } - else - { - OUString *pNew = new OUString[props.nOidCacheSize]; - sal_Int32 i; - sal_Int32 iMin = mymin( m_properties.nOidCacheSize , props.nOidCacheSize ); - for( i = 0; i < iMin ; i ++ ) - { - pNew[i] = m_pOidIn[i]; - } - delete [] m_pOidIn; - m_pOidIn = pNew; - } - OSL_ASSERT( props.nOidCacheSize <= 0xffff ); - m_oidCacheOut.resize( (sal_uInt16)props.nOidCacheSize ); - m_properties.nOidCacheSize = props.nOidCacheSize; - } - - if( m_properties.nTidCacheSize != props.nTidCacheSize ) - { - if( 0 == props.nTidCacheSize ) - { - delete [] m_pTidIn; - m_pTidIn = 0; - } - else - { - ByteSequence *pNew = new ByteSequence[props.nTidCacheSize]; - sal_Int32 i; - sal_Int32 iMin = mymin( m_properties.nTidCacheSize , props.nTidCacheSize ); - for( i = 0; i < iMin ; i ++ ) - { - pNew[i] = m_pTidIn[i]; - } - delete [] m_pTidIn; - m_pTidIn = pNew; - } - OSL_ASSERT( props.nTidCacheSize <= 0xffff ); - m_tidCacheOut.resize( (sal_uInt16)props.nTidCacheSize ); - m_properties.nTidCacheSize = props.nTidCacheSize; - } - - if( m_properties.sVersion != props.sVersion ) - { - m_properties.sVersion = props.sVersion; - } - - if( m_properties.nFlushBlockSize != props.nFlushBlockSize ) - { - m_properties.nFlushBlockSize = props.nFlushBlockSize; - } - - if( m_properties.nOnewayTimeoutMUSEC != props.nOnewayTimeoutMUSEC ) - { - m_properties.nOnewayTimeoutMUSEC = props.nOnewayTimeoutMUSEC; - } - - if( props.bClearCache ) - { - if( m_properties.nTypeCacheSize ) - { - delete [] m_pTypeIn; - m_pTypeIn = new Type[m_properties.nTypeCacheSize]; - m_typeCacheOut.clear(); - } - m_lastInType = Type(); - m_lastOutType = Type(); - - if( m_properties.nOidCacheSize ) - { - delete [] m_pOidIn; - m_pOidIn = new OUString[ m_properties.nOidCacheSize]; - m_oidCacheOut.clear(); - } - m_lastOutOid = OUString(); - m_lastInOid = OUString(); - - if( m_properties.nTidCacheSize ) - { - delete [] m_pTidIn; - m_pTidIn = new ByteSequence[m_properties.nTidCacheSize]; - m_tidCacheOut.clear(); - } - m_lastInTid = ByteSequence(); - m_lastOutTid = ByteSequence(); - } - - if( m_properties.bNegotiate != props.bNegotiate ) - { - m_properties.bNegotiate = props.bNegotiate; - } - - if( m_properties.bForceSynchronous != props.bForceSynchronous ) - { - m_properties.bForceSynchronous = props.bForceSynchronous; - } - - m_properties.bCurrentContext = props.bCurrentContext; -} - -void urp_BridgeImpl::addError( char const *pError ) -{ - OUString message = OUString(RTL_CONSTASCII_USTRINGPARAM("(tid=" )); - message += OUString::valueOf( (sal_Int32 ) osl_getThreadIdentifier( 0 ) ); - message += OUString(RTL_CONSTASCII_USTRINGPARAM(") ")); - message += OUString::createFromAscii( pError ); - MutexGuard guard( m_errorListMutex ); - m_lstErrors.push_back( message ); -} - -void urp_BridgeImpl::addError( const OUString & error ) -{ - OUString message = OUString(RTL_CONSTASCII_USTRINGPARAM("(tid=")); - message += OUString::valueOf( (sal_Int32 ) osl_getThreadIdentifier( 0 ) ); - message += OUString(RTL_CONSTASCII_USTRINGPARAM(") ")); - message += error; - MutexGuard guard( m_errorListMutex ); - m_lstErrors.push_back( message ); -} - -void urp_BridgeImpl::dumpErrors( FILE * f) -{ - MutexGuard guard( m_errorListMutex ); - for( ::std::list< OUString >::iterator ii = m_lstErrors.begin() ; - ii != m_lstErrors.end() ; - ++ii ) - { - OString o = OUStringToOString( *ii , RTL_TEXTENCODING_UTF8 ); - fprintf( f, "%s\n" , o.getStr() ); - } -} - -OUString urp_BridgeImpl::getErrorsAsString( ) -{ - MutexGuard guard( m_errorListMutex ); - OUString ret; - for( ::std::list< OUString >::iterator ii = m_lstErrors.begin() ; - ii != m_lstErrors.end() ; - ++ii ) - { - ret += *ii; - } - return ret; -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_bridgeimpl.hxx b/bridges/source/remote/urp/urp_bridgeimpl.hxx deleted file mode 100644 index 4e6d31d22505..000000000000 --- a/bridges/source/remote/urp/urp_bridgeimpl.hxx +++ /dev/null @@ -1,130 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _URP_BRIDGEIMPL_HXX_ -#define _URP_BRIDGEIMPL_HXX_ - -#include <stdio.h> -#include <osl/mutex.hxx> -#include <osl/conditn.hxx> -#include <rtl/ustring.hxx> -#include <rtl/byteseq.hxx> - -#include <uno/threadpool.h> -#include <bridges/remote/bridgeimpl.hxx> - -#include "urp_cache.hxx" -#include "urp_marshal_decl.hxx" - -#include "urp_replycontainer.hxx" -#include "urp_property.hxx" - - -namespace bridges_urp -{ - -class PropertyObject; - -struct equalOUString -{ - sal_Int32 operator() ( const ::rtl::OUString &s1, const ::rtl::OUString &s2 ) const - { - return s1 == s2; - } -}; - -struct equalType -{ - sal_Int32 operator() ( const ::com::sun::star::uno::Type &t1, - const ::com::sun::star::uno::Type &t2 ) const - { - return t1 == t2; - } -}; - -class OWriterThread; -class OReaderThread; - -struct urp_BridgeImpl : - public remote_BridgeImpl -{ - urp_BridgeImpl( sal_Int32 nCacheSize , sal_uInt32 nInitialMarshalerSize ); - ~urp_BridgeImpl(); - - void applyProtocolChanges( const Properties & ); - - void startBlockBridge(); - void stopBlockBridge(); - void addError( char const *pError ); - void addError( const ::rtl::OUString &anError ); - void dumpErrors( FILE *f ); - ::rtl::OUString getErrorsAsString(); - - ::osl::Mutex m_marshalingMutex; - ::osl::Mutex m_disposingMutex; - ::osl::Mutex m_errorListMutex; - Marshal m_blockMarshaler; - sal_Int32 m_nMarshaledMessages; - - // Caches for vars, that go from local process to the remote process - Cache < ::rtl::OUString , equalOUString > m_oidCacheOut; - Cache < ::rtl::ByteSequence , EqualThreadId > m_tidCacheOut; - Cache < ::com::sun::star::uno::Type , equalType > m_typeCacheOut; - - ::com::sun::star::uno::Type m_lastOutType; - ::rtl::ByteSequence m_lastOutTid; - ::rtl::OUString m_lastOutOid; - - // Caches for vars, that come from the remote process to the local process - ::rtl::OUString *m_pOidIn; - ::rtl::ByteSequence *m_pTidIn; - ::com::sun::star::uno::Type *m_pTypeIn; - - ::com::sun::star::uno::Type m_lastInType; - ::rtl::ByteSequence m_lastInTid; - ::rtl::OUString m_lastInOid; - - urp_ClientJobContainer m_clientJobContainer; - - OWriterThread *m_pWriter; - OReaderThread *m_pReader; - ::rtl::OString m_sLogFileName; - FILE *m_pLogFile; - ::osl::Condition m_initialized; - ::osl::Condition m_cndWaitForThreads; - - struct Properties m_properties; - class PropertyObject *m_pPropertyObject; - ::std::list< ::rtl::OUString > m_lstErrors; - uno_ThreadPool m_hThreadPool; -}; - - -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_cache.h b/bridges/source/remote/urp/urp_cache.h deleted file mode 100644 index a0150c854594..000000000000 --- a/bridges/source/remote/urp/urp_cache.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -namespace bridges_urp -{ - template < class t , class tequals > - class Cache - { - public: - inline Cache ( sal_uInt16 nMaxEntries ); - inline ~Cache(); - - // puts the value t into the cache. Returns then entry, - // that is used for this value. - inline sal_uInt16 put( const t & ); - - // lookup, if there is an entry for this value - // returns 0xffff, when value cannot be found in the list - inline sal_uInt16 seek( const t & ); - - // resizes the cache, conserving overlapping values - inline void resize( sal_uInt16 nNewMaxEntries ); - - // empties the cache - inline void clear(); - private: - t *m_pCache; - ::std::list< sal_uInt16 > m_lstLeastRecentlyUsed; - sal_uInt16 m_nMaxEntries; - sal_uInt16 m_nEntries; - }; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_cache.hxx b/bridges/source/remote/urp/urp_cache.hxx deleted file mode 100644 index 5aec834199be..000000000000 --- a/bridges/source/remote/urp/urp_cache.hxx +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <stdio.h> -#include <list> -#include <algorithm> -#include <rtl/ustring.hxx> - -#include "urp_threadid.hxx" -#include "urp_cache.h" - -namespace bridges_urp -{ - - template < class t , class tequals > - inline Cache< t , tequals >::Cache( sal_uInt16 nMaxEntries ) : - m_pCache( new t[nMaxEntries] ), - m_nMaxEntries( nMaxEntries ), - m_nEntries( 0 ) - { - - } - - template < class t , class tequals > - inline Cache< t , tequals >::~Cache( ) - { - delete [] m_pCache; - } - - - template < class t , class tequals > - inline sal_uInt16 Cache< t , tequals >::put( const t & value ) - { - if( ! m_nMaxEntries ) - { - return 0xffff; - } - sal_uInt16 nEntry = 0xffff; - if( m_nEntries < m_nMaxEntries ) - { - // cache has still empty places - m_pCache[m_nEntries] = value; - nEntry = m_nEntries; - m_nEntries ++; - - // add it to the cache - m_lstLeastRecentlyUsed.push_front( nEntry ); - } - else - { - // cache is full, remove an element and insert the new one - nEntry = m_lstLeastRecentlyUsed.back(); - m_lstLeastRecentlyUsed.pop_back(); - m_lstLeastRecentlyUsed.push_front( nEntry ); - - m_pCache[nEntry] = value; - } - return nEntry; - } - - template < class t , class tequals > - inline sal_uInt16 Cache< t , tequals >::seek( const t & value ) - { - for( ::std::list< sal_uInt16 >::iterator ii = m_lstLeastRecentlyUsed.begin() ; - ii != m_lstLeastRecentlyUsed.end() ; - ++ ii ) - { - if( value == m_pCache[*ii] ) - { - sal_uInt16 nEntry = *ii; - m_lstLeastRecentlyUsed.erase( ii ); - m_lstLeastRecentlyUsed.push_front( nEntry ); - return nEntry; - } - } - return 0xffff; - } - - // helper predicate for element removal - template < class t > - struct PredicateOverMax - { - t m_; - inline PredicateOverMax( const t &value ) : m_(value) - {} - sal_Int32 operator () ( const t &value ) const - { return value >= m_; } - }; - - template < class t, class tequals > - inline void Cache < t , tequals >::resize( sal_uInt16 nNewMaxEntries ) - { - if( 0 == nNewMaxEntries ) - { - m_lstLeastRecentlyUsed.clear(); - delete [] m_pCache; - m_pCache = 0; - m_nMaxEntries = 0; - } - else - { - // allocate - t *pNew = new t[nNewMaxEntries]; - sal_Int32 nMin = nNewMaxEntries < m_nMaxEntries ? nNewMaxEntries : m_nMaxEntries; - - // copy - for( sal_Int32 i = 0; i < nMin ; i ++ ) - { - pNew[i] = m_pCache[i]; - } - // delete - delete [] m_pCache; - - // assign - m_pCache = pNew; - - // remove overlapping lru cache entries - ::std::remove_if(m_lstLeastRecentlyUsed.begin(), - m_lstLeastRecentlyUsed.end(), - PredicateOverMax< sal_Int32 > ( nMin ) ); - } - m_nMaxEntries = nNewMaxEntries; - m_nEntries = m_nEntries < m_nMaxEntries ? - m_nEntries : m_nMaxEntries; - } - - template < class t, class tequals > - inline void Cache < t, tequals >:: clear() - { - for( sal_Int32 i = 0; i < m_nMaxEntries ; i ++ ) - { - m_pCache[i] = t(); - } - m_lstLeastRecentlyUsed.clear(); - m_nEntries = 0; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_dispatch.cxx b/bridges/source/remote/urp/urp_dispatch.cxx deleted file mode 100644 index 459900b2460a..000000000000 --- a/bridges/source/remote/urp/urp_dispatch.cxx +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <sal/alloca.h> -#include <osl/mutex.hxx> -#include <osl/diagnose.h> - -#include <rtl/alloc.h> -#include <rtl/ustrbuf.hxx> - -#include <uno/mapping.hxx> -#include <uno/threadpool.h> - -#include <bridges/remote/remote.h> -#include <bridges/remote/stub.hxx> -#include <bridges/remote/proxy.hxx> -#include <bridges/remote/remote.hxx> - -#include "urp_bridgeimpl.hxx" -#include "urp_marshal.hxx" -#include "urp_dispatch.hxx" -#include "urp_job.hxx" -#include "urp_writer.hxx" -#include "urp_log.hxx" - -using namespace ::rtl; -using namespace ::osl; -using namespace ::com::sun::star::uno; - -namespace bridges_urp -{ - -void SAL_CALL urp_sendCloseConnection( uno_Environment *pEnvRemote ) -{ - remote_Context *pContext = (remote_Context *) pEnvRemote->pContext; - urp_BridgeImpl *pImpl = (urp_BridgeImpl*) ( pContext->m_pBridgeImpl ); - - { - MutexGuard guard( pImpl->m_marshalingMutex ); - - // send immediately - if( ! pImpl->m_blockMarshaler.empty() ) - { - pImpl->m_pWriter->touch( sal_True ); - } - - pImpl->m_pWriter->sendEmptyMessage(); - } -} -extern "C" void SAL_CALL urp_sendRequest( - uno_Environment *pEnvRemote, - typelib_TypeDescription const * pMemberType, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pInterfaceType, - void *pReturn, - void *ppArgs[], - uno_Any **ppException ) -{ - remote_Context *pContext = (remote_Context *) pEnvRemote->pContext; - urp_BridgeImpl *pImpl = (urp_BridgeImpl*) ( pContext->m_pBridgeImpl ); - pImpl->m_initialized.wait(); - urp_sendRequest_internal( - pEnvRemote, pMemberType, pOid, pInterfaceType, pReturn, ppArgs, - ppException ); -} -void SAL_CALL urp_sendRequest_internal( - uno_Environment *pEnvRemote, - typelib_TypeDescription const * pMemberType, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pInterfaceType, - void *pReturn, - void *ppArgs[], - uno_Any **ppException ) -{ - remote_Context *pContext = (remote_Context *) pEnvRemote->pContext; - urp_BridgeImpl *pImpl = (urp_BridgeImpl*) ( pContext->m_pBridgeImpl ); - - ClientJob job( - pEnvRemote, pContext, pImpl, pOid, pMemberType, pInterfaceType, pReturn, - ppArgs, ppException); - - if( job.pack() && ! job.isOneway() ) - { - job.wait(); - } -} - -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_dispatch.hxx b/bridges/source/remote/urp/urp_dispatch.hxx deleted file mode 100644 index 2b44854e3350..000000000000 --- a/bridges/source/remote/urp/urp_dispatch.hxx +++ /dev/null @@ -1,80 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <rtl/ustring.hxx> - -#include <typelib/typedescription.h> - -#include <uno/any2.h> - - -typedef struct _uno_Environment uno_Environment; -struct remote_Interface; - - - -namespace bridges_urp { - - const sal_uInt8 HDRFLAG_LONGHEADER = 0x80; - const sal_uInt8 HDRFLAG_REQUEST = 0x40; - const sal_uInt8 HDRFLAG_NEWTYPE = 0x20; - const sal_uInt8 HDRFLAG_NEWOID = 0x10; - const sal_uInt8 HDRFLAG_NEWTID = 0x08; - const sal_uInt8 HDRFLAG_LONGMETHODID = 0x04; - const sal_uInt8 HDRFLAG_IGNORECACHE = 0x02; - const sal_uInt8 HDRFLAG_MOREFLAGS = 0x01; - const sal_uInt8 HDRFLAG_MUSTREPLY = 0x80; - const sal_uInt8 HDRFLAG_SYNCHRONOUS = 0x40; - - const sal_uInt8 HDRFLAG_EXCEPTION = 0x20; - - void SAL_CALL urp_sendCloseConnection( uno_Environment *pEnvRemote ); - - extern "C" void SAL_CALL urp_sendRequest( - uno_Environment *pEnvRemote, - typelib_TypeDescription const * pMemberType, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pInterfaceType, - void *pReturn, - void *ppArgs[], - uno_Any **ppException - ); - - void SAL_CALL urp_sendRequest_internal( - uno_Environment *pEnvRemote, - typelib_TypeDescription const * pMemberType, - rtl_uString *pOid, - typelib_InterfaceTypeDescription *pInterfaceType, - void *pReturn, - void *ppArgs[], - uno_Any **ppException - ); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_environment.cxx b/bridges/source/remote/urp/urp_environment.cxx deleted file mode 100644 index f1a61896202b..000000000000 --- a/bridges/source/remote/urp/urp_environment.cxx +++ /dev/null @@ -1,554 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" - -#include <stdio.h> - -#include <osl/interlck.h> -#include <osl/diagnose.h> -#include <osl/conditn.h> -#include <osl/mutex.hxx> -#include <osl/process.h> - -#include <rtl/alloc.h> -#include <rtl/uuid.h> -#include <rtl/unload.h> - -#include <uno/environment.h> -#include <uno/lbnames.h> -#include <uno/mapping.hxx> -#include <uno/threadpool.h> - -#include <com/sun/star/uno/Sequence.hxx> - -#include <bridges/remote/proxy.hxx> -#include <bridges/remote/stub.hxx> -#include <bridges/remote/context.h> -#include <bridges/remote/mapping.hxx> -#include <bridges/remote/counter.hxx> -#include <bridges/remote/bridgeimpl.hxx> -#include <bridges/remote/helper.hxx> - -#include "urp_bridgeimpl.hxx" -#include "urp_writer.hxx" -#include "urp_reader.hxx" -#include "urp_dispatch.hxx" -#include "urp_log.hxx" -#include "urp_propertyobject.hxx" - -using namespace ::rtl; -using namespace ::osl; -using namespace ::com::sun::star::uno; - -namespace bridges_urp -{ -rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; - -// static void dumpProperties( struct Properties *p ) -// { -// fprintf( stderr , "FlushBlockSize : %d\n" , p->nFlushBlockSize ); -// fprintf( stderr , "OnewayTimeoutMUSEC : %d\n" , p->nOnewayTimeoutMUSEC ); -// fprintf( stderr , "OidCacheSize : %d\n" , p->nOidCacheSize ); -// fprintf( stderr , "TypeCacheSize : %d\n" , p->nTypeCacheSize ); -// fprintf( stderr , "TidCacheSize : %d\n" , p->nTidCacheSize ); -// OString o = OUStringToOString( p->sSupportedVersions , RTL_TEXTENCODING_ASCII_US ); -// fprintf( stderr , "SupportedVersions : %s\n" , o.pData->buffer ); -// o = OUStringToOString( p->sVersion , RTL_TEXTENCODING_ASCII_US ); -// fprintf( stderr , "Version : %s\n" , o.pData->buffer ); -// fprintf( stderr , "SupportsMultipleSynchronous : %d\n" , p->bSupportsMultipleSynchronous ); -// fprintf( stderr , "SupportsMustReply : %d\n" , p->bSupportsMustReply ); -// fprintf( stderr , "SupportsSynchronous : %d\n" , p->bSupportsSynchronous ); -// } - -// PropertySetterThread -//------------------------------------ -class PropertySetterThread : public ::osl::Thread -{ - urp_BridgeImpl *m_pImpl; - ::rtl::OUString m_sProps; - uno_Environment *m_pEnvRemote; -public: - PropertySetterThread( uno_Environment *pEnvRemote, - urp_BridgeImpl *pImpl, - const ::rtl::OUString & props ) - : m_pImpl( pImpl ) - , m_sProps( props ) - , m_pEnvRemote( pEnvRemote ) - { - if (m_sProps.getLength() > 0) { - m_sProps += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(",")); - } - m_sProps += rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM("CurrentContext=")); - // hold the environment in case all references are released before this - // thread terminates - m_pEnvRemote->acquire( pEnvRemote ); - } - ~PropertySetterThread() - { - m_pEnvRemote->release( m_pEnvRemote ); - } - - virtual void SAL_CALL run() - { - for (;;) - { - switch ( m_pImpl->m_pPropertyObject->localRequestChange( ) ) - { - case 1: - sal_Bool bExceptionThrown; - m_pImpl->m_pPropertyObject->localCommitChange( m_sProps , &bExceptionThrown ); - OSL_ENSURE( !bExceptionThrown, "properties were not set\n" ); - goto done; - case 0: - OSL_TRACE( "urp-bridge : remote-counterpart won the changing-the-protocol-race\n" ); - goto done; - } - } - done: - m_pImpl->m_initialized.set(); - } - virtual void SAL_CALL onTerminated() - { - delete this; - } -}; -//------------------------------------ - - -void test_cache() -{ - OUString a = OUString( RTL_CONSTASCII_USTRINGPARAM( "a" ) ); - OUString b = OUString( RTL_CONSTASCII_USTRINGPARAM( "b" ) ); - OUString c = OUString( RTL_CONSTASCII_USTRINGPARAM( "c" ) ); - Cache < OUString , equalOUString > cache ( 2 ); - - sal_Int32 n = cache.put( a ); - if (cache.seek( a ) != n) - { - OSL_ASSERT( false ); - } - OSL_ASSERT( 0 == n ); - - n = cache.put( b ); - OSL_ASSERT( 1 == n ); - - cache.put( c ); - - OSL_ASSERT( 0xffff == cache.seek( a ) ); - OSL_ASSERT( 1 == cache.seek( b ) ); - OSL_ASSERT( 0 == cache.seek( c ) ); - - OSL_ASSERT( 1 == cache.put( a ) ); - OSL_ASSERT( 0xffff == cache.seek( b) ); - OSL_ASSERT( 1 == cache.seek( a ) ); - OSL_ASSERT( 0 == cache.seek( c ) ); -} - -/******************* - * Are we within thread, that calls destructors of static objects ? - *******************/ -sal_Bool g_bStaticDestructorsCalled = sal_False; -struct StaticSingleton -{ - ~StaticSingleton() - { - ::osl::MutexGuard guard( ::osl::Mutex::getGlobalMutex() ); - g_bStaticDestructorsCalled = sal_True; - } -}; -StaticSingleton singleton; - -#if OSL_DEBUG_LEVEL > 1 -static MyCounter thisCounter( "Remote Environment" ); -#endif - -void SAL_CALL allThreadsAreGone( uno_Environment * pEnvRemote ) -{ - remote_Context *pContext = (remote_Context *) pEnvRemote->pContext; - urp_BridgeImpl *pImpl = ( urp_BridgeImpl *) pContext->m_pBridgeImpl; - - // if the current thread is not the writer thread, the writer thread - // object is not destroyed up to now, though it may already have run out. - // In both cases, it must be safe to cal pImpl->m_pWriter->getIdentifier() - OSL_ASSERT( pImpl->m_pWriter ); - if( pImpl->m_pWriter->getIdentifier() == osl_getThreadIdentifier(0) ) - { - // This is the writer thread. It has done some release calls, - // and is now the last one, that was active. Because the writer - // thread holds the environment weakly, there may also be a thread within - // the dispose of the bridge ( because the enviroment may have a refcount == 0 ). - // However, this thread MUST wait for the writer thread, so it is perfectly ok, - // not to set m_cndWaitForThreads. ( The check for m_nRemoteThreads is done - // after the join of the writer thread ). - } - else - { - pImpl->m_cndWaitForThreads.set(); - } - -} - -void SAL_CALL releaseStubs( uno_Environment *pEnvRemote ) -{ - - ((remote_Context * ) pEnvRemote->pContext )->m_pBridgeImpl->m_bReleaseStubsCalled = sal_True; - - remote_Interface **ppInterfaces = 0; - sal_Int32 nCount; - pEnvRemote->pExtEnv->getRegisteredInterfaces( pEnvRemote->pExtEnv, - (void***)&ppInterfaces, - &nCount, - rtl_allocateMemory ); - - sal_Int32 i; - for( i = 0 ; i < nCount ; i ++ ) - { - if( ppInterfaces[i]->acquire == bridges_remote::acquireUno2RemoteStub ) - { - // these are freed by the environment, so no release necessary - pEnvRemote->pExtEnv->revokeInterface( pEnvRemote->pExtEnv, ppInterfaces[i] ); - } - else - { - ppInterfaces[i]->release( ppInterfaces[i] ); - } - } - - rtl_freeMemory( (void*) ppInterfaces ); -} - -} // end namespace bridges_urp - -using namespace bridges_urp; - -extern "C" { - -static void SAL_CALL RemoteEnvironment_thisDispose( uno_Environment *pEnvRemote ) -{ - remote_Context *pContext = (remote_Context *) pEnvRemote->pContext; - urp_BridgeImpl *pImpl = ( urp_BridgeImpl *) pContext->m_pBridgeImpl; - - ::osl::ClearableMutexGuard guard( pImpl->m_disposingMutex ); - if( pContext->m_pBridgeImpl->m_bDisposed && - ( ! pImpl->m_pReader || - osl_getThreadIdentifier(0) == - (oslThreadIdentifier) pImpl->m_pReader->getIdentifier() ) ) - { - return; - } - // in case, that the static destructors already have been called, no - // tiding up is done. - bool tidyUp; - { - ::osl::MutexGuard guard2( ::osl::Mutex::getGlobalMutex() ); - tidyUp = ! g_bStaticDestructorsCalled && - ! pContext->m_pBridgeImpl->m_bDisposed; - } - if( tidyUp ) - { - // TODO : not threadsafe - // synchronization with dispatch methods needed ! - - pImpl->m_bDisposed = sal_True; - - - // close the connection - uno_threadpool_dispose( pImpl->m_hThreadPool ); - pImpl->m_pWriter->abortThread(); - pContext->m_pConnection->close( pContext->m_pConnection ); - - if( osl_getThreadIdentifier(0) == - (oslThreadIdentifier) pImpl->m_pReader->getIdentifier() ) - { - // This is the reader thread. Let the thread destroy itself - // the reader thread object must also release the connection at this stage ! - pImpl->m_pReader->destroyYourself(); - pImpl->m_pReader = 0; - } - else - { - // wait for the reader thread - // the reader thread object must also release the connection, - // when terminating !!!! - pImpl->m_pReader->join(); - } - - // wait for the writer thread - pImpl->m_pWriter->join(); - - // now let the context go ! - pContext->dispose( pContext ); - - if( 0 != pImpl->m_nRemoteThreads ) - { - // Wait for all threads - guard.clear(); - pImpl->m_cndWaitForThreads.wait(); - OSL_ASSERT( ! pImpl->m_nRemoteThreads ); - } - else - { - guard.clear(); - } -#ifdef BRIDGES_URP_PROT - if( pImpl->m_pLogFile ) - { - fclose( pImpl->m_pLogFile ); - pImpl->m_pLogFile = 0; - } -#endif -#if OSL_DEBUG_LEVEL > 1 - pImpl->dumpErrors( stderr ); -#endif - - // destroy the threads - delete pImpl->m_pWriter; - pImpl->m_pWriter = 0; - - if( pImpl->m_pReader != 0 ) - { - // This is not the reader thread, so the thread object is deleted - delete pImpl->m_pReader; - pImpl->m_pReader = 0; - } - - bool bReleaseStubs = false; - { - ::osl::MutexGuard guard2( ::osl::Mutex::getGlobalMutex() ); - bReleaseStubs = !g_bStaticDestructorsCalled; - } - if( bReleaseStubs ) - { - releaseStubs( pEnvRemote ); - } - } -} - -static void SAL_CALL RemoteEnvironment_thisDisposing( - uno_Environment *pEnvRemote ) -{ - remote_Context *pContext = (remote_Context * )pEnvRemote->pContext; - urp_BridgeImpl *pImpl = ((urp_BridgeImpl*) pContext->m_pBridgeImpl); - - { - ::osl::ClearableMutexGuard guard( pImpl->m_disposingMutex ); - if( ! pImpl->m_bDisposed ) - { - guard.clear(); - urp_sendCloseConnection( pEnvRemote ); - RemoteEnvironment_thisDispose( pEnvRemote ); - } - } - pImpl->m_pPropertyObject->thisRelease(); - pImpl->m_pPropertyObject = 0; - - uno_threadpool_destroy( pImpl->m_hThreadPool ); - - delete pImpl; - pContext->aBase.release( (uno_Context * ) pContext ); - g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.release(); -#endif -} - -static void SAL_CALL RemoteEnvironment_thisComputeObjectIdentifier( - uno_ExtEnvironment *, rtl_uString **, void *) -{ - OSL_ENSURE( 0, "RemoteEnvironment_thisComputeObjectIdentifier should never be called" ); -} - -static void SAL_CALL RemoteEnvironment_thisAcquireInterface( - uno_ExtEnvironment *, void *pInterface ) -{ - ((remote_Interface *)pInterface)->acquire( ( remote_Interface *) pInterface ); -} - -static void SAL_CALL RemoteEnvironment_thisReleaseInterface( - uno_ExtEnvironment *, void *pInterface ) -{ - ((remote_Interface *)pInterface)->release( ( remote_Interface *) pInterface ); -} - -//################################################################################################## -void SAL_CALL uno_initEnvironment( uno_Environment * pEnvRemote ) -{ - g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); - // set C-virtual methods - pEnvRemote->environmentDisposing = RemoteEnvironment_thisDisposing; - pEnvRemote->pExtEnv->computeObjectIdentifier = RemoteEnvironment_thisComputeObjectIdentifier; - pEnvRemote->pExtEnv->acquireInterface = RemoteEnvironment_thisAcquireInterface; - pEnvRemote->pExtEnv->releaseInterface = RemoteEnvironment_thisReleaseInterface; - pEnvRemote->dispose = RemoteEnvironment_thisDispose; - - remote_Context *pContext = ( remote_Context * ) pEnvRemote->pContext; - pContext->aBase.acquire( ( uno_Context * ) pContext ); - pContext->getRemoteInstance = ::bridges_remote::remote_sendQueryInterface; - - // Initialize impl struct urp_BridgeImpl - urp_BridgeImpl *pImpl = new ::bridges_urp::urp_BridgeImpl( 256, 8192 ); - pContext->m_pBridgeImpl = pImpl; - - // Initialize threadpool - pImpl->m_hThreadPool = uno_threadpool_create(); - - // take the bridgepointer as id - pImpl->m_properties.seqBridgeID = ByteSequence( (sal_Int8*)&pEnvRemote , sizeof( pEnvRemote ) ); - - pImpl->m_allThreadsAreGone = allThreadsAreGone; - pImpl->m_sendRequest = urp_sendRequest; - pImpl->m_nRemoteThreads = 0; - pImpl->m_bDisposed = sal_False; - pImpl->m_bReleaseStubsCalled = sal_False; - - pImpl->m_pPropertyObject = new PropertyObject( &(pImpl->m_properties ), pEnvRemote, pImpl ); - pImpl->m_pPropertyObject->thisAcquire(); - - OUString sProtocolProperties; - if( pContext->m_pProtocol->length > 3 ) - { - sProtocolProperties = OUString( pContext->m_pProtocol ).copy( 4, pContext->m_pProtocol->length-4); - } - if( sProtocolProperties.getLength() ) - { - struct Properties props = pImpl->m_properties; - assignFromStringToStruct( sProtocolProperties , &props ); - if( ! props.bNegotiate ) - { - // no negotiation takes place, the creator of the bridge knows the parameter - // of the other side ! - pImpl->applyProtocolChanges( props ); - sProtocolProperties = OUString(); - } - } - -#ifdef BRIDGES_URP_PROT - char *p = getenv( "PROT_REMOTE" ); - pImpl->m_pLogFile = 0; - if( p ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - static int counter; - oslProcessInfo data; - data.Size = sizeof( data ); - osl_getProcessInfo( 0 , osl_Process_HEAPUSAGE | osl_Process_IDENTIFIER , &data ); - OString s(p); - s += "_pid"; - s += OString::valueOf( (sal_Int32) data.Ident ); - s += "_"; - s += OString::valueOf( (sal_Int32) counter ); - pImpl->m_sLogFileName = s; - // clear the file - FILE *f = fopen( s.getStr() , "w" ); - OSL_ASSERT( f ); - if( getenv( "PROT_REMOTE_FAST") ) - { - pImpl->m_pLogFile = f; - } - else - { - fclose( f ); - } - counter++; - } -#endif - - // start reader and writer threads - pImpl->m_pWriter = new ::bridges_urp::OWriterThread( pContext->m_pConnection , pImpl, - pEnvRemote); - pImpl->m_pWriter->create(); - - pImpl->m_pReader = new ::bridges_urp::OReaderThread( pContext->m_pConnection , - pEnvRemote, - pImpl->m_pWriter ); - pImpl->m_pReader->create(); - - PropertySetterThread *pPropsSetterThread = - new PropertySetterThread( pEnvRemote, pImpl , sProtocolProperties ); - pPropsSetterThread->create(); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.acquire(); -#endif -} - - -//################################################################################################## -void SAL_CALL uno_ext_getMapping( - uno_Mapping ** ppMapping, - uno_Environment * pFrom, - uno_Environment * pTo ) -{ - OSL_ASSERT( ppMapping && pFrom && pTo ); - if (ppMapping && pFrom && pTo) - { - if (*ppMapping) - ((*ppMapping)->release)( *ppMapping ); - bridges_remote::RemoteMapping * pMapping = 0; - - ::rtl::OUString sFromName = pFrom->pTypeName; - ::rtl::OUString sToName = pTo->pTypeName; - ::rtl::OUString sUno(RTL_CONSTASCII_USTRINGPARAM(UNO_LB_UNO)); - ::rtl::OUString sRemote(RTL_CONSTASCII_USTRINGPARAM("urp")); - if ( sFromName.equalsIgnoreAsciiCase( sRemote ) && - sToName.equalsIgnoreAsciiCase( sUno ) ) - { - pMapping = new bridges_remote::RemoteMapping( pTo, /* Uno */ - pFrom, /*remote*/ - bridges_remote::remoteToUno, - OUString() ); - } - else if ( sFromName.equalsIgnoreAsciiCase( sUno ) && - sToName.equalsIgnoreAsciiCase( sRemote ) ) - { - pMapping = new bridges_remote::RemoteMapping( pFrom , - pTo , - bridges_remote::unoToRemote, - OUString() ); - } - - *ppMapping = (uno_Mapping * )pMapping; - OUString dummy; - uno_registerMapping( ppMapping , - bridges_remote::freeRemoteMapping, - pFrom , - pTo , - dummy.pData ); - } -} - -sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) -{ - return g_moduleCount.canUnload( &g_moduleCount , pTime ); -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_job.cxx b/bridges/source/remote/urp/urp_job.cxx deleted file mode 100644 index 25a97e0c42e2..000000000000 --- a/bridges/source/remote/urp/urp_job.cxx +++ /dev/null @@ -1,941 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <string.h> -#include <stdio.h> -#include <osl/diagnose.h> -#include <osl/mutex.hxx> - -#include <rtl/alloc.h> -#include <rtl/ustrbuf.hxx> - -#include <uno/current_context.h> -#include <uno/current_context.hxx> -#include <uno/threadpool.h> - -#include <bridges/cpp_uno/type_misc.hxx> -#include <bridges/remote/proxy.hxx> - -#include <com/sun/star/uno/Any.hxx> -#include <com/sun/star/uno/XCurrentContext.hpp> -#include <com/sun/star/lang/DisposedException.hpp> - -#include "urp_job.hxx" -#include "urp_bridgeimpl.hxx" -#include "urp_writer.hxx" -#include "urp_dispatch.hxx" -#include "urp_log.hxx" -#include "urp_marshal.hxx" -#include "urp_propertyobject.hxx" -#include "urp_reader.hxx" - -using namespace ::std; -using namespace ::rtl; -using namespace ::osl; -using namespace ::com::sun::star::uno; - -using namespace bridges_urp; - -extern "C" { - -static void SAL_CALL doit(void * job) { - ServerMultiJob * p = static_cast< ServerMultiJob * >(job); - p->execute(); - delete p; -} - -} - -namespace bridges_urp -{ - static sal_Bool isDisposedExceptionDescriptionAvail( const Type &type ) - { - static sal_Bool bInit; - static sal_Bool bReturn; - // we don't care for thread safety here, as both threads must come - // to the same result - if( ! bInit ) - { - typelib_TypeDescription *pTD = 0; - typelib_typedescriptionreference_getDescription( & pTD, type.getTypeLibType() ); - if( pTD ) - { - bReturn = sal_True; - typelib_typedescription_release( pTD ); - } - else - { - bReturn = sal_False; - } - bInit = sal_True; - } - return bReturn; - } - - //-------------------------------------------------------------------------------------- - static void prepareRuntimeExceptionClientSide( uno_Any **ppException , const OUString &s) - { - com::sun::star::lang::DisposedException exception( s , Reference< XInterface > () ); - Type type = ::getCppuType( &exception ); - if( !isDisposedExceptionDescriptionAvail( type ) ) - { - // if it is not available (probably missing type library), - // then we are satisfied with throwing a normal runtime exception, - // for which cppu provides a static description - type = getCppuType( ( RuntimeException * ) 0 ); - } - uno_type_any_construct( *ppException , &exception , type.getTypeLibType() , 0 ); - } - - - Job::Job( uno_Environment *pEnvRemote, - remote_Context *pContext, - sal_Sequence *pTid, - struct urp_BridgeImpl *pBridgeImpl, - Unmarshal *pUnmarshal ) - : m_pContext( pContext ) - , m_pUnmarshal( pUnmarshal ) - , m_pBridgeImpl( pBridgeImpl ) - , m_pTid( pTid ) - , m_counter( pEnvRemote ) - { - if ( m_pContext ) - { - m_pContext->aBase.acquire( &m_pContext->aBase ); - } - if( m_pTid ) - rtl_byte_sequence_acquire( pTid ); - } - - Job::~Job() - { - if( m_pTid ) - rtl_byte_sequence_release( m_pTid ); - if ( m_pContext ) - { - m_pContext->aBase.release( &m_pContext->aBase ); - } - } - - - - - //-------------------------------------------------------------------------------------- - sal_Bool ClientJob::extract( ) - { - sal_Bool bReturn = sal_True; - //------------------------------- - // Handle the reply, unpack data - //------------------------------- - if( m_bExceptionOccurred ) - { - bReturn = m_pUnmarshal->unpackAny( *m_ppException ); - } - else - { - //--------------------------------- - // alles ist gut - //--------------------------------- - if( m_pMethodType ) - { - if( m_pMethodType->pReturnTypeRef->eTypeClass != typelib_TypeClass_VOID ) - { - typelib_TypeDescription *pType = 0; - TYPELIB_DANGER_GET( &pType , m_pMethodType->pReturnTypeRef ); - bReturn = m_pUnmarshal->unpack( m_pReturn , pType ) && bReturn; - TYPELIB_DANGER_RELEASE( pType ); - } - - // out parameters - sal_Int32 i; - for( i = 0 ; i < m_pMethodType->nParams ; i ++ ) - { - if( m_pMethodType->pParams[i].bOut ) - { - typelib_TypeDescription *pType = 0; - TYPELIB_DANGER_GET( &pType , m_pMethodType->pParams[i].pTypeRef ); - if( m_pMethodType->pParams[i].bIn ) - { - uno_destructData( m_ppArgs[i] , pType , ::bridges_remote::remote_release ); - } - bReturn = m_pUnmarshal->unpack( m_ppArgs[i] , pType ) && bReturn; - TYPELIB_DANGER_RELEASE( pType ); - } - } - } - else if( m_pAttributeType && m_pReturn ) - { - typelib_TypeDescription *pType = 0; - TYPELIB_DANGER_GET( &pType , m_pAttributeType->pAttributeTypeRef ); - bReturn = m_pUnmarshal->unpack( m_pReturn , pType ) && bReturn; - TYPELIB_DANGER_RELEASE( pType ); - } - else if( m_pAttributeType && m_ppArgs ) - { - // nothing to do - } - else - { - OSL_ASSERT( 0 ); - } - } - return bReturn; - } - - //------------------------------------------------------------------------------------------- - void ClientJob::initiate() - { - uno_threadpool_putJob( m_pBridgeImpl->m_hThreadPool, m_pTid , this, 0, sal_False); - } - - //-------------------------------------------------------------------------------------------- - sal_Bool ClientJob::pack() - { - sal_Bool bSuccess = sal_True; - MutexGuard guard( m_pBridgeImpl->m_marshalingMutex ); - - if( m_pMethodType && - REMOTE_RELEASE_METHOD_INDEX == m_pMethodType->aBase.nPosition && - ! m_pBridgeImpl->m_bDisposed && - m_pBridgeImpl->m_pWriter->getIdentifier() != ::osl::Thread::getCurrentIdentifier() ) - { - // all release calls are delegated to the writer thread to avoid - // multiple synchron calls with the same thread id and reentrant - // marshaling (in case during destruction of parameters a release is - // invoked ). - m_pBridgeImpl->m_pWriter->insertReleaseRemoteCall( - m_pOid, m_pInterfaceType->aBase.pWeakRef ); - - // No waiting, please - return sal_False; - } - else if ( m_pMethodType && - REMOTE_RELEASE_METHOD_INDEX == m_pMethodType->aBase.nPosition && - m_pBridgeImpl->m_bDisposed ) - { - // no exception for release calls ! - return sal_False; - } - else if( m_pBridgeImpl->m_bDisposed ) - { - OUStringBuffer buf( 128 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "URP-Bridge: disposed" ) ); - buf.append( m_pBridgeImpl->getErrorsAsString() ); - prepareRuntimeExceptionClientSide( m_ppException , buf.makeStringAndClear() ); - return sal_False; - } - - // build up the flag byte - sal_Bool bType = sal_False, bOid = sal_False, bTid = sal_False; - sal_uInt8 nFlags = 0; - if( m_pBridgeImpl->m_lastOutType.getTypeLibType() != m_pInterfaceType->aBase.pWeakRef && - ! typelib_typedescriptionreference_equals( - m_pBridgeImpl->m_lastOutType.getTypeLibType(), m_pInterfaceType->aBase.pWeakRef ) ) - { - //new type - nFlags = nFlags | HDRFLAG_NEWTYPE; - bType = sal_True; - } - if( m_pBridgeImpl->m_lastOutOid.pData != m_pOid && - rtl_ustr_compare_WithLength( m_pBridgeImpl->m_lastOutOid.pData->buffer, - m_pBridgeImpl->m_lastOutOid.pData->length, - m_pOid->buffer, - m_pOid->length ) ) - { - //new object id - nFlags = nFlags | HDRFLAG_NEWOID; - bOid = sal_True; - } - if( m_pBridgeImpl->m_lastOutTid.getHandle() != m_pTid && - !(m_pBridgeImpl->m_lastOutTid == *(ByteSequence*) &(m_pTid) ) ) - { - // new threadid - nFlags = nFlags | HDRFLAG_NEWTID; - bTid = sal_True; - } - - if( m_bCallingConventionForced ) - { - nFlags = nFlags | HDRFLAG_MOREFLAGS; - } -#ifdef BRIDGES_URP_PROT - sal_Int32 nLogStart = m_pBridgeImpl->m_blockMarshaler.getPos(); -#endif - // Short request headers can only handle 14-bit method IDs, so - // unconditionally use a long header for method IDs that are too large: - if( nFlags || m_nMethodIndex >= 0xC000 ) - { - // the flag byte is needed + request - nFlags = nFlags | HDRFLAG_LONGHEADER | HDRFLAG_REQUEST; // - - // as long as we do not have customized calls, no MOREFLAGS must be set - if( m_nMethodIndex >= 0x100 ) - { - nFlags = nFlags | HDRFLAG_LONGMETHODID; - } - m_pBridgeImpl->m_blockMarshaler.packInt8( &nFlags ); - - if( nFlags & HDRFLAG_MOREFLAGS ) - { - sal_uInt8 nMoreFlags = 0; - if( ! m_bOneway ) - { - nMoreFlags = HDRFLAG_SYNCHRONOUS |HDRFLAG_MUSTREPLY; - } - m_pBridgeImpl->m_blockMarshaler.packInt8( &nMoreFlags ); - } - if( nFlags & HDRFLAG_LONGMETHODID ) - { - sal_uInt16 nMethod = (sal_uInt16 ) m_nMethodIndex; - m_pBridgeImpl->m_blockMarshaler.packInt16( &nMethod ); - } - else - { - sal_uInt8 nMethod = (sal_uInt8) m_nMethodIndex; - m_pBridgeImpl->m_blockMarshaler.packInt8( &nMethod ); - } - } - else - { - // no flag byte needed, simply marshal the method index - if( m_nMethodIndex >= 64 ) - { - sal_uInt16 nMethod = ( sal_uInt16 ) m_nMethodIndex; - nMethod = nMethod | 0x4000; - m_pBridgeImpl->m_blockMarshaler.packInt16( &nMethod ); - } - else - { - sal_uInt8 nMethod = (sal_uInt8 ) m_nMethodIndex; - m_pBridgeImpl->m_blockMarshaler.packInt8( &nMethod ); - } - } - - // marshal type,oid,tid - if( bType ) - { - m_pBridgeImpl->m_lastOutType = m_pInterfaceType->aBase.pWeakRef; - m_pBridgeImpl->m_blockMarshaler.packType( &(m_pBridgeImpl->m_lastOutType) ); - } - if( bOid ) - { - m_pBridgeImpl->m_lastOutOid = *(OUString *)&m_pOid; - m_pBridgeImpl->m_blockMarshaler.packOid( m_pBridgeImpl->m_lastOutOid ); - } - if( bTid ) - { - m_pBridgeImpl->m_lastOutTid = *(ByteSequence*)&(m_pTid); - m_pBridgeImpl->m_blockMarshaler.packTid( m_pBridgeImpl->m_lastOutTid ); - } - - if ( m_pBridgeImpl->m_properties.bCurrentContext - && m_nMethodIndex != REMOTE_RELEASE_METHOD_INDEX - && m_pContext != 0 ) - { - void * pCc = 0; - rtl::OUString aEnvName( RTL_CONSTASCII_USTRINGPARAM( "urp" ) ); - bSuccess = bSuccess && uno_getCurrentContext( - &pCc, aEnvName.pData, m_pContext ); - typelib_TypeDescription * pType = 0; - TYPELIB_DANGER_GET( - &pType, XCurrentContext::static_type().getTypeLibType() ); - bSuccess = bSuccess && m_pBridgeImpl->m_blockMarshaler.pack( - &pCc, pType ); - TYPELIB_DANGER_RELEASE( pType ); - if ( pCc ) - { - remote_Interface * p = static_cast< remote_Interface * >( pCc ); - p->release( p ); - } - } - - // marshal arguments ! -#ifdef BRIDGES_URP_PROT - sal_Int32 nLogHeader = m_pBridgeImpl->m_blockMarshaler.getPos(); -#endif - if( m_pMethodType ) - { - sal_Int32 i; - for( i = 0 ; i < m_pMethodType->nParams ; i ++ ) - { - if( m_pMethodType->pParams[i].bIn ) - { - typelib_TypeDescription *pType = 0; - TYPELIB_DANGER_GET( &pType , m_pMethodType->pParams[i].pTypeRef ); - if( pType ) - { - bSuccess = - bSuccess && m_pBridgeImpl->m_blockMarshaler.pack( m_ppArgs[i] , pType ); - TYPELIB_DANGER_RELEASE( pType ); - } - else - { - bSuccess = sal_False; - OUStringBuffer buffer( 128 ); - buffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "no typedescription available for type" ) ); - buffer.append( m_pMethodType->pParams[i].pTypeRef->pTypeName ); - m_pBridgeImpl->addError( buffer.makeStringAndClear() ); - } - } - } - } - else if( m_pAttributeType && m_pReturn ) - { - // nothing to do ! - } - else if( m_pAttributeType && m_ppArgs ) - { - typelib_TypeDescription *pType = 0; - TYPELIB_DANGER_GET( &pType , m_pAttributeType->pAttributeTypeRef ); - if( pType ) - { - bSuccess = bSuccess && m_pBridgeImpl->m_blockMarshaler.pack( m_ppArgs[0] , pType ); - TYPELIB_DANGER_RELEASE( pType ); - } - else - { - bSuccess = sal_False; - OUStringBuffer buffer( 128 ); - buffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( "no typedescription available for type" ) ); - buffer.append( m_pAttributeType->pAttributeTypeRef->pTypeName ); - m_pBridgeImpl->addError( buffer.makeStringAndClear() ); - } - } - else - { - OSL_ASSERT( 0 ); - } - -#ifdef BRIDGES_URP_PROT - urp_logCall( m_pBridgeImpl, m_pBridgeImpl->m_blockMarshaler.getPos() - nLogStart, - m_pBridgeImpl->m_blockMarshaler.getPos() - nLogHeader, ! m_bOneway, - m_pMethodType ? m_pMethodType->aBase.pMemberName : - m_pAttributeType->aBase.pMemberName ); -#endif - - if( bSuccess ) - { - if( ! m_bOneway ) - { - uno_threadpool_attach( m_pBridgeImpl->m_hThreadPool ); - m_pBridgeImpl->m_clientJobContainer.add( *(ByteSequence*)&(m_pTid), this ); - } - - m_pBridgeImpl->m_nMarshaledMessages ++; - //--------------------------- - // Inform the writer thread, that there is some work to do - //--------------------------- - m_pBridgeImpl->m_pWriter->touch( ! m_bOneway ); - - if( m_bOneway ) - { - *m_ppException = 0; - } - } - else - { - // Something went wrong during packing, which means, that the caches may not be in sync - // anymore. So we have no other choice than to dispose the environment. - m_pEnvRemote->dispose( m_pEnvRemote ); - OUStringBuffer buf( 128 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Error during marshaling " ) ); - if( m_pMethodType ) - { - buf.append( m_pMethodType->aBase.aBase.pTypeName ); - } - else if( m_pAttributeType ) - { - buf.append( m_pAttributeType->aBase.aBase.pTypeName ); - } - buf.appendAscii( "\n" ); - buf.append( m_pBridgeImpl->getErrorsAsString() ); - prepareRuntimeExceptionClientSide( m_ppException , buf.makeStringAndClear() ); - } - return bSuccess; - // release the guard - } - - //------------------------------------------------------------------------------------ - void ClientJob::wait() - { - //--------------------------- - // Wait for the reply - //--------------------------- - void * pDisposeReason = 0; - - uno_threadpool_enter(m_pBridgeImpl->m_hThreadPool, &pDisposeReason ); - - if( ! pDisposeReason ) - { - // thread has been disposed ! - // avoid leak due continous calling on a disposed reference. The - // reply may or may not be within the container. If the reader thread - // got into problems during unmarshaling the reply for this request, - // it won't be in the container anymore, but it is eiterway safe to call - // the method - ClientJob *pJob = - m_pBridgeImpl->m_clientJobContainer.remove( *(ByteSequence*) &m_pTid ); - if( pJob != this ) - { - // this is not our job, it is probably one of the callstack below, so - // push it back - m_pBridgeImpl->m_clientJobContainer.add( *(ByteSequence*) &m_pTid , pJob ); - } - - OUStringBuffer sMessage( 256 ); - sMessage.appendAscii( RTL_CONSTASCII_STRINGPARAM( "URP_Bridge : disposed\n" ) ); - sMessage.append( m_pBridgeImpl->getErrorsAsString() ); - prepareRuntimeExceptionClientSide( m_ppException, sMessage.makeStringAndClear() ); - m_bExceptionOccurred = sal_True; - } - else - { - OSL_ASSERT( pDisposeReason == (void*)this ); - } - if( !m_bExceptionOccurred ) - { - *m_ppException = 0; - } - uno_threadpool_detach( m_pBridgeImpl->m_hThreadPool ); - } - - //------------------------------------------------------------------------------------ - // ServerMultiJob - //------------------------------------------------------------------------------------ - ServerMultiJob::ServerMultiJob( - uno_Environment *pEnvRemote, - remote_Context *pContext, - sal_Sequence *pTid, - struct urp_BridgeImpl *pBridgeImpl, - Unmarshal *pUnmarshal, - sal_Int32 nMaxMessages ) - : Job( pEnvRemote, pContext, pTid, pBridgeImpl, pUnmarshal ) - , m_pEnvRemote( pEnvRemote ) - , m_nCalls( 0 ) - , m_nMaxMessages( nMaxMessages ) - , m_nCurrentMemPosition( 0 ) - { - m_pEnvRemote->acquire( m_pEnvRemote ); - m_nCurrentMemSize = MULTIJOB_STANDARD_MEMORY_SIZE + m_nMaxMessages * ( - MULTIJOB_PER_CALL_MEMORY_SIZE + sizeof(ServerJobEntry) + sizeof(MemberTypeInfo) ); - m_pCurrentMem = ( sal_Int8 * ) rtl_allocateMemory( m_nCurrentMemSize ); - m_aEntries = ( ServerJobEntry * ) getHeap( m_nMaxMessages * sizeof( ServerJobEntry ) ); - m_aTypeInfo = ( MemberTypeInfo * ) getHeap( m_nMaxMessages * sizeof( MemberTypeInfo ) ); - } - - ServerMultiJob::~ServerMultiJob() - { - sal_Int32 i; - for( i = 0 ; i < m_nCalls ; i ++ ) - { - struct MemberTypeInfo *const pMTI = &( m_aTypeInfo[i] ); - struct ServerJobEntry *const pSJE = &( m_aEntries[i] ); - - if( pSJE->m_pRemoteI ) - pSJE->m_pRemoteI->release( pSJE->m_pRemoteI ); - - if( pSJE->m_pOid ) - rtl_uString_release( pSJE->m_pOid ); - - if( pSJE->m_pInterfaceTypeRef ) - typelib_typedescriptionreference_release( pSJE->m_pInterfaceTypeRef ); - - if( pMTI->m_pInterfaceType ) - TYPELIB_DANGER_RELEASE( (typelib_TypeDescription *)pMTI->m_pInterfaceType ); - - for( sal_Int32 iArgs = 0 ; iArgs < pMTI->m_nArgCount ; iArgs ++ ) - { - if( pMTI->m_ppArgType[iArgs] ) - TYPELIB_DANGER_RELEASE( pMTI->m_ppArgType [iArgs] ); - } - if( pMTI->m_pReturnType ) - TYPELIB_DANGER_RELEASE( pMTI->m_pReturnType ); - - if( pMTI->m_pMethodType ) - typelib_typedescription_release( (typelib_TypeDescription*)pMTI->m_pMethodType ); - if( pMTI->m_pAttributeType ) - typelib_typedescription_release( (typelib_TypeDescription*)pMTI->m_pAttributeType ); - } - - rtl_freeMemory( m_pCurrentMem ); - for( list< sal_Int8 *>::iterator ii = m_lstMem.begin() ; ii != m_lstMem.end() ; ++ii ) - rtl_freeMemory( *ii ); - - if( m_pEnvRemote ) - m_pEnvRemote->release( m_pEnvRemote ); - } - - //------------------------------------------------------------------------------------- - void ServerMultiJob::execute() - { - Reference< XCurrentContext > xOldCc; - bool bHasOldCc = false; - for( sal_Int32 i = 0; i < m_nCalls ; i ++ ) - { - struct MemberTypeInfo * const pMTI = &( m_aTypeInfo[i] ); - struct ServerJobEntry * const pSJE = &( m_aEntries[i] ); - - if ( pSJE->m_bHasCurrentContext ) - { - if ( !bHasOldCc ) - { - xOldCc = com::sun::star::uno::getCurrentContext(); - bHasOldCc = true; - } - rtl::OUString aEnvName( RTL_CONSTASCII_USTRINGPARAM( "urp" ) ); - if ( !uno_setCurrentContext( - pSJE->m_pCurrentContext, aEnvName.pData, m_pContext ) ) - { - throw RuntimeException( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "fatal: uno_setCurrentContext failed" ) ), - Reference< XInterface >() ); - } - if ( pSJE->m_pCurrentContext ) - { - pSJE->m_pCurrentContext->release( pSJE->m_pCurrentContext ); - } - } - - if( ! pSJE->m_pRemoteI ) - { - // ------------------- - // Initial object ? - // ------------------ - // be robust : Sending a release on a not constructed object - // provokes an segfault. Make sure, the call - // is not a release call. - remote_Context *pRemoteC = ((remote_Context*)m_pEnvRemote->pContext); - - if( ! pMTI->m_bIsReleaseCall && pRemoteC->m_pInstanceProvider ) - { - pSJE->m_pException = &(pSJE->m_exception); - - pRemoteC->m_pInstanceProvider->getInstance( - pRemoteC->m_pInstanceProvider, - m_pEnvRemote, - &(pSJE->m_pRemoteI), - pSJE->m_pOid, - pMTI->m_pInterfaceType, - &(pSJE->m_pException)); - } - else - { - prepareRuntimeException( - OUString( RTL_CONSTASCII_USTRINGPARAM( "urp: No instance provider set")),i); - } - } - - if( pSJE->m_pException ) - { - // errors during extracting, do nothing - } - else if( ! pSJE->m_pRemoteI ) - { - // May only occur during the queryInterface call on the initial object !!! - // construct the return value - uno_type_any_construct( (uno_Any*) pSJE->m_pReturn , 0 , 0 , 0 ); - } - else - { - pSJE->m_pException = &(pSJE->m_exception ); - - if( pMTI->m_bIsReleaseCall ) - { - pSJE->m_pRemoteI->release( pSJE->m_pRemoteI ); - pSJE->m_pException = 0; - } - else - { - pSJE->m_pRemoteI->pDispatcher( - pSJE->m_pRemoteI, - pMTI->m_pMethodType ? (typelib_TypeDescription*) pMTI->m_pMethodType : - (typelib_TypeDescription*) pMTI->m_pAttributeType, - pSJE->m_pReturn, - pSJE->m_ppArgs, - &(pSJE->m_pException) ); - } - } - if( pSJE->m_pRemoteI ) - { - /** - Do the release here, in case of ForceSynchronous=1, calls - originated by the destructor of an UNO object must be sent BEFORE the - release returns ( otherwise we don't own the thread anymore ! ) - */ - pSJE->m_pRemoteI->release( pSJE->m_pRemoteI ); - pSJE->m_pRemoteI = 0; - } - - // now destruct parameters and marshal replies - // Note : when call is synchron => m_nCalls == 1 - if( pMTI->m_bIsOneway ) - { - // Oneway call, destruct in parameters - for( sal_Int32 j = 0 ; j < pMTI->m_pMethodType->nParams ; j ++ ) - { - // usually all parameters must be in parameters, but to be robust ... - if( pMTI->m_pbIsIn[j] && !cppu_isSimpleType( pMTI->m_ppArgType[j] ) ) - { - uno_destructData( pSJE->m_ppArgs[j] , pMTI->m_ppArgType[j] , 0 ); - } - } - - if( pSJE->m_pException ) - { - uno_any_destruct( pSJE->m_pException, ::bridges_remote::remote_release ); - } - - } - else - { - // synchron, get the mutex to marshal reply and send immeadiatly - MutexGuard guard( m_pBridgeImpl->m_marshalingMutex ); - - sal_Bool bTid = sal_False; - sal_uInt8 nFlags = HDRFLAG_LONGHEADER; - ByteSequence tid = m_pTid; - if( !( tid == m_pBridgeImpl->m_lastOutTid ) || pSJE->m_bIgnoreCache ) - { - // new threadid - nFlags = nFlags | HDRFLAG_NEWTID; - bTid = sal_True; - } - - if( pSJE->m_pException ) - { - nFlags = nFlags | HDRFLAG_EXCEPTION; - } -#ifdef BRIDGES_URP_PROT - sal_Int32 nLogStart = m_pBridgeImpl->m_blockMarshaler.getPos(); -#endif - m_pBridgeImpl->m_blockMarshaler.packInt8( &nFlags ); - - if( bTid ) - { - if( ! pSJE->m_bIgnoreCache ) - { - m_pBridgeImpl->m_lastOutTid = tid; - } - m_pBridgeImpl->m_blockMarshaler.packTid( tid , pSJE->m_bIgnoreCache ); - } - -#ifdef BRIDGES_URP_PROT - sal_Int32 nLogHeader = m_pBridgeImpl->m_blockMarshaler.getPos(); -#endif - - if( pSJE->m_pException ) - { - //-------------------- - // an exception was thrown - //-------------------- - m_pBridgeImpl->m_blockMarshaler.packAny( &(pSJE->m_exception) ); - uno_any_destruct( &(pSJE->m_exception) , ::bridges_remote::remote_release ); - - // destroy in parameters - for( sal_Int32 j = 0 ; j < pMTI->m_nArgCount ; j ++ ) - { - if( pMTI->m_pbIsIn[j] && ! cppu_isSimpleType( pMTI->m_ppArgType[j] )) - { - uno_destructData( pSJE->m_ppArgs[j] , pMTI->m_ppArgType[j] , - ::bridges_remote::remote_release ); - } - } - } - else - { - //--------------------------- - // alles ist gut ... - //-------------------------- - if( pMTI->m_pReturnType ) - { - m_pBridgeImpl->m_blockMarshaler.pack( - pSJE->m_pReturn, pMTI->m_pReturnType ); - if( ! cppu_isSimpleType( pMTI->m_pReturnType ) ) - { - uno_destructData( pSJE->m_pReturn , pMTI->m_pReturnType , - ::bridges_remote::remote_release ); - } - } - for( sal_Int32 j = 0 ; j < pMTI->m_nArgCount ; j ++ ) - { - if( pMTI->m_pbIsOut[j] ) - { - m_pBridgeImpl->m_blockMarshaler.pack( - pSJE->m_ppArgs[j] , pMTI->m_ppArgType[j] ); - } - if( ! cppu_isSimpleType( pMTI->m_ppArgType[j] ) ) - { - uno_destructData( pSJE->m_ppArgs[j], pMTI->m_ppArgType[j] , - ::bridges_remote::remote_release ); - } - } - } - -#ifdef BRIDGES_URP_PROT - { - typelib_InterfaceMemberTypeDescription *pMemberType = - pMTI->m_pMethodType ? - (typelib_InterfaceMemberTypeDescription*)pMTI->m_pMethodType : - (typelib_InterfaceMemberTypeDescription*)pMTI->m_pAttributeType; - - urp_logReplying( m_pBridgeImpl , - m_pBridgeImpl->m_blockMarshaler.getPos() - nLogStart, - m_pBridgeImpl->m_blockMarshaler.getPos() - nLogHeader, - pMemberType->pMemberName ); - } -#endif - - m_pBridgeImpl->m_nMarshaledMessages ++; - // put it on the wire - m_pBridgeImpl->m_pWriter->touch( sal_True ); - } // MutexGuard marshalingMutex - } - if ( bHasOldCc ) - { - if ( !com::sun::star::uno::setCurrentContext( xOldCc ) ) - { - throw RuntimeException( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "fatal: com::sun::star::uno::setCurrentContext" - " failed" ) ), - Reference< XInterface >() ); - } - } - } - - //------------------------------------------------------------------------------------- - void ServerMultiJob::prepareRuntimeException( const OUString & sMessage , sal_Int32 nCall ) - { - // ------------------------------- - // Construct the DisposedException - // ------------------------------- - com::sun::star::lang::DisposedException exception( sMessage , Reference< XInterface > () ); - Type type = getCppuType( &exception ); - if( !isDisposedExceptionDescriptionAvail( type ) ) - { - // if it is not available (probably missing type library), - // then we are satisfied with throwing a normal runtime exception, - // for which cppu provides a static description - type = getCppuType( ( RuntimeException * ) 0 ); - } - - m_aEntries[nCall].m_pException = &(m_aEntries[nCall].m_exception); - uno_type_any_construct( m_aEntries[nCall].m_pException , &exception , type.getTypeLibType() , 0 ); - } - - //------------------------------------------------------------------------------------- - void ServerMultiJob::initiate() - { - uno_threadpool_putJob( - m_pBridgeImpl->m_hThreadPool, - m_pTid, - this, - doit, - m_aTypeInfo[0].m_bIsOneway ); - } - - - //------------------------------------------------------------------------------------- - sal_Bool ServerMultiJob::extract() - { - sal_Bool bContinue = sal_True; - struct MemberTypeInfo * const pMTI = &(m_aTypeInfo[m_nCalls]); - struct ServerJobEntry * const pSJE = &(m_aEntries[m_nCalls]); - - pSJE->m_pException = 0; - pSJE->m_ppArgs = 0; - pSJE->m_pReturn = 0; - pMTI->m_pReturnType = 0; - - if( pMTI->m_nArgCount ) - { - pMTI->m_ppArgType = - ( typelib_TypeDescription ** ) getHeap( sizeof(void*) * pMTI->m_nArgCount ); - pSJE->m_ppArgs = (void**) getHeap( sizeof( void * ) * pMTI->m_nArgCount ); - pMTI->m_pbIsIn = (sal_Bool *) getHeap( sizeof( sal_Bool ) * pMTI->m_nArgCount ); - pMTI->m_pbIsOut = (sal_Bool *) getHeap( sizeof( sal_Bool ) * pMTI->m_nArgCount ); - } - if( pMTI->m_pMethodType && - pMTI->m_pMethodType->pReturnTypeRef->eTypeClass != typelib_TypeClass_VOID ) - { - TYPELIB_DANGER_GET( &(pMTI->m_pReturnType), pMTI->m_pMethodType->pReturnTypeRef ); - } - else if( pMTI->m_pAttributeType && ! pMTI->m_nArgCount ) - { - TYPELIB_DANGER_GET( &(pMTI->m_pReturnType) , pMTI->m_pAttributeType->pAttributeTypeRef ); - } - - // normal method - if( pMTI->m_pMethodType ) - { - for( sal_Int32 i = 0 ; i < pMTI->m_nArgCount ; i ++ ) - { - pMTI->m_ppArgType[i] = 0; - TYPELIB_DANGER_GET( & ( pMTI->m_ppArgType[i] ) , pMTI->m_pMethodType->pParams[i].pTypeRef); - pMTI->m_pbIsIn[i] = pMTI->m_pMethodType->pParams[i].bIn; - pMTI->m_pbIsOut[i] = pMTI->m_pMethodType->pParams[i].bOut; - - pSJE->m_ppArgs[i] = getHeap( pMTI->m_ppArgType[i]->nSize ); - if( pMTI->m_pbIsIn[i] ) - { - // everything needs to be constructed - bContinue = m_pUnmarshal->unpack( - pSJE->m_ppArgs[i], pMTI->m_ppArgType[i] ) && bContinue; - } - } - } - else if( pMTI->m_nArgCount ) - { - // set attribut - pMTI->m_ppArgType[0] = 0; - pMTI->m_pbIsIn[0] = sal_True; - pMTI->m_pbIsOut[0] = sal_False; - TYPELIB_DANGER_GET( - & ( pMTI->m_ppArgType[0] ) , pMTI->m_pAttributeType->pAttributeTypeRef ); - pSJE->m_ppArgs[0] = getHeap( pMTI->m_ppArgType[0]->nSize ); - bContinue = m_pUnmarshal->unpack( - pSJE->m_ppArgs[0], pMTI->m_ppArgType[0] ) && bContinue; - } - - if( pMTI->m_pReturnType ) - { - pSJE->m_pReturn = getHeap( pMTI->m_pReturnType->nSize ); - } - - m_nCalls ++; - return bContinue; - } -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_job.hxx b/bridges/source/remote/urp/urp_job.hxx deleted file mode 100644 index b2bd6734b97b..000000000000 --- a/bridges/source/remote/urp/urp_job.hxx +++ /dev/null @@ -1,381 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _URP_JOB_HXX_ -#define _URP_JOB_HXX_ -#include <list> -#include <typelib/typedescription.hxx> -#include <uno/any2.h> -#include <uno/environment.h> -#include <uno/threadpool.h> -#include "urp_threadid.hxx" -#include "urp_unmarshal.hxx" -#include "urp_bridgeimpl.hxx" - - -namespace bridges_urp -{ -const sal_Int32 MULTIJOB_STANDARD_MEMORY_SIZE = 1024; -const sal_Int32 MULTIJOB_PER_CALL_MEMORY_SIZE = 96; - -class Unmarshal; -struct urp_BridgeImpl; - -template < class t > -inline t mymax( const t &t1 , const t &t2 ) -{ - return t1 > t2 ? t1 : t2; -} - -class Job -{ -public: - Job( uno_Environment *pEnvRemote, - remote_Context *pContext, - sal_Sequence *pTid, - struct urp_BridgeImpl *pBridgeImpl, - Unmarshal *pUnmarshal ); - - Job( uno_Environment *pEnvRemote, - remote_Context *pContext, - struct urp_BridgeImpl *pBridgeImpl, - ::bridges_remote::RemoteThreadCounter_HoldEnvWeak value ) - : m_pContext( pContext ) - , m_pBridgeImpl( pBridgeImpl ) - , m_pTid( 0 ) - , m_counter( pEnvRemote , value ) - { - if ( m_pContext ) - { - m_pContext->aBase.acquire( &m_pContext->aBase ); - } - } - - ~Job(); - -public: - remote_Context *m_pContext; - Unmarshal *m_pUnmarshal; - struct urp_BridgeImpl *m_pBridgeImpl; - sal_Sequence *m_pTid; - ::bridges_remote::RemoteThreadCounter m_counter; -}; - -class ClientJob : private Job -{ -public: - // pContext is null for bridge-internal UrpProtocolProperties requests - inline ClientJob( uno_Environment *pEnvRemote, // weak ! - remote_Context *pContext, - struct urp_BridgeImpl *pBridgeImpl, - rtl_uString *pOid, // weak - typelib_TypeDescription const * pMemberType, // weak - typelib_InterfaceTypeDescription *pInterfaceType, // weak - void *pReturn, - void *ppArgs[], - uno_Any **ppException ); - - // ~ClientJob - // no release for method type and attribute type necessary, because - // it was acquired by the caller of urp_sendRequest. The lifetime - // of the ClientJob object is always shorter than the urp_sendRequest call. - inline ~ClientJob() - { - if( m_bReleaseForTypeDescriptionNecessary ) - typelib_typedescription_release( (typelib_TypeDescription*) m_pInterfaceType ); - uno_releaseIdFromCurrentThread(); - } - - sal_Bool pack(); - void wait(); - sal_Bool extract( ); - void initiate(); - - inline void setBridgePropertyCall() - { m_bBridgePropertyCall = sal_True; } - inline sal_Bool isBridgePropertyCall() const - { return m_bBridgePropertyCall; } - inline sal_Bool isOneway() const - { return m_bOneway; } - - inline void setUnmarshal( Unmarshal *p ) - { m_pUnmarshal = p; } -public: - typelib_InterfaceMethodTypeDescription *m_pMethodType; - typelib_InterfaceAttributeTypeDescription *m_pAttributeType; - sal_Bool m_bExceptionOccurred; - -private: - void **m_ppArgs; - void *m_pReturn; - typelib_InterfaceTypeDescription *m_pInterfaceType; - sal_Bool m_bReleaseForTypeDescriptionNecessary; - - uno_Any **m_ppException; - sal_Bool m_bOneway; - sal_Bool m_bBridgePropertyCall; - sal_uInt16 m_nMethodIndex; - uno_Environment *m_pEnvRemote; - rtl_uString *m_pOid; - sal_Bool m_bCallingConventionForced; -}; - -struct MemberTypeInfo -{ - typelib_InterfaceTypeDescription *m_pInterfaceType; - typelib_InterfaceMethodTypeDescription *m_pMethodType; - typelib_InterfaceAttributeTypeDescription *m_pAttributeType; - sal_Int32 m_nArgCount; - sal_Bool m_bIsReleaseCall; - sal_Bool *m_pbIsIn; - sal_Bool *m_pbIsOut; - sal_Bool m_bIsOneway; - typelib_TypeDescription *m_pReturnType; - typelib_TypeDescription **m_ppArgType; -}; - - -struct ServerJobEntry -{ - rtl_uString *m_pOid; - remote_Interface *m_pRemoteI; - typelib_TypeDescriptionReference *m_pInterfaceTypeRef; - void **m_ppArgs; - void *m_pReturn; - uno_Any m_exception; - uno_Any *m_pException; - remote_Interface *m_pCurrentContext; - sal_Bool m_bHasCurrentContext; - sal_Bool m_bIgnoreCache; -}; - -class ServerMultiJob : private Job -{ -public: - ServerMultiJob( uno_Environment *pEnvRemote, - remote_Context *pContext, - sal_Sequence *pTid, - struct urp_BridgeImpl *pBridgeImpl, - Unmarshal *pUnmarshal, - sal_Int32 nMaxMessages ); - ~ServerMultiJob(); -public: - sal_Bool extract( ); - void initiate(); - void execute(); - -public: - // setMethodType or setAttributeType MUST be called before extract - inline void setMethodType( - typelib_InterfaceMethodTypeDescription *pMethodType, - sal_Bool bIsReleaseCall, - sal_Bool bIsOneway ) - { - m_aTypeInfo[m_nCalls].m_pMethodType = pMethodType; - m_aTypeInfo[m_nCalls].m_pAttributeType = 0; - m_aTypeInfo[m_nCalls].m_nArgCount = pMethodType->nParams; - m_aTypeInfo[m_nCalls].m_bIsReleaseCall = bIsReleaseCall; - m_aTypeInfo[m_nCalls].m_bIsOneway = bIsOneway; - } - - inline void setAttributeType( - typelib_InterfaceAttributeTypeDescription *pAttributeType, sal_Bool bIsSetter, sal_Bool bIsOneway ) - { - m_aTypeInfo[m_nCalls].m_pAttributeType = pAttributeType; - m_aTypeInfo[m_nCalls].m_pMethodType = 0; - m_aTypeInfo[m_nCalls].m_nArgCount = bIsSetter ? 1 : 0; - m_aTypeInfo[m_nCalls].m_bIsReleaseCall = sal_False; - m_aTypeInfo[m_nCalls].m_bIsOneway = bIsOneway; - } - - inline void setType( typelib_TypeDescriptionReference *pTypeRef ) - { - m_aEntries[m_nCalls].m_pInterfaceTypeRef = pTypeRef; - typelib_typedescriptionreference_acquire( m_aEntries[m_nCalls].m_pInterfaceTypeRef ); - TYPELIB_DANGER_GET( - (typelib_TypeDescription ** )&(m_aTypeInfo[m_nCalls].m_pInterfaceType) , - pTypeRef ); - } - // setOid or setInterface MUST be called before extract - inline void setOid( rtl_uString *pOid ) - { - m_aEntries[m_nCalls].m_pOid = pOid; - rtl_uString_acquire( m_aEntries[m_nCalls].m_pOid ); - m_aEntries[m_nCalls].m_pRemoteI = 0; - } - - // setOid or setInterface MUST be called - inline void setInterface( remote_Interface *pRemoteI ) - { - m_aEntries[m_nCalls].m_pRemoteI = pRemoteI; - pRemoteI->acquire( pRemoteI ); - m_aEntries[m_nCalls].m_pOid = 0; - } - - inline void setCurrentContext( - bool bHasCurrentContext, remote_Interface *pCurrentContext ) - { - m_aEntries[m_nCalls].m_pCurrentContext = pCurrentContext; - m_aEntries[m_nCalls].m_bHasCurrentContext = bHasCurrentContext; - } - - inline void setIgnoreCache( sal_Bool bIgnoreCache ) - { - m_aEntries[m_nCalls].m_bIgnoreCache = bIgnoreCache; - } - - inline sal_Bool isFull() const - { return m_nCalls >= m_nMaxMessages; } - - inline sal_Int8 *getHeap( sal_Int32 nSizeToAlloc ) - { - if( nSizeToAlloc + m_nCurrentMemPosition > m_nCurrentMemSize ) - { - m_lstMem.push_back( m_pCurrentMem ); - m_nCurrentMemSize = mymax( nSizeToAlloc , MULTIJOB_STANDARD_MEMORY_SIZE ) + - (m_nMaxMessages -m_nCalls)*MULTIJOB_PER_CALL_MEMORY_SIZE; - m_pCurrentMem = (sal_Int8*) rtl_allocateMemory( m_nCurrentMemSize ); - m_nCurrentMemPosition = 0; - } - sal_Int8 *pHeap = m_pCurrentMem + m_nCurrentMemPosition; - m_nCurrentMemPosition += nSizeToAlloc; - - // care for alignment - if( m_nCurrentMemPosition & 0x7 ) - { - m_nCurrentMemPosition = ( ((sal_uInt32)m_nCurrentMemPosition) & ( 0xffffffff - 0x7 )) + 8; - } - return pHeap; - } - void prepareRuntimeException( const ::rtl::OUString &sMessage, sal_Int32 nCall ); - -private: - uno_Environment *m_pEnvRemote; - sal_Int32 m_nCalls; - sal_Int32 m_nMaxMessages; - - ServerJobEntry *m_aEntries; - MemberTypeInfo *m_aTypeInfo; - - sal_Int8 *m_pCurrentMem; - sal_Int32 m_nCurrentMemSize; - sal_Int32 m_nCurrentMemPosition; - - // list of memory pointers, that must be freed - ::std::list< sal_Int8 * > m_lstMem; -}; - - - -//--------------------------------------------------------------------------------------------- -inline ClientJob::ClientJob( - uno_Environment *pEnvRemote, - remote_Context *pContext, - struct urp_BridgeImpl *pBridgeImpl, - rtl_uString *pOid, - typelib_TypeDescription const * pMemberType, - typelib_InterfaceTypeDescription *pInterfaceType, - void *pReturn, - void *ppArgs[], - uno_Any **ppException ) - : Job( - pEnvRemote, pContext, pBridgeImpl, ::bridges_remote::RTC_HOLDENVWEAK ) - , m_ppArgs( ppArgs ) - , m_pReturn( pReturn ) - , m_pInterfaceType( pInterfaceType ) // weak - , m_bReleaseForTypeDescriptionNecessary( sal_False ) - , m_ppException( ppException ) - , m_bBridgePropertyCall( sal_False ) - , m_pEnvRemote( pEnvRemote ) // weak - , m_pOid( pOid ) // weak - , m_bCallingConventionForced( sal_False ) -{ - uno_getIdOfCurrentThread( &m_pTid ); - - if( typelib_TypeClass_INTERFACE_METHOD == pMemberType->eTypeClass ) - { - m_pMethodType = ( typelib_InterfaceMethodTypeDescription * ) pMemberType; - m_pAttributeType = 0; - } - else if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pMemberType->eTypeClass ) - { - m_pAttributeType = ( typelib_InterfaceAttributeTypeDescription * ) pMemberType; - m_pMethodType = 0; - } - else - { - OSL_ASSERT( ! "wrong member type" ); - } - - // calculate method index - if( ! m_pInterfaceType->aBase.bComplete ) - { - // must be acquired because typedescription may be exchanged - typelib_typedescription_acquire((typelib_TypeDescription*) m_pInterfaceType ); - m_bReleaseForTypeDescriptionNecessary = sal_True; - typelib_typedescription_complete( (typelib_TypeDescription ** ) &m_pInterfaceType ); - } - m_nMethodIndex = (sal_uInt16) m_pInterfaceType->pMapMemberIndexToFunctionIndex[ - ((typelib_InterfaceMemberTypeDescription*)pMemberType)->nPosition ]; - - if( m_pAttributeType && m_ppArgs ) - { - // setter - m_nMethodIndex ++; - } - - if( typelib_TypeClass_INTERFACE_METHOD == pMemberType->eTypeClass ) - { -// if( (( typelib_InterfaceMemberTypeDescription * ) pMemberType)->nPosition -// == REMOTE_RELEASE_METHOD_INDEX ) -// { -// m_bOneway = sal_True; -// } -// else - if( pBridgeImpl->m_properties.bForceSynchronous ) - { - m_bOneway = sal_False; - if( (( typelib_InterfaceMethodTypeDescription * ) pMemberType)->bOneWay ) - { - m_bCallingConventionForced = sal_True; - } - } - else - { - m_bOneway = (( typelib_InterfaceMethodTypeDescription * ) pMemberType)->bOneWay; - } - } - else - { - m_bOneway = sal_False; - } -} - -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_log.cxx b/bridges/source/remote/urp/urp_log.cxx deleted file mode 100644 index cdaa1727e6b9..000000000000 --- a/bridges/source/remote/urp/urp_log.cxx +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <osl/time.h> -#include "urp_bridgeimpl.hxx" -#include "urp_log.hxx" - -using namespace ::rtl; -using namespace ::osl; -namespace bridges_urp -{ -#ifdef BRIDGES_URP_PROT - Mutex g_logFileMutex; - - class FileAccess - { - public: - FileAccess( urp_BridgeImpl *pBridgeImpl_ ) : - pBridgeImpl( pBridgeImpl_ ), - guard( g_logFileMutex ) - { - if( pBridgeImpl->m_pLogFile ) - { - f = pBridgeImpl->m_pLogFile; - } - else - { - f = fopen( pBridgeImpl->m_sLogFileName.getStr() , "a" ); - } - } - ~FileAccess() - { - if( ! pBridgeImpl->m_pLogFile ) - { - fclose( f ); - } - } - FILE *getFile() - { - return f; - } - private: - urp_BridgeImpl *pBridgeImpl; - MutexGuard guard; - FILE *f; - }; - - void urp_logCall( urp_BridgeImpl *pBridgeImpl, sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron , - const ::rtl::OUString &sMethodName ) - { - if( pBridgeImpl->m_sLogFileName.getLength() && getenv( "PROT_REMOTE_ACTIVATE" ) ) - { - OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US ); - - FileAccess access( pBridgeImpl ); - fprintf( access.getFile() , - "%06u: calling [size=%d(usedata=%d)] [synchron=%d] [name=%s]\n" , - static_cast< unsigned int > (osl_getGlobalTimer()), - static_cast< int > (nSize), - static_cast< int > (nUseData), - bSynchron, sOperation.pData->buffer ); - } - } - - void urp_logServingRequest( urp_BridgeImpl *pBridgeImpl, - sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron , - const ::rtl::OUString &sMethodName ) - { - if( pBridgeImpl->m_sLogFileName.getLength() && getenv( "PROT_REMOTE_ACTIVATE" ) ) - { - OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US ); - - FileAccess access( pBridgeImpl ); - fprintf( - access.getFile(), - "%06u: serving request [size=%d(usedata=%d)] [synchron=%d] [name=%s]\n", - static_cast< unsigned int > (osl_getGlobalTimer()), - static_cast< int > (nSize), - static_cast< int > (nUseData), - bSynchron, - sOperation.pData->buffer - ); - } - } - - void urp_logGettingReply( urp_BridgeImpl *pBridgeImpl, - sal_Int32 nSize, sal_Int32 nUseData, - const ::rtl::OUString &sMethodName ) - { - if( pBridgeImpl->m_sLogFileName.getLength() && getenv( "PROT_REMOTE_ACTIVATE" ) ) - { - OString sOperation = OUStringToOString( sMethodName,RTL_TEXTENCODING_ASCII_US ); - FileAccess access( pBridgeImpl ); - fprintf( access.getFile(), - "%06u: getting reply [size=%d(usedata=%d)][name=%s]\n" , - static_cast< unsigned int > (osl_getGlobalTimer()), - static_cast< int > (nSize), - static_cast< int > (nUseData), - sOperation.pData->buffer); - } - } - - void urp_logReplying( urp_BridgeImpl *pBridgeImpl, - sal_Int32 nSize , sal_Int32 nUseData, - const ::rtl::OUString &sMethodName ) - { - if( pBridgeImpl->m_sLogFileName.getLength() && getenv( "PROT_REMOTE_ACTIVATE" ) ) - { - OString sOperation = OUStringToOString(sMethodName,RTL_TEXTENCODING_ASCII_US); - - FileAccess access( pBridgeImpl ); - fprintf( access.getFile(), - "%06u: replying [size=%d(usedata=%d)] [name=%s]\n", - static_cast< unsigned int > (osl_getGlobalTimer()), - static_cast< int > (nSize), - static_cast< int > (nUseData), - sOperation.pData->buffer); - } - } -#endif -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_log.hxx b/bridges/source/remote/urp/urp_log.hxx deleted file mode 100644 index 8eb3751932a6..000000000000 --- a/bridges/source/remote/urp/urp_log.hxx +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -namespace bridges_urp -{ -#ifdef DBG_UTIL -#define BRIDGES_URP_PROT -#endif - -#ifdef BRIDGES_URP_PROT - void urp_logCall( urp_BridgeImpl *pBridgeImpl , - sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron , - const ::rtl::OUString &sMethodName ); - - void urp_logServingRequest( urp_BridgeImpl *pBridgeImpl, - sal_Int32 nSize, sal_Int32 nUseData, sal_Bool bSynchron , - const ::rtl::OUString &sMethodName ); - - void urp_logGettingReply( urp_BridgeImpl *pBridgeImpl, - sal_Int32 nSize, sal_Int32 nUseData, - const ::rtl::OUString &sMethodName ); - - void urp_logReplying( urp_BridgeImpl *pBridgeImpl, - sal_Int32 nSize , sal_Int32 nUseData, - const ::rtl::OUString &sMethodName ); -#endif -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_marshal.cxx b/bridges/source/remote/urp/urp_marshal.cxx deleted file mode 100644 index ae23cfb87eb5..000000000000 --- a/bridges/source/remote/urp/urp_marshal.cxx +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <string.h> -#include <osl/diagnose.h> -#include <rtl/alloc.h> - -#include <uno/any2.h> -#include <uno/sequence2.h> - -#include "urp_marshal.hxx" - -using namespace ::rtl; - -using namespace ::com::sun::star::uno; - -namespace bridges_urp { - -static int g_nDetectLittleEndian = 1; -char g_bMarshalSystemIsLittleEndian = ((char*)&g_nDetectLittleEndian)[0]; - -Marshal::Marshal( urp_BridgeImpl *pBridgeImpl, - sal_Int32 nBufferSize, - urp_extractOidCallback callback) : - m_nBufferSize( nBufferSize ), - m_base( (sal_Int8*)rtl_allocateMemory( nBufferSize ) ), - m_pos( m_base + 2*sizeof( sal_Int32 ) ), - m_pBridgeImpl( pBridgeImpl ), - m_callback( callback ) -{} - -Marshal::~Marshal( ) -{ - rtl_freeMemory( m_base ); -} - -void Marshal::packOid( const ::rtl::OUString & oid ) -{ - sal_uInt16 nIndex; - if( oid.getLength() ) - { - nIndex = m_pBridgeImpl->m_oidCacheOut.seek( oid ); - if( 0xffff == nIndex ) - { - nIndex = m_pBridgeImpl->m_oidCacheOut.put( oid ); - packString( (void*)(&oid.pData) ); - } - else - { - OUString dummy; - packString( &dummy ); - } - } - else - { - // null reference - nIndex = 0xffff; - OUString dummy; - packString( &dummy ); - } - packInt16( &nIndex ); -} - -void Marshal::packTid( const ByteSequence & threadId, sal_Bool bIgnoreCache ) -{ - - sal_uInt16 nIndex = 0xffff; - if( ! bIgnoreCache ) - { - nIndex = m_pBridgeImpl->m_tidCacheOut.seek( threadId ); - } - - if( 0xffff == nIndex ) - { - if( ! bIgnoreCache ) - { - nIndex = m_pBridgeImpl->m_tidCacheOut.put( threadId ); - } - packByteSequence( (sal_Int8*) threadId.getConstArray() ,threadId.getLength()); - } - else - { - packByteSequence( 0 , 0 ); - } - packInt16( &nIndex ); -} - - -void Marshal::packType( void *pSource ) -{ - typelib_TypeDescriptionReference *pRef = - *(typelib_TypeDescriptionReference ** ) pSource; - - OSL_ASSERT( pRef ); - - sal_uInt8 nTypeClass = ( sal_uInt8 ) pRef->eTypeClass; - - if( nTypeClass <= /* any*/ 14 ) - { - packInt8( (sal_Int8*)&nTypeClass ); - } - else - { - OUString sTypeName; - sal_uInt16 nIndex = 0xffff; - - nIndex = m_pBridgeImpl->m_typeCacheOut.seek( *(Type*)&pRef ); - if( 0xffff == nIndex ) - { - // put it into the cache - nIndex = m_pBridgeImpl->m_typeCacheOut.put( *(Type*)&pRef ); - sTypeName = pRef->pTypeName; - nTypeClass = nTypeClass | 0x80; - } - packInt8( &nTypeClass ); - packInt16( &nIndex ); - if( 0x80 & nTypeClass ) - { - packString( &sTypeName ); - } - } -} - -sal_Bool Marshal::packRecursive( void *pSource , typelib_TypeDescription *pType ) -{ - sal_Bool bSuccess = sal_True; - switch( pType->eTypeClass ) - { - case typelib_TypeClass_EXCEPTION: - case typelib_TypeClass_STRUCT: - { - typelib_CompoundTypeDescription * pCompType = (typelib_CompoundTypeDescription*)pType; - - if (pCompType->pBaseTypeDescription) - { - bSuccess = pack( pSource , (typelib_TypeDescription*) pCompType->pBaseTypeDescription ); - } - - // then construct members - typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs; - sal_Int32 * pMemberOffsets = pCompType->pMemberOffsets; - sal_Int32 nDescr = pCompType->nMembers; - - for ( sal_Int32 nPos = 0; nPos < nDescr; ++nPos ) - { - typelib_TypeDescription * pMemberType = 0; - TYPELIB_DANGER_GET( &pMemberType, ppTypeRefs[nPos] ); - if( pMemberType ) - { - bSuccess = bSuccess && pack( (char*)pSource + pMemberOffsets[nPos] , pMemberType ); - TYPELIB_DANGER_RELEASE( pMemberType ); - } - else - { - OUStringBuffer buf( 64 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("Couldn't get typedescription for type ")); - buf.append( ppTypeRefs[nPos]->pTypeName ); - m_pBridgeImpl->addError( buf.makeStringAndClear() ); - bSuccess = sal_False; - } - } - break; - } - case typelib_TypeClass_SEQUENCE: - { - typelib_IndirectTypeDescription *pIndirectType = - ( typelib_IndirectTypeDescription* ) pType; - - const sal_Int32 nElements = (*(uno_Sequence **)pSource)->nElements; - char * pSourceElements = (char *)(*(uno_Sequence **)pSource)->elements; - - if( typelib_TypeClass_BYTE == pIndirectType->pType->eTypeClass ) - { - // Byte sequences are optimized - packByteSequence( (sal_Int8*)pSourceElements , nElements ); - } - else - { - typelib_TypeDescription *pElementType = 0; - TYPELIB_DANGER_GET( &pElementType, pIndirectType->pType ); - if( pElementType ) - { - const sal_Int32 nElementSize = pElementType->nSize; - - packCompressedSize( nElements ); - for ( sal_Int32 i = 0 ; i < nElements; i++ ) - { - bSuccess = bSuccess && pack( pSourceElements + (nElementSize*i) , pElementType ); - } - TYPELIB_DANGER_RELEASE( pElementType ); - } - else - { - bSuccess = sal_False; - OUStringBuffer buf( 64 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("Couldn't get typedescription for type ")); - buf.append( pIndirectType->pType->pTypeName ); - m_pBridgeImpl->addError( buf.makeStringAndClear() ); - } - } - break; - } - default: - OSL_ASSERT( 0 ); - } - return bSuccess; -} - -} // end namespace bridges - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_marshal.hxx b/bridges/source/remote/urp/urp_marshal.hxx deleted file mode 100644 index 60292cd23612..000000000000 --- a/bridges/source/remote/urp/urp_marshal.hxx +++ /dev/null @@ -1,345 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _URP_MARSHAL_HXX_ -#define _URP_MARSHAL_HXX_ -#include <rtl/ustrbuf.hxx> -#include <rtl/byteseq.hxx> -#include <com/sun/star/uno/Type.hxx> -#include "urp_bridgeimpl.hxx" -#include "urp_marshal_decl.hxx" - -#include <string.h> - -struct remote_Interface; - -namespace bridges_urp -{ - // methods for accessing marshaling buffer - inline void Marshal::finish( sal_Int32 nMessageCount ) - { - sal_Int32 nSize = getSize() - 2*sizeof( sal_Int32 ); - - // save the state - sal_Int8 *pos = m_pos; - m_pos = m_base; - packInt32( &nSize ); - packInt32( &nMessageCount ); - - // reset the state - m_pos = pos; - } - - inline void Marshal::restart() - { - m_pos = m_base + 2*sizeof( sal_Int32 ); - } - - inline sal_Int8 *Marshal::getBuffer() - { - return m_base; - } - - inline sal_Bool Marshal::empty() const - { - return ( m_pos - m_base ) == 2*sizeof( sal_Int32 ); - } - - inline sal_Int32 Marshal::getSize() const - { - return ((sal_Int32) (m_pos - m_base)); - } - - inline void Marshal::ensureAdditionalMem( sal_Int32 nMemToAdd ) - { - sal_Int32 nDiff = m_pos - m_base; - if( nDiff + nMemToAdd > m_nBufferSize ) - { - m_nBufferSize = m_nBufferSize * 2 > nDiff + nMemToAdd ? - m_nBufferSize* 2 : - nDiff + nMemToAdd; - - m_base = ( sal_Int8 * ) rtl_reallocateMemory( m_base , m_nBufferSize ); - m_pos = m_base + nDiff; - } - } - - // marshaling methods - inline void Marshal::packInt8( void *pSource ) - { - ensureAdditionalMem( 1 ); - *m_pos = *((sal_Int8*) pSource ); - m_pos++; - } - - inline void Marshal::packInt16( void *pSource ) - { - ensureAdditionalMem( 2 ); - if( isSystemLittleEndian() ) - { - m_pos[0] = ((unsigned char *)pSource)[1]; - m_pos[1] = ((unsigned char *)pSource)[0]; - } - else - { - m_pos[1] = ((unsigned char *)pSource)[1]; - m_pos[0] = ((unsigned char *)pSource)[0]; - } - m_pos +=2; - } - - inline void Marshal::packByteSequence( sal_Int8 *pData , sal_Int32 nLength ) - { - packCompressedSize( nLength ); - - ensureAdditionalMem( nLength ); - memcpy( m_pos , pData , nLength ); - m_pos += nLength; - } - - inline void Marshal::packString( void *pSource ) - { - rtl_uString *p = *( rtl_uString ** ) pSource; - - // to be optimized ! - // static buffer in marshal - ::rtl::OString o = ::rtl::OUStringToOString( p , RTL_TEXTENCODING_UTF8 ); - sal_Int32 nLength = o.pData->length; - packCompressedSize( nLength ); - - ensureAdditionalMem( nLength ); - - memcpy( m_pos , o.pData->buffer , nLength ); - m_pos += nLength; - } - - inline sal_Bool Marshal::packAny( void *pSource ) - { - sal_Bool bSuccess = sal_True; - uno_Any *pAny = (uno_Any * ) pSource; - - // pack the type - packType( &( pAny->pType ) ); - // pack the value - typelib_TypeDescription *pType = 0; - TYPELIB_DANGER_GET( &pType, pAny->pType ); - if( pType ) - { - pack( pAny->pData , pType ); - TYPELIB_DANGER_RELEASE( pType ); - } - else - { - rtl::OUStringBuffer buf( 128 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM("couldn't get typedescription for type " ) ); - buf.append( pAny->pType->pTypeName ); - m_pBridgeImpl->addError( buf.makeStringAndClear() ); - bSuccess = sal_False; - } - return bSuccess; - } - - inline void Marshal::packInt32( void *pSource ) - { - ensureAdditionalMem( 4 ); - if( isSystemLittleEndian() ) - { - m_pos[0] = ((unsigned char *)pSource)[3]; - m_pos[1] = ((unsigned char *)pSource)[2]; - m_pos[2] = ((unsigned char *)pSource)[1]; - m_pos[3] = ((unsigned char *)pSource)[0]; - } - else { - m_pos[3] = ((unsigned char *)pSource)[3]; - m_pos[2] = ((unsigned char *)pSource)[2]; - m_pos[1] = ((unsigned char *)pSource)[1]; - m_pos[0] = ((unsigned char *)pSource)[0]; - } - m_pos +=4; - } - - inline void Marshal::packCompressedSize( sal_Int32 nSize ) - { - ensureAdditionalMem( 5 ); - - if( nSize < 0xff ) - { - *((sal_uInt8*)m_pos) = (sal_uInt8) nSize; - m_pos ++; - } - else - { - *((sal_uInt8*)m_pos) = 0xff; - m_pos ++; - packInt32( &nSize ); - } - } - - inline sal_Bool Marshal::pack( void *pSource , typelib_TypeDescription *pType ) - { - sal_Bool bSuccess = sal_True; - switch( pType->eTypeClass ) - { - case typelib_TypeClass_BYTE: - { - packInt8( pSource ); - break; - } - case typelib_TypeClass_BOOLEAN: - { - ensureAdditionalMem( 1 ); - *m_pos = ( *((sal_Bool*) pSource ) ) ? 1 : 0; - m_pos++; - break; - } - - case typelib_TypeClass_CHAR: - case typelib_TypeClass_SHORT: - case typelib_TypeClass_UNSIGNED_SHORT: - { - packInt16( pSource ); - break; - } - case typelib_TypeClass_ENUM: - case typelib_TypeClass_LONG: - case typelib_TypeClass_UNSIGNED_LONG: - case typelib_TypeClass_FLOAT: - { - packInt32( pSource ); - break; - } - case typelib_TypeClass_DOUBLE: - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - { - ensureAdditionalMem( 8 ); - if( isSystemLittleEndian() ) - { - m_pos[0] = ((unsigned char *)pSource)[7]; - m_pos[1] = ((unsigned char *)pSource)[6]; - m_pos[2] = ((unsigned char *)pSource)[5]; - m_pos[3] = ((unsigned char *)pSource)[4]; - m_pos[4] = ((unsigned char *)pSource)[3]; - m_pos[5] = ((unsigned char *)pSource)[2]; - m_pos[6] = ((unsigned char *)pSource)[1]; - m_pos[7] = ((unsigned char *)pSource)[0]; - } - else - { - m_pos[7] = ((unsigned char *)pSource)[7]; - m_pos[6] = ((unsigned char *)pSource)[6]; - m_pos[5] = ((unsigned char *)pSource)[5]; - m_pos[4] = ((unsigned char *)pSource)[4]; - m_pos[3] = ((unsigned char *)pSource)[3]; - m_pos[2] = ((unsigned char *)pSource)[2]; - m_pos[1] = ((unsigned char *)pSource)[1]; - m_pos[0] = ((unsigned char *)pSource)[0]; - } - m_pos += 8; - break; - } - - case typelib_TypeClass_STRING: - { - packString( pSource ); - break; - } - case typelib_TypeClass_TYPE: - { - packType( pSource ); - break; - } - case typelib_TypeClass_ANY: - { - bSuccess = packAny( pSource ); - break; - } - case typelib_TypeClass_TYPEDEF: - { - bSuccess = sal_False; - m_pBridgeImpl->addError( "can't handle typedef typedescriptions" ); - break; - } - case typelib_TypeClass_INTERFACE: - { - remote_Interface *pRemoteI = *( remote_Interface ** )pSource; - - ::rtl::OUString sOid; - sal_uInt16 nIndex = 0xffff; - if( pRemoteI ) - { - m_callback( pRemoteI , &(sOid.pData) ); - - nIndex = m_pBridgeImpl->m_oidCacheOut.seek( sOid ); - if( 0xffff == nIndex ) - { - nIndex = m_pBridgeImpl->m_oidCacheOut.put( sOid ); - } - else - { - // cached ! - sOid = ::rtl::OUString(); - } - } - packString( &sOid ); - packInt16( &nIndex ); - break; - } - case typelib_TypeClass_VOID: - { - // do nothing - break; - } - case typelib_TypeClass_EXCEPTION: - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_SEQUENCE: - { - bSuccess = packRecursive( pSource, pType ); - break; - } - default: - { - bSuccess = sal_False; - rtl::OUStringBuffer buf( 128 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "can't handle values with typeclass " ) ); - buf.append( (sal_Int32 ) pType->eTypeClass , 10 ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " (" ) ); - buf.append( pType->pTypeName ); - buf.appendAscii( RTL_CONSTASCII_STRINGPARAM( ")" ) ); - m_pBridgeImpl->addError( buf.makeStringAndClear() ); - break; - } - } - return bSuccess; - } -} - - - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_marshal_decl.hxx b/bridges/source/remote/urp/urp_marshal_decl.hxx deleted file mode 100644 index 639d08e47e5c..000000000000 --- a/bridges/source/remote/urp/urp_marshal_decl.hxx +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#ifndef _URP_MARSHAL_DECL_HXX_ -#define _URP_MARSHAL_DECL_HXX_ - -#include <rtl/ustring.hxx> -#include <rtl/byteseq.hxx> - -#include <com/sun/star/uno/Type.hxx> - -namespace bridges_urp -{ - struct urp_BridgeImpl; - - typedef void - ( SAL_CALL * urp_extractOidCallback )( remote_Interface *pRemoteI, rtl_uString **ppOid ); - - extern char g_bMarshalSystemIsLittleEndian; - class Marshal - { - public: - Marshal( /* cache access */ struct urp_BridgeImpl *, - sal_Int32 m_nBufferSize, - urp_extractOidCallback callback = 0 - ); - ~Marshal( ); - - inline sal_Bool pack( void *pSource , typelib_TypeDescription *pType ); - - sal_Bool packRecursive( void *pSource, typelib_TypeDescription *pType ); - - void packTid( const ::rtl::ByteSequence &id, sal_Bool bIgnoreCache = sal_False ); - void packOid( const ::rtl::OUString &oid ); - void packType( void *pSource ); - - inline void packCompressedSize( sal_Int32 nSize ); - inline void packInt8( void *pSource ); - inline void packInt16( void *pSource ); - inline void packInt32( void *pSource ); - inline void packString( void *pSource ); - inline sal_Bool packAny( void *pSource ); - inline void packByteSequence( sal_Int8 *pBuffer , sal_Int32 nSize ); - - // can be called during marshaling, but not between - // finish and restart - // returns true, when nothing has been marshaled - inline sal_Bool empty() const; - - // stops marshaling, inserts size in front of the buffer - // getStart and getSize can now be called - inline void finish( sal_Int32 nMessageCount ); - - // must be called after finish. After calling restart, - // a new marshalling session is started invalidating - // the previous bufer - inline void restart(); - - // is only valid, after finish has been called. - // valid until destructed. - inline sal_Int8 *getBuffer(); - - // is only valid, after finish has been called. - // valid until destructed. - inline sal_Int32 getSize() const; - - inline sal_Int32 getPos() const - { return m_pos - m_base; } - - inline sal_Bool isSystemLittleEndian() const - { return g_bMarshalSystemIsLittleEndian; } - - private: - inline void ensureAdditionalMem( sal_Int32 nMemToAdd ); - sal_Int32 m_nBufferSize; - sal_Int8 *m_base; - sal_Int8 *m_pos; - struct urp_BridgeImpl *m_pBridgeImpl; - urp_extractOidCallback m_callback; - }; -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_property.hxx b/bridges/source/remote/urp/urp_property.hxx deleted file mode 100644 index 0cd5525e63ad..000000000000 --- a/bridges/source/remote/urp/urp_property.hxx +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _URP_PROPERTY_HXX_ -#define _URP_PROPERTY_HXX_ -#include <bridges/remote/remote.h> -#include <rtl/ustring.hxx> -#include <rtl/byteseq.hxx> - -namespace bridges_urp -{ - struct Properties - { - ::rtl::ByteSequence seqBridgeID; - sal_Int32 nTypeCacheSize; - sal_Int32 nOidCacheSize; - sal_Int32 nTidCacheSize; - ::rtl::OUString sSupportedVersions; - ::rtl::OUString sVersion; - sal_Int32 nFlushBlockSize; - sal_Int32 nOnewayTimeoutMUSEC; - sal_Bool bSupportsMustReply; - sal_Bool bSupportsSynchronous; - sal_Bool bSupportsMultipleSynchronous; - sal_Bool bClearCache; - sal_Bool bNegotiate; - sal_Bool bForceSynchronous; - sal_Bool bCurrentContext; - - inline Properties() - : nTypeCacheSize( 256 ) - , nOidCacheSize( 256 ) - , nTidCacheSize( 256 ) - , sSupportedVersions( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "1.0" ) ) ) - , sVersion( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "1.0" ))) - , nFlushBlockSize( 4*1024 ) - , nOnewayTimeoutMUSEC( 10000 ) - , bSupportsMustReply( sal_False ) - , bSupportsSynchronous( sal_False ) - , bSupportsMultipleSynchronous( sal_False ) - , bClearCache( sal_False ) - , bNegotiate( sal_True ) - , bForceSynchronous( sal_True ) - , bCurrentContext( sal_False ) - {} - - inline Properties & SAL_CALL operator = ( const Properties &props ) - { - seqBridgeID = props.seqBridgeID; - nTypeCacheSize = props.nTypeCacheSize; - nOidCacheSize = props.nOidCacheSize; - nTidCacheSize = props.nTidCacheSize; - sSupportedVersions = props.sSupportedVersions; - sVersion = props.sVersion; - nFlushBlockSize = props.nFlushBlockSize; - nOnewayTimeoutMUSEC = props.nOnewayTimeoutMUSEC; - bSupportsMustReply = props.bSupportsMustReply; - bSupportsSynchronous = props.bSupportsSynchronous; - bSupportsMultipleSynchronous = props.bSupportsMultipleSynchronous; - bClearCache = props.bClearCache; - bNegotiate = props.bNegotiate; - bForceSynchronous = props.bForceSynchronous; - bCurrentContext = props.bCurrentContext; - return *this; - } - }; -} // end namespace bridges_urp -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_propertyobject.cxx b/bridges/source/remote/urp/urp_propertyobject.cxx deleted file mode 100644 index 323faee2e929..000000000000 --- a/bridges/source/remote/urp/urp_propertyobject.cxx +++ /dev/null @@ -1,796 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <stdlib.h> -#include <osl/diagnose.h> - -#include <rtl/random.h> - -#include <uno/data.h> - -#include "com/sun/star/bridge/InvalidProtocolChangeException.hpp" -#include <com/sun/star/bridge/XProtocolProperties.hpp> - -#include "urp_propertyobject.hxx" -#include "urp_dispatch.hxx" -#include "urp_bridgeimpl.hxx" -#include "urp_job.hxx" - -using namespace ::rtl; -using namespace ::osl; -using namespace ::com::sun::star::bridge; -using namespace ::com::sun::star::uno; - -using namespace bridges_urp; - -extern "C" { - -static void SAL_CALL staticAcquire( remote_Interface *pRemoteI ) -{ - PropertyObject *pProperties = (PropertyObject *) pRemoteI; - pProperties->thisAcquire(); -} - -static void SAL_CALL staticRelease( remote_Interface *pRemoteI ) -{ - PropertyObject *pProperties = (PropertyObject *) pRemoteI; - pProperties->thisRelease(); -} - -static void SAL_CALL staticDispatch( - remote_Interface * pRemoteI, typelib_TypeDescription const * pMemberType, - void * pReturn, void * pArgs[], uno_Any ** ppException ) -{ - PropertyObject *pProperties = (PropertyObject *) pRemoteI; - pProperties->thisDispatch( pMemberType, pReturn, pArgs, ppException ); -} - -} - -namespace bridges_urp -{ -// some nice constants .... -static const sal_Int32 METHOD_QUERY_INTERFACE = 0; -static const sal_Int32 METHOD_GET_PROPERTIES = 3; -static const sal_Int32 METHOD_REQUEST_CHANGE = 4; -static const sal_Int32 METHOD_COMMIT_CHANGE = 5; - -static const sal_Int32 PROPERTY_BRIDGEID = 0; -static const sal_Int32 PROPERTY_TYPECACHESIZE = 1; -static const sal_Int32 PROPERTY_OIDCACHESIZE = 2; -static const sal_Int32 PROPERTY_TIDCACHESIZE = 3; -static const sal_Int32 PROPERTY_SUPPORTEDVERSIONS = 4; -static const sal_Int32 PROPERTY_VERSION =5; -static const sal_Int32 PROPERTY_FLUSHBLOCKSIZE = 6; -static const sal_Int32 PROPERTY_ONEWAYTIMEOUT_MUSEC = 7; -static const sal_Int32 PROPERTY_SUPPORTSMUSTREPLY = 8; -static const sal_Int32 PROPERTY_SUPPERTSSYNCHRONOUS = 9; -static const sal_Int32 PROPERTY_SUPPORTSMULTIPLESYNCHRONOUS = 10; -static const sal_Int32 PROPERTY_CLEARCACHE = 11; -static const sal_Int32 PROPERTY_NEGOTIATE = 12; -static const sal_Int32 PROPERTY_FORCESYNCHRONOUS = 13; -static const sal_Int32 PROPERTY_CURRENTCONTEXT = 14; - -static const sal_Int32 MAX_PROPERTIES = PROPERTY_CURRENTCONTEXT +1; - -const sal_Char *g_aPropertyName[] = -{ - "BridgeId", - "TypeCacheSize", - "OidCacheSize", - "TidCacheSize", - "SupportedVersion", - "Version", - "FlushBlockSize", - "OnewayTimeoutMUSEC", - "SupportsMustReply", - "SupportsSynchronous", - "SupportsMultipleSynchronous", - "ClearCache", - "Negotiate", - "ForceSynchronous", - "CurrentContext" -}; - -// nice little helper functions for conversion -template< class t > -void assignToIdl( ProtocolProperty *pIdl, sal_Int32 nIndex, const t &value ) -{ - pIdl->Name = OUString::createFromAscii( g_aPropertyName[nIndex] ); - ( *(::com::sun::star::uno::Any *)&(pIdl->Value) ) <<= value; -} - -template< class t > -void assignFromIdl( t * p, const ProtocolProperty & property ) -{ - property.Value >>=*p; -} - -static sal_Int32 getIndexFromIdl( const ProtocolProperty & property ) -{ - sal_Int32 nResult = -1; - for( sal_Int32 i = 0 ; i < MAX_PROPERTIES ; i ++ ) - { - if( 0 == property.Name.compareToAscii( g_aPropertyName[i] ) ) - { - nResult = i; - break; - } - } - return nResult; -} - -static sal_Int32 getIndexFromString( const OUString & property ) -{ - sal_Int32 nResult = -1; - for( sal_Int32 i = 0 ; i < MAX_PROPERTIES ; i ++ ) - { - if( 0 == property.compareToAscii( g_aPropertyName[i] ) ) - { - nResult = i; - break; - } - } - return nResult; -} - -static sal_Bool assignFromIdlToStruct( Properties *pProps, const ProtocolProperty &idl ) -{ - sal_Bool bReturn = sal_True; - - sal_Int32 nIndex = getIndexFromIdl( idl ); - if( nIndex >= 0 ) - { - switch( nIndex ) - { - case PROPERTY_SUPPORTSMULTIPLESYNCHRONOUS: - assignFromIdl( &(pProps->bSupportsMultipleSynchronous) , idl ); - break; - case PROPERTY_SUPPERTSSYNCHRONOUS: - assignFromIdl( &(pProps->bSupportsMustReply) , idl ); - break; - case PROPERTY_SUPPORTSMUSTREPLY: - assignFromIdl( &(pProps->bSupportsSynchronous) , idl ); - break; - case PROPERTY_ONEWAYTIMEOUT_MUSEC: - assignFromIdl( &(pProps->nOnewayTimeoutMUSEC) , idl ); - break; - case PROPERTY_BRIDGEID: - assignFromIdl( (Sequence< sal_Int8 > * )&(pProps->seqBridgeID), idl ); - break; - case PROPERTY_TYPECACHESIZE: - assignFromIdl( &(pProps->nTypeCacheSize) , idl ); - break; - case PROPERTY_OIDCACHESIZE: - assignFromIdl( &(pProps->nOidCacheSize) , idl ); - break; - case PROPERTY_TIDCACHESIZE: - assignFromIdl( &(pProps->nTidCacheSize), idl ); - break; - case PROPERTY_SUPPORTEDVERSIONS: - assignFromIdl( &(pProps->sSupportedVersions) , idl ); - break; - case PROPERTY_VERSION: - assignFromIdl( &(pProps->sVersion) , idl ); - break; - case PROPERTY_FLUSHBLOCKSIZE: - assignFromIdl( &(pProps->nFlushBlockSize) ,idl ); - break; - case PROPERTY_CLEARCACHE: - assignFromIdl( &(pProps->bClearCache) ,idl ); - break; - case PROPERTY_NEGOTIATE: - assignFromIdl( &(pProps->bNegotiate) ,idl ); - break; - case PROPERTY_FORCESYNCHRONOUS: - assignFromIdl( &(pProps->bForceSynchronous) ,idl ); - break; - case PROPERTY_CURRENTCONTEXT: - pProps->bCurrentContext = true; - break; - default: - bReturn = sal_False; - } - } - else - { - bReturn = sal_False; - } - return bReturn; -} - -static void extractTokens( - const ::rtl::OUString &sProps , ::std::list< OUString > &lst ) -{ - sal_Int32 nNext = 0; - while ( sal_True ) - { - sal_Int32 nStart = nNext; - nNext = sProps.indexOf( ',' , nNext ); - if( -1 == nNext ) - { - lst.push_back( sProps.copy( nStart, sProps.getLength() - nStart ) ); - break; - } - lst.push_back( sProps.copy( nStart , nNext - nStart ) ); - nNext ++; - } -} - - -static void assignFromStringToPropSeq( const OUString &sProps, uno_Sequence **ppPropertySeq) -{ - ::std::list< OUString > lst; - extractTokens( sProps , lst ); - - typelib_TypeDescription *pSequenceType = 0; - getCppuType( (Sequence< ProtocolProperty > *)0).getDescription( &pSequenceType ); - uno_Sequence *pSeq = 0; - uno_sequence_construct( &pSeq , pSequenceType , 0, lst.size() , 0 ); - ProtocolProperty *pElements = (ProtocolProperty * ) pSeq->elements; - - sal_Int32 i = 0; - for( ::std::list< OUString >::iterator ii = lst.begin() ; ii != lst.end() ; ++ ii, i++ ) - { - sal_Int32 nAssign = (*ii).indexOf( '=' ); - if( -1 == nAssign ) - { - OString o = OUStringToOString( *ii, RTL_TEXTENCODING_ASCII_US ); - OSL_ENSURE( !"wrong protocol propertyt format, ignored", o.getStr() ); - } - OUString sPropName = (*ii).copy( 0, nAssign ); - OUString sValue = (*ii).copy( nAssign +1, (*ii).getLength() - nAssign -1 ); - - sal_Int32 nIndex = getIndexFromString( sPropName ); - if( -1 == nIndex ) - { - OString o = OUStringToOString( sPropName , RTL_TEXTENCODING_ASCII_US); - OSL_ENSURE( !"unknown protocol property, ignored", o.getStr() ); - } - switch( nIndex ) - { - // voids - case PROPERTY_CURRENTCONTEXT: - pElements[i].Name = OUString::createFromAscii( - g_aPropertyName[nIndex] ); - break; - // bools - case PROPERTY_CLEARCACHE: - case PROPERTY_NEGOTIATE: - case PROPERTY_FORCESYNCHRONOUS: - { - sal_Bool bClearCache = (sal_Bool ) sValue.toInt32(); - assignToIdl( &(pElements[i]) , nIndex , bClearCache ); - break; - } - // ints - case PROPERTY_TYPECACHESIZE: - case PROPERTY_OIDCACHESIZE: - case PROPERTY_TIDCACHESIZE: - case PROPERTY_FLUSHBLOCKSIZE: - case PROPERTY_ONEWAYTIMEOUT_MUSEC: - { - sal_Int32 nValue = sValue.toInt32(); - assignToIdl( &(pElements[i]) , nIndex , nValue ); - break; - } - - // strings - case PROPERTY_VERSION: - assignToIdl( &(pElements[i]) , nIndex , sValue ); - break; - default: - OString o = OUStringToOString( sPropName, RTL_TEXTENCODING_ASCII_US ); - OSL_ENSURE( !"readonly protocol property, ignored" , o.getStr() ); - } - } - *ppPropertySeq = pSeq; - typelib_typedescription_release( pSequenceType ); -} - -static void assignFromPropSeqToStruct( uno_Sequence *pSeq , struct Properties *pProps ) -{ - sal_Int32 i; - ProtocolProperty *pElements = (ProtocolProperty *)pSeq->elements; - for( i = 0 ; i < pSeq->nElements ; i ++ ) - { - assignFromIdlToStruct( pProps , pElements[i] ); - } -} - -void assignFromStringToStruct( const OUString & sProps , struct Properties *pProps ) -{ - uno_Sequence *pSeq = 0; - assignFromStringToPropSeq( sProps , &pSeq ); - assignFromPropSeqToStruct( pSeq , pProps ); - uno_type_destructData( &pSeq, getCppuType( (Sequence< ProtocolProperty > *)0).getTypeLibType(),0); -} - - -//---------------------------------------------------------------------------------------------- -// PropertyObject implementation -PropertyObject::PropertyObject( - struct Properties *pLocalSetting , uno_Environment *pEnvRemote, urp_BridgeImpl *pImpl ) - : m_commitChangeCondition( osl_createCondition() ) - , m_nRefCount( 0 ) - , m_pBridgeImpl( pImpl ) - , m_pLocalSetting( pLocalSetting ) - , m_pEnvRemote( pEnvRemote ) - , m_bRequestChangeHasBeenCalled( sal_False ) - , m_bServerWaitingForCommit( sal_False ) - , m_bApplyProperties( sal_False ) -{ - acquire = staticAcquire; - release = staticRelease; - pDispatcher = staticDispatch; -} - -PropertyObject::~PropertyObject() -{ - osl_destroyCondition( m_commitChangeCondition ); -} - -void SAL_CALL PropertyObject::thisDispatch( - typelib_TypeDescription const * pMemberType, void * pReturn, void * ppArgs[], - uno_Any ** ppException ) -{ - OSL_ASSERT( pMemberType->eTypeClass == typelib_TypeClass_INTERFACE_METHOD ); - - typelib_InterfaceMethodTypeDescription *pMethodType = - ( typelib_InterfaceMethodTypeDescription * ) pMemberType; - - switch( pMethodType->aBase.nPosition ) - { - case METHOD_QUERY_INTERFACE: - OSL_ENSURE( 0 , "not implemented yet !" ); - break; - case METHOD_GET_PROPERTIES: - { - implGetProperties( (uno_Sequence **) pReturn ); - *ppException = 0; - break; - } - case METHOD_COMMIT_CHANGE: - { - implCommitChange( *(uno_Sequence ** ) ppArgs[0] , ppException ); - break; - } - case METHOD_REQUEST_CHANGE: - { - *(sal_Int32 *) pReturn = implRequestChange( *(sal_Int32 *)ppArgs[0], ppException ); - break; - } - default: - OSL_ENSURE( 0 , "unkown method !" ); - } -} - -void SAL_CALL PropertyObject::localGetPropertiesFromRemote( struct Properties *pR ) -{ - OUString oid = OUString::createFromAscii( g_NameOfUrpProtocolPropertiesObject ); - - typelib_TypeDescription *pInterfaceType = 0; - getCppuType( (Reference< XProtocolProperties > *) 0 ).getDescription( &pInterfaceType ); - - if( !pInterfaceType->bComplete ) - { - typelib_typedescription_complete( &pInterfaceType ); - } - - typelib_TypeDescription *pMethodType = 0; - typelib_typedescriptionreference_getDescription( - &pMethodType, - ((typelib_InterfaceTypeDescription*) pInterfaceType)->ppAllMembers[METHOD_GET_PROPERTIES] ); - - - uno_Sequence *pResult = 0; - uno_Any exception; - uno_Any *pException = &exception; - urp_sendRequest( m_pEnvRemote, - pMethodType, - oid.pData, - (typelib_InterfaceTypeDescription*) pInterfaceType, - &pResult, - 0, - &pException ); - - if( pException ) - { - OSL_ENSURE( 0 , "remote urp-bridge doesn't support property-object" ); - uno_any_destruct( pException , 0 ); - return; - } - - ProtocolProperty *pP = (ProtocolProperty * ) pResult->elements; - for( sal_Int32 i = 0; i < pResult->nElements ; i ++ ) - { - if( ! assignFromIdlToStruct( pR , pP[i] ) ) - { - OSL_ENSURE( 0 , "unknown property !!!!" ); - } - } - - typelib_typedescription_release( pInterfaceType ); - typelib_typedescription_release( pMethodType ); -} - - -// implementation for call from remote -void SAL_CALL PropertyObject::implGetProperties( uno_Sequence **ppReturnValue ) -{ - typelib_TypeDescription *pElementType= 0; - getCppuType( (Sequence< ProtocolProperty > *)0).getDescription( &pElementType ); - - OSL_ENSURE( pElementType , "Couldn't get property type" ); - - *ppReturnValue = 0; - uno_sequence_construct( ppReturnValue , pElementType , 0, MAX_PROPERTIES , 0 ); - ProtocolProperty *pElements = (ProtocolProperty * ) ( *ppReturnValue )->elements; - Properties *pP = m_pLocalSetting; - - assignToIdl( &(pElements[PROPERTY_BRIDGEID]),PROPERTY_BRIDGEID, toUnoSequence(pP->seqBridgeID) ); - assignToIdl( &(pElements[PROPERTY_TYPECACHESIZE]),PROPERTY_TYPECACHESIZE,pP->nTypeCacheSize ); - assignToIdl( &(pElements[PROPERTY_OIDCACHESIZE]),PROPERTY_OIDCACHESIZE, pP->nOidCacheSize ); - assignToIdl( &(pElements[PROPERTY_TIDCACHESIZE]),PROPERTY_TIDCACHESIZE, pP->nTidCacheSize ); - assignToIdl( &(pElements[PROPERTY_SUPPORTEDVERSIONS]),PROPERTY_SUPPORTEDVERSIONS, pP->sSupportedVersions ); - assignToIdl( &(pElements[PROPERTY_VERSION]),PROPERTY_VERSION, pP->sVersion ); - assignToIdl( &(pElements[PROPERTY_FLUSHBLOCKSIZE]), PROPERTY_FLUSHBLOCKSIZE,pP->nFlushBlockSize ); - assignToIdl( &(pElements[PROPERTY_ONEWAYTIMEOUT_MUSEC]), PROPERTY_ONEWAYTIMEOUT_MUSEC, pP->nOnewayTimeoutMUSEC ); - assignToIdl( &(pElements[PROPERTY_SUPPORTSMUSTREPLY]), PROPERTY_SUPPORTSMUSTREPLY, pP->bSupportsMustReply ); - assignToIdl( &(pElements[PROPERTY_SUPPERTSSYNCHRONOUS]), PROPERTY_SUPPERTSSYNCHRONOUS, pP->bSupportsSynchronous ); - assignToIdl( &(pElements[PROPERTY_SUPPORTSMULTIPLESYNCHRONOUS]), PROPERTY_SUPPORTSMULTIPLESYNCHRONOUS, pP->bSupportsMultipleSynchronous ); - assignToIdl( &(pElements[PROPERTY_CLEARCACHE]), PROPERTY_CLEARCACHE, pP->bClearCache ); - - typelib_typedescription_release( pElementType ); -} - -//---------------------------------------------------------------------------------------------- -sal_Int32 SAL_CALL PropertyObject::localRequestChange( ) -{ - sal_Int32 nResult = 0; - sal_Bool bCall = sal_True; - - // disallow marshaling NOW ! - ClearableMutexGuard marshalingGuard( m_pBridgeImpl->m_marshalingMutex ); - { - MutexGuard guard( m_mutex ); - if( m_bRequestChangeHasBeenCalled || m_bServerWaitingForCommit ) - { - // another transaction is already underway - // try again later ! - bCall = sal_False; - } - m_bRequestChangeHasBeenCalled = sal_True; - - if( bCall ) - { - // calulate random number - rtlRandomPool pool = rtl_random_createPool (); - rtl_random_getBytes( pool , &m_nRandomNumberOfRequest, sizeof( m_nRandomNumberOfRequest ) ); - rtl_random_destroyPool( pool ); - } - } - - if( bCall ) - { - OUString oid = OUString::createFromAscii( g_NameOfUrpProtocolPropertiesObject ); - - // gather types for calling - typelib_TypeDescription *pInterfaceType = 0; - getCppuType( (Reference< XProtocolProperties > *) 0 ).getDescription( &pInterfaceType ); - - if( !pInterfaceType->bComplete ) - { - typelib_typedescription_complete( &pInterfaceType ); - } - - typelib_TypeDescription *pMethodType = 0; - typelib_typedescriptionreference_getDescription( - &pMethodType, - ((typelib_InterfaceTypeDescription*) pInterfaceType)->ppAllMembers[METHOD_REQUEST_CHANGE] ); - - void *pArg1 = &m_nRandomNumberOfRequest; - void **ppArgs = &pArg1; - - uno_Any exception; - uno_Any *pException = &exception; - - ClientJob job( m_pEnvRemote, - 0, - m_pBridgeImpl, - oid.pData, - pMethodType, - (typelib_InterfaceTypeDescription*) pInterfaceType, - &nResult, - ppArgs, - &pException ); - - // put the call on the line ! - sal_Bool bSuccess = job.pack(); - - // now allow writing on wire again. - // NOTE : this has been locked, because it is inevitable to set m_bRequestChangeHasBeenCalled - // and call requestChange in an atomar operation. Otherwise, implRequestChange may be called - // inbetween and reply, before the request is put on the wire. This certainly would - // be confusing for the remote counterpart ! - marshalingGuard.clear(); - - // wait for the reply ... - if( bSuccess ) - { - job.wait(); - - if( pException ) - { - // the object is unknown on the other side. - uno_any_destruct( pException , 0 ); - nResult = 0; - } - } - else - { - nResult = 0; - } - typelib_typedescription_release( pInterfaceType ); - typelib_typedescription_release( pMethodType ); - } - - { - MutexGuard guard( m_mutex ); - m_bRequestChangeHasBeenCalled = sal_False; - m_bServerWaitingForCommit = ( 0 == nResult ); - } - return nResult; -} - -// implementation for call from remote -sal_Int32 SAL_CALL PropertyObject::implRequestChange( sal_Int32 nRandomNumber, uno_Any **ppException ) -{ - sal_Int32 nResult = 0; - MutexGuard guard( m_mutex ); - if( m_bRequestChangeHasBeenCalled ) - { - // this side has also called requestChange, now negotiate, which side is allowed - // to commit the change ! - if( m_nRandomNumberOfRequest > nRandomNumber ) - { - // this side may commit !!!! - nResult = 0; - } - else if( m_nRandomNumberOfRequest == nRandomNumber ) - { - // sorry, try again ! - nResult = -1; - } - else if( m_nRandomNumberOfRequest < nRandomNumber ) - { - // the other side may commit ! - nResult = 1; - // m_bServerWaitingForCommit will be set by localRequestChange - } - } - else - { - // This side has NOT called requestChange, so the other side may commit - nResult = 1; - m_bServerWaitingForCommit = sal_True; - } - - *ppException = 0; - return nResult; -} - - - -void SAL_CALL PropertyObject::localCommitChange( const ::rtl::OUString &sProps , sal_Bool *pbExceptionThrown ) -{ - // lock the bridge NOW ! - // NOTE: it is not allowed for other threads to call, when a commit change is underway. - // The remote counterpart cannot if the call following the commit already uses - // the new properties or not. - MutexGuard guard( m_pBridgeImpl->m_marshalingMutex ); - - OUString oid = OUString::createFromAscii( g_NameOfUrpProtocolPropertiesObject ); - - osl_resetCondition( m_commitChangeCondition ); - - Properties props = *m_pLocalSetting; - - typelib_TypeDescription *pInterfaceType = 0; - getCppuType( (Reference< XProtocolProperties > *) 0 ).getDescription( &pInterfaceType ); - - if( !pInterfaceType->bComplete ) - { - typelib_typedescription_complete( &pInterfaceType ); - } - - typelib_TypeDescription *pMethodType = 0; - typelib_typedescriptionreference_getDescription( - &pMethodType, - ((typelib_InterfaceTypeDescription*) pInterfaceType)->ppAllMembers[METHOD_COMMIT_CHANGE] ); - -// typelib_TypeDescription *pSequenceType= 0; - - - // extract name/value pairs - uno_Sequence *pSeq = 0; - assignFromStringToPropSeq( sProps, &pSeq ); - assignFromPropSeqToStruct( pSeq , &props ); -// ::std::list< OUString > lst; -// extractTokens( sProps , lst ); - -// getCppuType( (Sequence< ProtocolProperty > *)0).getDescription( &pSequenceType ); -// uno_sequence_construct( &pSeq , pSequenceType , 0, lst.size() , 0 ); -// ProtocolProperty *pElements = (ProtocolProperty * ) pSeq->elements; - -// sal_Int32 i = 0; -// for( ::std::list< OUString >::iterator ii = lst.begin() ; ii != lst.end() ; ++ ii, i++ ) -// { -// sal_Int32 nAssign = (*ii).indexOf( '=' ); -// if( -1 == nAssign ) -// { -// OString o = OUStringToOString( *ii, RTL_TEXTENCODING_ASCII_US ); -// OSL_ENSURE( !"wrong protocol propertyt format, ignored", o.getStr() ); -// } -// OUString sPropName = (*ii).copy( 0, nAssign ); -// OUString sValue = (*ii).copy( nAssign +1, (*ii).getLength() - nAssign -1 ); - -// sal_Int32 nIndex = getIndexFromString( sPropName ); -// if( -1 == nIndex ) -// { -// OString o = OUStringToOString( sPropName , RTL_TEXTENCODING_ASCII_US); -// OSL_ENSURE( !"unknown protocol property, ignored", o.getStr() ); -// } -// switch( nIndex ) -// { -// // bools -// case PROPERTY_CLEARCACHE: -// { -// sal_Bool bClearCache = (sal_Bool ) sValue.toInt32(); -// assignToIdl( &(pElements[i]) , nIndex , bClearCache ); -// break; -// } -// // ints -// case PROPERTY_TYPECACHESIZE: -// case PROPERTY_OIDCACHESIZE: -// case PROPERTY_TIDCACHESIZE: -// case PROPERTY_FLUSHBLOCKSIZE: -// case PROPERTY_ONEWAYTIMEOUT_MUSEC: -// { -// sal_Int32 nValue = sValue.toInt32(); -// assignToIdl( &(pElements[i]) , nIndex , nValue ); -// break; -// } - -// // strings -// case PROPERTY_VERSION: -// assignToIdl( &(pElements[i]) , nIndex , sValue ); -// break; -// default: -// OString o = OUStringToOString( sPropName, RTL_TEXTENCODING_ASCII_US ); -// OSL_ENSURE( !"readonly protocol property, ignored" , o.getStr() ); -// } -// assignFromIdlToStruct( &props, pElements[i] ); -// } - - void *pArg1 = &pSeq; - uno_Any exception; - uno_Any *pException = &exception; - - ClientJob job( m_pEnvRemote, - 0, - m_pBridgeImpl, - oid.pData, - pMethodType, - (typelib_InterfaceTypeDescription*) pInterfaceType, - 0, - &pArg1, - &pException ); - job.setBridgePropertyCall(); - if( job.pack() ) - { - job.wait(); - } - else - { - OSL_ASSERT( pException != NULL ); - } - - ::uno_type_destructData( - &pSeq, getCppuType( (Sequence< ProtocolProperty > *)0).getTypeLibType(), 0 ); - - *pbExceptionThrown = pException ? sal_True : sal_False; - - if( pException ) - { - OString o = OUStringToOString( ((com::sun::star::uno::Exception*)pException->pData)->Message, - RTL_TEXTENCODING_ASCII_US); - OSL_ENSURE( !"exception thrown during calling on PropertyObject",o.getStr() ); - uno_any_destruct( pException , 0 ); - } - else - { - m_pBridgeImpl->applyProtocolChanges( props ); - m_bServerWaitingForCommit = sal_False; - m_bApplyProperties = sal_False; - } - - // let the reader thread go ... - osl_setCondition( m_commitChangeCondition ); - - typelib_typedescription_release( pMethodType ); - typelib_typedescription_release( pInterfaceType ); -} - -void SAL_CALL PropertyObject::implCommitChange( uno_Sequence *pSequence, uno_Any **ppException ) -{ - MutexGuard guard( m_mutex ); - m_propsToBeApplied = *m_pLocalSetting; - - ProtocolProperty *pP = (ProtocolProperty * ) pSequence->elements; - for( sal_Int32 i = 0; i < pSequence->nElements ; i ++ ) - { - if( ! assignFromIdlToStruct( &m_propsToBeApplied , pP[i] ) ) - { - InvalidProtocolChangeException exception; - Type type = getCppuType( &exception ); - exception.Message = OUString(RTL_CONSTASCII_USTRINGPARAM("urp: unknown Property ")); - exception.Message += pP[i].Name; - exception.invalidProperty = pP[i]; - exception.reason = 1; - - uno_type_any_construct( *ppException, &exception, type.getTypeLibType() , 0 ); - - m_bApplyProperties = sal_False; - m_bServerWaitingForCommit = sal_False; - return; - } - } - - m_bApplyProperties = sal_True; - *ppException = 0; -} - -Properties SAL_CALL PropertyObject::getCommitedChanges() -{ - MutexGuard guard( m_mutex ); - OSL_ASSERT( m_bApplyProperties ); - m_bApplyProperties = sal_False; - m_bServerWaitingForCommit = sal_False; - return m_propsToBeApplied; -} - -void SAL_CALL PropertyObject::waitUntilChangesAreCommitted() -{ - osl_waitCondition( m_commitChangeCondition , 0 ); -} -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_propertyobject.hxx b/bridges/source/remote/urp/urp_propertyobject.hxx deleted file mode 100644 index d6cfbc84ff95..000000000000 --- a/bridges/source/remote/urp/urp_propertyobject.hxx +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <stdio.h> -#include <osl/interlck.h> -#include <osl/mutex.hxx> - -#include <osl/conditn.h> -#include <rtl/string.hxx> -#include <uno/sequence2.h> - -#include <bridges/remote/remote.h> -#include "urp_property.hxx" - -namespace bridges_urp { - -struct urp_BridgeImpl; -const sal_Char g_NameOfUrpProtocolPropertiesObject[] = "UrpProtocolProperties"; - -// helper functions -void assignFromStringToStruct( const ::rtl::OUString & sProps , struct Properties *pProps ); - -class PropertyObject : public remote_Interface -{ -private: - ::osl::Mutex m_mutex; - oslCondition m_commitChangeCondition; - oslInterlockedCount m_nRefCount; - urp_BridgeImpl *m_pBridgeImpl; - struct Properties *m_pLocalSetting; - struct Properties m_propsToBeApplied; - - uno_Environment *m_pEnvRemote; - sal_Int32 m_nRandomNumberOfRequest; - sal_Bool m_bRequestChangeHasBeenCalled; - sal_Bool m_bServerWaitingForCommit; - sal_Bool m_bApplyProperties; - -public: - PropertyObject( - struct Properties *pLocalSetting , uno_Environment *pEnvRemote, urp_BridgeImpl *pImpl ); - ~PropertyObject(); - - void SAL_CALL thisAcquire( ) - { - osl_incrementInterlockedCount( &m_nRefCount ); - } - - void SAL_CALL thisRelease() - { - if( ! osl_decrementInterlockedCount( &m_nRefCount ) ) - { - delete this; - } - } - - void SAL_CALL thisDispatch( typelib_TypeDescription const * pMemberType, - void * pReturn, - void * pArgs[], - uno_Any ** ppException ); - -public: // local - sal_Int32 SAL_CALL localRequestChange( ); - void SAL_CALL localCommitChange( const ::rtl::OUString &properties, sal_Bool *pbExceptionThrown ); - void SAL_CALL localGetPropertiesFromRemote( struct Properties * ); - - // returns 0, if nothing was commited. - inline sal_Bool SAL_CALL changesHaveBeenCommited() - { return m_bApplyProperties; } - Properties SAL_CALL getCommitedChanges(); - - void SAL_CALL waitUntilChangesAreCommitted(); - -protected: - // these methods are called by thisDispatch - void SAL_CALL implGetProperties( uno_Sequence **ppReturnValue ); - sal_Int32 SAL_CALL implRequestChange( sal_Int32 nRandomNumber, uno_Any **ppException ); - void SAL_CALL implCommitChange( uno_Sequence *seqOfProperties, uno_Any **ppException ); -}; - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_reader.cxx b/bridges/source/remote/urp/urp_reader.cxx deleted file mode 100644 index 761168d7f516..000000000000 --- a/bridges/source/remote/urp/urp_reader.cxx +++ /dev/null @@ -1,835 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <string.h> - -#include <osl/diagnose.h> -#include <rtl/ustrbuf.hxx> - -#include <bridges/remote/connection.h> -#include <bridges/remote/counter.hxx> -#include <bridges/remote/context.h> -#include <bridges/remote/helper.hxx> - -#include <com/sun/star/uno/XCurrentContext.hpp> -#include <uno/environment.h> - -#include "urp_reader.hxx" -#include "urp_writer.hxx" -#include "urp_dispatch.hxx" -#include "urp_job.hxx" -#include "urp_bridgeimpl.hxx" -#include "urp_log.hxx" -#include "urp_propertyobject.hxx" - -using namespace ::rtl; -using namespace ::osl; -using namespace ::com::sun::star::uno; - -#if OSL_DEBUG_LEVEL > 1 -static MyCounter thisCounter( "DEBUG : ReaderThread" ); -#endif - -namespace bridges_urp -{ - - /** - * This callback is used to ensure, that the release call is sent for the correct type. - * - ***/ - void SAL_CALL urp_releaseRemoteCallback ( - remote_Interface *, rtl_uString *pOid, - typelib_TypeDescriptionReference *pTypeRef, uno_Environment *pEnvRemote ) - { - remote_Context *pContext = (remote_Context *) pEnvRemote->pContext; - urp_BridgeImpl *pImpl = (urp_BridgeImpl*) ( pContext->m_pBridgeImpl ); - - pImpl->m_pWriter->insertReleaseRemoteCall( pOid , pTypeRef ); - } - - - struct MessageFlags - { - sal_uInt16 nMethodId; - sal_Bool bRequest; - sal_Bool bType; - sal_Bool bOid; - sal_Bool bTid; - sal_Bool bException; - sal_Bool bMustReply; - sal_Bool bSynchronous; - sal_Bool bMoreFlags; - sal_Bool bIgnoreCache; - sal_Bool bBridgePropertyCall; - ///-------------------------- - inline MessageFlags() - { - bTid = sal_False; - bOid = sal_False; - bType = sal_False; - bException = sal_False; - bMoreFlags = sal_False; - bIgnoreCache = sal_False; - bBridgePropertyCall = sal_False; - } - //--------------------------- - }; // end struct MessageFlags - -inline sal_Bool OReaderThread::getMemberTypeDescription( - typelib_InterfaceAttributeTypeDescription **ppAttributeType, - typelib_InterfaceMethodTypeDescription **ppMethodType, - sal_Bool *pbIsSetter, - sal_uInt16 nMethodId , - typelib_TypeDescriptionReference * pITypeRef ) -{ - if( pITypeRef->eTypeClass != typelib_TypeClass_INTERFACE ) - { - OUStringBuffer sMessage; - sMessage.appendAscii( "interface type is not of typeclass interface (" ); - sMessage.append( (sal_Int32) pITypeRef->eTypeClass ); - m_pBridgeImpl->addError( sMessage.makeStringAndClear() ); - OSL_ENSURE( 0 , "type is not an interface" ); - return sal_False; - } - - typelib_InterfaceTypeDescription *pInterfaceType = 0; - TYPELIB_DANGER_GET( - (typelib_TypeDescription **)&pInterfaceType , pITypeRef ); - if( ! pInterfaceType ) - { - OUStringBuffer sMessage; - sMessage.appendAscii( "No typedescription can be retrieved for type " ); - sMessage.append( OUString( pITypeRef->pTypeName ) ); - m_pBridgeImpl->addError( sMessage.makeStringAndClear() ); - OSL_ENSURE( 0 , "urp: unknown type " ); - return sal_False; - } - - if( ! pInterfaceType->aBase.bComplete ) - { - typelib_typedescription_complete( (typelib_TypeDescription **) &pInterfaceType ); - } - - if ( nMethodId >= pInterfaceType->nMapFunctionIndexToMemberIndex ) - { - OUStringBuffer sMessage; - sMessage.appendAscii( "vtable out of range for type " ); - sMessage.append( OUString( pITypeRef->pTypeName ) ); - sMessage.appendAscii( " (" ); - sMessage.append( (sal_Int32) nMethodId ); - sMessage.appendAscii( " )" ); - m_pBridgeImpl->addError( sMessage.makeStringAndClear() ); - - OSL_ENSURE( 0 , "vtable index out of range" ); - return sal_False; - } - - sal_Int32 nMemberIndex = pInterfaceType->pMapFunctionIndexToMemberIndex[ nMethodId ]; - - if( !( pInterfaceType->nAllMembers > nMemberIndex && nMemberIndex >= 0 ) ) - { - OUStringBuffer sMessage; - sMessage.appendAscii( "vtable out of range for type " ); - sMessage.append( OUString( pITypeRef->pTypeName ) ); - sMessage.appendAscii( " (" ); - sMessage.append( (sal_Int32) nMethodId ); - sMessage.appendAscii( " )" ); - m_pBridgeImpl->addError( sMessage.makeStringAndClear() ); - - OSL_ENSURE( 0 , "vtable index out of range" ); - return sal_False; - } - - typelib_InterfaceMemberTypeDescription *pMemberType = 0; - typelib_typedescriptionreference_getDescription( - (typelib_TypeDescription **) &pMemberType,pInterfaceType->ppAllMembers[nMemberIndex]); - - if(! pMemberType ) - { - OUStringBuffer sMessage; - sMessage.appendAscii( "unknown method type description for type" ); - sMessage.append( OUString( pITypeRef->pTypeName ) ); - sMessage.appendAscii( " (" ); - sMessage.append( (sal_Int32) nMethodId ); - sMessage.appendAscii( " )" ); - m_pBridgeImpl->addError( sMessage.makeStringAndClear() ); - - OSL_ENSURE( 0 , "unknown method type description" ); - return sal_False; - } - - if( typelib_TypeClass_INTERFACE_ATTRIBUTE == pMemberType->aBase.eTypeClass ) - { - // Note: pMapMemberIndexToFunctionIndex always contains the function - // index of the attribute getter! setter function index is getter index - // + 1. - *ppAttributeType = (typelib_InterfaceAttributeTypeDescription *) pMemberType; - *pbIsSetter = ! ( - pInterfaceType->pMapMemberIndexToFunctionIndex[nMemberIndex] == nMethodId ); - } - else - { - *ppMethodType = (typelib_InterfaceMethodTypeDescription *) pMemberType; - } - - TYPELIB_DANGER_RELEASE( (typelib_TypeDescription * )pInterfaceType ); - return sal_True; -} - -OReaderThread::OReaderThread( remote_Connection *pConnection, - uno_Environment *pEnvRemote, - OWriterThread * pWriterThread ) : - m_pConnection( pConnection ), - m_pEnvRemote( pEnvRemote ), - m_pWriterThread( pWriterThread ), - m_bDestroyMyself( sal_False ), - m_bContinue( sal_True ), - m_pBridgeImpl((struct urp_BridgeImpl*) - ((remote_Context *)pEnvRemote->pContext)->m_pBridgeImpl ), - m_unmarshal( m_pBridgeImpl, m_pEnvRemote, ::bridges_remote::remote_createStub ) -{ - m_pEnvRemote->acquireWeak( m_pEnvRemote ); - m_pConnection->acquire( m_pConnection ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.acquire(); -#endif -} - - -OReaderThread::~OReaderThread( ) -{ - m_pEnvRemote->releaseWeak( m_pEnvRemote ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.release(); -#endif -} - -// may only be called in the callstack of this thread !!!!! -// run() -> dispose() -> destroyYourself() -void OReaderThread::destroyYourself() -{ - m_bDestroyMyself = sal_True; - m_pConnection->release( m_pConnection ); - m_pConnection = 0; - m_bContinue = sal_False; -} - -void OReaderThread::onTerminated() -{ - if( m_bDestroyMyself ) - { - delete this; - } -} - - -void OReaderThread::disposeEnvironment() -{ - struct remote_Context *pContext = - ( struct remote_Context * ) m_pEnvRemote->pContext; - m_bContinue = sal_False; - if( ! pContext->m_pBridgeImpl->m_bDisposed ) - { - uno_Environment *pEnvRemote = 0; - m_pEnvRemote->harden( &pEnvRemote , m_pEnvRemote ); - if( pEnvRemote ) - { - pEnvRemote->dispose( m_pEnvRemote ); - pEnvRemote->release( m_pEnvRemote ); - } - else - { - // environment has been disposed eitherway ! - } - } -} - -inline sal_Bool OReaderThread::readBlock( sal_Int32 *pnMessageCount ) -{ - m_unmarshal.setSize( 8 ); - if( 8 != m_pConnection->read( m_pConnection , m_unmarshal.getBuffer(), 8 ) ) - { - OUString s( RTL_CONSTASCII_USTRINGPARAM( "Unexpected connection closure" ) ); - m_pBridgeImpl->addError( s ); - return sal_False; - } - - sal_Int32 nSize; - m_unmarshal.unpackInt32( &nSize ); - m_unmarshal.unpackInt32( pnMessageCount ); - - if( nSize < 0 ) - { - // buffer too big - // no exception can be thrown, because there is no thread id, which could be - // used. -> terminate ! - OUStringBuffer s; - s.appendAscii( "Packet-size too big (" ); - s.append( (sal_Int64) (sal_uInt32 ) nSize ); - s.append( sal_Unicode( ')' ) ); - m_pBridgeImpl->addError( s.makeStringAndClear() ); - OSL_ENSURE( 0 , "urp bridge: Packet-size too big" ); - return sal_False; - } - - if( 0 == nSize ) - { - // normal termination ! - return sal_False; - } - - // allocate the necessary memory - if( ! m_unmarshal.setSize( nSize ) ) - { - OUStringBuffer s; - s.appendAscii( "Packet-size too big, couln't allocate necessary memory (" ); - s.append( (sal_Int64) (sal_uInt32 ) nSize ); - s.append( sal_Unicode( ')' ) ); - m_pBridgeImpl->addError( s.makeStringAndClear() ); - OSL_ENSURE( 0 , "urp bridge: messages size too large, terminating connection" ); - return sal_False; - } - - sal_Int32 nRead = m_pConnection->read( m_pConnection , m_unmarshal.getBuffer() , nSize ); - - if( nSize != nRead ) - { - OUStringBuffer s; - s.appendAscii( "Unexpected connection closure, inconsistent packet (" ); - s.append( (sal_Int64) (sal_uInt32 ) nSize ); - s.appendAscii( " asked, " ); - s.append( (sal_Int64) (sal_uInt32 ) nRead ); - s.appendAscii( " got )" ); - m_pBridgeImpl->addError( s.makeStringAndClear() ); - // couldn't get the asked amount of bytes, quit - // should only occur, when the environment has already been disposed - OSL_ENSURE( m_pBridgeImpl->m_bDisposed , "urp bridge: inconsistent packet, terminating connection." ); - return sal_False; - } - return sal_True; -} - -inline sal_Bool OReaderThread::readFlags( struct MessageFlags *pFlags ) -{ - sal_uInt8 nBitField; - if( ! m_unmarshal.unpackInt8( &nBitField ) ) - { - m_pBridgeImpl->addError( "Unexpected end of message header (1)" ); - return sal_False; - } - - if( HDRFLAG_LONGHEADER & nBitField ) - { - // this is a long header, interpret the byte as bitfield - pFlags->bTid = (HDRFLAG_NEWTID & nBitField ); - pFlags->bRequest = (HDRFLAG_REQUEST & nBitField); - - if( pFlags->bRequest ) - { - // request - pFlags->bType = ( HDRFLAG_NEWTYPE & nBitField ); - pFlags->bOid = ( HDRFLAG_NEWOID & nBitField ); - pFlags->bIgnoreCache = ( HDRFLAG_IGNORECACHE & nBitField ); - pFlags->bMoreFlags = ( HDRFLAG_MOREFLAGS & nBitField ); - - if( pFlags->bMoreFlags ) - { - // another byte with flags - sal_Int8 moreFlags; - if( ! m_unmarshal.unpackInt8( &moreFlags ) ) - { - m_pBridgeImpl->addError( "Unexpected end of message header (2)" ); - return sal_False; - } - pFlags->bSynchronous = ( HDRFLAG_SYNCHRONOUS & moreFlags ); - pFlags->bMustReply = ( HDRFLAG_MUSTREPLY & moreFlags ); - OSL_ENSURE( (pFlags->bSynchronous && pFlags->bMustReply) || - (!pFlags->bSynchronous && !pFlags->bMustReply), - "urp-bridge : customized calls currently not supported !"); - } - - if( HDRFLAG_LONGMETHODID & nBitField ) - { - // methodid as unsigned short - if( ! m_unmarshal.unpackInt16( &(pFlags->nMethodId )) ) - { - m_pBridgeImpl->addError( "Unexpected end of message header (3)" ); - return sal_False; - } - } - else - { - sal_uInt8 id; - if( ! m_unmarshal.unpackInt8( &id ) ) - { - m_pBridgeImpl->addError( "Unexpected end of message header (4)" ); - return sal_False; - } - pFlags->nMethodId = (sal_uInt16) id; - } - } - else - { - // reply - pFlags->bRequest = sal_False; - pFlags->bException = ( HDRFLAG_EXCEPTION & nBitField ); - } - } - else - { - // short request - pFlags->bRequest = sal_True; - if( 0x40 & nBitField ) - { - sal_uInt8 lower; - if( ! m_unmarshal.unpackInt8( &lower ) ) - { - m_pBridgeImpl->addError( "Unexpected end of message header (5)" ); - return sal_False; - } - pFlags->nMethodId = ( nBitField & 0x3f ) << 8 | lower; - } - else - { - pFlags->nMethodId = ( nBitField & 0x3f ); - } - } - return sal_True; -} - -void OReaderThread::run() -{ - // This vars are needed to hold oid,tid and type information, which should not be cached. - Type lastTypeNoCache; - OUString lastOidNoCache; - ByteSequence lastTidNoCache; - - while( m_bContinue ) - { - sal_Int32 nMessageCount; - if( ! readBlock( &nMessageCount ) ) - { - disposeEnvironment(); - break; - } - - uno_Environment *pEnvRemote = 0; - m_pEnvRemote->harden( &pEnvRemote , m_pEnvRemote ); - if( !pEnvRemote ) - { - // environment has been disposed already, quit here - break; - } - ServerMultiJob *pMultiJob = 0; - remote_Interface *pLastRemoteI = 0; - while( ! m_unmarshal.finished() ) - { -#ifdef BRIDGES_URP_PROT - sal_uInt32 nLogStart = m_unmarshal.getPos(); - sal_Bool bIsOneWay = sal_False; - OUString sMemberName; -#endif - MessageFlags flags; - - if( ! readFlags( &flags ) ) - { - m_pBridgeImpl->addError( "incomplete message, skipping block" ); - OSL_ENSURE ( 0 , "urp-bridge : incomplete message, skipping block" ); - break; - } - - // use these ** to access the ids fast ( avoid acquire/release calls ) - sal_Sequence **ppLastTid = flags.bIgnoreCache ? - (sal_Sequence **) &lastTidNoCache : - (sal_Sequence **) &(m_pBridgeImpl->m_lastInTid); - rtl_uString **ppLastOid = flags.bIgnoreCache ? - (rtl_uString ** ) &lastOidNoCache : - (rtl_uString ** ) &(m_pBridgeImpl->m_lastInOid); - typelib_TypeDescriptionReference **ppLastType = - flags.bIgnoreCache ? - (typelib_TypeDescriptionReference ** ) &lastTypeNoCache : - (typelib_TypeDescriptionReference ** ) &(m_pBridgeImpl->m_lastInType); - - // get new type - if( flags.bType ) - { - typelib_TypeDescriptionReference *pTypeRef = 0; - if( m_unmarshal.unpackType( &pTypeRef ) ) - { - // release the old type - typelib_typedescriptionreference_release( *ppLastType ); - // set the new type - *ppLastType = pTypeRef; - - // no release on pTypeRef necessary (will be released by type dtor) - } - else - { - typelib_typedescriptionreference_release( pTypeRef ); - m_pBridgeImpl->addError( "error during unpacking (maybe cached) interface type" ); - OSL_ENSURE( 0 , "urp-bridge : error during unpacking interface type, terminating connection" ); - disposeEnvironment(); - break; - } - if( m_pBridgeImpl->m_lastInType.getTypeClass() != TypeClass_INTERFACE ) - { - OUStringBuffer sMessage; - sMessage.appendAscii( "interface type is not of typeclass interface (" ); - sMessage.append( (sal_Int32) m_pBridgeImpl->m_lastInType.getTypeClass() ); - m_pBridgeImpl->addError( sMessage.makeStringAndClear() ); - OSL_ENSURE( 0 , "urp-bridge : not an interface type" ); - disposeEnvironment(); - break; - } - } - if( flags.bOid ) - { - rtl_uString *pOid = 0; - if( m_unmarshal.unpackOid( &pOid ) ) - { - rtl_uString_release( *ppLastOid ); - *ppLastOid = pOid; - } - else - { - rtl_uString_release( pOid ); - m_pBridgeImpl->addError( "error during unpacking (maybe cached) oid" ); - OSL_ENSURE( 0 , "urp-bridge : error during unpacking cached data, terminating connection" ); - disposeEnvironment(); - break; - } - } - - if( flags.bTid ) - { - sal_Sequence *pSeq = 0; - if( m_unmarshal.unpackTid( &pSeq ) ) - { - rtl_byte_sequence_release( *ppLastTid ); - *ppLastTid = pSeq; - } - else - { - rtl_byte_sequence_release( pSeq ); - - m_pBridgeImpl->addError( "error during unpacking (maybe cached) tid" ); - OSL_ENSURE( 0 , "urp-bridge : error during unpacking cached data, terminating connection" ); - disposeEnvironment(); - break; - } - } - - // do the job - if( flags.bRequest ) - { - bool bHasCc = m_pBridgeImpl->m_properties.bCurrentContext - && flags.nMethodId != REMOTE_RELEASE_METHOD_INDEX - && !rtl::OUString( *ppLastOid ).equalsAsciiL( - RTL_CONSTASCII_STRINGPARAM( - g_NameOfUrpProtocolPropertiesObject ) ); - remote_Interface * pCc = 0; - if ( bHasCc ) - { - typelib_TypeDescription * pType = 0; - TYPELIB_DANGER_GET( - &pType, - XCurrentContext::static_type().getTypeLibType() ); - bool ok = m_unmarshal.unpack( &pCc, pType ); - TYPELIB_DANGER_RELEASE( pType ); - if ( !ok ) - { - OSL_ENSURE( - false, - ("urp_bridge: error while unpacking current" - " context") ); - disposeEnvironment(); - break; - } - } - - //-------------------------- - // handle request - //-------------------------- - // get the membertypedescription - typelib_InterfaceMethodTypeDescription *pMethodType = 0; - typelib_InterfaceAttributeTypeDescription *pAttributeType = 0; - sal_Bool bIsSetter = sal_False; - - if( getMemberTypeDescription( - &pAttributeType, &pMethodType, &bIsSetter, - flags.nMethodId, *ppLastType ) ) - { - if( ! pLastRemoteI || flags.bOid || flags.bType ) - { - // a new interface must be retrieved - - // retrieve the interface NOW from the environment - // (avoid race conditions : oneway followed by release ) - typelib_InterfaceTypeDescription *pInterfaceType = 0; - - TYPELIB_DANGER_GET( - (typelib_TypeDescription ** ) &pInterfaceType , - *ppLastType ); - if( !pInterfaceType ) - { - OUStringBuffer sMessage; - sMessage.appendAscii( "Couldn't retrieve type description for type " ); - sMessage.append( OUString( (*ppLastType)->pTypeName ) ); - m_pBridgeImpl->addError( sMessage.makeStringAndClear() ); - delete pMultiJob; - pMultiJob = 0; - disposeEnvironment(); - pLastRemoteI = 0; // stubs are released during dispose eitherway - break; - } - pEnvRemote->pExtEnv->getRegisteredInterface( - pEnvRemote->pExtEnv, ( void ** ) &pLastRemoteI, - *ppLastOid, pInterfaceType ); - TYPELIB_DANGER_RELEASE( (typelib_TypeDescription * )pInterfaceType ); - - if( !pLastRemoteI && - REMOTE_RELEASE_METHOD_INDEX != flags.nMethodId && - 0 == rtl_ustr_ascii_compare_WithLength( - (*ppLastOid)->buffer, (*ppLastOid)->length, g_NameOfUrpProtocolPropertiesObject ) ) - { - // check for bridge internal propertyobject - pLastRemoteI = m_pBridgeImpl->m_pPropertyObject; - pLastRemoteI->acquire( pLastRemoteI ); - flags.bBridgePropertyCall = sal_True; - } - - // NOTE : Instance provider is called in the executing thread - // Otherwise, instance provider may block the bridge - } - - sal_Bool bCallIsOneway = sal_False; - if( flags.bMoreFlags ) - { - // flags override the default ! - bCallIsOneway = ! flags.bSynchronous; - } - else if( pMethodType && pMethodType->bOneWay ) - { - bCallIsOneway = sal_True; - } - - if( pMultiJob && ! flags.bTid && bCallIsOneway && ! pMultiJob->isFull()) - { - // add to the existing multijob, nothing to do here - } - else - { - // create a new multijob - if( pMultiJob ) - { - // there exists an old one, start it first. - pMultiJob->initiate(); - } - - pMultiJob = new ServerMultiJob( - pEnvRemote, - static_cast< remote_Context * >( - pEnvRemote->pContext ), - *ppLastTid, m_pBridgeImpl, &m_unmarshal, - nMessageCount ); - } - - pMultiJob->setCurrentContext( bHasCc, pCc ); - pMultiJob->setIgnoreCache( flags.bIgnoreCache ); - pMultiJob->setType( *ppLastType ); - if( pMethodType ) - { - pMultiJob->setMethodType( pMethodType , - REMOTE_RELEASE_METHOD_INDEX == flags.nMethodId, - bCallIsOneway ); - } - else if( pAttributeType ) - { - pMultiJob->setAttributeType( pAttributeType, bIsSetter, bCallIsOneway ); - } - else - { - OSL_ASSERT( 0 ); - } - - if( pLastRemoteI ) - pMultiJob->setInterface( pLastRemoteI ); - else - pMultiJob->setOid( *ppLastOid ); - } /* getMemberTypeDescription */ - else - { - delete pMultiJob; - pMultiJob = 0; - pLastRemoteI = 0; // stubs are released during dispose eitherway - disposeEnvironment(); - break; - } -#ifdef BRIDGES_URP_PROT - bIsOneWay = pMethodType && pMethodType->bOneWay; - sMemberName = pMethodType ? - pMethodType->aBase.pMemberName : - pAttributeType->aBase.pMemberName; - sal_uInt32 nLogHeader = m_unmarshal.getPos(); -#endif - if( ! pMultiJob->extract( ) ) - { - // severe error during extracting, dispose - delete pMultiJob; - pMultiJob = 0; - pLastRemoteI = 0; // stubs are released during dispose eitherway - disposeEnvironment(); - break; - } - -#ifdef BRIDGES_URP_PROT - urp_logServingRequest( - m_pBridgeImpl, m_unmarshal.getPos() - nLogStart, - m_unmarshal.getPos() - nLogHeader, - !bIsOneWay, - sMemberName ); -#endif - if ( flags.bBridgePropertyCall ) - { - // call to the bridge internal object. - // these calls MUST be executed within the dispatcher thread in order - // to synchronize properly with protocol changes - // NOTE : Threadid is not preserved for this call. - - // lock the marshaling NOW ! - { - MutexGuard guard( m_pBridgeImpl->m_marshalingMutex ); - - pMultiJob->execute(); - - if( m_pBridgeImpl->m_pPropertyObject->changesHaveBeenCommited() ) - { - Properties props; - props = m_pBridgeImpl->m_pPropertyObject->getCommitedChanges(); - - // This call modified the protocol, apply the changes NOW ! - m_pBridgeImpl->applyProtocolChanges( props ); - } - } - delete pMultiJob; - pMultiJob = 0; - } - } - else - { - //-------------------------- - // handle reply - //-------------------------- - if( pMultiJob ) - { - pMultiJob->initiate(); - pMultiJob = 0; - } - if( pLastRemoteI ) - { - pLastRemoteI->release( pLastRemoteI ); - pLastRemoteI = 0; - } - ClientJob *pClientJob = - m_pBridgeImpl->m_clientJobContainer.remove( *( ByteSequence * )ppLastTid ); - - // Bridge MUST be already disposed, otherwise we got a wrong threadid - // from remote ! - OSL_ASSERT( pClientJob || m_pBridgeImpl->m_bDisposed ); - if( ! pClientJob ) - { - OUStringBuffer error( 128 ); - error.appendAscii( "ThreadID " ); - OString o = byteSequence2HumanReadableString( *(ByteSequence* )ppLastTid ); - error.appendAscii( o.getStr(), o.getLength() ); - error.appendAscii( " unknown, so couldn't unmarshal reply" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - pLastRemoteI = 0; - disposeEnvironment(); - break; - } - - pClientJob->m_bExceptionOccurred = flags.bException; - - pClientJob->setUnmarshal( &m_unmarshal ); -#ifdef BRIDGES_URP_PROT - sMemberName = pClientJob->m_pMethodType ? - pClientJob->m_pMethodType->aBase.pMemberName : - pClientJob->m_pAttributeType->aBase.pMemberName; - sal_uInt32 nLogHeader = m_unmarshal.getPos(); -#endif - if( ! pClientJob->extract( ) ) - { - // severe error during extracting, dispose - pLastRemoteI = 0; // stubs are released during dispose eitherway - disposeEnvironment(); - break; - } -#ifdef BRIDGES_URP_PROT - urp_logGettingReply( - m_pBridgeImpl, m_unmarshal.getPos() - nLogStart, - m_unmarshal.getPos() - nLogHeader, sMemberName ); -#endif - sal_Bool bBridgePropertyCallAndWaitingForReply = - pClientJob->isBridgePropertyCall(); - - pClientJob->initiate(); - - if( bBridgePropertyCallAndWaitingForReply ) - { - // NOTE : This must be the reply for commit change. The new properties - // are now applied by the clientJob thread, but the reader thread - // must wait for it, because the next message on the wire already - // uses the new protocol settings. - // waiting for the commit change reply - m_pBridgeImpl->m_pPropertyObject->waitUntilChangesAreCommitted(); - } - } - } // end while( !m_unmarshal.finished() ) - - if( pLastRemoteI ) - pLastRemoteI->release( pLastRemoteI ); - - if( pMultiJob ) - pMultiJob->initiate(); - - if( pEnvRemote ) - pEnvRemote->release( pEnvRemote ); - } - - if( m_pConnection ) - { - m_pConnection->release( m_pConnection ); - m_pConnection = 0; - } -} -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_reader.hxx b/bridges/source/remote/urp/urp_reader.hxx deleted file mode 100644 index aa4042ce197b..000000000000 --- a/bridges/source/remote/urp/urp_reader.hxx +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <osl/thread.hxx> - -#include "urp_unmarshal.hxx" - -struct remote_Connection; -typedef struct _uno_Environment uno_Environment; - -namespace bridges_urp -{ - -class OWriterThread; -struct MessageFlags; - -class OReaderThread : - public ::osl::Thread -{ -public: - OReaderThread( remote_Connection *pConnection , - uno_Environment *pEnvRemote, - OWriterThread *pWriterThread ); - ~OReaderThread(); - - // may only be called in the callstack of this thread !!!!! - // run() -> disposeEnvironment() -> dispose() -> destroyYourself() - void destroyYourself(); - -private: - virtual void SAL_CALL run(); - virtual void SAL_CALL onTerminated(); - - inline sal_Bool readBlock( sal_Int32 *pnMessageCount ); - inline sal_Bool readFlags( struct MessageFlags *pFlags ); - - void disposeEnvironment(); - - inline sal_Bool getMemberTypeDescription( - typelib_InterfaceAttributeTypeDescription **ppAttributeType, - typelib_InterfaceMethodTypeDescription **ppMethodType, - sal_Bool *pbIsSetter, - sal_uInt16 nMethodId , - typelib_TypeDescriptionReference *pITypeRef); - - remote_Connection *m_pConnection; - uno_Environment *m_pEnvRemote; - OWriterThread *m_pWriterThread; - sal_Bool m_bDestroyMyself; - sal_Bool m_bContinue; - urp_BridgeImpl *m_pBridgeImpl; - Unmarshal m_unmarshal; -}; - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_replycontainer.hxx b/bridges/source/remote/urp/urp_replycontainer.hxx deleted file mode 100644 index 9d32faf004db..000000000000 --- a/bridges/source/remote/urp/urp_replycontainer.hxx +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <boost/unordered_map.hpp> -#include <list> - -#include <osl/mutex.hxx> -#include <osl/diagnose.h> - -#include "urp_threadid.hxx" - -namespace bridges_urp -{ - class ClientJob; - typedef ::boost::unordered_map< ::rtl::ByteSequence , - ::std::list < ClientJob * > , - HashThreadId , - EqualThreadId > Id2ClientJobStackMap; - - class urp_ClientJobContainer - { - public: - void add( const ::rtl::ByteSequence &id , ClientJob *p ) - { - ::osl::MutexGuard guard( m_mutex ); - m_map[id].push_back( p ); - } - - ClientJob *remove( const ::rtl::ByteSequence & id ) - { - ::osl::MutexGuard guard( m_mutex ); - Id2ClientJobStackMap::iterator ii = m_map.find( id ); - - ClientJob *p = 0; - if( ii != m_map.end() ) - { - p = (*ii).second.back(); - (*ii).second.pop_back(); - if( (*ii).second.empty() ) - { - m_map.erase( ii ); - } - } - - return p; - } - - private: - ::osl::Mutex m_mutex; - Id2ClientJobStackMap m_map; - }; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_threadid.cxx b/bridges/source/remote/urp/urp_threadid.cxx deleted file mode 100644 index 5c991e142eef..000000000000 --- a/bridges/source/remote/urp/urp_threadid.cxx +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include "urp_threadid.hxx" - -#include <rtl/strbuf.hxx> - -using ::rtl::OString; -using ::rtl::OStringBuffer; - -namespace bridges_urp -{ - rtl::OString byteSequence2HumanReadableString( const rtl::ByteSequence &a ) - { - const sal_uInt8 *p = (const sal_uInt8 * ) a.getConstArray(); - sal_Int32 nLength = a.getLength(); - OStringBuffer buf( a.getLength() * 2 + 2 ); - buf.append( RTL_CONSTASCII_STRINGPARAM( "0x" ) ); - for( sal_Int32 i = 0 ; i < nLength ; i ++ ) - buf.append( (sal_Int32) p[i] , 16 ); - return buf.makeStringAndClear(); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_threadid.hxx b/bridges/source/remote/urp/urp_threadid.hxx deleted file mode 100644 index e920e2c1e9c3..000000000000 --- a/bridges/source/remote/urp/urp_threadid.hxx +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _URP_THREADID_HXX_ -#define _URP_THREADID_HXX_ - -#include <sal/types.h> -#include <rtl/byteseq.hxx> -#include <rtl/string.hxx> - -namespace bridges_urp -{ - - struct EqualThreadId - { - sal_Int32 operator () ( const ::rtl::ByteSequence &a , const ::rtl::ByteSequence &b ) const - { - return a == b; - } - }; - - struct HashThreadId - { - sal_Int32 operator () ( const ::rtl::ByteSequence &a ) const - { - if( a.getLength() >= 4 ) - { - return *(sal_Int32*) a.getConstArray(); - } - return 0; - } - }; - - rtl::OString byteSequence2HumanReadableString( const rtl::ByteSequence &a ); -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_unmarshal.cxx b/bridges/source/remote/urp/urp_unmarshal.cxx deleted file mode 100644 index 90cfff80aa27..000000000000 --- a/bridges/source/remote/urp/urp_unmarshal.cxx +++ /dev/null @@ -1,709 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <string.h> - -#include <osl/diagnose.h> - -#include <rtl/alloc.h> -#include <rtl/ustrbuf.hxx> - -#include <uno/data.h> -#include <uno/any2.h> -#include <uno/sequence2.h> - -#include <com/sun/star/uno/Any.hxx> - -#include "urp_unmarshal.hxx" -#include "urp_bridgeimpl.hxx" - - -using namespace ::rtl; -using namespace ::com::sun::star::uno; - -namespace bridges_urp -{ -static int g_nDetectLittleEndian = 1; -char g_bSystemIsLittleEndian = ((char*)&g_nDetectLittleEndian)[0]; - - -Unmarshal::Unmarshal( struct urp_BridgeImpl *pBridgeImpl, - uno_Environment *pEnvRemote, - remote_createStubFunc callback ) : - m_nBufferSize( 4096 ), - m_base( (sal_Int8*) rtl_allocateMemory( m_nBufferSize ) ), - m_pos( m_base ), - m_nLength( 0 ), - m_callback( callback ), - m_pEnvRemote( pEnvRemote ), - m_pBridgeImpl( pBridgeImpl ) -{ -} - -Unmarshal::~Unmarshal() -{ - rtl_freeMemory( m_base ); -} - -// special unpacks -sal_Bool Unmarshal::unpackTid( sal_Sequence **ppThreadId ) -{ - sal_Int32 nSize; - sal_Bool bReturn = unpackCompressedSize( &nSize ); - if( bReturn ) - { - if( nSize ) - { - rtl_byte_sequence_constructFromArray( ppThreadId , m_pos , nSize ); - m_pos += nSize; - sal_uInt16 nIndex; - bReturn = unpackInt16( &nIndex ); - if( nIndex < m_pBridgeImpl->m_properties.nTidCacheSize ) - { - m_pBridgeImpl->m_pTidIn[nIndex] = *(ByteSequence * )ppThreadId; - } - else if( 0xffff != nIndex ) - { - bReturn = sal_False; - rtl_byte_sequence_construct( ppThreadId , 0 ); - - OUStringBuffer error( 128 ); - error.appendAscii( "cache index for tid " ); - OString o = byteSequence2HumanReadableString( *(ByteSequence * ) ppThreadId ); - error.appendAscii( o.getStr(), o.getLength() ); - error.appendAscii( "out of range(0x"); - error.append( (sal_Int32) nIndex ,16 ); - error.appendAscii( ")" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - } - else - { - sal_uInt16 nIndex; - bReturn = unpackInt16( &nIndex ); - if( nIndex < m_pBridgeImpl->m_properties.nTidCacheSize ) - { - *ppThreadId = m_pBridgeImpl->m_pTidIn[nIndex].getHandle(); - rtl_byte_sequence_acquire( *ppThreadId ); - } - else - { - bReturn = sal_False; - rtl_byte_sequence_construct( ppThreadId , 0 ); - OUStringBuffer error(128); - error.appendAscii( "cache index for tids out of range(0x" ); - error.append( (sal_Int32) nIndex ,16 ); - error.appendAscii( ")" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - } - } - else - { - m_pBridgeImpl->addError( "couldn't unpack thread id because of previous errors" ); - } - return bReturn; -} - -sal_Bool Unmarshal::unpackOid( rtl_uString **ppOid ) -{ - sal_Bool bReturn = sal_True; - sal_uInt16 nCacheIndex = 0; - - bReturn = bReturn && unpackString( ppOid ); - bReturn = bReturn && unpackInt16( &nCacheIndex ); - - if( bReturn && - ! ( 0xffff == nCacheIndex && 0 == (*ppOid)->length ) /* null reference */ ) - { - if( (*ppOid)->length ) - { - // new unknown reference - if( 0xffff != nCacheIndex ) - { - // oid should be cached ? - if( nCacheIndex < m_pBridgeImpl->m_properties.nOidCacheSize ) - { - m_pBridgeImpl->m_pOidIn[nCacheIndex] = *ppOid; - } - else - { - OUStringBuffer error( 128 ); - error.appendAscii( "new oid provided (" ); - error.append( *ppOid ); - error.appendAscii( "), but new cache index is out of range(0x"); - error.append( (sal_Int32) nCacheIndex ,16 ); - error.appendAscii( ")" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - - bReturn = sal_False; - rtl_uString_new( ppOid ); - } - } - } - else - { - // reference in cache ! - if( nCacheIndex < m_pBridgeImpl->m_properties.nOidCacheSize ) - { - rtl_uString_assign( ppOid , m_pBridgeImpl->m_pOidIn[nCacheIndex].pData ); - } - else - { - bReturn = sal_False; - rtl_uString_new( ppOid ); - - OUStringBuffer error( 128 ); - error.appendAscii( "cache index for oids out of range(0x"); - error.append( (sal_Int32) nCacheIndex ,16 ); - error.appendAscii( ")" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - } - } - - return bReturn; -} - -sal_Bool Unmarshal::unpack( void *pDestination , - typelib_TypeDescription *pTypeDescr ) -{ - // Note: We implement unpack functionality without recursions in order - // to avoid stack overflows caused by rotten URP blocks. - - m_aItemsToUnpack.push( UnpackItem( pDestination, pTypeDescr ) ); - - sal_Bool bReturn = sal_True; - do - { - void * pDest = m_aItemsToUnpack.top().pDest; - typelib_TypeDescription * pType = m_aItemsToUnpack.top().pType; - m_aItemsToUnpack.pop(); - - switch( pType->eTypeClass ) - { - case typelib_TypeClass_VOID: - // do nothing - break; - case typelib_TypeClass_BYTE: - { - bReturn = unpackInt8( pDest ); - break; - } - case typelib_TypeClass_BOOLEAN: - { - bReturn = ! checkOverflow( 1 ); - if( bReturn ) - { - *((sal_Bool*)pDest) = (sal_Bool ) ( *m_pos); - m_pos ++; - } - else - { - *((sal_Bool*)pDest) = 0; - } - break; - } - - case typelib_TypeClass_CHAR: - case typelib_TypeClass_SHORT: - case typelib_TypeClass_UNSIGNED_SHORT: - { - unpackInt16( pDest ); - break; - } - case typelib_TypeClass_ENUM: - case typelib_TypeClass_FLOAT: - case typelib_TypeClass_LONG: - case typelib_TypeClass_UNSIGNED_LONG: - { - bReturn = unpackInt32( pDest ); - break; - } - case typelib_TypeClass_DOUBLE: - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - { - sal_Int8 * p = static_cast< sal_Int8 * >(pDest); - bReturn = ! checkOverflow( 8 ); - if( bReturn ) - { - if( isSystemLittleEndian() ) - { - p[7] = m_pos[0]; - p[6] = m_pos[1]; - p[5] = m_pos[2]; - p[4] = m_pos[3]; - p[3] = m_pos[4]; - p[2] = m_pos[5]; - p[1] = m_pos[6]; - p[0] = m_pos[7]; - } - else - { - p[0] = m_pos[0]; - p[1] = m_pos[1]; - p[2] = m_pos[2]; - p[3] = m_pos[3]; - p[4] = m_pos[4]; - p[5] = m_pos[5]; - p[6] = m_pos[6]; - p[7] = m_pos[7]; - } - m_pos += 8; - } - else - { - // Do not trigger alignment errors: - p[0] = p[1] = p[2] = p[3] = p[4] = p[5] = p[6] = p[7] = 0; - } - break; - } - case typelib_TypeClass_STRING: - { - unpackString( pDest ); - break; - } - case typelib_TypeClass_ANY: - { - uno_Any *pAny = ( uno_Any * )pDest; - - pAny->pType = 0; - // Type is acquired with typelib_typedescription_acquire - - bReturn = unpackType( &(pAny->pType) ); - - typelib_TypeDescription *pDataType = 0; - if( bReturn && pAny->pType ) - { - typelib_typedescriptionreference_getDescription( &pDataType , pAny->pType ); - - if( pDataType ) - { - switch (pDataType->eTypeClass) - { - case typelib_TypeClass_HYPER: - case typelib_TypeClass_UNSIGNED_HYPER: - if (sizeof(void *) < sizeof(sal_Int64)) - { - pAny->pData = rtl_allocateMemory( sizeof(sal_Int64) ); - } - else - { - pAny->pData = &pAny->pReserved; - } - break; - case typelib_TypeClass_FLOAT: - if (sizeof(void *) < sizeof(float)) - { - pAny->pData = rtl_allocateMemory( sizeof(float) ); - } - else - { - pAny->pData = &pAny->pReserved; - } - break; - case typelib_TypeClass_DOUBLE: - if (sizeof(void *) < sizeof(double)) - { - pAny->pData = rtl_allocateMemory( sizeof(double) ); - } - else - { - pAny->pData = &pAny->pReserved; - } - break; - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_UNION: - case typelib_TypeClass_EXCEPTION: - case typelib_TypeClass_ARRAY: - pAny->pData = rtl_allocateMemory( pDataType->nSize ); - break; - case typelib_TypeClass_ANY: - { - m_pBridgeImpl->addError( - OUString( RTL_CONSTASCII_USTRINGPARAM( - "can't unmarshal any: any in any not supported!" ) ) ); - - pAny->pData = 0; - Type type; // void - pAny->pType = type.getTypeLibType(); - typelib_typedescriptionreference_acquire( pAny->pType ); - - bReturn = sal_False; - break; - } - default: - pAny->pData = &pAny->pReserved; - } - - if ( bReturn ) - { - m_aItemsToUnpack.push( - UnpackItem( pAny->pData, pDataType ) ); - } - } - else - { - OUStringBuffer error; - error.appendAscii( "can't unmarshal any because typedescription for " ); - error.append( pAny->pType->pTypeName ); - error.appendAscii( " is missing" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - } - - if( pDataType ) - { - typelib_typedescription_release( pDataType ); - } - else - { - pAny->pData = 0; - Type type; // void - pAny->pType = type.getTypeLibType(); - typelib_typedescriptionreference_acquire( pAny->pType ); - - bReturn = sal_False; - } - - break; - } - case typelib_TypeClass_INTERFACE: - { - *(remote_Interface**)pDest = 0; - - rtl_uString *pString = 0; - bReturn = unpackOid( &pString ) && bReturn; - - if( bReturn && pString && pString->length ) - { - m_callback( (remote_Interface**) pDest , - pString, - pType->pWeakRef , - m_pEnvRemote, - urp_releaseRemoteCallback ); - } - if( pString ) - { - rtl_uString_release( pString ); - } - break; - } - case typelib_TypeClass_TYPE: - { - bReturn = unpackType( pDest ); - break; - } - case typelib_TypeClass_STRUCT: - case typelib_TypeClass_EXCEPTION: - { - typelib_CompoundTypeDescription * pCompType = - (typelib_CompoundTypeDescription *)pType; - - // direct members - typelib_TypeDescriptionReference ** ppTypeRefs = pCompType->ppTypeRefs; - sal_Int32 * pMemberOffsets = pCompType->pMemberOffsets; - sal_Int32 nDescr = pCompType->nMembers; - - // at least assume 1 byte per member - bReturn = bReturn && ! checkOverflow( nDescr * 1 ); - for ( sal_Int32 nPos = nDescr; nPos; --nPos ) - { - typelib_TypeDescription * pMemberType = 0; - typelib_typedescriptionreference_getDescription( - &pMemberType, ppTypeRefs[ nPos - 1 ] ); - - m_aItemsToUnpack.push( - UnpackItem( (char*)pDest + pMemberOffsets[ nPos - 1 ], - pMemberType, - true /* construct even in error case */ ) ); - - m_aTypesToRelease.push_back( pMemberType ); - } - - // parent - if (pCompType->pBaseTypeDescription) - { - m_aItemsToUnpack.push( - UnpackItem( pDest, - (typelib_TypeDescription *) - pCompType->pBaseTypeDescription ) ); - } - break; - } - case typelib_TypeClass_SEQUENCE: - { - sal_Int32 nLen; - bReturn = unpackCompressedSize( &nLen ); - - // urp protocol does not allow to use the elementsize as a guess, if enough data - // is available. However, at least one byte per member must be within the message - bReturn = bReturn && ! checkOverflow( 1 * nLen ); - uno_Sequence *pSequence = 0; - if( nLen && bReturn ) - { - typelib_TypeDescriptionReference * pETRef = - ((typelib_IndirectTypeDescription *)pType)->pType; - - typelib_TypeDescription * pET = 0; - typelib_typedescriptionreference_getDescription( &pET , pETRef ); - - if( pET ) - { - sal_Int32 nElementSize = pET->nSize; - - pSequence = (uno_Sequence *)rtl_allocateMemory( - SAL_SEQUENCE_HEADER_SIZE + nElementSize * nLen ); - pSequence->nRefCount = 1; - pSequence->nElements = nLen; - - if( typelib_TypeClass_BYTE == pET->eTypeClass ) - { - memcpy( pSequence->elements , m_pos , nLen ); - m_pos += nLen; - } - else - { - for ( sal_Int32 i = nLen; i; --i ) - { - m_aItemsToUnpack.push( - UnpackItem( - ((char*)pSequence->elements) - + (i - 1) * nElementSize, - pET ) ); - } - } - m_aTypesToRelease.push_back( pET ); - } - else - { - bReturn = sal_False; - uno_constructData( &pSequence , pType ); - OUStringBuffer error; - error.appendAscii( "can't unmarshal sequence, because there is no typedescription for element type " ); - error.append( pETRef->pTypeName ); - error.appendAscii( " available" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - } - else - { - uno_constructData( &pSequence , pType ); - } - - *((uno_Sequence **)pDest) = pSequence; - break; - } - case typelib_TypeClass_UNION: - case typelib_TypeClass_ARRAY: - case typelib_TypeClass_SERVICE: - case typelib_TypeClass_MODULE: - case typelib_TypeClass_INTERFACE_METHOD: - case typelib_TypeClass_INTERFACE_ATTRIBUTE: - case typelib_TypeClass_UNKNOWN: - default: - { - ::rtl::OUStringBuffer buffer( 128 ); - buffer.appendAscii( RTL_CONSTASCII_STRINGPARAM("Unsupported typeclass during unmarshaling (")); - buffer.append( ( sal_Int32 ) pType->eTypeClass , 10 ); - buffer.appendAscii( ")" ); - m_pBridgeImpl->addError( buffer.makeStringAndClear() ); - bReturn = sal_False; - } - } - - if ( !bReturn ) - { - // construct default data for every remaining item. - while ( !m_aItemsToUnpack.empty() ) - { - const UnpackItem & rItem = m_aItemsToUnpack.top(); - - if ( rItem.bMustBeConstructed ) - uno_constructData( rItem.pDest , rItem.pType ); - - m_aItemsToUnpack.pop(); - } - } - } - while ( !m_aItemsToUnpack.empty() ); - - // release pending type descriptions - TypeDescVector::const_iterator it = m_aTypesToRelease.begin(); - const TypeDescVector::const_iterator end = m_aTypesToRelease.end(); - while ( it != end ) - { - typelib_typedescription_release( *it ); - ++it; - } - m_aTypesToRelease.clear(); - - return bReturn; -} - -sal_Bool Unmarshal::unpackType( void *pDest ) -{ - *(typelib_TypeDescriptionReference **) pDest = 0; - - sal_uInt8 nTypeClass; - sal_Bool bReturn = unpackInt8( &nTypeClass ); - - typelib_TypeDescriptionReference *pTypeRef = 0; - if( bReturn ) - { - if( nTypeClass <= 14 /* any */ ) - { - pTypeRef = * typelib_static_type_getByTypeClass((typelib_TypeClass )nTypeClass); - typelib_typedescriptionreference_acquire( pTypeRef ); - } - else - { - sal_uInt16 nCacheIndex = 0; - bReturn = bReturn && unpackInt16( &nCacheIndex ); - - if( bReturn ) - { - if( nTypeClass & 0x80 ) - { - // new type - rtl_uString *pString = 0; - bReturn = bReturn && unpackString( &pString ); - if( bReturn ) - { - typelib_TypeDescription *pType = 0; - typelib_typedescription_getByName( &pType, pString ); - if( pType ) - { - // type is known in this process - if( (typelib_TypeClass )(nTypeClass & 0x7f) == pType->eTypeClass ) - { - //typename and typeclass match, this is as it should be - pTypeRef = pType->pWeakRef; - typelib_typedescriptionreference_acquire( pTypeRef ); - } - else - { - // typename and typeclass do not match, dispose the bridge - // as there must be inconsistent type base between both processes - // or trash comes over the wire ... - bReturn = sal_False; - OUStringBuffer error( 128 ); - error.appendAscii( "it is tried to introduce type " ); - error.append( pString ); - error.appendAscii( "with typeclass " ); - error.append( (sal_Int32)( nTypeClass & 0x7f ) , 10 ); - error.appendAscii( " , which does not match with typeclass " ); - error.append( (sal_Int32) pType->eTypeClass ,10 ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - typelib_typedescription_release( pType ); - pType = 0; - } - else - { - // a type by this name is not known in the process. - if( (nTypeClass & 0x7f) < typelib_TypeClass_UNKNOWN ) - { - // typeclass is within a valid range, introduce the new - // type. - typelib_typedescriptionreference_new( - &pTypeRef, (typelib_TypeClass )(nTypeClass & 0x7f), pString ); - } - else - { - // typeclass is out of range ! - bReturn = sal_False; - OUStringBuffer error( 128 ); - error.appendAscii( "it is tried to introduce type " ); - error.append( pString ); - error.appendAscii( "with an out of range typeclass " ); - error.append( (sal_Int32)( nTypeClass & 0x7f ) , 10 ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - } - - if( bReturn && nCacheIndex != 0xffff ) - { - if( nCacheIndex < m_pBridgeImpl->m_properties.nTypeCacheSize ) - { - m_pBridgeImpl->m_pTypeIn[nCacheIndex] = *( Type * )&pTypeRef; - } - else - { - bReturn = sal_False; - OUStringBuffer error( 128 ); - error.appendAscii( "cache index for type " ); - error.append( pString ); - error.appendAscii( "out of range(0x" ); - error.append( (sal_Int32) nCacheIndex ,16 ); - error.appendAscii( ")" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - } - } - if( pString ) - { - rtl_uString_release( pString ); - } - } - else - { - if( nCacheIndex < m_pBridgeImpl->m_properties.nTypeCacheSize ) - { - pTypeRef = m_pBridgeImpl->m_pTypeIn[nCacheIndex].getTypeLibType(); - typelib_typedescriptionreference_acquire( pTypeRef ); - } - else - { - bReturn = sal_False; - OUStringBuffer error; - error.appendAscii( "cache index for types out of range(0x" ); - error.append( (sal_Int32) nCacheIndex ,16 ); - error.appendAscii( ")" ); - m_pBridgeImpl->addError( error.makeStringAndClear() ); - } - } - } - } - } - if( ! pTypeRef ) - { - pTypeRef = * typelib_static_type_getByTypeClass(typelib_TypeClass_VOID); - typelib_typedescriptionreference_acquire( pTypeRef ); - } - // pTypeRef is already acquired - *(typelib_TypeDescriptionReference**)pDest = pTypeRef; - return bReturn; -} - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_unmarshal.hxx b/bridges/source/remote/urp/urp_unmarshal.hxx deleted file mode 100644 index ca963c3eac46..000000000000 --- a/bridges/source/remote/urp/urp_unmarshal.hxx +++ /dev/null @@ -1,281 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef _URP_UNMARSHAL_HXX_ -#define _URP_UNMARSHAL_HXX_ - -#include <stack> -#include <vector> -#include <rtl/byteseq.hxx> -#include <rtl/ustrbuf.hxx> -#include <bridges/remote/context.h> - -#include <bridges/remote/helper.hxx> -#include <com/sun/star/uno/Type.hxx> -#include "urp_bridgeimpl.hxx" - -typedef struct _uno_Environment uno_Environment; -struct remote_Interface; - -namespace bridges_urp -{ - -extern char g_bSystemIsLittleEndian; -class ThreadId; -struct urp_BridgeImpl; -void SAL_CALL urp_releaseRemoteCallback( - remote_Interface *pRemoteI,rtl_uString *pOid, - typelib_TypeDescriptionReference *pTypeRef, - uno_Environment *pEnvRemote ); - -struct UnpackItem -{ - void * pDest; - typelib_TypeDescription * pType; - bool bMustBeConstructed; - - UnpackItem() - : pDest( 0 ), pType( 0 ), bMustBeConstructed( false ) {} - UnpackItem( void * d, typelib_TypeDescription * t, bool b = false ) - : pDest( d ), pType( t ), bMustBeConstructed( b ) {} -}; - -typedef std::stack< UnpackItem > UnpackItemStack; -typedef std::vector< typelib_TypeDescription * > TypeDescVector; - -class Unmarshal -{ -public: - Unmarshal( - struct urp_BridgeImpl *, - uno_Environment *pEnvRemote, - remote_createStubFunc callback ); - ~Unmarshal(); - - inline sal_Bool finished() const - { return m_base + m_nLength == m_pos; } - inline sal_uInt32 getPos() const - { return (sal_uInt32 ) (m_pos - m_base); } - - inline sal_Bool setSize( sal_Int32 nSize ); - - sal_Bool unpack( void *pDest, typelib_TypeDescription *pType ); - inline sal_Bool unpackCompressedSize( sal_Int32 *pData ); - inline sal_Bool unpackInt8( void *pDest ); - inline sal_Bool unpackString( void *pDest ); - inline sal_Bool unpackInt16( void *pDest ); - inline sal_Bool unpackInt32( void *pDest ); - sal_Bool unpackType( void *pDest ); - - inline sal_Bool unpackAny( void *pDest ); - sal_Bool unpackOid( rtl_uString **ppOid ); - sal_Bool unpackTid( sal_Sequence **ppThreadId ); - - sal_Int8 *getBuffer() - { return m_base; } - inline sal_Bool isSystemLittleEndian() const - { return g_bSystemIsLittleEndian; } - -private: - inline sal_Bool checkOverflow( sal_Int32 nNextMem ); - - UnpackItemStack m_aItemsToUnpack; - TypeDescVector m_aTypesToRelease; - - sal_Int32 m_nBufferSize; - sal_Int8 *m_base; - sal_Int8 *m_pos; - sal_Int32 m_nLength; - - remote_createStubFunc m_callback; - uno_Environment *m_pEnvRemote; - urp_BridgeImpl *m_pBridgeImpl; -}; - -inline sal_Bool Unmarshal::setSize( sal_Int32 nSize ) -{ - if( nSize > m_nBufferSize ) - { - // adjust buffer size and length. - sal_Int8 * base = - (sal_Int8*)rtl_reallocateMemory (m_base, sal_Size(nSize)); - if (base != 0) - { - m_base = base; - m_nLength = m_nBufferSize = nSize; - } - } - else - { - // adjust buffer length, only. - m_nLength = nSize; - } - - // reset buffer position, and leave. - m_pos = m_base; - return (m_nLength == nSize); -} - -inline sal_Bool Unmarshal::checkOverflow( sal_Int32 nNextMem ) -{ - sal_Bool bOverflow = nNextMem < 0 || - (((sal_Int32)( m_pos - m_base )) + nNextMem ) > m_nLength; - if( bOverflow ) - m_pBridgeImpl->addError( "message too short" ); - return bOverflow; -} - - -inline sal_Bool Unmarshal::unpackInt8( void *pDest ) -{ - sal_Bool bReturn = ! checkOverflow( 1 ); - if( bReturn ) - { - *((sal_Int8*)pDest ) = *m_pos; - m_pos++; - } - else - { - *((sal_Int8*)pDest ) = 0; - } - return bReturn; -} - -inline sal_Bool Unmarshal::unpackInt32( void *pDest ) -{ - sal_uInt32 *p = ( sal_uInt32 * ) pDest; - sal_Bool bReturn = ! checkOverflow(4); - if( bReturn ) - { - if( isSystemLittleEndian() ) - { - ((sal_Int8*) p )[3] = m_pos[0]; - ((sal_Int8*) p )[2] = m_pos[1]; - ((sal_Int8*) p )[1] = m_pos[2]; - ((sal_Int8*) p )[0] = m_pos[3]; - } - else - { - ((sal_Int8*) p )[3] = m_pos[3]; - ((sal_Int8*) p )[2] = m_pos[2]; - ((sal_Int8*) p )[1] = m_pos[1]; - ((sal_Int8*) p )[0] = m_pos[0]; - } - m_pos += 4; - } - else - { - *p = 0; - } - return bReturn; -} - -inline sal_Bool Unmarshal::unpackInt16( void *pDest ) -{ - sal_uInt16 *p = ( sal_uInt16 * ) pDest; - - sal_Bool bReturn = ! checkOverflow( 2 ); - if( bReturn ) - { - if( isSystemLittleEndian() ) - { - ((sal_Int8*) p )[1] = m_pos[0]; - ((sal_Int8*) p )[0] = m_pos[1]; - } - else - { - ((sal_Int8*) p )[1] = m_pos[1]; - ((sal_Int8*) p )[0] = m_pos[0]; - } - m_pos ++; - m_pos ++; - } - else - { - *p = 0; - } - return bReturn; -} - -inline sal_Bool Unmarshal::unpackString( void *pDest ) -{ - sal_Int32 nLength; - sal_Bool bReturn = unpackCompressedSize( &nLength ); - - bReturn = bReturn && ! checkOverflow( nLength ); - if( bReturn ) - { - *(rtl_uString **) pDest = 0; - rtl_string2UString( (rtl_uString**) pDest, (const sal_Char * )m_pos , nLength, - RTL_TEXTENCODING_UTF8, OSTRING_TO_OUSTRING_CVTFLAGS ); - m_pos += nLength; - } - else - { - *(rtl_uString ** ) pDest = 0; - rtl_uString_new( (rtl_uString **) pDest ); - } - return bReturn; -} - -inline sal_Bool Unmarshal::unpackCompressedSize( sal_Int32 *pData ) -{ - sal_uInt8 n8Size; - sal_Bool bReturn = unpackInt8( &n8Size ); - if( bReturn ) - { - if( n8Size == 0xff ) - { - unpackInt32( pData ); - } - else - { - *pData = (sal_Int32 ) n8Size; - } - } - return bReturn; -} - -inline sal_Bool Unmarshal::unpackAny( void *pDest ) -{ - typelib_TypeDescriptionReference *pTypeRef = - * typelib_static_type_getByTypeClass( typelib_TypeClass_ANY ); - - typelib_TypeDescription * pTD = 0; - typelib_typedescriptionreference_getDescription( &pTD, pTypeRef ); - - sal_Bool bReturn = unpack( pDest, pTD ); - - typelib_typedescription_release( pTD ); - - return bReturn; -} - -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_writer.cxx b/bridges/source/remote/urp/urp_writer.cxx deleted file mode 100644 index 58795d9f3359..000000000000 --- a/bridges/source/remote/urp/urp_writer.cxx +++ /dev/null @@ -1,271 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_bridges.hxx" -#include <stdio.h> -#include <osl/time.h> - -#include <osl/mutex.hxx> -#include <osl/conditn.h> - -#include <typelib/typedescription.h> - -#include <bridges/remote/connection.h> -#include <bridges/remote/remote.hxx> - -#include <com/sun/star/uno/Sequence.hxx> - -#include <bridges/remote/counter.hxx> - -#include "urp_writer.hxx" -#include "urp_bridgeimpl.hxx" -#include "urp_marshal.hxx" -#include "urp_dispatch.hxx" - -#if OSL_DEBUG_LEVEL > 1 -static MyCounter thisCounter( "DEBUG : WriterThread" ); -#endif - -using namespace ::osl; - -namespace bridges_urp { - -OWriterThread::OWriterThread( remote_Connection *pConnection, urp_BridgeImpl *pBridgeImpl, - uno_Environment *pEnvRemote) : - m_bAbort( sal_False ), - m_bInBlockingWait( sal_False ), - m_bEnterBlockingWait( sal_False ), - m_pConnection( pConnection ), - m_pBridgeImpl( pBridgeImpl ), - m_pEnvRemote( pEnvRemote ) - -{ - m_oslCondition = osl_createCondition(); - osl_resetCondition( m_oslCondition ); - m_pConnection->acquire( m_pConnection ); - -#if OSL_DEBUG_LEVEL > 1 - thisCounter.acquire(); -#endif -} - -OWriterThread::~OWriterThread() -{ - osl_destroyCondition( m_oslCondition ); - m_pConnection->release( m_pConnection ); -#if OSL_DEBUG_LEVEL > 1 - thisCounter.release(); -#endif -} - - -// touch is called with locked m_marshalingMutex -void OWriterThread::touch( sal_Bool bImmediately ) -{ - if( bImmediately || m_pBridgeImpl->m_blockMarshaler.getPos() > m_pBridgeImpl->m_properties.nFlushBlockSize ) - { - write(); - } - else - { - // wake the writer thread up - if( m_bInBlockingWait ) - { - m_bInBlockingWait = sal_False; - osl_setCondition( m_oslCondition ); - } - else - { - // ensure, that the writing thread does not enter blocking mode - m_bEnterBlockingWait = sal_False; - } - } -} - - -void OWriterThread::abortThread() -{ - MutexGuard guard( m_pBridgeImpl->m_marshalingMutex ); - - m_bAbort = sal_True; - m_bEnterBlockingWait = sal_False; - if( m_bInBlockingWait ) - { - m_bInBlockingWait = sal_False; - osl_setCondition( m_oslCondition ); - } -} - - -// must be called with locked marshaling mutex -void OWriterThread::write() -{ - if( ! m_pBridgeImpl->m_blockMarshaler.empty() && ! m_bAbort ) - { - m_pBridgeImpl->m_blockMarshaler.finish( m_pBridgeImpl->m_nMarshaledMessages); - m_pBridgeImpl->m_nMarshaledMessages = 0; - - sal_Int32 nLength = m_pBridgeImpl->m_blockMarshaler.getSize(); - sal_Int8 *pBuf = m_pBridgeImpl->m_blockMarshaler.getBuffer(); - - if( nLength != m_pConnection->write( m_pConnection, pBuf, nLength )) - { - m_pBridgeImpl->m_blockMarshaler.restart(); - return; - } - m_pConnection->flush( m_pConnection ); - m_pBridgeImpl->m_blockMarshaler.restart(); - } -} - -void OWriterThread::sendEmptyMessage() -{ - // must be called with locked marshaling mutex - sal_Int32 a[2] = {0,0}; - m_pConnection->write( m_pConnection , (sal_Int8*) a , sizeof( sal_Int32) *2 ); -} - -void OWriterThread::insertReleaseRemoteCall( - rtl_uString *pOid,typelib_TypeDescriptionReference *pTypeRef) -{ - { - ::osl::MutexGuard guard( m_releaseCallMutex ); - - struct RemoteReleaseCall call; - call.sOid = pOid; - call.typeInterface = pTypeRef; - m_lstReleaseCalls.push_back( call ); - } - { - MutexGuard guard( m_pBridgeImpl->m_marshalingMutex ); - if( m_bInBlockingWait ) - { - m_bInBlockingWait = sal_False; - osl_setCondition( m_oslCondition ); - } - else - { - // ensure, that the writing thread does not enter blocking mode - m_bEnterBlockingWait = sal_False; - } - } -} - -/* The release calls for doubled interfaces - * - * - ***/ -void OWriterThread::executeReleaseRemoteCalls() -{ - ::std::list< struct RemoteReleaseCall > lstReleaseCalls; - { - ::osl::MutexGuard guard( m_releaseCallMutex ); - lstReleaseCalls.swap( m_lstReleaseCalls ); - } - - for( ::std::list< struct RemoteReleaseCall >::iterator ii = lstReleaseCalls.begin(); - ii != lstReleaseCalls.end(); - ++ ii ) - { - struct RemoteReleaseCall &call = (*ii) ; - - typelib_TypeDescription *pInterfaceTypeDesc = 0; - typelib_TypeDescription *pReleaseMethod = 0; - - call.typeInterface.getDescription( &pInterfaceTypeDesc ); - if( ! pInterfaceTypeDesc->bComplete ) - { - typelib_typedescription_complete( &pInterfaceTypeDesc ); - } - - uno_Any any; - uno_Any *pAny = &any; - - typelib_typedescriptionreference_getDescription( - &pReleaseMethod , - ((typelib_InterfaceTypeDescription*)pInterfaceTypeDesc)->ppAllMembers[REMOTE_RELEASE_METHOD_INDEX] ); - - urp_sendRequest_internal( - m_pEnvRemote , pReleaseMethod, call.sOid.pData, - (typelib_InterfaceTypeDescription*) pInterfaceTypeDesc, 0, 0, - &pAny ); - - typelib_typedescription_release( pReleaseMethod ); - typelib_typedescription_release( pInterfaceTypeDesc ); - } -} - - -void OWriterThread::run() -{ - while( ! m_bAbort ) - { - sal_Bool bWait; - { - MutexGuard guard( m_pBridgeImpl->m_marshalingMutex ); - bWait = m_bEnterBlockingWait; - if( bWait ) - { - osl_resetCondition( m_oslCondition ); - m_bInBlockingWait = sal_True; - } - m_bEnterBlockingWait = sal_True; - } - - // wait for some notification - if( bWait ) - osl_waitCondition( m_oslCondition , 0 ); - // (m_bInBlockingWait = sal_False was set by the activating thread) - - if( m_bAbort ) - break; - - // Wait for the timeout - TimeValue value = { 0 , 1000 * m_pBridgeImpl->m_properties.nOnewayTimeoutMUSEC }; - osl_resetCondition( m_oslCondition ); - osl_waitCondition( m_oslCondition , &value ); - - // check if there are some release calls to be sent .... - executeReleaseRemoteCalls(); - - { - // write to the socket - MutexGuard guard( m_pBridgeImpl->m_marshalingMutex ); - if( ! m_pBridgeImpl->m_blockMarshaler.empty() ) - { - write(); - } - } - } -} - - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/source/remote/urp/urp_writer.hxx b/bridges/source/remote/urp/urp_writer.hxx deleted file mode 100644 index 041f0b4d753f..000000000000 --- a/bridges/source/remote/urp/urp_writer.hxx +++ /dev/null @@ -1,85 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <list> - -#include <osl/conditn.h> -#include <osl/mutex.hxx> - -#include <rtl/ustring.hxx> - -#include <osl/thread.hxx> - -#include <com/sun/star/uno/Type.hxx> - -struct remote_Connection; - -namespace bridges_urp -{ - struct RemoteReleaseCall - { - ::rtl::OUString sOid; - ::com::sun::star::uno::Type typeInterface; - }; - - struct urp_BridgeImpl; - class OWriterThread : - public ::osl::Thread - { - public: - OWriterThread( remote_Connection *pConnection, - urp_BridgeImpl *m_pBridgeImpl, - uno_Environment *pEnvRemote); - ~OWriterThread( ); - - virtual void SAL_CALL run(); - - void touch( sal_Bool bImmediately ); - void sendEmptyMessage(); - - void abortThread(); - - void SAL_CALL insertReleaseRemoteCall ( - rtl_uString *pOid,typelib_TypeDescriptionReference *pTypeRef); - void SAL_CALL executeReleaseRemoteCalls(); - - private: - void write(); - oslCondition m_oslCondition; - sal_Bool m_bAbort; - sal_Bool m_bInBlockingWait; - sal_Bool m_bEnterBlockingWait; - remote_Connection *m_pConnection; - urp_BridgeImpl *m_pBridgeImpl; - uno_Environment *m_pEnvRemote; // this is held weak only - - ::osl::Mutex m_releaseCallMutex; - ::std::list< struct RemoteReleaseCall > m_lstReleaseCalls; - }; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/bridges/unotypes/makefile.mk b/bridges/unotypes/makefile.mk index d775638ac4af..d5b3bc970e51 100644 --- a/bridges/unotypes/makefile.mk +++ b/bridges/unotypes/makefile.mk @@ -41,20 +41,7 @@ UNOUCRRDB=$(SOLARBINDIR)$/udkapi.rdb UNOUCROUT=$(OUT)$/inc UNOTYPES = \ - com.sun.star.bridge.XProtocolProperties \ - com.sun.star.corba.giop.MessageHeader_1_2 \ - com.sun.star.corba.giop.MsgType_1_1 \ - com.sun.star.corba.iop.ServiceContextList \ - com.sun.star.corba.iop.ProfileIdGroup \ - com.sun.star.corba.iiop.ProfileBody_1_1 \ - com.sun.star.corba.LogicalThreadID \ - com.sun.star.corba.iop.ServiceIdGroup \ - com.sun.star.corba.giop.ReplyHeader_1_2 \ - com.sun.star.corba.giop.RequestHeader_1_2 \ - com.sun.star.corba.TCKind \ - com.sun.star.corba.ObjectKey \ com.sun.star.uno.XInterface \ - com.sun.star.lang.DisposedException \ com.sun.star.uno.TypeClass # --- Targets ------------------------------------------------------ diff --git a/cppu/inc/com/sun/star/uno/Sequence.h b/cppu/inc/com/sun/star/uno/Sequence.h index 942050866eae..68abc9d24748 100644 --- a/cppu/inc/com/sun/star/uno/Sequence.h +++ b/cppu/inc/com/sun/star/uno/Sequence.h @@ -126,7 +126,7 @@ public: @param len initial sequence length */ - inline Sequence( sal_Int32 len ); + inline explicit Sequence( sal_Int32 len ); /** Destructor: Releases sequence handle. Last handle will destruct elements and free memory. diff --git a/cppu/source/threadpool/jobqueue.cxx b/cppu/source/threadpool/jobqueue.cxx index a148b0773768..9f629e43a457 100644 --- a/cppu/source/threadpool/jobqueue.cxx +++ b/cppu/source/threadpool/jobqueue.cxx @@ -99,6 +99,10 @@ namespace cppu_threadpool { if( 0 == m_lstCallstack.front() ) { // disposed ! + if( m_lstJob.empty() ) + { + osl_resetCondition( m_cndWait ); + } break; } diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx index f84350f27691..fc18050eb399 100644 --- a/cppu/source/typelib/typelib.cxx +++ b/cppu/source/typelib/typelib.cxx @@ -373,7 +373,6 @@ TypeDescriptor_Init_Impl::~TypeDescriptor_Init_Impl() SAL_THROW( () ) delete pCallbacks; pCallbacks = 0; #endif // CPPU_LEAK_STATIC_DATA - if( pMutex ) { delete pMutex; diff --git a/cppu/source/uno/data.cxx b/cppu/source/uno/data.cxx index ea0b8b2ad6b6..7ba327b9f8b3 100644 --- a/cppu/source/uno/data.cxx +++ b/cppu/source/uno/data.cxx @@ -29,6 +29,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cppu.hxx" +#include <cstddef> +#include <stdio.h> + #include "cppu/macros.hxx" #include "osl/mutex.hxx" @@ -351,8 +354,6 @@ sal_Bool SAL_CALL uno_type_isAssignableFromData( #if OSL_DEBUG_LEVEL > 1 -#include <stdio.h> - #if defined( SAL_W32) #pragma pack(push, 8) #elif defined(SAL_OS2) @@ -366,12 +367,12 @@ sal_Bool SAL_CALL uno_type_isAssignableFromData( #define MAX_ALIGNMENT_4 #endif -#define OFFSET_OF( s, m ) ((sal_Size)((char *)&((s *)16)->m -16)) +#define OFFSET_OF( s, m ) reinterpret_cast< std::size_t >((char *)&((s *)16)->m -16) #define BINTEST_VERIFY( c ) \ - if (! (c)) { fprintf( stderr, "### binary compatibility test failed: " #c " [line %d]!!!\n", __LINE__ ); abort(); } + if (! (c)) { fprintf( stderr, "### binary compatibility test failed: %s [line %d]!!!\n", #c, __LINE__ ); abort(); } #define BINTEST_VERIFYOFFSET( s, m, n ) \ - if (OFFSET_OF(s, m) != n) { fprintf( stderr, "### OFFSET_OF(" #s ", " #m ") = %d instead of expected %d!!!\n", OFFSET_OF(s, m), n ); abort(); } + if (OFFSET_OF(s, m) != n) { fprintf( stderr, "### OFFSET_OF(" #s ", " #m ") = %" SAL_PRI_SIZET "u instead of expected %d!!!\n", OFFSET_OF(s, m), n ); abort(); } #define BINTEST_VERIFYSIZE( s, n ) \ if (sizeof(s) != n) { fprintf( stderr, "### sizeof(" #s ") = %d instead of expected %d!!!\n", sizeof(s), n ); abort(); } diff --git a/cppuhelper/inc/cppuhelper/factory.hxx b/cppuhelper/inc/cppuhelper/factory.hxx index 0ba8c603a8ed..9348fa0a52ba 100644 --- a/cppuhelper/inc/cppuhelper/factory.hxx +++ b/cppuhelper/inc/cppuhelper/factory.hxx @@ -53,7 +53,7 @@ typedef struct _uno_Environment uno_Environment; compiled it. If the environment is NOT session specific (needs no additional context), then this function should return the environment type name and leave ppEnv (to 0). - @paramppEnvTypeName environment type name; string must be constant + @param ppEnvTypeName environment type name; string must be constant @param ppEnv function returns its environment if the environment is session specific, i.e. has special context */ @@ -86,6 +86,9 @@ typedef void (SAL_CALL * component_getImplementationEnvironmentExtFunc)( typedef const sal_Char * (SAL_CALL * component_getDescriptionFunc)(void); /** Function pointer declaration. + + @obsolete component_writeInfo should no longer be used in new components + Function writes component registry info, at least writing the supported service names. @param pServiceManager diff --git a/cppuhelper/inc/cppuhelper/implementationentry.hxx b/cppuhelper/inc/cppuhelper/implementationentry.hxx index 1ff7e49676b7..2561811fba1b 100644 --- a/cppuhelper/inc/cppuhelper/implementationentry.hxx +++ b/cppuhelper/inc/cppuhelper/implementationentry.hxx @@ -73,6 +73,8 @@ struct ImplementationEntry /** Helper function for implementation of the component_writeInfo()-function. + @obsolete component_writeInfo should no longer be used in new components + @param pServiceManager The first parameter passed to component_writeInfo()-function (This is an instance of the service manager, that creates the factory). @param pRegistryKey The second parameter passed to the component_writeInfo()-function. @@ -91,9 +93,9 @@ sal_Bool component_writeInfoHelper( @param pImplName The implementation-name to be instantiated ( This is the first parameter passed to the component_getFactory - @param pServiceManager The first parameter passed to component_writeInfo()-function + @param pServiceManager The second parameter passed to component_getFactory()-function (This is a of the service manager, that creates the factory). - @param pRegistryKey The second parameter passed to the component_writeInfo()-function. + @param pRegistryKey The third parameter passed to the component_getFactory()-function. This is a reference to the registry key, where the implementation data has been written to. @param entries Each element of the entries-array must contains a function pointer diff --git a/cppuhelper/inc/cppuhelper/propshlp.hxx b/cppuhelper/inc/cppuhelper/propshlp.hxx index a288feb284ba..89a2fa7dc72f 100644 --- a/cppuhelper/inc/cppuhelper/propshlp.hxx +++ b/cppuhelper/inc/cppuhelper/propshlp.hxx @@ -596,6 +596,29 @@ protected: ::com::sun::star::uno::Any& rValue, sal_Int32 nHandle ) const = 0; + /** sets an dependent property's value + + <p>Sometimes setting a given property needs to implicitly modify another property's value. Calling |setPropertyValue| + from within |setFastPropertyValue_NoBroadcast| is not an option here, as it would notify the property listeners + while our mutex is still locked. Setting the dependent property's value directly (e.g. by calling |setFastPropertyValue_NoBroadcast| + recursively) is not an option, too, since it would miss firing the property change event.</p> + + <p>So, in such cases, you use |setDependentFastPropertyValue| from within |setFastPropertyValue_NoBroadcast|. + It will convert and actually set the property value (invoking |convertFastPropertyValue| and |setFastPropertyValue_NoBroadcast| + for the given handle and value), and add the property change event to the list of events to be notified + when the bottom-most |setFastPropertyValue_NoBroadcast| on the stack returns.</p> + + <p><strong>Note</strong>: The method will <em>not</em> invoke veto listeners for the property.</p> + + <p><strong>Note</strong>: It's the caller's responsibility to ensure that our mutex is locked. This is + canonically given when the method is invoked from within |setFastPropertyValue_NoBroadcast|, in other + contexts, you might need to take own measures.</p> + */ + void setDependentFastPropertyValue( + sal_Int32 i_handle, + const ::com::sun::star::uno::Any& i_value + ); + /** The common data of a broadcaster. Use the mutex, disposing state and the listener container. */ OBroadcastHelper &rBHelper; /** @@ -611,12 +634,22 @@ protected: /** reserved for future use. finally, the future has arrived... */ - const std::auto_ptr<const Impl> m_pReserved; + const std::auto_ptr<Impl> m_pReserved; private: OPropertySetHelper( const OPropertySetHelper & ) SAL_THROW( () ); OPropertySetHelper & operator = ( const OPropertySetHelper & ) SAL_THROW( () ); + /** notifies the given changes in property's values, <em>plus</em> all property changes collected during recent + |setDependentFastPropertyValue| calls. + */ + void impl_fireAll( + sal_Int32* i_handles, + const ::com::sun::star::uno::Any * i_newValues, + const ::com::sun::star::uno::Any * i_oldValues, + sal_Int32 i_count + ); + public: // Suppress warning about virtual functions but non-virtual destructor: #if defined __GNUC__ diff --git a/cppuhelper/inc/cppuhelper/shlib.hxx b/cppuhelper/inc/cppuhelper/shlib.hxx index 4d19171db096..7bfdc97ea75e 100644 --- a/cppuhelper/inc/cppuhelper/shlib.hxx +++ b/cppuhelper/inc/cppuhelper/shlib.hxx @@ -66,6 +66,8 @@ SAL_CALL loadSharedLibComponentFactory( directory. The resulting path of the library will be checked against environment variable CPLD_ACCESSPATH if set. + @obsolete component_writeInfo should no longer be used in new components + @param rLibName name of the library @param rPath optional path @param xMgr service manager to be provided to the component diff --git a/cppuhelper/prj/build.lst b/cppuhelper/prj/build.lst index de66b2d61a4b..ff837f90dd1a 100644 --- a/cppuhelper/prj/build.lst +++ b/cppuhelper/prj/build.lst @@ -1,4 +1,4 @@ -ch cppuhelper : BOOST:boost codemaker cppu offuh NULL +ch cppuhelper : BOOST:boost LIBXSLT:libxslt codemaker cppu offuh NULL ch cppuhelper usr1 - all ch_mkout NULL ch cppuhelper\inc nmake - all ch_include NULL ch cppuhelper\source nmake - all ch_source ch_unotypes ch_include NULL diff --git a/cppuhelper/qa/propertysetmixin/JavaSupplier.java b/cppuhelper/qa/propertysetmixin/JavaSupplier.java index 2d37c8901077..0aa267610801 100644 --- a/cppuhelper/qa/propertysetmixin/JavaSupplier.java +++ b/cppuhelper/qa/propertysetmixin/JavaSupplier.java @@ -75,11 +75,6 @@ public final class JavaSupplier extends WeakBase implements XSupplier { : null; } - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo( - implementationName, serviceName, regKey); - } - private static final String implementationName = JavaSupplier.class.getName(); private static final String serviceName diff --git a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx index 4769904687b1..674652a24d11 100644 --- a/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/comp_propertysetmixin.cxx @@ -429,11 +429,5 @@ extern "C" void SAL_CALL component_getImplementationEnvironment( *envTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -extern "C" sal_Bool SAL_CALL component_writeInfo( - void * serviceManager, void * registryKey) -{ - return cppu::component_writeInfoHelper( - serviceManager, registryKey, entries); -} -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/cppuhelper/qa/propertysetmixin/makefile.mk b/cppuhelper/qa/propertysetmixin/makefile.mk index edd4795fc115..04aa2479c3b8 100644 --- a/cppuhelper/qa/propertysetmixin/makefile.mk +++ b/cppuhelper/qa/propertysetmixin/makefile.mk @@ -37,6 +37,8 @@ PACKAGE = test/cppuhelper/propertysetmixin/comp ENABLE_EXCEPTIONS := TRUE +my_components = $(TARGET).cpp $(TARGET).java + .INCLUDE: settings.mk .IF "$(OS)" == "WNT" @@ -75,51 +77,62 @@ JARFILES = java_uno.jar juh.jar jurt.jar ridl.jar ALLTAR: test $(MISC)/$(TARGET)/types.urd: types.idl - - $(MKDIR) $(@:d) + $(MKDIRHIER) $(@:d) $(IDLC) -O$(@:d) -I$(SOLARIDLDIR) -cid -we $< $(MISC)/$(TARGET)/types.rdb: $(MISC)/$(TARGET)/types.urd - $(RM) $@ $(REGMERGE) $@ /UCR $< -$(MISC)/$(TARGET)/uno.rdb: $(MISC)/$(TARGET)/types.rdb $(SHL2TARGETN) \ - $(MISC)/$(TARGET)/$(TARGET).uno.jar $(MISC)/$(TARGET)/bootstrap.rdb - - $(MKDIR) $(@:d) - $(COPY) $(SOLARBINDIR)/types.rdb $@ - $(REGMERGE) $@ / $(MISC)/$(TARGET)/types.rdb - $(REGCOMP) -register -r $@ -wop -c javaloader.uno -c javavm.uno \ - -c reflection.uno -c stocservices.uno -c $(SHL2TARGETN) - $(REGCOMP) -register -br $(MISC)/$(TARGET)/bootstrap.rdb -r $@ \ - -c $(my_file)$(PWD)/$(MISC)/$(TARGET)/$(TARGET).uno.jar \ - -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) - -$(MISC)/$(TARGET)/bootstrap.rdb: - - $(MKDIR) $(@:d) - $(COPY) $(SOLARBINDIR)/types.rdb $@ - $(REGCOMP) -register -r $@ -wop -c javaloader.uno -c javavm.uno \ - -c stocservices.uno - $(MISC)/$(TARGET)/cppumaker.flag: $(MISC)/$(TARGET)/types.rdb $(CPPUMAKER) -O$(MISC)/$(TARGET)/inc -BUCR -Gc \ - -X$(SOLARBINDIR)/types.rdb $< + -X$(SOLARBINDIR)/udkapi.rdb $< $(TOUCH) $@ $(SLOFILES): $(MISC)/$(TARGET)/cppumaker.flag $(MISC)/$(TARGET)/javamaker.flag: $(MISC)/$(TARGET)/types.rdb - $(JAVAMAKER) -O$(CLASSDIR) -BUCR -nD -Gc -X$(SOLARBINDIR)/types.rdb $< + $(JAVAMAKER) -O$(CLASSDIR) -BUCR -nD -Gc -X$(SOLARBINDIR)/udkapi.rdb $< $(TOUCH) $@ $(JAVATARGET): $(MISC)/$(TARGET)/javamaker.flag +$(MISC)/$(TARGET)/services.rdb .ERRREMOVE: $(SOLARENV)/bin/packcomponents.xslt \ + $(MISC)/$(TARGET)/services.input \ + $(my_components:^"$(MISC)/$(TARGET)/":+".component") + $(XSLTPROC) --nonet --stringparam prefix $(PWD)/$(MISC)/$(TARGET)/ -o $@ \ + $(SOLARENV)/bin/packcomponents.xslt $(MISC)/$(TARGET)/services.input + +$(MISC)/$(TARGET)/services.input: + $(MKDIRHIER) $(@:d) + echo \ + '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \ + > $@ + +$(MISC)/$(TARGET)/$(TARGET).cpp.component .ERRREMOVE: \ + $(SOLARENV)/bin/createcomponent.xslt $(TARGET).cpp.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_INBUILD_NATIVE)$(SHL2TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt $(TARGET).cpp.component + +$(MISC)/$(TARGET)/$(TARGET).java.component .ERRREMOVE: \ + $(SOLARENV)/bin/createcomponent.xslt $(TARGET).java.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_INBUILD_JAVA)$(TARGET).uno.jar' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt $(TARGET).java.component + $(MISC)/$(TARGET)/$(TARGET).uno.jar: $(JAVATARGET) \ $(MISC)/$(TARGET)/javamaker.flag manifest jar cfm $@ manifest -C $(CLASSDIR) test/cppuhelper/propertysetmixin -test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/uno.rdb +test .PHONY: $(SHL1TARGETN) $(SHL2TARGETN) $(MISC)/$(TARGET)/$(TARGET).uno.jar \ + $(MISC)/$(TARGET)/types.rdb $(MISC)/$(TARGET)/services.rdb $(CPPUNITTESTER) $(SHL1TARGETN) \ - -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) \ + '-env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/types.rdb' \ + '-env:UNO_SERVICES=$(my_file)$(SOLARXMLDIR)/ure/services.rdb $(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb'\ -env:URE_INTERNAL_LIB_DIR=$(my_file)$(SOLARSHAREDBIN) \ - -env:arg-reg=$(MISC)/$(TARGET)/uno.rdb -env:arg-path=$(SOLARSHAREDBIN) + -env:URE_INTERNAL_JAVA_DIR=$(my_file)$(SOLARBINDIR) \ + -env:OOO_INBUILD_SHAREDLIB_DIR=$(my_file)$(PWD)/$(DLLDEST) \ + -env:OOO_INBUILD_JAR_DIR=$(my_file)$(PWD)/$(MISC)/$(TARGET) .END diff --git a/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component new file mode 100644 index 000000000000..a654e07581a3 --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.cpp.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="test.cppuhelper.propertysetmixin.comp.CppSupplier"> + <service name="test.cppuhelper.propertysetmixin.CppSupplier"/> + </implementation> +</component> diff --git a/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.java.component b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.java.component new file mode 100644 index 000000000000..9711563b758b --- /dev/null +++ b/cppuhelper/qa/propertysetmixin/qa_propertysetmixin.java.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.Java2" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="test.cppuhelper.propertysetmixin.comp.JavaSupplier"> + <service name="test.cppuhelper.propertysetmixin.JavaSupplier"/> + </implementation> +</component> diff --git a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx index eea2e0f6cc2b..49b8cd07a6fd 100644 --- a/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx +++ b/cppuhelper/qa/propertysetmixin/test_propertysetmixin.cxx @@ -53,21 +53,19 @@ #include "com/sun/star/beans/XPropertySetInfo.hpp" #include "com/sun/star/beans/XVetoableChangeListener.hpp" #include "com/sun/star/lang/XComponent.hpp" -#include "com/sun/star/lang/XMultiComponentFactory.hpp" #include "com/sun/star/uno/Any.hxx" #include "com/sun/star/uno/Reference.hxx" #include "com/sun/star/uno/RuntimeException.hpp" #include "com/sun/star/uno/Sequence.hxx" #include "com/sun/star/uno/Type.hxx" #include "com/sun/star/uno/XComponentContext.hpp" +#include "cppuhelper/bootstrap.hxx" #include "cppuhelper/implbase1.hxx" -#include "cppuhelper/servicefactory.hxx" #include "cppunit/TestAssert.h" #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" #include "cppunit/plugin/TestPlugIn.h" #include "osl/mutex.hxx" -#include "rtl/bootstrap.hxx" #include "rtl/ref.hxx" #include "rtl/string.h" #include "rtl/textenc.h" @@ -99,14 +97,6 @@ std::ostream & operator <<(std::ostream & out, css::uno::Any const & value) { out << "com::sun::star::uno::Any[" << value.getValueType() << ", ...]"; } -rtl::OUString getArgument(rtl::OUString const & name) { - rtl::OUString val; - CPPUNIT_ASSERT( - rtl::Bootstrap::get( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("arg-")) + name, val)); - return val; -} - class BoundListener: public cppu::WeakImplHelper1< css::beans::XPropertyChangeListener > { @@ -179,7 +169,7 @@ class Test: public CppUnit::TestFixture { public: virtual void setUp(); - void finish(); + virtual void tearDown(); void testCppEmpty1() { testEmpty1(getCppSupplier()); } @@ -200,7 +190,6 @@ public: CPPUNIT_TEST(testJavaEmpty1); CPPUNIT_TEST(testJavaEmpty2); CPPUNIT_TEST(testJavaFull); - CPPUNIT_TEST(finish); CPPUNIT_TEST_SUITE_END(); private: @@ -222,30 +211,15 @@ private: css::uno::Reference< test::cppuhelper::propertysetmixin::XSupplier > const & supplier) const; - static css::uno::Reference< css::uno::XComponentContext > m_context; + css::uno::Reference< css::uno::XComponentContext > m_context; }; void Test::setUp() { - // For whatever reason, on W32 it does not work to create/destroy a fresh - // component context for each test in Test::setUp/tearDown; therefore, a - // single component context is used for all tests and destroyed in the last - // pseudo-test "finish": - if (!m_context.is()) { - css::uno::Reference< css::lang::XMultiComponentFactory > factory( - cppu::createRegistryServiceFactory( - getArgument(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("reg"))), - sal_False, - getArgument( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("path")))), - css::uno::UNO_QUERY_THROW); - css::uno::Reference< css::beans::XPropertySet >( - factory, css::uno::UNO_QUERY_THROW)->getPropertyValue( - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultContext"))) - >>= m_context; - } + m_context = cppu::defaultBootstrap_InitialComponentContext(); + CPPUNIT_ASSERT(m_context.is()); } -void Test::finish() { +void Test::tearDown() { css::uno::Reference< css::lang::XComponent >( m_context, css::uno::UNO_QUERY_THROW)->dispose(); } @@ -672,8 +646,6 @@ void Test::testFull( } catch (css::beans::UnknownPropertyException &) {} } -css::uno::Reference< css::uno::XComponentContext > Test::m_context; - CPPUNIT_TEST_SUITE_REGISTRATION(Test); } diff --git a/cppuhelper/source/bootstrap.cxx b/cppuhelper/source/bootstrap.cxx index 6cbe33274fbb..4f9ba819b19c 100644 --- a/cppuhelper/source/bootstrap.cxx +++ b/cppuhelper/source/bootstrap.cxx @@ -381,9 +381,15 @@ SAL_CALL defaultBootstrap_InitialComponentContext( Bootstrap const & bootstrap ) SAL_THROW( (Exception) ) { - OUString bootstrapPath( get_this_libpath() ); - OUString iniDir; + OUString bootstrapPath; + if (!bootstrap.getFrom( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("URE_INTERNAL_LIB_DIR")), + bootstrapPath)) + { + bootstrapPath = get_this_libpath(); + } + OUString iniDir; osl_getProcessWorkingDir(&iniDir.pData); Reference<lang::XMultiComponentFactory> smgr_XMultiComponentFactory( diff --git a/cppuhelper/source/cc5_solaris_sparc.map b/cppuhelper/source/cc5_solaris_sparc.map index d43ea690e11a..5dd703cf9fc9 100755 --- a/cppuhelper/source/cc5_solaris_sparc.map +++ b/cppuhelper/source/cc5_solaris_sparc.map @@ -387,3 +387,9 @@ UDK_3.7 { # OOo 3.3 __1cDcomDsunEstarDunoTWeakReferenceHelperFclear6M_v_; __1cEcppubHcreateOneInstanceComponentFactory6FpFrknDcomDsunEstarDunoJReference4n0ERXComponentContext____n0EJReference4n0EKXInterface___rknDrtlIOUString_rkn0EISequence4n0K___pnQ_rtl_ModuleCount__n0EJReference4n0DElangXXSingleComponentFactory____; } UDK_3.6; + +UDK_3.8 { # OOo 3.4 + global: + __1cEcppuSOPropertySetHelperbDsetDependentFastPropertyValue6MlrknDcomDsunEstarDunoDAny__v_; +} UDK_3.7; + diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx index 4e34b470e608..4c203c3ef07f 100644 --- a/cppuhelper/source/factory.cxx +++ b/cppuhelper/source/factory.cxx @@ -229,9 +229,17 @@ Reference< XInterface > OSingleFactoryHelper::createInstanceWithArgumentsAndCont else { if ( rArguments.getLength() ) + { + // dispose the here created UNO object before throwing out exception + // to avoid risk of memory leaks #i113722# + Reference<XComponent> xComp( xRet, UNO_QUERY ); + if (xComp.is()) + xComp->dispose(); + throw lang::IllegalArgumentException( OUString( RTL_CONSTASCII_USTRINGPARAM("cannot pass arguments to component => no XInitialization implemented!") ), Reference< XInterface >(), 0 ); + } } return xRet; diff --git a/cppuhelper/source/gcc3.map b/cppuhelper/source/gcc3.map index 59ab83e34e82..7017d274c95d 100644 --- a/cppuhelper/source/gcc3.map +++ b/cppuhelper/source/gcc3.map @@ -382,3 +382,9 @@ UDK_3.6 { # OOo 3.3 _ZN4cppu33createOneInstanceComponentFactoryEPFN3com3sun4star3uno9ReferenceINS3_10XInterfaceEEERKNS4_INS3_17XComponentContextEEEERKN3rtl8OUStringERKNS3_8SequenceISE_EEP16_rtl_ModuleCount; } UDK_3.5; + +UDK_3.7 { # OOo 3.4 + global: + _ZN4cppu18OPropertySetHelper29setDependentFastPropertyValueE?RKN3com3sun4star3uno3AnyE; +} UDK_3.6; + diff --git a/cppuhelper/source/msvc_win32_intel.map b/cppuhelper/source/msvc_win32_intel.map index 6d5a491ab925..7069276e2baa 100644 --- a/cppuhelper/source/msvc_win32_intel.map +++ b/cppuhelper/source/msvc_win32_intel.map @@ -278,3 +278,9 @@ UDK_3.6 { # OOo 3.3 ?clear@WeakReferenceHelper@uno@star@sun@com@@QAAXXZ; ?createOneInstanceComponentFactory@cppu@@YA?AV?$Reference@VXSingleComponentFactory@lang@star@sun@com@@@uno@star@sun@com@@P6A?AV?$Reference@VXInterface@uno@star@sun@com@@@3456@ABV?$Reference@VXComponentContext@uno@star@sun@com@@@3456@@ZABVOUString@rtl@@ABV?$Sequence@VOUString@rtl@@@3456@PAU_rtl_ModuleCount@@@Z; } UDK_3.5; + +UDK_3.7 { # OOo 3.4 + global: + ?setDependentFastPropertyValue@OPropertySetHelper@cppu@@IAEXJABVAny@uno@star@sun@com@@@Z; +} UDK_3.6; + diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx index 9abc35dd3632..5782da7a40d8 100644 --- a/cppuhelper/source/propshlp.cxx +++ b/cppuhelper/source/propshlp.cxx @@ -33,6 +33,7 @@ #include "cppuhelper/implbase1.hxx" #include "cppuhelper/weak.hxx" #include "cppuhelper/propshlp.hxx" +#include "cppuhelper/exc_hlp.hxx" #include "com/sun/star/beans/PropertyAttribute.hpp" #include "com/sun/star/lang/DisposedException.hpp" @@ -147,15 +148,20 @@ sal_Bool OPropertySetHelperInfo_Impl::hasPropertyByName( const OUString & Proper class OPropertySetHelper::Impl { public: - Impl ( bool i_bIgnoreRuntimeExceptionsWhileFiring, - IEventNotificationHook *i_pFireEvents) - : m_bIgnoreRuntimeExceptionsWhileFiring( - i_bIgnoreRuntimeExceptionsWhileFiring ), - m_pFireEvents( i_pFireEvents ) - { } + Impl( bool i_bIgnoreRuntimeExceptionsWhileFiring, + IEventNotificationHook *i_pFireEvents + ) + :m_bIgnoreRuntimeExceptionsWhileFiring( i_bIgnoreRuntimeExceptionsWhileFiring ) + ,m_pFireEvents( i_pFireEvents ) + { + } bool m_bIgnoreRuntimeExceptionsWhileFiring; class IEventNotificationHook * const m_pFireEvents; + + ::std::vector< sal_Int32 > m_handles; + ::std::vector< Any > m_newValues; + ::std::vector< Any > m_oldValues; }; @@ -435,6 +441,57 @@ void OPropertySetHelper::removeVetoableChangeListener( } } +void OPropertySetHelper::setDependentFastPropertyValue( sal_Int32 i_handle, const ::com::sun::star::uno::Any& i_value ) +{ + //OSL_PRECOND( rBHelper.rMutex.isAcquired(), "OPropertySetHelper::setDependentFastPropertyValue: to be called with a locked mutex only!" ); + // there is no such thing as Mutex.isAcquired, sadly ... + + sal_Int16 nAttributes(0); + IPropertyArrayHelper& rInfo = getInfoHelper(); + if ( !rInfo.fillPropertyMembersByHandle( NULL, &nAttributes, i_handle ) ) + // unknown property + throw UnknownPropertyException(); + + // no need to check for READONLY-ness of the property. The method is intended to be called internally, which + // implies it might be invoked for properties which are read-only to the instance's clients, but well allowed + // to change their value. + + Any aConverted, aOld; + sal_Bool bChanged = convertFastPropertyValue( aConverted, aOld, i_handle, i_value ); + if ( !bChanged ) + return; + + // don't fire vetoable events. This method is called with our mutex locked, so calling into listeners would not be + // a good idea. The caler is responsible for not invoking this for constrained properties. + OSL_ENSURE( ( nAttributes & PropertyAttribute::CONSTRAINED ) == 0, + "OPropertySetHelper::setDependentFastPropertyValue: not to be used for constrained properties!" ); + (void)nAttributes; + + // actually set the new value + try + { + setFastPropertyValue_NoBroadcast( i_handle, aConverted ); + } + catch (const UnknownPropertyException& ) { throw; /* allowed to leave */ } + catch (const PropertyVetoException& ) { throw; /* allowed to leave */ } + catch (const IllegalArgumentException& ) { throw; /* allowed to leave */ } + catch (const WrappedTargetException& ) { throw; /* allowed to leave */ } + catch (const RuntimeException& ) { throw; /* allowed to leave */ } + catch (const Exception& ) + { + // not allowed to leave this meathod + WrappedTargetException aWrapped; + aWrapped.TargetException <<= ::cppu::getCaughtException(); + aWrapped.Context = static_cast< XPropertySet* >( this ); + throw aWrapped; + } + + // remember the handle/values, for the events to be fired later + m_pReserved->m_handles.push_back( i_handle ); + m_pReserved->m_newValues.push_back( aConverted ); // TODO: setFastPropertyValue notifies the unconverted value here ...? + m_pReserved->m_oldValues.push_back( aOld ); +} + // XFastPropertySet void OPropertySetHelper::setFastPropertyValue( sal_Int32 nHandle, const Any& rValue ) throw(::com::sun::star::beans::UnknownPropertyException, @@ -501,7 +558,7 @@ void OPropertySetHelper::setFastPropertyValue( sal_Int32 nHandle, const Any& rVa // release guard to fire events } // file a change event, if the value changed - fire( &nHandle, &rValue, &aOldVal, 1, sal_False ); + impl_fireAll( &nHandle, &rValue, &aOldVal, 1 ); } } @@ -524,6 +581,42 @@ Any OPropertySetHelper::getFastPropertyValue( sal_Int32 nHandle ) } //-------------------------------------------------------------------------- +void OPropertySetHelper::impl_fireAll( sal_Int32* i_handles, const Any* i_newValues, const Any* i_oldValues, sal_Int32 i_count ) +{ + ClearableMutexGuard aGuard( rBHelper.rMutex ); + if ( m_pReserved->m_handles.empty() ) + { + aGuard.clear(); + fire( i_handles, i_newValues, i_oldValues, i_count, sal_False ); + return; + } + + const size_t additionalEvents = m_pReserved->m_handles.size(); + OSL_ENSURE( additionalEvents == m_pReserved->m_newValues.size() + && additionalEvents == m_pReserved->m_oldValues.size(), + "OPropertySetHelper::impl_fireAll: inconsistency!" ); + + ::std::vector< sal_Int32 > allHandles( additionalEvents + i_count ); + ::std::copy( m_pReserved->m_handles.begin(), m_pReserved->m_handles.end(), allHandles.begin() ); + ::std::copy( i_handles, i_handles + i_count, allHandles.begin() + additionalEvents ); + + ::std::vector< Any > allNewValues( additionalEvents + i_count ); + ::std::copy( m_pReserved->m_newValues.begin(), m_pReserved->m_newValues.end(), allNewValues.begin() ); + ::std::copy( i_newValues, i_newValues + i_count, allNewValues.begin() + additionalEvents ); + + ::std::vector< Any > allOldValues( additionalEvents + i_count ); + ::std::copy( m_pReserved->m_oldValues.begin(), m_pReserved->m_oldValues.end(), allOldValues.begin() ); + ::std::copy( i_oldValues, i_oldValues + i_count, allOldValues.begin() + additionalEvents ); + + m_pReserved->m_handles.clear(); + m_pReserved->m_newValues.clear(); + m_pReserved->m_oldValues.clear(); + + aGuard.clear(); + fire( &allHandles[0], &allNewValues[0], &allOldValues[0], additionalEvents + i_count, sal_False ); +} + +//-------------------------------------------------------------------------- void OPropertySetHelper::fire ( sal_Int32 * pnHandles, @@ -806,7 +899,7 @@ void OPropertySetHelper::setFastPropertyValues( } // fire change events - fire( pHandles, pConvertedValues, pOldValues, n, sal_False ); + impl_fireAll( pHandles, pConvertedValues, pOldValues, n ); } catch( ... ) { diff --git a/cppuhelper/source/servicefactory.cxx b/cppuhelper/source/servicefactory.cxx index 22058bb14082..742f94ac5f97 100644 --- a/cppuhelper/source/servicefactory.cxx +++ b/cppuhelper/source/servicefactory.cxx @@ -29,13 +29,9 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cppuhelper.hxx" -#if OSL_DEBUG_LEVEL > 0 -#include <stdio.h> -#endif #include <vector> #include "rtl/string.hxx" -#include "rtl/ustrbuf.hxx" #include "rtl/bootstrap.hxx" #include "osl/diagnose.h" #include "osl/file.h" @@ -47,6 +43,7 @@ #include "cppuhelper/servicefactory.hxx" #include "cppuhelper/bootstrap.hxx" +#include "com/sun/star/uno/DeploymentException.hpp" #include "com/sun/star/uno/XComponentContext.hpp" #include "com/sun/star/lang/XInitialization.hpp" #include "com/sun/star/lang/XSingleServiceFactory.hpp" @@ -65,6 +62,7 @@ using namespace ::rtl; using namespace ::osl; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; +namespace css = com::sun::star; namespace cppu { @@ -418,39 +416,42 @@ Reference< XComponentContext > bootstrapInitialContext( keys.getConstArray(); for ( sal_Int32 nPos = keys.getLength(); nPos--; ) { - Reference< registry::XRegistryKey > const & xKey2 = - pKeys[ nPos ]; - try - { - OUStringBuffer buf( 32 ); - buf.appendAscii( - RTL_CONSTASCII_STRINGPARAM("/singletons/") ); - buf.append( - xKey2->getKeyName().copy( - sizeof("/SINGLETONS") /* -\0 +'/' */ ) ); - entry.name = buf.makeStringAndClear(); - entry.value <<= xKey2->getStringValue(); - context_values.push_back( entry ); - } - catch (Exception & rExc) - { -#if OSL_DEBUG_LEVEL > 0 - OString aStr( - OUStringToOString( - xKey2->getKeyName().copy( 11 ), - RTL_TEXTENCODING_ASCII_US ) ); - OString aStr2( - OUStringToOString( - rExc.Message, RTL_TEXTENCODING_ASCII_US ) ); - fprintf( - stderr, - "### failed reading singleton [%s]" - " service name from registry: %s\n", - aStr.getStr(), aStr2.getStr() ); -#else - (void) rExc; // avoid warning about unused variable -#endif + css::uno::Sequence< rtl::OUString > impls( + css::uno::Reference< css::registry::XRegistryKey >( + pKeys[nPos]->openKey( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "REGISTERED_BY"))), + css::uno::UNO_SET_THROW)->getAsciiListValue()); + switch (impls.getLength()) { + case 0: + throw css::uno::DeploymentException( + (pKeys[nPos]->getKeyName() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "/REGISTERED_BY is empty"))), + css::uno::Reference< css::uno::XInterface >()); + case 1: + break; + default: + OSL_TRACE( + ("arbitrarily chosing \"%s\" among multiple" + " implementations for \"%s\""), + rtl::OUStringToOString( + impls[0], RTL_TEXTENCODING_UTF8).getStr(), + rtl::OUStringToOString( + pKeys[nPos]->getKeyName(), + RTL_TEXTENCODING_UTF8).getStr()); + break; } + context_values.push_back( + ContextEntry_Init( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("/singletons/")) + + pKeys[nPos]->getKeyName().copy( + RTL_CONSTASCII_LENGTH("/SINGLETONS/"))), + css::uno::makeAny(impls[0]), + true)); } } } diff --git a/cppuhelper/source/tdmgr.cxx b/cppuhelper/source/tdmgr.cxx index 291d514fcd80..7090adbe90d3 100644 --- a/cppuhelper/source/tdmgr.cxx +++ b/cppuhelper/source/tdmgr.cxx @@ -28,6 +28,11 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_cppuhelper.hxx" + +#include "sal/config.h" + +#include <vector> + #include <sal/alloca.h> #include <osl/diagnose.h> @@ -46,7 +51,7 @@ #include <com/sun/star/reflection/XEnumTypeDescription.hpp> #include <com/sun/star/reflection/XIndirectTypeDescription.hpp> #include <com/sun/star/reflection/XInterfaceMemberTypeDescription.hpp> -#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription.hpp> +#include <com/sun/star/reflection/XInterfaceAttributeTypeDescription2.hpp> #include <com/sun/star/reflection/XMethodParameter.hpp> #include <com/sun/star/reflection/XInterfaceMethodTypeDescription.hpp> #include <com/sun/star/reflection/XInterfaceTypeDescription2.hpp> @@ -303,7 +308,7 @@ inline static typelib_TypeDescription * createCTD( } //================================================================================================== inline static typelib_TypeDescription * createCTD( - const Reference< XInterfaceAttributeTypeDescription > & xAttribute ) + const Reference< XInterfaceAttributeTypeDescription2 > & xAttribute ) { typelib_TypeDescription * pRet = 0; if (xAttribute.is()) @@ -311,14 +316,31 @@ inline static typelib_TypeDescription * createCTD( OUString aMemberName( xAttribute->getName() ); Reference< XTypeDescription > xType( xAttribute->getType() ); OUString aMemberTypeName( xType->getName() ); - - typelib_typedescription_newInterfaceAttribute( + std::vector< rtl_uString * > getExc; + Sequence< Reference< XCompoundTypeDescription > > getExcs( + xAttribute->getGetExceptions() ); + for (sal_Int32 i = 0; i != getExcs.getLength(); ++i) + { + OSL_ASSERT( getExcs[i].is() ); + getExc.push_back( getExcs[i]->getName().pData ); + } + std::vector< rtl_uString * > setExc; + Sequence< Reference< XCompoundTypeDescription > > setExcs( + xAttribute->getSetExceptions() ); + for (sal_Int32 i = 0; i != setExcs.getLength(); ++i) + { + OSL_ASSERT( setExcs[i].is() ); + setExc.push_back( setExcs[i]->getName().pData ); + } + typelib_typedescription_newExtendedInterfaceAttribute( (typelib_InterfaceAttributeTypeDescription **)&pRet, xAttribute->getPosition(), aMemberName.pData, // name (typelib_TypeClass)xType->getTypeClass(), aMemberTypeName.pData, // type name - xAttribute->isReadOnly() ); + xAttribute->isReadOnly(), + getExc.size(), getExc.empty() ? 0 : &getExc[0], + setExc.size(), setExc.empty() ? 0 : &setExc[0] ); } return pRet; } @@ -643,7 +665,7 @@ static typelib_TypeDescription * createCTD( pRet = createCTD( Reference< XInterfaceMethodTypeDescription >::query( xType ) ); break; case TypeClass_INTERFACE_ATTRIBUTE: - pRet = createCTD( Reference< XInterfaceAttributeTypeDescription >::query( xType ) ); + pRet = createCTD( Reference< XInterfaceAttributeTypeDescription2 >::query( xType ) ); break; default: break; diff --git a/cpputools/prj/build.lst b/cpputools/prj/build.lst index 7cd9053c5476..ca820871b3c3 100644 --- a/cpputools/prj/build.lst +++ b/cpputools/prj/build.lst @@ -2,7 +2,6 @@ pt cpputools : cppuhelper offuh LIBXML2:libxml2 NULL pt cpputools usr1 - all pt_mkout NULL pt cpputools\prj get - all pt_prj NULL pt cpputools\source\registercomponent nmake - all pt_regcomp NULL -pt cpputools\source\regcomplazy nmake - all pt_regcomplazy NULL pt cpputools\source\regsingleton nmake - all pt_regsingleton NULL pt cpputools\source\unoexe nmake - all pt_unoexe NULL pt cpputools\source\sp2bv nmake - all pt_sp2bv NULL diff --git a/cpputools/prj/d.lst b/cpputools/prj/d.lst index fa029cc4deeb..14de5e78af75 100644 --- a/cpputools/prj/d.lst +++ b/cpputools/prj/d.lst @@ -1,8 +1,6 @@ ..\%__SRC%\bin\regcomp.exe %_DEST%\bin%_EXT%\regcomp.exe ..\%__SRC%\bin\regcomp %_DEST%\bin%_EXT%\regcomp ..\%__SRC%\bin\regcomp %_DEST%\bin%_EXT%\regcomp.bin -..\%__SRC%\bin\regcomplazy.exe %_DEST%\bin%_EXT%\regcomplazy.exe -..\%__SRC%\bin\regcomplazy %_DEST%\bin%_EXT%\regcomplazy ..\%__SRC%\bin\uno.exe %_DEST%\bin%_EXT%\uno.exe ..\%__SRC%\bin\uno %_DEST%\bin%_EXT%\uno ..\%__SRC%\bin\uno %_DEST%\bin%_EXT%\uno.bin diff --git a/cpputools/source/regcomplazy/regcomplazy.cxx b/cpputools/source/regcomplazy/regcomplazy.cxx deleted file mode 100644 index 3b5b6421e9e4..000000000000 --- a/cpputools/source/regcomplazy/regcomplazy.cxx +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <stdio.h> - -#include "sal/main.h" -#include <osl/diagnose.h> -#include <osl/thread.h> -#include <osl/file.hxx> -#include <rtl/strbuf.hxx> -#include <rtl/ustrbuf.hxx> - -#include <vector> - -#include <registry/registry.hxx> - - -#define OSToOUS(x) ::rtl::OStringToOUString(x, osl_getThreadTextEncoding()) -#define OUSToOS(x) ::rtl::OUStringToOString(x, osl_getThreadTextEncoding()) -using namespace ::rtl; - -typedef ::std::vector< ::rtl::OString > OSVector; - -struct CompDescriptor { - OString sImplementationName; - OString sComponentName; - OString sLoaderName; - OSVector vSupportedServices; -}; - -typedef ::std::vector< CompDescriptor > CDescrVector; - -static void print_options() SAL_THROW( () ) -{ - printf( - "\nusage: regcomplazy [-v]registry_file cmp_descr_file ...\n\n" - "Register a cmponent using a comp description file.\n" - "Option -v prints verbose output on stdout.\n" ); -} - -static bool checkImplValue(RegistryValueList<sal_Char*>* pValueList, OString sImplName) { - for (sal_uInt32 i=0; i < pValueList->getLength(); i++) { - if (sImplName.equals(pValueList->getElement(i))) - return true; - } - - return false; -} - -//================================================================================================== -SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) -{ - if (argc < 3) - { - print_options(); - return 1; - } - - bool bVerbose = false; - int nPos = 1; - if ('-' == argv[ nPos ][ 0 ] && 'v' == argv[ nPos ][ 1 ]) - { - if ('\0' != argv[ nPos ][ 2 ]) - { - print_options(); - return 1; - } - bVerbose = true; - ++nPos; - } - - OUString sys_path( ::rtl::OUString::createFromAscii( argv[ nPos ] ) ); - OUString reg_url; - oslFileError rc = osl_getFileURLFromSystemPath( sys_path.pData, ®_url.pData ); - if (osl_File_E_None != rc) - { - if (bVerbose) - fprintf( stderr, "\nERROR: cannot make file url out of %s\n", argv[nPos]); - return 1; - } - - FILE* fDescr = fopen(argv[ ++nPos ], "r"); - OStringBuffer sBuffer(512); - - if ( fDescr) { - size_t totalSize = 0; - size_t readSize = 0; - char pBuffer[513]; - - while ( !feof(fDescr) ) - { - if ( (readSize = fread(pBuffer, 1, 512, fDescr)) > 0 - && !ferror(fDescr) ) { - totalSize += readSize; - if (totalSize >= 512) - sBuffer.ensureCapacity(totalSize * 2); - - sBuffer.append(pBuffer, readSize); - } - } - fclose(fDescr); - fDescr = 0; // just to be sure noone tries to use the file ever after - } - - OString sDescr = sBuffer.makeStringAndClear(); - sal_Int32 nTokenIndex = 0; - - CDescrVector vDescr; - CompDescriptor descr; - bool bFirst = true; - - do { - OString sTmp = sDescr.getToken(0, '\x0A', nTokenIndex); - OString sToken(sTmp); - if (sTmp.pData->buffer[sTmp.getLength()-1] == '\x0D') - sToken = sTmp.copy(0, sTmp.getLength()-1); - if ( sToken.indexOf("[ComponentDescriptor]") >= 0) { - if (bFirst) - bFirst = false; - else - vDescr.push_back(descr); - - descr = CompDescriptor(); - } - else if ( sToken.indexOf("ImplementationName=") >= 0) { - descr.sImplementationName = sToken.copy(19); - } - else if ( sToken.indexOf("ComponentName=") >= 0) { - descr.sComponentName = sToken.copy(14); - } - else if ( sToken.indexOf("LoaderName=") >= 0) { - descr.sLoaderName = sToken.copy(11); - } - else if ( (sToken.indexOf("[SupportedServices]") < 0) && - (sToken.getLength() > 0) && - (sToken.pData->buffer[0] != '[') ) { - descr.vSupportedServices.push_back(sToken); - } - } while (nTokenIndex >= 0 ); - // insert the last descriptor - vDescr.push_back(descr); - - Registry *pReg = new Registry; - - RegistryKey rootKey, key, subKey, serviceKey; - - if (pReg->open(reg_url, REG_READWRITE)) - { - if (pReg->create(reg_url)) - { - if (bVerbose) - fprintf(stderr, "ERROR: open registry \"%s\" failed\n", argv[1]); - return 1; - } - } - if (pReg->openRootKey(rootKey)) { - if (bVerbose) - fprintf(stderr, "ERROR: open root key failed\n"); - return 1; - } - - CDescrVector::const_iterator comp_iter = vDescr.begin(); - do { - OString sImplName = (*comp_iter).sImplementationName; - OUStringBuffer sbImpl; - sbImpl.appendAscii("/IMPLEMENTATIONS/"); - sbImpl.append(OSToOUS(sImplName)); - OUString sImplKeyName = sbImpl.makeStringAndClear(); - - if (rootKey.openKey(sImplKeyName, key) == REG_NO_ERROR) { - if (bVerbose) { - fprintf(stderr, "WARNING: implementation entry for \"%s\" already exists, existing entries are overwritten\n", sImplName.getStr()); - } - } else { - if (rootKey.createKey(sImplKeyName, key)) { - if (bVerbose) { - fprintf(stderr, "ERROR: can't create new implementation entry \"%s\".\n", sImplName.getStr()); - } - return 1; - } - } - - OString sLoaderName = (*comp_iter).sLoaderName; - OUString usKeyName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNO/ACTIVATOR"))); - key.createKey(usKeyName, subKey); - subKey.setValue(OUString(), RG_VALUETYPE_STRING, - (sal_Char*)sLoaderName.getStr(), sLoaderName.getLength()+1); - - OString sCompName = (*comp_iter).sComponentName; - usKeyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNO/LOCATION")); - key.createKey(usKeyName, subKey); - subKey.setValue(OUString(), RG_VALUETYPE_STRING, - (sal_Char*)sCompName.getStr(), sCompName.getLength()+1); - - usKeyName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("UNO/SERVICES")); - key.createKey(usKeyName, subKey); - - rootKey.createKey(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/SERVICES")), serviceKey); - - OSVector::const_iterator serv_iter = ((*comp_iter).vSupportedServices).begin(); - OUString usServiceKeyName; - do { - usServiceKeyName = OSToOUS(*serv_iter); - // write service key in impl section - subKey.createKey(usServiceKeyName, key); - - if (serviceKey.openKey(usServiceKeyName, key) == REG_NO_ERROR) { - RegistryValueList<sal_Char*> valueList; - serviceKey.getStringListValue(usServiceKeyName, valueList); - if ( checkImplValue(&valueList, sImplName) ) { - serv_iter++; - continue; - } - - sal_uInt32 nServices = valueList.getLength()+1; - sal_Char** pImplList = (sal_Char**)rtl_allocateZeroMemory( - nServices * sizeof(sal_Char*)); - pImplList[0] = (sal_Char*)rtl_allocateZeroMemory( - sImplName.getLength()+1 * sizeof(sal_Char)); - rtl_copyMemory(pImplList[0], (sal_Char*)sImplName.getStr(), - sImplName.getLength()+1); - for (sal_uInt32 i=0; i < valueList.getLength(); i++) { - pImplList[i+1]=valueList.getElement(i); - } - key.setStringListValue(OUString(), pImplList, nServices); - - // free memory - rtl_freeMemory(pImplList[0]); - rtl_freeMemory(pImplList); - - } else { - serviceKey.createKey(usServiceKeyName, key); - - sal_Char* pImplList[1]; - pImplList[0] = (sal_Char*)rtl_allocateZeroMemory( - sImplName.getLength()+1 * sizeof(sal_Char)); - rtl_copyMemory(pImplList[0], (sal_Char*)sImplName.getStr(), - sImplName.getLength()+1); - key.setStringListValue(OUString(), pImplList, 1); - - // free memory - rtl_freeMemory(pImplList[0]); - } - serv_iter++; - } while (serv_iter != (*comp_iter).vSupportedServices.end()); - - comp_iter++; - } while (comp_iter != vDescr.end()); - - key.closeKey(); - subKey.closeKey(); - serviceKey.closeKey(); - rootKey.closeKey(); - pReg->close(); - delete pReg; - - return 0; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/cpputools/source/unoexe/unoexe.cxx b/cpputools/source/unoexe/unoexe.cxx index fef9d5ff666a..81bf81baec91 100644 --- a/cpputools/source/unoexe/unoexe.cxx +++ b/cpputools/source/unoexe/unoexe.cxx @@ -280,23 +280,14 @@ void createInstance( OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.io.Connector") ), xSF, Reference< XRegistryKey >() ) ) ); - // iiop bridge - xSet->insert( makeAny( loadSharedLibComponentFactory( - OUString( RTL_CONSTASCII_USTRINGPARAM( - "remotebridge.uno" SAL_DLLEXTENSION) ), - OUString(), - OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.comp.remotebridges." - "Bridge.various") ), - xSF, Reference< XRegistryKey >() ) ) ); // bridge factory xSet->insert( makeAny( loadSharedLibComponentFactory( OUString( RTL_CONSTASCII_USTRINGPARAM( - "bridgefac.uno" SAL_DLLEXTENSION) ), + "binaryurp.uno" SAL_DLLEXTENSION) ), OUString(), - OUString( RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.comp.remotebridges." - "BridgeFactory") ), + OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.comp.bridge.BridgeFactory") ), xSF, Reference< XRegistryKey >() ) ) ); } s_bSet = sal_True; diff --git a/io/prj/build.lst b/io/prj/build.lst index 2fa4900f52e6..f2be62d2aa1e 100644 --- a/io/prj/build.lst +++ b/io/prj/build.lst @@ -1,4 +1,4 @@ -io io : rdbmaker NULL +io io : LIBXSLT:libxslt rdbmaker NULL io io usr1 - all io_mkout NULL io io\inc nmake - all io_inc NULL io io\source\acceptor nmake - all io_acceptor io_connector io_inc NULL diff --git a/io/prj/d.lst b/io/prj/d.lst index 9d19e5f8e41b..eaadf64dba11 100644 --- a/io/prj/d.lst +++ b/io/prj/d.lst @@ -5,3 +5,8 @@ ..\source\stm\stm.xml %_DEST%\xml%_EXT%\streams.uno.xml ..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\* ..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\* +..\%__SRC%\misc\acceptor.component %_DEST%\xml%_EXT%\acceptor.component +..\%__SRC%\misc\connector.component %_DEST%\xml%_EXT%\connector.component +..\%__SRC%\misc\streams.component %_DEST%\xml%_EXT%\streams.component +..\%__SRC%\misc\textinstream.component %_DEST%\xml%_EXT%\textinstream.component +..\%__SRC%\misc\textoutstream.component %_DEST%\xml%_EXT%\textoutstream.component diff --git a/io/source/TextInputStream/TextInputStream.cxx b/io/source/TextInputStream/TextInputStream.cxx index e8beb3f4a63a..a5ee3002a797 100644 --- a/io/source/TextInputStream/TextInputStream.cxx +++ b/io/source/TextInputStream/TextInputStream.cxx @@ -522,12 +522,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/io/source/TextInputStream/makefile.mk b/io/source/TextInputStream/makefile.mk index 3c0cd5c5702d..ea476c57c0eb 100644 --- a/io/source/TextInputStream/makefile.mk +++ b/io/source/TextInputStream/makefile.mk @@ -59,3 +59,11 @@ DEF1NAME= $(SHL1TARGET) .ENDIF # L10N_framework .INCLUDE : target.mk + +ALLTAR : $(MISC)/textinstream.component + +$(MISC)/textinstream.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt textinstream.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt textinstream.component diff --git a/io/source/TextInputStream/textinstream.component b/io/source/TextInputStream/textinstream.component new file mode 100644 index 000000000000..6ac7d2a9825b --- /dev/null +++ b/io/source/TextInputStream/textinstream.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.io.TextInputStream"> + <service name="com.sun.star.io.TextInputStream"/> + </implementation> +</component> diff --git a/io/source/TextOutputStream/TextOutputStream.cxx b/io/source/TextOutputStream/TextOutputStream.cxx index f71e7f216034..a50cc712bfbd 100644 --- a/io/source/TextOutputStream/TextOutputStream.cxx +++ b/io/source/TextOutputStream/TextOutputStream.cxx @@ -320,12 +320,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/io/source/TextOutputStream/makefile.mk b/io/source/TextOutputStream/makefile.mk index ad78178f8bfa..2c9d4eb2efbc 100644 --- a/io/source/TextOutputStream/makefile.mk +++ b/io/source/TextOutputStream/makefile.mk @@ -60,3 +60,11 @@ DEF1NAME= $(SHL1TARGET) .ENDIF # L10N_framework .INCLUDE : target.mk + +ALLTAR : $(MISC)/textoutstream.component + +$(MISC)/textoutstream.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt textoutstream.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt textoutstream.component diff --git a/io/source/TextOutputStream/textoutstream.component b/io/source/TextOutputStream/textoutstream.component new file mode 100644 index 000000000000..afbc50ab8502 --- /dev/null +++ b/io/source/TextOutputStream/textoutstream.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.io.TextOutputStream"> + <service name="com.sun.star.io.TextOutputStream"/> + </implementation> +</component> diff --git a/io/source/acceptor/acc_pipe.cxx b/io/source/acceptor/acc_pipe.cxx index 27a298bf5c7f..199a7baf1591 100644 --- a/io/source/acceptor/acc_pipe.cxx +++ b/io/source/acceptor/acc_pipe.cxx @@ -102,11 +102,17 @@ namespace io_acceptor { if( ! m_nStatus ) { - if( aReadBytes.getLength() != nBytesToRead ) + if( aReadBytes.getLength() < nBytesToRead ) { aReadBytes.realloc( nBytesToRead ); } - return m_pipe.read( aReadBytes.getArray() , aReadBytes.getLength() ); + sal_Int32 n = m_pipe.read( aReadBytes.getArray(), nBytesToRead ); + OSL_ASSERT( n >= 0 && n <= aReadBytes.getLength() ); + if( n < aReadBytes.getLength() ) + { + aReadBytes.realloc( n ); + } + return n; } else { throw IOException(); diff --git a/io/source/acceptor/acceptor.component b/io/source/acceptor/acceptor.component new file mode 100644 index 000000000000..81e0399b2024 --- /dev/null +++ b/io/source/acceptor/acceptor.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.io.Acceptor"> + <service name="com.sun.star.connection.Acceptor"/> + </implementation> +</component> diff --git a/io/source/acceptor/acceptor.cxx b/io/source/acceptor/acceptor.cxx index 3edca9d0841e..9b50048abca3 100644 --- a/io/source/acceptor/acceptor.cxx +++ b/io/source/acceptor/acceptor.cxx @@ -367,12 +367,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/io/source/acceptor/makefile.mk b/io/source/acceptor/makefile.mk index 3da3fbe18913..bbc7ac6d3836 100644 --- a/io/source/acceptor/makefile.mk +++ b/io/source/acceptor/makefile.mk @@ -71,3 +71,11 @@ DEF1NAME= $(SHL1TARGET) .ENDIF # L10N_framework .INCLUDE : target.mk + +ALLTAR : $(MISC)/acceptor.component + +$(MISC)/acceptor.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + acceptor.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt acceptor.component diff --git a/io/source/connector/connector.component b/io/source/connector/connector.component new file mode 100644 index 000000000000..95fa72aa50d7 --- /dev/null +++ b/io/source/connector/connector.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.io.Connector"> + <service name="com.sun.star.connection.Connector"/> + </implementation> +</component> diff --git a/io/source/connector/connector.cxx b/io/source/connector/connector.cxx index 4ba32fc54a26..076a246c79f8 100644 --- a/io/source/connector/connector.cxx +++ b/io/source/connector/connector.cxx @@ -279,12 +279,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/io/source/connector/makefile.mk b/io/source/connector/makefile.mk index 7f12b850f1e3..e3a67abe66ff 100644 --- a/io/source/connector/makefile.mk +++ b/io/source/connector/makefile.mk @@ -71,3 +71,11 @@ DEF1NAME= $(SHL1TARGET) .ENDIF # L10N_framework .INCLUDE : target.mk + +ALLTAR : $(MISC)/connector.component + +$(MISC)/connector.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + connector.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt connector.component diff --git a/io/source/stm/factreg.cxx b/io/source/stm/factreg.cxx index 9b9a8a68384b..bbaa4dc60478 100644 --- a/io/source/stm/factreg.cxx +++ b/io/source/stm/factreg.cxx @@ -111,12 +111,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/io/source/stm/makefile.mk b/io/source/stm/makefile.mk index a6a163eca4e2..52dd0c492823 100644 --- a/io/source/stm/makefile.mk +++ b/io/source/stm/makefile.mk @@ -75,3 +75,10 @@ DEF1NAME= $(SHL1TARGET) .INCLUDE : target.mk +ALLTAR : $(MISC)/streams.component + +$(MISC)/streams.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + streams.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt streams.component diff --git a/io/source/stm/streams.component b/io/source/stm/streams.component new file mode 100644 index 000000000000..76890d360bb3 --- /dev/null +++ b/io/source/stm/streams.component @@ -0,0 +1,55 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.io.Pump"> + <service name="com.sun.star.io.Pump"/> + </implementation> + <implementation name="com.sun.star.comp.io.stm.DataInputStream"> + <service name="com.sun.star.io.DataInputStream"/> + </implementation> + <implementation name="com.sun.star.comp.io.stm.DataOutputStream"> + <service name="com.sun.star.io.DataOutputStream"/> + </implementation> + <implementation name="com.sun.star.comp.io.stm.MarkableInputStream"> + <service name="com.sun.star.io.MarkableInputStream"/> + </implementation> + <implementation name="com.sun.star.comp.io.stm.MarkableOutputStream"> + <service name="com.sun.star.io.MarkableOutputStream"/> + </implementation> + <implementation name="com.sun.star.comp.io.stm.ObjectInputStream"> + <service name="com.sun.star.io.ObjectInputStream"/> + </implementation> + <implementation name="com.sun.star.comp.io.stm.ObjectOutputStream"> + <service name="com.sun.star.io.ObjectOutputStream"/> + </implementation> + <implementation name="com.sun.star.comp.io.stm.Pipe"> + <service name="com.sun.star.io.Pipe"/> + </implementation> +</component> diff --git a/javaunohelper/com/sun/star/comp/JavaUNOHelperServices.java b/javaunohelper/com/sun/star/comp/JavaUNOHelperServices.java index ba928eb81c1f..5a5cb7b19b4e 100644 --- a/javaunohelper/com/sun/star/comp/JavaUNOHelperServices.java +++ b/javaunohelper/com/sun/star/comp/JavaUNOHelperServices.java @@ -28,7 +28,6 @@ package com.sun.star.comp; import com.sun.star.lib.uno.helper.Factory; import com.sun.star.lang.XSingleComponentFactory; -import com.sun.star.registry.XRegistryKey; import com.sun.star.comp.juhtest.SmoketestCommandEnvironment; @@ -62,20 +61,4 @@ public class JavaUNOHelperServices { return xFactory; } - - /** - * Writes the service information into the given registry key. - * This method is called by the <code>JavaLoader</code> - * <p> - * @return returns true if the operation succeeded - * @param regKey the registryKey - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return Factory.writeRegistryServiceInfo(SmoketestCommandEnvironment.class.getName(), - SmoketestCommandEnvironment.getServiceNames(), - regKey); - } } - - diff --git a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java index 33d107279633..0780f26486f2 100644 --- a/javaunohelper/com/sun/star/lib/uno/helper/Factory.java +++ b/javaunohelper/com/sun/star/lib/uno/helper/Factory.java @@ -53,6 +53,30 @@ public class Factory @param impl_class implementation class + @param impl_name + implementation name + @param supported_services + services implemented + @return + object factory + + @since UDK 3.2.13 + */ + public static XSingleComponentFactory createComponentFactory( + Class impl_class, String impl_name, String supported_services [] ) + throws com.sun.star.uno.RuntimeException + { + return new Factory( impl_class, impl_name, supported_services ); + } + + /** Creates an object factory supporting interfaces + com.sun.star.lang.XSingleComponentFactory and + com.sun.star.lang.XServiceInfo + + The implementation name is the name of the implementation class. + + @param impl_class + implementation class @param supported_services services implemented @return @@ -62,7 +86,8 @@ public class Factory Class impl_class, String supported_services [] ) throws com.sun.star.uno.RuntimeException { - return new Factory( impl_class, supported_services ); + return createComponentFactory( + impl_class, impl_class.getName(), supported_services ); } /** Writes component's implementation info to given registry key. @@ -106,11 +131,10 @@ public class Factory private java.lang.reflect.Method m_method; private java.lang.reflect.Constructor m_ctor; - // ctor - private Factory( Class impl_class, String supported_services [] ) - throws com.sun.star.uno.RuntimeException + private Factory( + Class impl_class, String impl_name, String supported_services [] ) { - m_impl_name = impl_class.getName(); + m_impl_name = impl_name; m_supported_services = supported_services; m_impl_class = impl_class; m_method = null; diff --git a/javaunohelper/prj/build.lst b/javaunohelper/prj/build.lst index c18dd3eb94dc..d97a6450d06a 100644 --- a/javaunohelper/prj/build.lst +++ b/javaunohelper/prj/build.lst @@ -1,4 +1,4 @@ -jh javaunohelper : bridges cppuhelper jurt ridljar unoil NULL +jh javaunohelper : LIBXSLT:libxslt bridges cppuhelper jurt ridljar unoil NULL jh javaunohelper usr1 - all jh_mkout NULL jh javaunohelper\inc nmake - all jh_inc NULL jh javaunohelper\com\sun\star\comp\helper nmake - all jh_helper jh_inc NULL diff --git a/javaunohelper/prj/d.lst b/javaunohelper/prj/d.lst index 1fbd9c223bab..d58290843f48 100644 --- a/javaunohelper/prj/d.lst +++ b/javaunohelper/prj/d.lst @@ -2,5 +2,6 @@ ..\%__SRC%\bin\juh*.dll %_DEST%\bin%_EXT%\juh*.dll ..\%__SRC%\lib\libjuh*.so %_DEST%\lib%_EXT%\libjuh*.so ..\%__SRC%\lib\libjuh*.dylib %_DEST%\lib%_EXT%\libjuh*.dylib +..\%__SRC%\misc\juh.component %_DEST%\xml%_EXT%\juh.component ..\%__SRC%\bin\juh_src.zip %COMMON_DEST%\bin%_EXT%\juh_src.zip diff --git a/javaunohelper/util/juh.component b/javaunohelper/util/juh.component new file mode 100644 index 000000000000..790a2a2b14d3 --- /dev/null +++ b/javaunohelper/util/juh.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.Java2" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.juhtest.SmoketestCommandEnvironment"> + <service name="com.sun.star.deployment.test.SmoketestCommandEnvironment"/> + </implementation> +</component> diff --git a/javaunohelper/util/makefile.mk b/javaunohelper/util/makefile.mk index 22b3a72be288..796280eb3876 100644 --- a/javaunohelper/util/makefile.mk +++ b/javaunohelper/util/makefile.mk @@ -50,4 +50,9 @@ ZIP1LIST=com -x "*makefile.mk" .INCLUDE : target.mk +ALLTAR : $(MISC)/juh.component +$(MISC)/juh.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + juh.component + $(XSLTPROC) --nonet --stringparam uri '$(COMPONENTPREFIX_URE_JAVA)juh.jar' \ + -o $@ $(SOLARENV)/bin/createcomponent.xslt juh.component diff --git a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java index a444f1813c3d..1c4819326268 100644 --- a/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java +++ b/jurt/com/sun/star/comp/bridgefactory/BridgeFactory.java @@ -94,18 +94,6 @@ public class BridgeFactory implements XBridgeFactory/*, XEventListener*/ { } /** - * Writes the service information into the given registry key. - * This method is called by the <code>JavaLoader</code> - * <p> - * @return returns true if the operation succeeded - * @param regKey the registryKey - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo(BridgeFactory.class.getName(), __serviceName, regKey); - } - - /** * Creates a remote bridge and memorizes it under <code>sName</code>. * <p> * @return the bridge diff --git a/jurt/com/sun/star/comp/connections/Acceptor.java b/jurt/com/sun/star/comp/connections/Acceptor.java index 3df51e735a1c..2dcfbc507d7b 100644 --- a/jurt/com/sun/star/comp/connections/Acceptor.java +++ b/jurt/com/sun/star/comp/connections/Acceptor.java @@ -84,21 +84,6 @@ public final class Acceptor implements XAcceptor { } /** - * Writes the service information into the given registry key. - * - * <p>This method is called by the <code>JavaLoader</code>.</p> - * - * @param regKey the registry key. - * @return <code>true</code> if the operation succeeded. - * - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo(Acceptor.class.getName(), - __serviceName, regKey); - } - - /** * Constructs a new <code>Acceptor</code> that uses the given service * factory to create a specific <code>XAcceptor</code>. * diff --git a/jurt/com/sun/star/comp/connections/Connector.java b/jurt/com/sun/star/comp/connections/Connector.java index c02db5c52b8b..a9e0a2c5cc84 100644 --- a/jurt/com/sun/star/comp/connections/Connector.java +++ b/jurt/com/sun/star/comp/connections/Connector.java @@ -84,21 +84,6 @@ public class Connector implements XConnector { } /** - * Writes the service information into the given registry key. - * - * <p>This method is called by the <code>JavaLoader</code>.</p> - * - * @param regKey the registry key. - * @return <code>true</code> if the operation succeeded. - * - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo(Connector.class.getName(), - __serviceName, regKey); - } - - /** * Constructs a new <code>Connector</code> that uses the given service * factory to create a specific <code>XConnector</code>. * diff --git a/jurt/com/sun/star/comp/connections/ConstantInstanceProvider.java b/jurt/com/sun/star/comp/connections/ConstantInstanceProvider.java index f63eeadf10d8..b801cb36d8a5 100644 --- a/jurt/com/sun/star/comp/connections/ConstantInstanceProvider.java +++ b/jurt/com/sun/star/comp/connections/ConstantInstanceProvider.java @@ -85,20 +85,6 @@ public class ConstantInstanceProvider implements XInstanceProvider { return xSingleServiceFactory; } - /** - * Writes the service information into the given registry key. - * This method is called by the <code>JavaLoader</code> - * <p> - * @return returns true if the operation succeeded - * @param regKey the registryKey - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo(ConstantInstanceProvider.class.getName(), __serviceName, regKey); - } - - - protected XMultiServiceFactory _serviceManager; protected String _serviceName; protected Object _instance; diff --git a/jurt/com/sun/star/comp/connections/PipedConnection.java b/jurt/com/sun/star/comp/connections/PipedConnection.java index 630adf4e223b..f5a839ea78c5 100644 --- a/jurt/com/sun/star/comp/connections/PipedConnection.java +++ b/jurt/com/sun/star/comp/connections/PipedConnection.java @@ -86,19 +86,6 @@ public class PipedConnection implements XConnection { } /** - * Writes the service information into the given registry key. - * This method is called by the <code>JavaLoader</code> - * <p> - * @return returns true if the operation succeeded - * @param regKey the registryKey - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo(PipedConnection.class.getName(), __serviceName, regKey); - } - - - /** * The amount of time in milliseconds, to wait to * see check the buffers. */ diff --git a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java index 3509dfb303f2..538315638553 100644 --- a/jurt/com/sun/star/comp/urlresolver/UrlResolver.java +++ b/jurt/com/sun/star/comp/urlresolver/UrlResolver.java @@ -154,18 +154,4 @@ public class UrlResolver { return xSingleServiceFactory; } - - /** - * Writes the service information into the given registry key. - * This method is called by the <code>JavaLoader</code> - * <p> - * @return returns true if the operation succeeded - * @param regKey the registryKey - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo(_UrlResolver.class.getName(), _UrlResolver.__serviceName, regKey); - } - } - diff --git a/jurt/com/sun/star/lib/connections/pipe/pipeAcceptor.java b/jurt/com/sun/star/lib/connections/pipe/pipeAcceptor.java index 4c5bf7f1c979..25b2ec4abfe3 100644 --- a/jurt/com/sun/star/lib/connections/pipe/pipeAcceptor.java +++ b/jurt/com/sun/star/lib/connections/pipe/pipeAcceptor.java @@ -84,21 +84,6 @@ public final class pipeAcceptor implements XAcceptor { } /** - * Writes the service information into the given registry key. - * - * <p>This method is called by the <code>JavaLoader</code>.</p> - * - * @param regKey the registry key. - * @return <code>true</code> if the operation succeeded. - * - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo( - pipeAcceptor.class.getName(), __serviceName, regKey); - } - - /** * Accepts a connection request via the described pipe. * * <p>This call blocks until a connection has been established.</p> diff --git a/jurt/com/sun/star/lib/connections/pipe/pipeConnector.java b/jurt/com/sun/star/lib/connections/pipe/pipeConnector.java index 9c0c412ec2bc..9856fb2e116e 100644 --- a/jurt/com/sun/star/lib/connections/pipe/pipeConnector.java +++ b/jurt/com/sun/star/lib/connections/pipe/pipeConnector.java @@ -84,21 +84,6 @@ public final class pipeConnector implements XConnector { } /** - * Writes the service information into the given registry key. - * - * <p>This method is called by the <code>JavaLoader</code>.</p> - * - * @param regKey the registry key. - * @return <code>true</code> if the operation succeeded. - * - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo( - pipeConnector.class.getName(), __serviceName, regKey); - } - - /** * Connects via the described pipe to a waiting server. * * <p>The connection description has the following format: diff --git a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java index f2119225f029..bf9456d0058a 100644 --- a/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java +++ b/jurt/com/sun/star/lib/connections/socket/socketAcceptor.java @@ -89,21 +89,6 @@ public final class socketAcceptor implements XAcceptor { } /** - * Writes the service information into the given registry key. - * - * <p>This method is called by the <code>JavaLoader</code>.</p> - * - * @param regKey the registry key. - * @return <code>true</code> if the operation succeeded. - * - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo( - socketAcceptor.class.getName(), __serviceName, regKey); - } - - /** * Accepts a connection request via the described socket. * * <p>This call blocks until a connection has been established.</p> diff --git a/jurt/com/sun/star/lib/connections/socket/socketConnector.java b/jurt/com/sun/star/lib/connections/socket/socketConnector.java index f85a5ac41bd0..3a7bf183d223 100644 --- a/jurt/com/sun/star/lib/connections/socket/socketConnector.java +++ b/jurt/com/sun/star/lib/connections/socket/socketConnector.java @@ -89,21 +89,6 @@ public final class socketConnector implements XConnector { } /** - * Writes the service information into the given registry key. - * - * <p>This method is called by the <code>JavaLoader</code>.</p> - * - * @param regKey the registry key. - * @return <code>true</code> if the operation succeeded. - * - * @see com.sun.star.comp.loader.JavaLoader - */ - public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) { - return FactoryHelper.writeRegistryServiceInfo( - socketConnector.class.getName(), __serviceName, regKey); - } - - /** * Connects via the described socket to a waiting server. * * <p>The connection description has the following format: diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java index b81db391966f..ae2719f1c07d 100644 --- a/jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java +++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/ProxyFactory.java @@ -148,11 +148,22 @@ final class ProxyFactory { private Object request(String operation, Object[] args) throws Throwable { - return requestHandler.sendRequest(oid, type, operation, args); + Object res = requestHandler.sendRequest(oid, type, operation, args); + // Avoid early finalization of this object, while an invoke -> + // request call is still ongoing; as finalize also calls request, + // this should fulfil the condition from The Java Language + // Specification, 3rd ed., that "if an object's finalizer can result + // in synchronization on that object, then that object must be alive + // and considered reachable whenever a lock is held on it:" + synchronized (this) { + ++dummy; + } + return res; } private final String oid; private final Type type; + private int dummy = 0; } private static final Method METHOD_EQUALS; diff --git a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java index 267a84d7515f..221870b0b035 100644 --- a/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java +++ b/jurt/com/sun/star/lib/uno/bridges/java_remote/java_remote_bridge.java @@ -155,7 +155,7 @@ public class java_remote_bridge new Job(obj, java_remote_bridge.this, msg)); } } catch (Throwable e) { - dispose(new DisposedException(e.toString())); + dispose(e); } } @@ -478,12 +478,12 @@ public class java_remote_bridge dispose = _life_count <= 0; } if (dispose) { - dispose(new com.sun.star.uno.RuntimeException("end of life")); + dispose(new Throwable("end of life")); } } public void dispose() { - dispose(new com.sun.star.uno.RuntimeException("user dispose")); + dispose(new Throwable("user dispose")); } private void dispose(Throwable throwable) { @@ -499,6 +499,8 @@ public class java_remote_bridge ((DisposeListener) i.next()).notifyDispose(this); } + _iProtocol.terminate(); + try { _messageDispatcher.terminate(); @@ -602,7 +604,8 @@ public class java_remote_bridge _iProtocol.writeReply(exception, threadId, result); } catch (IOException e) { dispose(e); - throw new DisposedException("unexpected " + e); + throw (DisposedException) + (new DisposedException("unexpected " + e).initCause(e)); } catch (RuntimeException e) { dispose(e); throw e; @@ -631,9 +634,9 @@ public class java_remote_bridge oid, TypeDescription.getTypeDescription(type), operation, threadId, params); } catch (IOException e) { - DisposedException d = new DisposedException(e.toString()); - dispose(d); - throw d; + dispose(e); + throw (DisposedException) + new DisposedException(e.toString()).initCause(e); } if (sync && Thread.currentThread() != _messageDispatcher) { result = _iThreadPool.enter(handle, threadId); diff --git a/jurt/com/sun/star/lib/uno/environments/remote/IProtocol.java b/jurt/com/sun/star/lib/uno/environments/remote/IProtocol.java index 1fae45e9ca23..de581ea86c7b 100644 --- a/jurt/com/sun/star/lib/uno/environments/remote/IProtocol.java +++ b/jurt/com/sun/star/lib/uno/environments/remote/IProtocol.java @@ -51,6 +51,8 @@ public interface IProtocol { */ void init() throws IOException; + void terminate(); + /** * Reads a request or reply message. * diff --git a/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java b/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java index c70ccfa7e934..71961737fd55 100644 --- a/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java +++ b/jurt/com/sun/star/lib/uno/environments/remote/IThreadPool.java @@ -110,10 +110,10 @@ public interface IThreadPool { /** * Disposes this thread pool, thus releasing - * all threads by throwing the given - * <code>Throwable</code>. + * all threads by throwing a <code>DisposedException</code> with the given + * <code>Throwable</code> cause. * <p> - * @param throwing the Throwable + * @param throwing the cause */ public void dispose(Throwable throwable); diff --git a/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java b/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java index f7568a30cef7..62e49cc44f16 100644 --- a/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java +++ b/jurt/com/sun/star/lib/uno/environments/remote/JobQueue.java @@ -27,6 +27,7 @@ package com.sun.star.lib.uno.environments.remote; +import com.sun.star.lang.DisposedException; /** * The <code>JobQueue</code> implements a queue for jobs. @@ -200,7 +201,7 @@ public class JobQueue { * @return a job or null if timed out * @param waitTime the maximum amount of time to wait for a job */ - private Job removeJob(int waitTime) throws Throwable { + private Job removeJob(int waitTime) { if(DEBUG) System.err.println("##### " + getClass().getName() + ".removeJob:" + _head + " " + _threadId); Job job = null; @@ -210,7 +211,8 @@ public class JobQueue { while(_head == null && (waitTime == 0 || !waited)) { if(_doDispose == _disposeId) { _doDispose = null; - throw _throwable; + throw (DisposedException) + new DisposedException().initCause(_throwable); } // notify sync queues @@ -250,7 +252,8 @@ public class JobQueue { if(_doDispose == _disposeId) { _doDispose = null; - throw _throwable; + throw (DisposedException) + new DisposedException().initCause(_throwable); } try { diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java b/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java index 48268a53a260..d9c57af30cce 100644 --- a/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java +++ b/jurt/com/sun/star/lib/uno/protocols/urp/Cache.java @@ -52,7 +52,7 @@ final class Cache { if (e == null) { if (map.size() < maxSize) { // There is still room for a new entry at the front: - e = new Entry(content, map.size(), last, null); + e = new Entry(content, map.size(), null, first); if (first == null) { last = e; } else { diff --git a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java index da54bc7612a1..a158e1138db1 100644 --- a/jurt/com/sun/star/lib/uno/protocols/urp/urp.java +++ b/jurt/com/sun/star/lib/uno/protocols/urp/urp.java @@ -30,6 +30,7 @@ package com.sun.star.lib.uno.protocols.urp; import com.sun.star.bridge.InvalidProtocolChangeException; import com.sun.star.bridge.ProtocolProperty; import com.sun.star.bridge.XProtocolProperties; +import com.sun.star.lang.DisposedException; import com.sun.star.lib.uno.environments.remote.IProtocol; import com.sun.star.lib.uno.environments.remote.Message; import com.sun.star.lib.uno.environments.remote.ThreadId; @@ -79,6 +80,15 @@ public final class urp implements IProtocol { } } + // @see IProtocol#terminate + public void terminate() { + synchronized (monitor) { + state = STATE_TERMINATED; + initialized = true; + monitor.notifyAll(); + } + } + // @see IProtocol#readMessage public Message readMessage() throws IOException { for (;;) { @@ -125,6 +135,9 @@ public final class urp implements IProtocol { throw new RuntimeException(e.toString()); } } + if (state == STATE_TERMINATED) { + throw new DisposedException(); + } return writeRequest(false, oid, type, function, tid, arguments); } } @@ -375,7 +388,6 @@ public final class urp implements IProtocol { if ((header & HEADER_NEWTID) != 0) { inL1Tid = unmarshal.readThreadId(); } - //TODO: check HEADER_IGNORECACHE return readRequest(funId, sync); } @@ -684,7 +696,6 @@ public final class urp implements IProtocol { private static final int HEADER_NEWOID = 0x10; private static final int HEADER_NEWTID = 0x08; private static final int HEADER_FUNCTIONID16 = 0x04; - private static final int HEADER_IGNORECACHE = 0x02; private static final int HEADER_MOREFLAGS = 0x01; private static final int HEADER_MUSTREPLY = 0x80; private static final int HEADER_SYNCHRONOUS = 0x40; @@ -701,6 +712,7 @@ public final class urp implements IProtocol { private static final int STATE_REQUESTED = 2; private static final int STATE_COMMITTED = 3; private static final int STATE_WAIT = 4; + private static final int STATE_TERMINATED = 5; private static final int MAX_RELEASE_QUEUE_SIZE = 100; diff --git a/jurt/prj/build.lst b/jurt/prj/build.lst index 9b9b722bc3ae..6ba92a9ec6b6 100644 --- a/jurt/prj/build.lst +++ b/jurt/prj/build.lst @@ -17,3 +17,4 @@ ju jurt\com\sun\star\comp\urlresolver nmake - all ju_urlres ju_co_loader NULL ju jurt\source\pipe nmake - all ju_src_pipe NULL ju jurt\source\pipe\wrapper nmake - w ju_src_pipe_wrapper NULL ju jurt\util nmake - all ju_ut ju_brid_jrm ju_co_bfactr ju_con ju_con_sock ju_con_pipe ju_cssl_uno ju_env_java ju_prot_urp ju_servman ju_urlres ju_src_pipe ju_libutil ju_uno NULL +ju jurt\test\com\sun\star\lib\uno\protocols\urp nmake - all ju_test_css_lib_uno_protocols_urp NULL diff --git a/jurt/prj/d.lst b/jurt/prj/d.lst index a55c9fa3572c..499812e28a93 100644 --- a/jurt/prj/d.lst +++ b/jurt/prj/d.lst @@ -3,5 +3,6 @@ ..\%__SRC%\bin\jpipx.dll %_DEST%\bin%_EXT%\jpipx.dll ..\%__SRC%\lib\libjpipe*.so %_DEST%\lib%_EXT%\libjpipe*.so ..\%__SRC%\lib\libjpipe.jnilib %_DEST%\lib%_EXT%\libjpipe.jnilib +..\%__SRC%\lib\libjpipe*.jnilib %_DEST%\lib%_EXT%\libjpipe*.jnilib ..\%__SRC%\bin\jurt_src.zip %COMMON_DEST%\bin%_EXT%\jurt_src.zip diff --git a/jurt/source/pipe/makefile.mk b/jurt/source/pipe/makefile.mk index 5be6f1ebfd10..4a6dc59c89c2 100644 --- a/jurt/source/pipe/makefile.mk +++ b/jurt/source/pipe/makefile.mk @@ -41,6 +41,7 @@ SHL1TARGET = jpipe .END SHL1CODETYPE = C +SHL1CREATEJNILIB=TRUE SHL1IMPLIB = i$(SHL1TARGET) SHL1OBJS = $(SLO)/com_sun_star_lib_connections_pipe_PipeConnection.obj SHL1RPATH = URELIB diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java index 31d3454bde48..2deb525adeac 100644 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java +++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java @@ -27,80 +27,114 @@ package com.sun.star.lib.uno.protocols.urp; -import complexlib.ComplexTestCase; +import org.junit.Test; +import static org.junit.Assert.*; -public final class Cache_Test extends ComplexTestCase { - public String[] getTestMethodNames() { - return new String[] { "test0", "test1", "test2", "test3" }; - } - - public void test0() { +public final class Cache_Test { + @Test public void test0() { Cache c = new Cache(0); boolean[] f = new boolean[1]; int i; i = c.add(f, "a"); - assure("1", i == Cache.NOT_CACHED && !f[0]); + assertTrue(i == Cache.NOT_CACHED && !f[0]); i = c.add(f, "a"); - assure("2", i == Cache.NOT_CACHED && !f[0]); + assertTrue(i == Cache.NOT_CACHED && !f[0]); i = c.add(f, "b"); - assure("3", i == Cache.NOT_CACHED && !f[0]); + assertTrue(i == Cache.NOT_CACHED && !f[0]); i = c.add(f, "a"); - assure("4", i == Cache.NOT_CACHED && !f[0]); + assertTrue(i == Cache.NOT_CACHED && !f[0]); } - public void test1() { + @Test public void test1() { Cache c = new Cache(1); boolean[] f = new boolean[1]; int i; i = c.add(f, "a"); - assure("1", i == 0 && !f[0]); + assertTrue(i == 0 && !f[0]); i = c.add(f, "a"); - assure("2", i == 0 && f[0]); + assertTrue(i == 0 && f[0]); i = c.add(f, "b"); - assure("3", i == 0 && !f[0]); + assertTrue(i == 0 && !f[0]); i = c.add(f, "b"); - assure("4", i == 0 && f[0]); + assertTrue(i == 0 && f[0]); i = c.add(f, "a"); - assure("5", i == 0 && !f[0]); + assertTrue(i == 0 && !f[0]); } - public void test2() { + @Test public void test2() { Cache c = new Cache(2); boolean[] f = new boolean[1]; int i; i = c.add(f, "a"); - assure("1", i == 0 && !f[0]); + assertTrue(i == 0 && !f[0]); i = c.add(f, "a"); - assure("2", i == 0 && f[0]); + assertTrue(i == 0 && f[0]); i = c.add(f, "b"); - assure("3", i == 1 && !f[0]); + assertTrue(i == 1 && !f[0]); i = c.add(f, "b"); - assure("4", i == 1 && f[0]); + assertTrue(i == 1 && f[0]); i = c.add(f, "a"); - assure("5", i == 0 && f[0]); + assertTrue(i == 0 && f[0]); i = c.add(f, "c"); - assure("6", i == 1 && !f[0]); + assertTrue(i == 1 && !f[0]); i = c.add(f, "b"); - assure("7", i == 0 && !f[0]); + assertTrue(i == 0 && !f[0]); } - public void test3() { + @Test public void test3() { Cache c = new Cache(3); boolean[] f = new boolean[1]; int i; i = c.add(f, "a"); - assure("1", i == 0 && !f[0]); + assertTrue(i == 0 && !f[0]); i = c.add(f, "a"); - assure("3", i == 0 && f[0]); + assertTrue(i == 0 && f[0]); i = c.add(f, "b"); - assure("5", i == 1 && !f[0]); + assertTrue(i == 1 && !f[0]); i = c.add(f, "a"); - assure("3", i == 0 && f[0]); + assertTrue(i == 0 && f[0]); i = c.add(f, "c"); - assure("7", i == 2 && !f[0]); + assertTrue(i == 2 && !f[0]); i = c.add(f, "d"); - assure("9", i == 1 && !f[0]); + assertTrue(i == 1 && !f[0]); i = c.add(f, "d"); - assure("11", i == 1 && f[0]); + assertTrue(i == 1 && f[0]); + } + + @Test public void testNothingLostFromLruList() { + // Regardless in what order arbitrary values from 0, ..., 3 are inserted + // into a size-4 cache, afterwards adding -1, ..., -4 must return each + // possible index in the range from 0, ..., 3 exactly once (so their sum + // must be 6); this code systematically tests all such arbitrary ways up + // to length 8 (the code arguably violates recommendations for writing + // good tests, but actually helped track down an error in the Cache + // implementation): + int[] a = new int[8]; + for (int i = 0; i < a.length; ++i) { + for (int j = 0; j < i; ++j) { + a[j] = 0; + } + for (;;) { + Cache c = new Cache(4); + for (int k = 0; k < i; ++k) { + c.add(new boolean[1], a[k]); + } + assertEquals( + 6, + (c.add(new boolean[1], -1) + c.add(new boolean[1], -2) + + c.add(new boolean[1], -3) + c.add(new boolean[1], -4))); + int j = i - 1; + while (j >= 0 && a[j] == 3) { + --j; + } + if (j < 0) { + break; + } + ++a[j]; + for (int k = j + 1; k < i; ++k) { + a[k] = 0; + } + } + } } } diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java index 4c01e9acc9c6..2621006faf95 100644 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java +++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/Marshaling_Test.java @@ -32,21 +32,14 @@ import com.sun.star.uno.IBridge; import com.sun.star.uno.Type; import com.sun.star.uno.TypeClass; import com.sun.star.uno.XInterface; -import complexlib.ComplexTestCase; import java.lang.reflect.Array; import java.lang.reflect.Field; import java.lang.reflect.Modifier; +import org.junit.Test; +import static org.junit.Assert.*; -public final class Marshaling_Test extends ComplexTestCase { - public String getTestObjectName() { - return getClass().getName(); - } - - public String[] getTestMethodNames() { - return new String[] { "test" }; - } - - public void test() throws Exception { +public final class Marshaling_Test { + @Test public void test() throws Exception { short cacheSize = (short)256; TestBridge testBridge = new TestBridge(); Marshal marshal = new Marshal(testBridge, cacheSize); @@ -239,7 +232,7 @@ public final class Marshaling_Test extends ComplexTestCase { if(op1 instanceof Any) op1 = ((Any)op1).getObject(); - assure("", compareObjects(op1, op2)); + assertTrue(compareObjects(op1, op2)); } } diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java b/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java index 393720c9756d..6a74710625e9 100644 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java +++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/Protocol_Test.java @@ -34,20 +34,17 @@ import com.sun.star.uno.Any; import com.sun.star.uno.IBridge; import com.sun.star.uno.Type; import com.sun.star.uno.XInterface; -import complexlib.ComplexTestCase; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; import java.util.LinkedList; +import org.junit.Test; +import static org.junit.Assert.*; -public final class Protocol_Test extends ComplexTestCase { - public String[] getTestMethodNames() { - return new String[] { "test" }; - } - - public void test() throws Exception { +public final class Protocol_Test { + @Test public void test() throws Exception { IBridge iBridge = new TestBridge(); PipedInputStream inA = new PipedInputStream(); PipedOutputStream outA = new PipedOutputStream(inA); @@ -93,7 +90,7 @@ public final class Protocol_Test extends ComplexTestCase { new Object[] { "hallo" }); Message iMessage = iReceiver.readMessage(); Object[] t_params = iMessage.getArguments(); - assure("", "hallo".equals((String)t_params[0])); + assertEquals("hallo", (String)t_params[0]); // send a reply iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null); @@ -118,7 +115,7 @@ public final class Protocol_Test extends ComplexTestCase { iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null); iSender.readMessage(); - assure("", "testString".equals(((String [])params[0])[0])); + assertEquals("testString", ((String [])params[0])[0]); } public void testCallWithInOutParameter( @@ -133,7 +130,7 @@ public final class Protocol_Test extends ComplexTestCase { Object[] t_params = iMessage.getArguments(); - assure("", "inString".equals(((String [])t_params[0])[0])); + assertEquals("inString", ((String [])t_params[0])[0]); // provide reply ((String [])t_params[0])[0] = "outString"; @@ -142,7 +139,7 @@ public final class Protocol_Test extends ComplexTestCase { iReceiver.writeReply(false, new ThreadId(new byte[] { 0, 1 }), null); iSender.readMessage(); - assure("", "outString".equals(((String [])params[0])[0])); + assertEquals("outString", ((String [])params[0])[0]); } public void testCallWithResult( @@ -161,7 +158,7 @@ public final class Protocol_Test extends ComplexTestCase { Message iMessage = iSender.readMessage(); Object result = iMessage.getResult(); - assure("", "resultString".equals(result)); + assertEquals("resultString", result); } public void testCallWhichRaisesException( @@ -181,7 +178,7 @@ public final class Protocol_Test extends ComplexTestCase { Object result = iMessage.getResult(); - assure("", result instanceof com.sun.star.uno.RuntimeException); + assertTrue(result instanceof com.sun.star.uno.RuntimeException); } public void testCallWithIn_Out_InOut_Paramters_and_result( @@ -196,9 +193,9 @@ public final class Protocol_Test extends ComplexTestCase { Object[] t_params = iMessage.getArguments(); - assure("", "hallo".equals((String)t_params[0])); + assertEquals("hallo", (String)t_params[0]); - assure("", "inOutString".equals(((String [])t_params[2])[0])); + assertEquals("inOutString", ((String [])t_params[2])[0]); ((String [])t_params[1])[0] = "outString"; ((String [])t_params[2])[0] = "inOutString_res"; @@ -209,11 +206,11 @@ public final class Protocol_Test extends ComplexTestCase { iMessage = iSender.readMessage(); Object result = iMessage.getResult(); - assure("", "outString".equals(((String [])params[1])[0])); + assertEquals("outString", ((String [])params[1])[0]); - assure("", "inOutString_res".equals(((String [])params[2])[0])); + assertEquals("inOutString_res", ((String [])params[2])[0]); - assure("", "resultString".equals(result)); + assertEquals("resultString", result); } public void testCallWhichReturnsAny( @@ -229,9 +226,11 @@ public final class Protocol_Test extends ComplexTestCase { false, new ThreadId(new byte[] { 0, 1 }), Any.VOID); Message iMessage = iSender.readMessage(); Object result = iMessage.getResult(); - assure("", result instanceof Any - && (TypeDescription.getTypeDescription(((Any) result).getType()). - getZClass() == void.class)); + assertTrue( + result instanceof Any && + ((TypeDescription.getTypeDescription(((Any) result).getType()). + getZClass()) == + void.class)); // send an ordinary request iSender.writeRequest( @@ -244,7 +243,7 @@ public final class Protocol_Test extends ComplexTestCase { new Any(XInterface.class, null)); iMessage = iSender.readMessage(); result = iMessage.getResult(); - assure("", result == null); + assertNull(result); // send an ordinary request iSender.writeRequest( @@ -256,7 +255,7 @@ public final class Protocol_Test extends ComplexTestCase { false, new ThreadId(new byte[] { 0, 1 }), new Integer(501)); iMessage = iSender.readMessage(); result = iMessage.getResult(); - assure("", result.equals(new Integer(501))); + assertEquals(501, result); } private static final class Endpoint { diff --git a/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk b/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk index c6e66558b65d..8403b2bd71ed 100644 --- a/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk +++ b/jurt/test/com/sun/star/lib/uno/protocols/urp/makefile.mk @@ -24,10 +24,16 @@ # for a copy of the LGPLv3 License. # #************************************************************************* + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + PRJ := ..$/..$/..$/..$/..$/..$/..$/.. PRJNAME := jurt TARGET := test_com_sun_star_lib_uno_protocols_urp +.IF "$(OOO_JUNIT_JAR)" != "" PACKAGE := com$/sun$/star$/lib$/uno$/protocols$/urp JAVATESTFILES := \ Cache_Test.java \ @@ -38,5 +44,8 @@ JAVAFILES := \ TestObject.java JARFILES := ridl.jar IDLTESTFILES := interfaces.idl +.END .INCLUDE: javaunittest.mk + +.END diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index 6557217f1463..52ea89176d12 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -50,16 +50,16 @@ using namespace osl; namespace jfw { -rtl::OString getElementUpdated() +rtl::OString getElement(::rtl::OString const & docPath, + xmlChar const * pathExpression, bool bThrowIfEmpty) { //Prepare the xml document and context - rtl::OString sSettingsPath = jfw::getVendorSettingsPath(); - OSL_ASSERT(sSettingsPath.getLength() > 0); - jfw::CXmlDocPtr doc(xmlParseFile(sSettingsPath.getStr())); + OSL_ASSERT(docPath.getLength() > 0); + jfw::CXmlDocPtr doc(xmlParseFile(docPath.getStr())); if (doc == NULL) throw FrameworkException( JFW_E_ERROR, - rtl::OString("[Java framework] Error in function getElementUpdated " + rtl::OString("[Java framework] Error in function getElement " "(elements.cxx)")); jfw::CXPathContextPtr context(xmlXPathNewContext(doc)); @@ -67,20 +67,42 @@ rtl::OString getElementUpdated() (xmlChar*) NS_JAVA_FRAMEWORK) == -1) throw FrameworkException( JFW_E_ERROR, - rtl::OString("[Java framework] Error in function getElementUpdated " + rtl::OString("[Java framework] Error in function getElement " "(elements.cxx)")); + CXPathObjectPtr pathObj; - pathObj = xmlXPathEvalExpression( - (xmlChar*)"/jf:javaSelection/jf:updated/text()", context); + pathObj = xmlXPathEvalExpression(pathExpression, context); + rtl::OString sValue; if (xmlXPathNodeSetIsEmpty(pathObj->nodesetval)) - throw FrameworkException( - JFW_E_ERROR, - rtl::OString("[Java framework] Error in function getElementUpdated " - "(elements.cxx)")); - rtl::OString sValue = (sal_Char*) pathObj->nodesetval->nodeTab[0]->content; + { + if (bThrowIfEmpty) + throw FrameworkException( + JFW_E_ERROR, + rtl::OString("[Java framework] Error in function getElement " + "(elements.cxx)")); + } + else + { + sValue = (sal_Char*) pathObj->nodesetval->nodeTab[0]->content; + } return sValue; } +rtl::OString getElementUpdated() +{ + return getElement(jfw::getVendorSettingsPath(), + (xmlChar*)"/jf:javaSelection/jf:updated/text()", true); +} + +// Use only in INSTALL mode !!! +rtl::OString getElementModified() +{ + //The modified element is only written in INSTALL mode. + //That is NodeJava::m_layer = INSTALL + return getElement(jfw::getInstallSettingsPath(), + (xmlChar*)"/jf:java/jf:modified/text()", false); +} + void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) { @@ -577,6 +599,21 @@ void NodeJava::write() const xmlAddChild(jreLocationsNode, nodeCrLf); } } + + if (INSTALL == m_layer) + { + //now write the current system time + ::TimeValue curTime = {0,0}; + if (::osl_getSystemTime(& curTime)) + { + rtl::OUString sSeconds = + rtl::OUString::valueOf((sal_Int64) curTime.Seconds); + xmlNewTextChild( + root,NULL, (xmlChar*) "modified", CXmlCharPtr(sSeconds)); + xmlNode * nodeCrLf = xmlNewText((xmlChar*) "\n"); + xmlAddChild(root, nodeCrLf); + } + } if (xmlSaveFormatFile(sSettingsPath.getStr(), docUser, 1) == -1) throw FrameworkException(JFW_E_ERROR, sExcMsg); } @@ -719,7 +756,7 @@ jfw::FileStatus NodeJava::checkSettingsFileStatus() const File::RC rc_stat = item.getFileStatus(stat); if (File::E_None == rc_stat) { - //ToDo we remove the file and create it shortly after. This + // This //function may be called multiple times when a java is started. //If the expiretime is too small then we may loop because everytime //the file is deleted and we need to search for a java again. @@ -730,16 +767,24 @@ jfw::FileStatus NodeJava::checkSettingsFileStatus() const //that after removing the file and shortly later creating it again //did not change the creation time. That is the newly created file //had the creation time of the former file. - ::TimeValue modTime = stat.getModifyTime(); ::TimeValue curTime = {0,0}; + ret = FILE_OK; if (sal_True == ::osl_getSystemTime(& curTime)) { - if ( curTime.Seconds - modTime.Seconds > + //get the modified time recorded in the <modified> element + sal_uInt32 modified = getModifiedTime(); + OSL_ASSERT(modified <= curTime.Seconds); + //Only if modified has a valued then NodeJava::write was called, + //then the xml structure was filled with data. + + if ( modified && curTime.Seconds - modified > BootParams::getInstallDataExpiration()) { #if OSL_DEBUG_LEVEL >=2 + fprintf(stderr, "[Java framework] Settings file is %d seconds old. \n", + (int)( curTime.Seconds - modified)); rtl::OString s = rtl::OUStringToOString(sURL, osl_getThreadTextEncoding()); - fprintf(stderr, "[Java framework] Deleting settings file at \n%s\n", s.getStr()); + fprintf(stderr, "[Java framework] Settings file is exspired. Deleting settings file at \n%s\n", s.getStr()); #endif //delete file File f(sURL); @@ -1089,6 +1134,17 @@ JavaInfo * CNodeJavaInfo::makeJavaInfo() const return pInfo; } +sal_uInt32 NodeJava::getModifiedTime() const +{ + sal_uInt32 ret = 0; + if (m_layer != INSTALL) + { + OSL_ASSERT(0); + return ret; + } + rtl::OString modTimeSeconds = getElementModified(); + return (sal_uInt32) modTimeSeconds.toInt64(); +} //================================================================================ MergedSettings::MergedSettings(): diff --git a/jvmfwk/source/elements.hxx b/jvmfwk/source/elements.hxx index 93aec47718e1..6efedbf96647 100644 --- a/jvmfwk/source/elements.hxx +++ b/jvmfwk/source/elements.hxx @@ -196,6 +196,34 @@ private: */ boost::optional< ::std::vector< ::rtl::OUString> > m_JRELocations; + /** Only in INSTALL mode. Then NodeJava.write writes a <modified> element + which contains the seconds value of the TimeValue (osl/time.h), obtained + with osl_getSystemTime. + It returns 0 if the value cannot be obtained. + This is used to fix the problem that the modified time of the settings + file is incorrect because it resides on an NFS volume where the NFS + server and NFS client do not have the same system time. For example if + the server time is ahead of the client time then checkSettingsFileStatus + deleted the settings. So even if javaldx determined a Java + (jfw_findAndSelectJRE) then jfw_startVM returned a JFW_E_NO_SELECT. Then + it looked again for a java by calling jfw_findAndSelectJRE, which + returned a JFW_E_NONE. But the following jfw_startVM returned again + JFW_E_NO_SELECT. So it looped. (see issue i114509) + + NFS server and NFS client should have the same time. It is common + practise to enforce this in networks. We actually should not work + around a malconfigured network. We must however, make sure that we do + not loop. Maybe a better approach is, that: + - assume that mtime and system time are reliable + - checkSettingsFile uses system time and mtime of the settings file, + instset of using getModifiedTime. + - allow a small error margin + - jfw_startVM must return a JFW_E_EXPIRED_SETTINGS + - XJavaVM::startVM should prevent the loop by processing the new return+ value + + */ + sal_uInt32 getModifiedTime() const; + public: NodeJava(Layer theLayer = USER_OR_INSTALL); diff --git a/offapi/com/sun/star/awt/AnimatedImagesControl.idl b/offapi/com/sun/star/awt/AnimatedImagesControl.idl new file mode 100755 index 000000000000..90f8b3a356e8 --- /dev/null +++ b/offapi/com/sun/star/awt/AnimatedImagesControl.idl @@ -0,0 +1,58 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_AnimatedImagesControl_idl__ +#define __com_sun_star_awt_AnimatedImagesControl_idl__ + +#include <com/sun/star/awt/UnoControl.idl> + +//====================================================================================================================== + +module com { module sun { module star { module awt { + +interface XAnimation; + +//====================================================================================================================== + +/** is the default control used for an <type>AnimatedImagesControlModel</type>, displayed a series of + images. + + @since OOo 3.4 + */ +service AnimatedImagesControl +{ + service com::sun::star::awt::UnoControl; + + interface XAnimation; +}; + +//====================================================================================================================== + +}; }; }; }; + +//====================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/AnimatedImagesControlModel.idl b/offapi/com/sun/star/awt/AnimatedImagesControlModel.idl new file mode 100755 index 000000000000..2bc1260775c9 --- /dev/null +++ b/offapi/com/sun/star/awt/AnimatedImagesControlModel.idl @@ -0,0 +1,57 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_AnimatedImagesControlModel_idl__ +#define __com_sun_star_awt_AnimatedImagesControlModel_idl__ + +#include <com/sun/star/awt/UnoControlModel.idl> + +//====================================================================================================================== + +module com { module sun { module star { module awt { + +interface XAnimatedImages; + +//====================================================================================================================== + +/** describes the model for a control displaying a series of images + + @since OOo 3.4 + */ +service AnimatedImagesControlModel +{ + service com::sun::star::awt::UnoControlModel; + + interface XAnimatedImages; +}; + +//====================================================================================================================== + +}; }; }; }; + +//====================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/SpinningProgressControlModel.idl b/offapi/com/sun/star/awt/SpinningProgressControlModel.idl new file mode 100755 index 000000000000..a75417d41cc3 --- /dev/null +++ b/offapi/com/sun/star/awt/SpinningProgressControlModel.idl @@ -0,0 +1,54 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_SpinningProgressControlModel_idl__ +#define __com_sun_star_awt_SpinningProgressControlModel_idl__ + +#include <com/sun/star/awt/AnimatedImagesControlModel.idl> + +//====================================================================================================================== + +module com { module sun { module star { module awt { + +//====================================================================================================================== + +/** is a specialization of the <type>AnimatedImagesControlModel</type> which provides standard image sets + for displaying a non-procentual progress. + + <p>Three image sets are provided, of size 16x16, 32x32, and 64x64 pixels.</p> + */ +service SpinningProgressControlModel +{ + service AnimatedImagesControlModel; +}; + +//====================================================================================================================== + +}; }; }; }; + +//====================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/UnoControlDialog.idl b/offapi/com/sun/star/awt/UnoControlDialog.idl index 443b0da18563..f2f1be2dc49c 100644 --- a/offapi/com/sun/star/awt/UnoControlDialog.idl +++ b/offapi/com/sun/star/awt/UnoControlDialog.idl @@ -35,8 +35,8 @@ #include <com/sun/star/awt/XTopWindow.idl> #endif -#ifndef __com_sun_star_awt_XDialog_idl__ -#include <com/sun/star/awt/XDialog.idl> +#ifndef __com_sun_star_awt_XDialog2_idl__ +#include <com/sun/star/awt/XDialog2.idl> #endif @@ -54,7 +54,7 @@ published service UnoControlDialog interface com::sun::star::awt::XTopWindow; - interface com::sun::star::awt::XDialog; + interface com::sun::star::awt::XDialog2; }; diff --git a/offapi/com/sun/star/awt/UnoControlDialogModelProvider.idl b/offapi/com/sun/star/awt/UnoControlDialogModelProvider.idl new file mode 100644 index 000000000000..a91065f72d66 --- /dev/null +++ b/offapi/com/sun/star/awt/UnoControlDialogModelProvider.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_UnoControlDialogModelProvider_idl__ +#define __com_sun_star_awt_UnoControlDialogModelProvider_idl__ + +#include <com/sun/star/container/XNameContainer.idl> +#include <com/sun/star/beans/XPropertySet.idl> +#include <com/sun/star/lang/IllegalArgumentException.idl> + +//============================================================================= + +module com { module sun { module star { module awt { + +//============================================================================= + +/** specifies a service to load a dialog model and allows to access the control models inside + + @since OOo 3.3.0 + */ +service UnoControlDialogModelProvider : com::sun::star::container::XNameContainer +{ + /** Creates a new dialog model + */ + create([in] string URL)raises ( com::sun::star::lang::IllegalArgumentException ); +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/UnoControlSimpleAnimation.idl b/offapi/com/sun/star/awt/UnoControlSimpleAnimation.idl index cf45f0aea0f0..b00ec8740521 100644..100755 --- a/offapi/com/sun/star/awt/UnoControlSimpleAnimation.idl +++ b/offapi/com/sun/star/awt/UnoControlSimpleAnimation.idl @@ -42,17 +42,14 @@ //============================================================================= -/** specifies a simple animation control. - - <p>The model of an <type>UnoControlSimpleAnimation</type> control must support - the <type>UnoControlSimpleAnimationModel</type> service.</p> - +/** @since OOo 2.2 + @deprecated + You should use <type>AnimatedImagesControl</type>. */ published service UnoControlSimpleAnimation { service com::sun::star::awt::UnoControl; - interface com::sun::star::awt::XSimpleAnimation; }; diff --git a/offapi/com/sun/star/awt/UnoControlSimpleAnimationModel.idl b/offapi/com/sun/star/awt/UnoControlSimpleAnimationModel.idl index ca301483263f..1f96099fee63 100644..100755 --- a/offapi/com/sun/star/awt/UnoControlSimpleAnimationModel.idl +++ b/offapi/com/sun/star/awt/UnoControlSimpleAnimationModel.idl @@ -38,36 +38,16 @@ //============================================================================= -/** specifies the standard model of an <type>UnoControlSimpleAnimation</type>. - - <p>The simple animation control displays a sequence of images.</p> - - <p> </p> - - @see UnoControlScrollBarModel +/** @since OOo 2.2 + @deprecated + You should use <type>AnimatedImagesControlModel</type>. */ published service UnoControlSimpleAnimationModel { service com::sun::star::awt::UnoControlModel; - - //------------------------------------------------------------------------- - - /** specifies the time in milliseconds between two animation steps. - - <pre>This is the minimum time, the actual value might be longer due to - system load. The default value will be 100 ms.</pre> - */ [property] long StepTime; - - //------------------------------------------------------------------------- - - /** specifies whether the animation will restart again after displaying the last - image. - - <p>The default is FALSE.</p> - */ [property] boolean AutoRepeat; }; diff --git a/offapi/com/sun/star/awt/UnoControlThrobber.idl b/offapi/com/sun/star/awt/UnoControlThrobber.idl index f5194075019a..85b5d8b850f7 100644 --- a/offapi/com/sun/star/awt/UnoControlThrobber.idl +++ b/offapi/com/sun/star/awt/UnoControlThrobber.idl @@ -42,17 +42,14 @@ //============================================================================= -/** specifies a simple animation control. - - <p>The model of an <type>UnoControlThrobber</type> control must support - the <type>UnoControlThrobberModel</type> service.</p> - +/** @since OOo 2.2 + @deprecatd + You should use <type>AnimatedImagesControl</type>. */ published service UnoControlThrobber { service com::sun::star::awt::UnoControl; - interface com::sun::star::awt::XThrobber; }; diff --git a/offapi/com/sun/star/awt/UnoControlThrobberModel.idl b/offapi/com/sun/star/awt/UnoControlThrobberModel.idl index f2eacad5b76b..060ff105c119 100644 --- a/offapi/com/sun/star/awt/UnoControlThrobberModel.idl +++ b/offapi/com/sun/star/awt/UnoControlThrobberModel.idl @@ -38,14 +38,10 @@ //============================================================================= -/** specifies the standard model of an <type>UnoControlThrobber</type>. - - <p>The simple animation control displays a sequence of images.</p> - - <p> </p> - - @see UnoControlScrollBarModel +/** @since OOo 2.2 + @deprecatd + You should use <type>SpinningAnimationControlModel</type>. */ published service UnoControlThrobberModel diff --git a/offapi/com/sun/star/awt/XAnimatedImages.idl b/offapi/com/sun/star/awt/XAnimatedImages.idl new file mode 100755 index 000000000000..a03d08c965f1 --- /dev/null +++ b/offapi/com/sun/star/awt/XAnimatedImages.idl @@ -0,0 +1,176 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_XAnimatedImages_idl__ +#define __com_sun_star_awt_XAnimatedImages_idl__ + +#include <com/sun/star/container/XContainerListener.idl> +#include <com/sun/star/lang/IndexOutOfBoundsException.idl> +#include <com/sun/star/container/XContainer.idl> +#include <com/sun/star/lang/IllegalArgumentException.idl> + +//====================================================================================================================== + +module com { module sun { module star { module awt { + +//====================================================================================================================== + +/** allows administrating a set of images, to be displayed as animated seres. + + <p>Components implementing this interface maintain a variable number of image sets. Components displaying + those images will choose the best-fitting image set depending on the available space, and possibly other + restrictions.</p> + + @since OOo 3.4 + */ +interface XAnimatedImages +{ + /** specifies the time in milliseconds between two animation steps. + + <p>This is the minimum time, the actual value might be longer due to + system load. The default value will be 100 ms.</p> + */ + [attribute] long StepTime; + + /** specifies whether the animation should start over with the first image of the image series when the last image + has been played. + + <p>The default value for this attribute is <TRUE/>.</p> + */ + [attribute] boolean AutoRepeat; + + /** controls the way the images are scaled up or down, when the available space is larger or smaller + than what is needed for them. + + <p>Allowed values are those from the <type>ImageScaleMode</type> constants group.</p> + */ + [attribute] short ScaleMode + { + set raises (::com::sun::star::lang::IllegalArgumentException); + }; + + /** returns the number of images sets maintained by the component. + */ + long + getImageSetCount(); + + /** returns the URLs of the image set with the given index + + @param i_index + the index of the set those image URLs are to be retrieved. Must be greater than or equal to <code>0</code>, + and smaller than the value returned by <member>getImageSetCount</member>. + + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the <code>i_index</code> is not a valid index. + */ + sequence< string > + getImageSet + ( + [in] long i_index + ) + raises + ( + ::com::sun::star::lang::IndexOutOfBoundsException + ); + + /** sets the URLs of the image set with the given index + + @param i_index + the index at which a new image set should be inserted. Must be greater than or equal to <code>0</code>, + and smaller than or equal to the value returned by <member>getImageSetCount</member>. + @param i_imageURLs + the URLs for the images for the given set. Will be resolved using a <type scope="com::sun::star::graphic">GraphicProvider</type>. + + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the <code>i_index</code> is not a valid index. + */ + void + insertImageSet + ( + [in] long i_index, + [in] sequence< string > i_imageURLs + ) + raises + ( + ::com::sun::star::lang::IndexOutOfBoundsException + ); + + /** replaces the image set given by index with a new one + + @param i_index + the index of the set those image URLs are to be replaced. Must be greater than or equal to <code>0</code>, + and smaller than the value returned by <member>getImageSetCount</member>. + + @param i_imageURLs + the URLs for the images for the given set. Will be resolved using a <type scope="com::sun::star::graphic">GraphicProvider</type>. + + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the <code>i_index</code> is not a valid index. + */ + void + replaceImageSet + ( + [in] long i_index, + [in] sequence< string > i_imageURLs + ) + raises + ( + ::com::sun::star::lang::IndexOutOfBoundsException + ); + + + /** removes the image set with the given index + + @param i_index + the index of the set to remove. Must be greater than or equal to <code>0</code>, + and smaller than the value returned by <member>getImageSetCount</member>. + + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the <code>i_index</code> is not a valid index. + */ + void + removeImageSet + ( + [in] long i_index + ) + raises + ( + ::com::sun::star::lang::IndexOutOfBoundsException + ); + + + /** allows other components to observer the insertion, removal, and replacement of image sets + */ + interface ::com::sun::star::container::XContainer; +}; + +//====================================================================================================================== + +}; }; }; }; + +//====================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/XAnimation.idl b/offapi/com/sun/star/awt/XAnimation.idl new file mode 100755 index 000000000000..e1e8f6023a7d --- /dev/null +++ b/offapi/com/sun/star/awt/XAnimation.idl @@ -0,0 +1,63 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_XAnimation_idl__ +#define __com_sun_star_awt_XAnimation_idl__ + +#include <com/sun/star/uno/XInterface.idl> + +//====================================================================================================================== + +module com { module sun { module star { module awt { + +//====================================================================================================================== + +/** allows controlling an animation. + + @since OOo 3.4 + */ +interface XAnimation +{ + /** starts the animation + */ + void startAnimation(); + + /** stops the animation + */ + void stopAnimation(); + + /** determines whether the animation is currently running + */ + boolean isAnimationRunning(); +}; + +//====================================================================================================================== + +}; }; }; }; + +//====================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/XDialog2.idl b/offapi/com/sun/star/awt/XDialog2.idl index cd42d792cd0a..e937dea9bb24 100644 --- a/offapi/com/sun/star/awt/XDialog2.idl +++ b/offapi/com/sun/star/awt/XDialog2.idl @@ -16,7 +16,7 @@ module com { module sun { module star { module awt { @since OOo 3.0 */ -interface XDialog2: com::sun::star::awt::XDialog +published interface XDialog2: com::sun::star::awt::XDialog { /** hides the dialog and then causes <member>XDialog::execute</member> to return with the given result value. @@ -25,7 +25,7 @@ interface XDialog2: com::sun::star::awt::XDialog /** sets the help id so that the standard help button action will show the appropriate help page. */ - void setHelpId ( [in] long Id ); + void setHelpId ( [in] string Id ); }; //============================================================================= diff --git a/offapi/com/sun/star/awt/XSimpleAnimation.idl b/offapi/com/sun/star/awt/XSimpleAnimation.idl index 1cfd758590b9..bff9eeeb5a90 100644..100755 --- a/offapi/com/sun/star/awt/XSimpleAnimation.idl +++ b/offapi/com/sun/star/awt/XSimpleAnimation.idl @@ -41,28 +41,15 @@ //============================================================================= -/** Controls the animation control. +/** + @deprecated + You should use <type>XAnimation</type>, <type>AnimatedImagesControl</type>, and <type>AnimatedImagesControlModel</type>. */ published interface XSimpleAnimation: com::sun::star::uno::XInterface { - //------------------------------------------------------------------------- - - /** starts the animation of the control. - */ void start(); - - //------------------------------------------------------------------------- - - /** stops the animation of the control. - */ void stop(); - - //------------------------------------------------------------------------- - - /** The list of images to be displayed. - */ void setImageList( [in] sequence < com::sun::star::graphic::XGraphic > ImageList ); - }; //============================================================================= diff --git a/offapi/com/sun/star/awt/XThrobber.idl b/offapi/com/sun/star/awt/XThrobber.idl index 0a4ac133524a..04dc6887cbe9 100644 --- a/offapi/com/sun/star/awt/XThrobber.idl +++ b/offapi/com/sun/star/awt/XThrobber.idl @@ -41,20 +41,13 @@ //============================================================================= -/** Controls the animation control. +/** + @deprecatd + You should use <type>XAnimation</type>, <type>AnimatedImagesControl</type>, and <type>AnimatedImagesControlModel</type>. */ published interface XThrobber: com::sun::star::uno::XInterface { - //------------------------------------------------------------------------- - - /** starts the animation of the control. - */ void start(); - - //------------------------------------------------------------------------- - - /** stops the animation of the control. - */ void stop(); }; diff --git a/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl b/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl index c487afc79b49..8c2726f42851 100644 --- a/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl +++ b/offapi/com/sun/star/awt/grid/DefaultGridDataModel.idl @@ -27,9 +27,7 @@ #ifndef __com_sun_star_awt_DefaultGridDataModel_idl__ #define __com_sun_star_awt_DefaultGridDataModel_idl__ -#ifndef __com_sun_star_awt_grid_XGridDataModel_idl__ -#include <com/sun/star/awt/grid/XGridDataModel.idl> -#endif +#include <com/sun/star/awt/grid/XMutableGridDataModel.idl> //============================================================================= @@ -39,12 +37,15 @@ /** If you do not want to implement the <type>XGridDataModel</type> yourself, use this service. + <p>The <code>DefaultGridDataModel</code> implementation is a dumb container of tabular data. You can add + and remove rows, modify cell values, and the like.</p> + + <p>The implementation will implicitly increase its column count if you add a row which has more values than + the current column count.</p> + @since OOo 3.3.0 */ -service DefaultGridDataModel -{ - interface com::sun::star::awt::grid::XGridDataModel; -}; +service DefaultGridDataModel : ::com::sun::star::awt::grid::XMutableGridDataModel; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/GridColumnEvent.idl b/offapi/com/sun/star/awt/grid/GridColumnEvent.idl index caab721185a5..4ab6e71caf51 100644 --- a/offapi/com/sun/star/awt/grid/GridColumnEvent.idl +++ b/offapi/com/sun/star/awt/grid/GridColumnEvent.idl @@ -42,17 +42,17 @@ module com { module sun { module star { module awt { module grid { */ struct GridColumnEvent: com::sun::star::lang::EventObject { - /** Contains the property name of the changed value **/ - string valueName; + /** Contains the name of the attributes whose value changed. **/ + string AttributeName; /** Contains the old value **/ - any oldValue; + any OldValue; /** Contains the new value **/ - any newValue; + any NewValue; /** Contains the index of the changed column**/ - long index; + long ColumnIndex; //------------------------------------------------------------------------- }; diff --git a/offapi/com/sun/star/awt/grid/GridDataEvent.idl b/offapi/com/sun/star/awt/grid/GridDataEvent.idl index 7762892fadea..3ac05f0ec1ae 100644 --- a/offapi/com/sun/star/awt/grid/GridDataEvent.idl +++ b/offapi/com/sun/star/awt/grid/GridDataEvent.idl @@ -35,40 +35,39 @@ module com { module sun { module star { module awt { module grid { //============================================================================= -/** An event used by a <type>XGridDataModel</type> to notify changes in the data - model to the <type>XGridControl</type>. - You usually need to fill this event only if you implement the <type>XGridDataModel</type> - yourself. +/** used to notify changes in the data represented by an <type>XMutableGridDataModel</type>. - @see XGridDataModel - @see XGridControl + <p>Effectively, a <code>GridDataEvent</code> denotes a continuous two-dimensional cell range + within a grid's data model, which is affected by a certain change.</p> + + @see XMutableGridDataModel @see XGridDataListener @since OOo 3.3.0 */ struct GridDataEvent: com::sun::star::lang::EventObject { - //------------------------------------------------------------------------- - - /** Contains the property name of the changed value **/ - string valueName; - - /** Contains the old value **/ - any oldValue; - - /** Contains the new value **/ - any newValue; + /** denotes the first column affected by a change. - /** Contains the index of the changed row**/ - long index; + <p>If <code>FirstColumn</code> is -1, the listener should assume that all rows of a grid's data model + are affected.</p> + */ + long FirstColumn; - /** Contains the header name of the changed row**/ - string headerName; + /** denotes the last column affected by a change + */ + long LastColumn; - /** Contains the changed row**/ - sequence<any> rowData; + /** denotes the first row affected by a change. + <p>If <code>FirstRow</code> is -1, the listener should assume that all rows of a grid's data model + are affected.</p> + */ + long FirstRow; + /** denotes the last row affected by a change + */ + long LastRow; }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/SortableGridDataModel.idl b/offapi/com/sun/star/awt/grid/SortableGridDataModel.idl new file mode 100755 index 000000000000..2b7aca1ca9f9 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/SortableGridDataModel.idl @@ -0,0 +1,102 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_grid_SortableGridDataModel_idl__ +#define __com_sun_star_awt_grid_SortableGridDataModel_idl__ + +#include <com/sun/star/i18n/XCollator.idl> +#include <com/sun/star/lang/IllegalArgumentException.idl> + +//================================================================================================================== + +module com { module sun { module star { module awt { module grid { + +interface XSortableMutableGridDataModel; +interface XMutableGridDataModel; + +//================================================================================================================== + +/** provides a default implementation of a <type>XSortableGridData</type>. + + <p>This service must be created with a secondary grid data model, which all actual data requests are delegated to. + But before providing this data to the service's own clients, it is sorted, according to the sort order defined + via the <code>XSortableGridData</code> interface.</p> + + <p>The service implementation is able to compare the default scalar types, plus strings.</p> + + <p>For determining the data type of a column which the data should be sorted by, the first non-<VOID/> data encountered + in this column is taken into account. Further read requests to this column will assume that all non-<VOID/> data is of + the same type.</p> + + <p>Consequently, you cannot use this service with data sets containing heterogenous data in a given column.</p> + + <p>All requests made via the <type>XMutableGridDataModel</type> are delegated to the <code>XMutableGridDataModel</code> + instance passed in the service constructor.</p> + + <p>Note that changing the data might result in the sort order being destroyed. If you want to ensure + that the data represented by the model is still sorted after your modifications, you should call + <member>XSortableGridData::sortByColumn</member>, again.</p> + */ +service SortableGridDataModel : XSortableMutableGridDataModel +{ + /** creates a new instance of the <code>SortableGridDataModel</code> + + <p>For string comparison, a default <type scope="::com::sun::star::i18n">Collator</type>, based on the system's + locale, will be used.</p> + + @param DelegatorModel + the data model to which read requests are delegated. + @throws ::com::sun::star::lang::IllegalArgumentException + if the given <code>DelegatorModel</code> is <NULL/> + */ + create( + [in] XMutableGridDataModel DelegatorModel + ) + raises ( ::com::sun::star::lang::IllegalArgumentException ); + + /** creates a new instance of the ScortableDefaultGridDataModel, passing a collator to be used for string comparison. + + @param DelegatorModel + is the data model to which read requests are delegated + @param Collator + is the collator to be used for string comparison + @throws ::com::sun::star::lang::IllegalArgumentException + if the given <code>DelegatorModel</code> is <NULL/> + */ + createWithCollator( + [in] XMutableGridDataModel DelegatorModel, + [in] ::com::sun::star::i18n::XCollator Collator + ) + raises ( ::com::sun::star::lang::IllegalArgumentException ); +}; + +//================================================================================================================== + +}; }; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl index 7eea49624045..a348d4b3e23c 100644 --- a/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl +++ b/offapi/com/sun/star/awt/grid/UnoControlGridModel.idl @@ -28,19 +28,11 @@ #define __com_sun_star_awt_grid_UnoControlGridModel_idl__ #include <com/sun/star/awt/grid/XGridColumnModel.idl> - #include <com/sun/star/awt/grid/XGridDataModel.idl> - -#include <com/sun/star/awt/grid/ScrollBarMode.idl> - #include <com/sun/star/awt/UnoControlModel.idl> - #include <com/sun/star/view/SelectionType.idl> - #include <com/sun/star/awt/FontDescriptor.idl> - #include <com/sun/star/style/VerticalAlignment.idl> - #include <com/sun/star/util/Color.idl> //============================================================================= @@ -49,7 +41,7 @@ module com { module sun { module star { module awt { module grid { //============================================================================= -/** specifies the standard model of a <type>UnoControlGridModel</type>. +/** specifies the standard model of a <type>UnoControlGrid</type> control. @since OOo 3.3.0 */ @@ -59,19 +51,51 @@ service UnoControlGridModel service com::sun::star::awt::UnoControlModel; /** Specifies whether the grid control should display a special header column. - <p>The default value is <FALSE/></p> + + <p>The default value is <FALSE/></p> */ [property] boolean ShowRowHeader; + /** specifies the width of the row header column, if applicable. + + <p>The width is specified in application font units - see <type scope="com::sun::star::util">MeasureUnit</type>.</p> + + <p>The value given here is ignored if <member>ShowRowHeader</member> is <FALSE/>.</p> + */ + [property] long RowHeaderWidth; + /** Specifies whether the grid control should display a title row. - <p>The default value is <TRUE/></p> + + <p>The default value is <TRUE/></p> */ [property] boolean ShowColumnHeader; + /** specifies the height of the column header row, if applicable. + + <p>The height is specified in application font units - see <type scope="com::sun::star::util">MeasureUnit</type>.</p> + + <p>The value given here is ignored if <member>ShowColumnHeader</member> is <FALSE/>.</p> + + <p>If the property is <void/>, the grid control shall automatically determine a height which conveniently allows, + according to the used font, to display one line of text.</p> + */ + [property, maybevoid] long ColumnHeaderHeight; + + /** Specifies the height of rows in the grid control. + + <p>The height is specified in application font units - see <type scope="com::sun::star::util">MeasureUnit</type>.</p> + */ + [property, maybevoid] long RowHeight; + /** Specifies the <type>XGridColumnModel</type> that is providing the column structure. <p>You can implement your own instance of <type>XGridColumnModel</type> or use the <type>DefaultGridColumnModel</type>. + + <p>The column model is in the ownership of the grid model: When you set a new column model, or dispose + the grid model, then the (old) column model is disposed, too.</p> + + <p>The default for this property is an empty instance of the <type>DefaultGridColumnModel</type>.</p> */ [property] XGridColumnModel ColumnModel; @@ -79,8 +103,13 @@ service UnoControlGridModel <p>You can implement your own instance of <type>XGridDataModel</type> or use the <type>DefaultGridDataModel</type>. + + <p>The data model is in the ownership of the grid model: When you set a new data model, or dispose + the grid model, then the (old) data model is disposed, too.</p> + + <p>The default for this property is an empty instance of the <type>DefaultGridDataModel</type>.</p> */ - [property] XGridDataModel DataModel; + [property] XGridDataModel GridDataModel; /** Specifies the vertical scrollbar mode. <p>The default value is <FALSE/></p> @@ -101,26 +130,48 @@ service UnoControlGridModel */ [property] ::com::sun::star::view::SelectionType SelectionModel; - /** Specifies the background color of rows. If color for even rows is set, then specifies - the color of odd rows. Default value is white. + /** controls whether or not to paint horizontal and vertical lines between the grid cells. + + @see LineColor */ - [property] ::com::sun::star::util::Color RowBackgroundColor; + [property] boolean UseGridLines; + + /** specifies the color to be used when drawing lines between cells - /** Specifies the background color of even rows. Default value is white. + <p>If this property has a value of <VOID/>, the grid control renderer will use some default color, + depending on the system's style settings.</p> + + @see UseGridLines */ - [property] ::com::sun::star::util::Color EvenRowBackgroundColor; + [property, maybevoid] ::com::sun::star::util::Color GridLineColor; + + /** specifies the color to be used when drawing the background of row or column headers - /** Specifies the background color of header. Default value is white. + <p>If this property has a value of <VOID/>, the grid control renderer will use some default color, + depending on the system's style settings.</p> */ - [property] ::com::sun::star::util::Color HeaderBackgroundColor; + [property, maybevoid] ::com::sun::star::util::Color HeaderBackgroundColor; - /** Specifies the text color. Default value is black. + /** specifies the color to be used when drawing the text within row or column headers + + <p>If this property has a value of <VOID/>, the grid control renderer will use some default color, + depending on the system's style settings.</p> */ - [property] ::com::sun::star::util::Color TextColor; + [property, maybevoid] ::com::sun::star::util::Color HeaderTextColor; + + /** specifies the colors to be used as background for data rows. + + <p>If this sequence is non-empty, the data rows will be rendered with alternating background colors: Assuming + the sequence has <code>n</code> elements, each row will use the background color as specified by its number's + remainder modulo <code>n</code>.</p> - /** Specifies the line color. Default value is white. + <p>If this sequence is empty, all rows will use the same background color as the control as whole.</p> + + <p>If this property does not exist at a particular implementation, or is <VOID/>, rows will be painted + in alternating background colors, every second row having a background color derived from the control's + selection color.</p> */ - [property] ::com::sun::star::util::Color LineColor; + [property, maybevoid] sequence< ::com::sun::star::util::Color > RowBackgroundColors; /** specifies the vertical alignment of the content in the control. @@ -136,6 +187,20 @@ service UnoControlGridModel */ [property] com::sun::star::awt::FontDescriptor FontDescriptor; + /** specifies the color to be used when drawing cell texts + + <p>If this property has a value of <VOID/>, the grid control renderer will use some default color, + depending on the system's style settings.</p> + */ + [property, maybevoid] ::com::sun::star::util::Color TextColor; + + /** specifies the color to be used when drawing text lines (underlining and strikethrough) + + <p>If this property has a value of <VOID/>, the grid control renderer will use some default color, + depending on the system's style settings.</p> + */ + [property, maybevoid] com::sun::star::util::Color TextLineColor; + /** specifies the <type scope="com::sun::star::text">FontEmphasis</type> value of the text in the control. */ diff --git a/offapi/com/sun/star/awt/grid/XGridColumn.idl b/offapi/com/sun/star/awt/grid/XGridColumn.idl index 4c340eb90e7e..46e651e60fa4 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumn.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumn.idl @@ -27,12 +27,11 @@ #ifndef __com_sun_star_awt_grid_XGridColumn_idl__ #define __com_sun_star_awt_grid_XGridColumn_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#include <com/sun/star/lang/XComponent.idl> #include <com/sun/star/style/HorizontalAlignment.idl> +#include <com/sun/star/lang/IllegalArgumentException.idl> #include <com/sun/star/awt/grid/XGridColumnListener.idl> - +#include <com/sun/star/util/XCloneable.idl> //============================================================================= @@ -45,42 +44,96 @@ module com { module sun { module star { module awt { module grid { */ interface XGridColumn { - /** Specifies the identifier of the column.**/ + /** implements life time control for the component + */ + interface ::com::sun::star::lang::XComponent; + + /** allows cloning the complete grid column + */ + interface ::com::sun::star::util::XCloneable; + + /** specifies an identifier of the column + + <p>This identifier will not be evaluated by the grid control, or its model. It is merely for clients + to identify particular columns.</p> + */ [attribute] any Identifier; - /** Specifies the default column width. **/ + /** specifies the current width of the column. + */ [attribute] long ColumnWidth; - /** Specifies the preferred column width. **/ - [attribute] long PreferredWidth; - - /** Specifies the min column width. **/ + /** specifies the minimal width the column can have. + */ [attribute] long MinWidth; - /** Specifies the max column width. **/ + /** specifies the maximal width the column can have. + */ [attribute] long MaxWidth; - /** Specifies whether column has fixed size or not. **/ + /** controls whether or not the column's width is fixed or not. + + <p>If this is <TRUE/>, the user can interactively change the column's width. Also, the column is subject to + auto-resizing, if its <member>Flexibility</member> attribute is greater <code>0</code>.</p> + */ [attribute] boolean Resizeable; - /** Specifies the horizontal alignment of the content in the control. + /** specifies the flexibility of the column when it is automatically resized due to the grid control as a whole + being resized. + + <p>Specify <code>0</code> here if you do not want the column to be resized automatically.</p> + + <p>If a column has a flexibility greater than 0, it is set in relationship to the flexibility of all + other such columns, and the respective widths of the columns are changed in the same relationship.</p> + + <p>Note that a column's flexibility is ignored if its <member>Resizeable</member> attribute is + <FALSE/>.</p> - <pre> - LEFT - CENTER - RIGHT - </pre> + <p>A column's flexibility cannot be negative, attempts to set a negative value will raise an exception.</p> + */ + [attribute] long Flexibility + { + set raises ( ::com::sun::star::lang::IllegalArgumentException ); + }; + + /** Specifies the horizontal alignment of the content in the control. */ [attribute] ::com::sun::star::style::HorizontalAlignment HorizontalAlign; /** A title is displayed in the column header row if <method>UnoControlGridModel::ShowRowHeader</method> is set to <true/>**/ [attribute] string Title; + /** is the help text associated with the column. + + <p>A grid control will usually display a column's help text as tooltip.</p> + */ + [attribute] string HelpText; + + /** denotes the index of the column within the grid column model it belongs to + + <p>If the column is not yet part of a column model, <code>Index</code> is -1.</p> + */ + [attribute, readonly] long Index; + + /** denotes the index of the data column which should be used to fetch this grid column's data + + <p>A grid control has a column model and a data model, both containing a possibly different number of columns. + The <code>DataColumnIndex</code> attribute defines the index of the column within the data model, which should + be used to retrieve actual data.</p> + + <p>Using this, you can do runtime changes to the column model, i.e. insertion and removal of columns, without + necessarily needing to adjust the data model, too.</p> + + <p>If <code>DataColumnIndex</code> is negative, the it will be ignored, then the column's index within its + column model, as determined by the <member>Index</member> attribute, will be used.</p> + */ + [attribute] long DataColumnIndex; + /** Adds a listener for the <type>GridColumnEvent</type> posted after the grid changes. @param Listener the listener to add. */ - [oneway] void addColumnListener( [in] XGridColumnListener listener); + void addGridColumnListener( [in] XGridColumnListener listener); //------------------------------------------------------------------------- @@ -88,20 +141,7 @@ interface XGridColumn @param Listener the listener to remove. */ - [oneway] void removeColumnListener( [in] XGridColumnListener listener); - - /**Updates changed column widths, when column widths are being resized. - @param name - can be PrefWidth or ColWidth, depending on which was changed - @param width - the new column width - */ - void updateColumn( [in] string name, [in] long width); - /**Sets column index - @param index - index, which is the index of the column in the column array of the column model - */ - void setIndex( [in] long index ); + void removeGridColumnListener( [in] XGridColumnListener listener); }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridColumnListener.idl b/offapi/com/sun/star/awt/grid/XGridColumnListener.idl index 8a2d044f33d5..9a8a02eca8f2 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumnListener.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumnListener.idl @@ -27,13 +27,8 @@ #ifndef __com_sun_star_awt_grid_XGridColumnListener_idl__ #define __com_sun_star_awt_grid_XGridColumnListener_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif - -#ifndef __com_sun_star_awt_grid_GridColumnEvent_idl__ #include <com/sun/star/awt/grid/GridColumnEvent.idl> -#endif +#include <com/sun/star/lang/XEventListener.idl> //============================================================================= @@ -44,25 +39,11 @@ module com { module sun { module star { module awt { module grid { /** An instance of this interface is used by the <type>XGridColumnModel</type> to get notifications about column model changes. - <p>Usually you must not implement this interface yourself, but you must notify it correctly if - you implement the <type>XGridColumnModel</type> yourself</p>. - @since OOo 3.3.0 */ -interface XGridColumnListener +interface XGridColumnListener : ::com::sun::star::lang::XEventListener { - // /** - // Invoked after a column was added to the column model. - //*/ - //void columnAdded( [in] GridColumnEvent event ); - // - // /** - // Invoked after a column was removed from the column model. - //*/ - //void columnRemoved( [in] GridColumnEvent event ); - - /** - Invoked after a column was modified. + /** Invoked after a column was modified. */ void columnChanged( [in] GridColumnEvent event ); }; diff --git a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl index 86e77680cd95..257f597fc7d2 100644 --- a/offapi/com/sun/star/awt/grid/XGridColumnModel.idl +++ b/offapi/com/sun/star/awt/grid/XGridColumnModel.idl @@ -28,10 +28,13 @@ #define __com_sun_star_awt_grid_XGridColumnModel_idl__ #include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/lang/XComponent.idl> +#include <com/sun/star/util/XCloneable.idl> #include <com/sun/star/awt/grid/XGridColumn.idl> - -#include <com/sun/star/awt/grid/XGridColumnListener.idl> +#include <com/sun/star/container/XContainer.idl> +#include <com/sun/star/lang/IndexOutOfBoundsException.idl> +#include <com/sun/star/lang/IllegalArgumentException.idl> //============================================================================= @@ -48,37 +51,64 @@ module com { module sun { module star { module awt { module grid { */ interface XGridColumnModel { - ///** Specifies whether column selection is allowed - //*/ - //[attribute] boolean ColumnSelectionAllowed; + /** implements life time control for the component + */ + interface ::com::sun::star::lang::XComponent; + + /** allows to register listeners to be notified when columns are inserted or removed + */ + interface ::com::sun::star::container::XContainer; - /**Specifies the height of column header. + /** allows cloning the complete column model */ - [attribute] long ColumnHeaderHeight; + interface ::com::sun::star::util::XCloneable; /** Returns the number of columns. + @returns the number of columns. */ long getColumnCount(); + /** creates a new column for use with the column model. + + <p>The newly created column is not yet inserted into the column container, you need to call <member>addColumn</member> + after you initialized the column object.</p> + */ + XGridColumn + createColumn(); + /** Adds a column to the model. + + <p>You should use the <member>createColumn</member> member to create a new column. This gives + implementations of the <code>XGridColumnModel</code> interface the possibility to provide own column + implementations which extend the basic <type>GridColumn</type> type.</p> + + <p>As soon as the column has been inserted into the model, the model takes ownership of it. This means when the + column is removed, or when the column model is disposed, the grid column is disposed as well.</p> + @param column the column to add to the model. - @returns - the index of new created column. - */ - long addColumn( [in] XGridColumn column ); + the index of new created column. - /* - long getSelectedCount(); + @throws ::com::sun::star::lang::IllegalArgumentException + if the given column is not a valid element for the column container, or if it is <NULL/>. + */ + long addColumn( [in] XGridColumn column ) + raises ( ::com::sun::star::lang::IllegalArgumentException ); - sequence<XGridColumn> getSelectedColumns(); + /** removes a column from the model - sequence<long> getSelectedIndex(); + <p>The column object will be disposed upon removal.</p> + @param ColumnIndex + denotes the index of the column to remove + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if <code>ColumnIndex</code> does not denote a valid column index. */ + void removeColumn( [in] long ColumnIndex ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); /** Returns all columns of the model. @returns @@ -92,24 +122,20 @@ interface XGridColumnModel @returns the requested column. */ - XGridColumn getColumn( [in] long index); + XGridColumn getColumn( [in] long index) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); + + /** Fills the model with the given number of default columns + + <p>Existing columns will be removed before adding new columns. Listeners at the column model will + be notified one <member scope="com::sun::star::container">XContainerListener::elementRemoved</member> event + for each removed column, and one <member scope="com::sun::star::container">XContainerListener::elementInserted</member> + event for each insertion.</p> - /** Sets default columns to the column model. @param elements the number of default columns that should be set. */ void setDefaultColumns([in] long elements); - - /**Creates new XGridColumn with the settings of other column. To be used if the columns which are added to - the column model have the same settings. - @param column - the column, which is already created - */ - XGridColumn copyColumn( [in] XGridColumn column ); - - /* - long getTotalColumnWidth(); - */ }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridControl.idl b/offapi/com/sun/star/awt/grid/XGridControl.idl index 5019a571663b..3c2c3d241528 100644 --- a/offapi/com/sun/star/awt/grid/XGridControl.idl +++ b/offapi/com/sun/star/awt/grid/XGridControl.idl @@ -28,9 +28,6 @@ #define __com_sun_star_awt_grid_XGridControl_idl__ #include <com/sun/star/awt/grid/XGridSelection.idl> -#include <com/sun/star/awt/grid/XGridColumnModel.idl> -#include <com/sun/star/awt/grid/XGridDataModel.idl> -#include <com/sun/star/awt/XMouseListener.idl> //============================================================================= @@ -44,23 +41,43 @@ module com { module sun { module star { module awt { module grid { @since OOo 3.3.0 */ -interface XGridControl: XGridSelection +interface XGridControl : XGridSelection { - /** Converting + /** retrieves the column which a given point belongs to + + @param X + the ordinate of the point, in pixel coordinates. + @param Y + the abscissa of the point, in pixel coordinates. + @return + the index of the column which the point lies in, or -1 if no column is under the given point. + */ + long getColumnAtPoint( [in] long X, [in] long Y ); + + /** retrieves the row which a given point belongs to + + @param X + the ordinate of the point, in pixel coordinates. + @param Y + the abscissa of the point, in pixel coordinates. + @return + the index of the row which the point lies in, or -1 if no row is under the given point. */ + long getRowAtPoint( [in] long X, [in] long Y ); - long getItemIndexAtPoint( [in] long x, [in] long y); + /** returns the column index of the currently active cell - /** Sets tooltip for row - @param textForTooltip - text, which will be shown as tooltip. - If only cell content should be displayed, leave sequence empty. - @param columnsForTooltip - column numbers, which define the cell content that should be shown in the tooltip. - If only text should be shown, leave this sequence empty. + <p>If the grid control's does not contain any cells (which happens if the grid column model does not contain any + columns, or if grid data model does not contain any rows), then <code>-1</code> is returned.</p> */ - void setToolTip( [in] sequence< string > textForTooltip, [in] sequence< long > columnsForTooltip); + long getCurrentColumn(); + + /** returns the row index of the currently active cell + <p>If the grid control's does not contain any cells (which happens if the grid column model does not contain any + columns, or if grid data model does not contain any rows), then <code>-1</code> is returned.</p> + */ + long getCurrentRow(); }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridDataListener.idl b/offapi/com/sun/star/awt/grid/XGridDataListener.idl index d6d0d930b331..709f048c08ce 100644 --- a/offapi/com/sun/star/awt/grid/XGridDataListener.idl +++ b/offapi/com/sun/star/awt/grid/XGridDataListener.idl @@ -52,20 +52,21 @@ module com { module sun { module star { module awt { module grid { interface XGridDataListener: com::sun::star::lang::XEventListener { - /** - Invoked after a row was added to the data model. + /** is called when one or more rows of data have been inserted into a grid control's data model. */ - void rowAdded( [in] GridDataEvent Event ); + void rowsInserted( [in] GridDataEvent Event ); - /** - Invoked after a row was added to the data model. + /** is called when one or more rows of data have been removed from a grid control's data model. */ - void rowRemoved( [in] GridDataEvent Event ); + void rowsRemoved( [in] GridDataEvent Event ); - /** - Invoked after a row was added to the data model. + /** is called when existing data in a grid control's data model has been modified. */ void dataChanged( [in] GridDataEvent Event ); + + /** is called when the title of one or more rows changed. + */ + void rowHeadingChanged( [in] GridDataEvent Event ); }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridDataModel.idl b/offapi/com/sun/star/awt/grid/XGridDataModel.idl index 5cc4085807e1..1ff15e1310e0 100644 --- a/offapi/com/sun/star/awt/grid/XGridDataModel.idl +++ b/offapi/com/sun/star/awt/grid/XGridDataModel.idl @@ -30,8 +30,9 @@ #include <com/sun/star/lang/XComponent.idl> +#include <com/sun/star/util/XCloneable.idl> #include <com/sun/star/awt/grid/XGridDataListener.idl> - +#include <com/sun/star/lang/IndexOutOfBoundsException.idl> //============================================================================= @@ -45,86 +46,57 @@ module com { module sun { module star { module awt { module grid { @since OOo 3.3.0 */ -interface XGridDataModel: ::com::sun::star::lang::XComponent +interface XGridDataModel { - /** Specifies the height of each row. - */ - [attribute] long RowHeight; - - /** Contains the row header. + /** implements life time control for the component */ - [attribute] sequence< string > RowHeaders; + interface ::com::sun::star::lang::XComponent; - /** Returns the content of each row. + /** allows cloning the complete column model */ - [attribute,readonly] sequence< sequence< any > > Data; + interface ::com::sun::star::util::XCloneable; - /**Specifies the width of row header. + /** denotes the number of rows for which the model can provide data */ - [attribute] long RowHeaderWidth; + [attribute, readonly] long RowCount; - /** Returns the number of rows in in the model. - @returns - the number of rows. + /** denotes the number of columns for which the model can provide data */ - long getRowCount(); + [attribute, readonly] long ColumnCount; - /** Adds a row to the model. + /** retrieves the data for a given cell - @param headername - specifies the name of the row. - @param data - the content of the row. + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the column or row index do not denote a valid cell position. */ - void addRow( [in] string headername, [in] sequence< any > data ); + any getCellData( [in] long Column, [in] long Row ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); - /** Removes a row from the model. + /** retrieves the tool tip to be displayed when the mouse hovers over a given cell - @param index - the index of the row that should be removed. - */ - void removeRow( [in] long index); + <p>At the moment, only string tool tips are supported.</p> - /** Removes all rows from the model. - */ - void removeAll(); - - /**Updates the content of a given cell. - @param row - the row index - @param column - the column index - @param value - the new value of the cell. - */ - void updateCell([in] long row, [in] long column, [in] any value ); - - /**Updates the content of a given row. - @param row - the row index - @param columns - column indexes of the cells, which should be updated - @param value - the new values of the cells. + <p>If <VOID/> is returned here, the cell's content will be displayed as tip, but only if it does + not fit into the cell.</p> + + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the column or row index do not denote a valid cell position. */ - void updateRow([in] long row, [in] sequence< long > columns, [in] sequence< any > values); + any getCellToolTip( [in] long Column, [in] long Row ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); - //------------------------------------------------------------------------- + /** retrieves the heading of a given row - /** Adds a listener for the <type>GridDataEvent</type> posted after the grid changes. - @param Listener - the listener to add. - */ - [oneway] void addDataListener( [in] XGridDataListener listener); + <p>A grid control will usually paint a row's title in the header column of the respective row.</p> - //------------------------------------------------------------------------- + <p>At the moment, only strings are supported as row headings.</p> - /** Removes a listener previously added with <method>addDataListener()</method>. - @param Listener - the listener to remove. + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the given index does not denote a valid row. */ - [oneway] void removeDataListener( [in] XGridDataListener listener); - + any + getRowHeading( [in] long RowIndex ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); }; //============================================================================= diff --git a/offapi/com/sun/star/awt/grid/XGridSelection.idl b/offapi/com/sun/star/awt/grid/XGridSelection.idl index cc3baf2fa360..be8d1a9b8b76 100644 --- a/offapi/com/sun/star/awt/grid/XGridSelection.idl +++ b/offapi/com/sun/star/awt/grid/XGridSelection.idl @@ -41,37 +41,27 @@ module com { module sun { module star { module awt { module grid { */ interface XGridSelection { - /** Returns the lowest index of the selection. - @returns - the lowest index. - */ - long getMinSelectionIndex(); - - /** Returns the highest index of the selection. - @returns - the highest index. - */ - long getMaxSelectionIndex(); - /** Selects all rows. */ - [oneway] void selectAllRows(); + void selectAllRows(); + + /** selects a given row - /** Selects multiple rows. Previous selections will be removed. - @param rangeOfRows - array of rows indexes, which will be selected. + @param RowIndex + denotes the index of the row to select */ - [oneway] void selectRows( [in] sequence< long > rangeOfRows); + void selectRow( [in] long RowIndex ); /** Deselects all selected rows. */ - [oneway] void deselectAllRows(); + void deselectAllRows(); - /** Deselects selected rows. Selected rows, which aren't in the range remain selected. - @param rangeOfRows - array of rows indexes, which will be deselected. + /** removes the selection for a given row + + @param RowIndex + denotes the index of the row to deselect */ - [oneway] void deselectRows( [in] sequence< long > rangeOfRows); + void deselectRow( [in] long RowIndex ); /** Returns the indices of all selected rows. @returns @@ -93,21 +83,11 @@ interface XGridSelection */ boolean isSelectedIndex( [in] long index); - /** Marks a row as selected. - @param index - the index of a row. - */ - [oneway] void selectRow( [in] long index); - - /* - [oneway] void selectColumn( [in] long x); - */ - /** Adds a listener for the <type>GridSelectionEvent</type> posted after the grid changes. @param listener the listener to add. */ - [oneway] void addSelectionListener( [in] XGridSelectionListener listener); + void addSelectionListener( [in] XGridSelectionListener listener); //------------------------------------------------------------------------- @@ -115,7 +95,7 @@ interface XGridSelection @param listener the listener to remove. */ - [oneway] void removeSelectionListener( [in] XGridSelectionListener listener); + void removeSelectionListener( [in] XGridSelectionListener listener); }; diff --git a/offapi/com/sun/star/awt/grid/XMutableGridDataModel.idl b/offapi/com/sun/star/awt/grid/XMutableGridDataModel.idl new file mode 100755 index 000000000000..5e10820ff9ef --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XMutableGridDataModel.idl @@ -0,0 +1,163 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_grid_XMutableGridDataModel_idl__ +#define __com_sun_star_awt_grid_XMutableGridDataModel_idl__ + +#include <com/sun/star/awt/grid/XGridDataModel.idl> +#include <com/sun/star/lang/IllegalArgumentException.idl> +#include <com/sun/star/lang/IndexOutOfBoundsException.idl> + +//================================================================================================================== + +module com { module sun { module star { module awt { module grid { + +//================================================================================================================== + +/** allows to modify the data represented by a <type>XGridDataModel</type> + */ +interface XMutableGridDataModel : XGridDataModel +{ + /** adds a row to the model. + + @param Heading + denotes the heading of the row. + @param Data + specifies the content of the row. + */ + void addRow( [in] any Heading, [in] sequence< any > Data ); + + /** adds multiple rows of data to the model. + @param Headings + denotes the headings of the to-be-added rows. + @param Data + specifies the data of the rows to be added. + @throws ::com::sun::star::lang::IllegalArgumentException + if <code>Titles</code> and <code>Data</code> are of different length. + */ + void addRows( [in] sequence< any > Headings, [in] sequence< sequence< any > > Data ) + raises ( ::com::sun::star::lang::IllegalArgumentException ); + + /** removes a row of data from the model + + @param RowIndex + the index of the row that should be removed. + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the given index is invalid + */ + void removeRow( [in] long RowIndex ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); + + /** Removes all rows from the model. + */ + void removeAllRows(); + + /** updates the content of the given cell + @param ColumnIndex + the column index of the to-be-updated cell + @param RowIndex + the row index of the to-be-updated cell + @param Value + the new value of the cell. + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the row or column index is invalid + */ + void updateCellData( [in] long ColumnIndex, [in] long RowIndex, [in] any Value ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); + + /** updates the content of a given row. + + <p>The change in the data model will be notified to registered listeners via + <member">XGridDataListener::dataChanged</member>. The <member>GridDataEvent::FirstColumn</member> and + <member>GridDataEvent::LastColumn</member> will denote the smallest respectively largest column + index from <argColumnIndexes</arg>.</p> + + @param ColumnIndexes + contains the column indexes of the cells, which should be updated + @param RowIndex + contains the index of the row whose data is to be updated + @param Values + specifies the new values of the cells. + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if one of the row indexes or the column index is invalid + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the lengths of the <code>ColumnIndexes</code> and <code>Values</code> sequences are not equal. + */ + void updateRowData( [in] sequence< long > ColumnIndexes, [in] long RowIndex, [in] sequence< any > Values ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException + , ::com::sun::star::lang::IllegalArgumentException); + + /** sets a new title for a given row. + + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if the given index does not denote a valid row. + */ + void + updateRowHeading( [in] long RowIndex, [in] any Heading ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); + + /** updates the tooltip to be displayed for a given cell + + @see XGridDataModel::getCellToolTip + */ + void updateCellToolTip( [in] long ColumnIndex, [in] long RowIndex, [in] any Value ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); + + /** updates the tooltip for all cells of a given row + + <p>Effectively this method is a shortcut for calling <member>updateCellToolTip</member> multiple + times in a row, for all cells of a given row.</p> + + @see XGridDataModel::getCellToolTip + @see updateCellToolTip + */ + void updateRowToolTip( [in] long RowIndex, [in] any Value ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); + + //------------------------------------------------------------------------- + + /** registers listener to be notified of data changes in the model + @param Listener + specifies the listener to register + */ + void addGridDataListener( [in] XGridDataListener Listener ); + + //------------------------------------------------------------------------- + + /** revokes a listener which was previously registered via <member>addGridDataListener</member> + @param Listener + specifies the listener to revoke. + */ + void removeGridDataListener( [in] XGridDataListener Listener ); +}; + +//================================================================================================================== + +}; }; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/grid/XSortableGridData.idl b/offapi/com/sun/star/awt/grid/XSortableGridData.idl new file mode 100755 index 000000000000..9dcf9d95fb85 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XSortableGridData.idl @@ -0,0 +1,77 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_grid_XSortableGridData_idl__ +#define __com_sun_star_awt_grid_XSortableGridData_idl__ + +#include <com/sun/star/lang/IndexOutOfBoundsException.idl> +#include <com/sun/star/beans/Pair.idl> + +//================================================================================================================== + +module com { module sun { module star { module awt { module grid { + +//================================================================================================================== + +/** allows to sort the data represented by a <type>XGridDataModel</type> + */ +interface XSortableGridData +{ + /** sorts the rows represented by the model by a given column's data. + + @param ColumnIndex + the index of the column whose data should be used as sort key + @param SortAscending + is <TRUE/> if the data should be sorted ascending, <FALSE/> otherwise. + @throws ::com::sun::star::lang::IndexOutOfBoundsException + if <code>ColumnIndex</code> does not denote a valid column. + */ + void sortByColumn( [in] long ColumnIndex, [in] boolean SortAscending ) + raises ( ::com::sun::star::lang::IndexOutOfBoundsException ); + + /** removes any possibly present sorting of the grid data + */ + void removeColumnSort(); + + /** returns the current sort order. + + @return + a structure describing the current sort order. <member scope="::com::sun::star::beans">Pair::First</member> + denotes the column by which the data is sorted, or -1 if the data is currently unsorted. + <member scope="::com::sun::star::beans">Pair::Second</member> is <TRUE/> if the data is sorted ascending, + <FALSE/> otherwise. + */ + ::com::sun::star::beans::Pair< long, boolean > + getCurrentSortOrder(); +}; + +//================================================================================================================== + +}; }; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/grid/XSortableMutableGridDataModel.idl b/offapi/com/sun/star/awt/grid/XSortableMutableGridDataModel.idl new file mode 100755 index 000000000000..bbcd6bc29540 --- /dev/null +++ b/offapi/com/sun/star/awt/grid/XSortableMutableGridDataModel.idl @@ -0,0 +1,61 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_awt_grid_XSortableMutableGridDataModel_idl__ +#define __com_sun_star_awt_grid_XSortableMutableGridDataModel_idl__ + +#include <com/sun/star/awt/grid/XMutableGridDataModel.idl> +#include <com/sun/star/awt/grid/XSortableGridData.idl> + +//================================================================================================================== + +module com { module sun { module star { module awt { module grid { + +//================================================================================================================== + +/** describes a grid control data model whose data can be modified and sorted. + */ +interface XSortableMutableGridDataModel +{ + /** provides access to the basic functionality of a grid data model, plus functions to modify it. + */ + interface XMutableGridDataModel; + + /** provides means to sort the data represented by the model. + + <p>If you set a new column sort order, the implementation will notify the registered <type>XGridDataListener</type>s + via a call to its <member>XGridDataListener::dataChanged</member> method.</p> + */ + interface XSortableGridData; +}; + +//================================================================================================================== + +}; }; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/awt/grid/makefile.mk b/offapi/com/sun/star/awt/grid/makefile.mk index 02c159f8ffec..8499dca27d82 100644 --- a/offapi/com/sun/star/awt/grid/makefile.mk +++ b/offapi/com/sun/star/awt/grid/makefile.mk @@ -39,27 +39,27 @@ PACKAGE=com$/sun$/star$/awt$/grid # ------------------------------------------------------------------------ IDLFILES=\ GridColumnEvent.idl\ - GridControlEvent.idl\ GridDataEvent.idl\ SelectionEventType.idl\ GridSelectionEvent.idl\ - XGridControlListener.idl\ XGridSelectionListener.idl\ XGridSelection.idl\ XGridColumn.idl\ XGridColumnListener.idl\ XGridDataListener.idl\ - XGridCell.idl\ - XGridCellRenderer.idl\ DefaultGridDataModel.idl\ XGridDataModel.idl\ + XMutableGridDataModel.idl\ XGridColumnModel.idl\ - ScrollBarMode.idl\ XGridControl.idl\ UnoControlGrid.idl\ UnoControlGridModel.idl\ GridInvalidDataException.idl\ - GridInvalidModelException.idl + GridInvalidModelException.idl\ + XSortableGridData.idl\ + SortableGridDataModel.idl\ + XSortableMutableGridDataModel.idl\ + # ------------------------------------------------------------------ .INCLUDE : target.mk diff --git a/offapi/com/sun/star/awt/makefile.mk b/offapi/com/sun/star/awt/makefile.mk index a6357703500c..c2397d81bf44 100644 --- a/offapi/com/sun/star/awt/makefile.mk +++ b/offapi/com/sun/star/awt/makefile.mk @@ -161,6 +161,7 @@ IDLFILES=\ UnoControlDialog.idl\ UnoControlDialogElement.idl\ UnoControlDialogModel.idl\ + UnoControlDialogModelProvider.idl\ UnoControlEdit.idl\ UnoControlEditModel.idl\ UnoControlFileControl.idl\ @@ -334,7 +335,12 @@ IDLFILES=\ XPopupMenuExtended.idl \ XItemList.idl \ XItemListListener.idl \ - ItemListEvent.idl + ItemListEvent.idl \ + AnimatedImagesControl.idl \ + AnimatedImagesControlModel.idl \ + XAnimatedImages.idl \ + XAnimation.idl \ + SpinningProgressControlModel.idl # ------------------------------------------------------------------ diff --git a/offapi/com/sun/star/awt/grid/GridControlEvent.idl b/offapi/com/sun/star/awt/tab/TabPageActivatedEvent.idl index ce8736fb1b93..ef678395fe06 100644 --- a/offapi/com/sun/star/awt/grid/GridControlEvent.idl +++ b/offapi/com/sun/star/awt/tab/TabPageActivatedEvent.idl @@ -24,26 +24,28 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef __com_sun_star_awt_GridControlEvent_idl__ -#define __com_sun_star_awt_GridControlEvent_idl__ +#ifndef __com_sun_star_awt_tab_TabPageActivationEvent_idl__ +#define __com_sun_star_awt_tab_TabPageActivationEvent_idl__ #ifndef __com_sun_star_lang_EventObject_idl__ #include <com/sun/star/lang/EventObject.idl> #endif - //============================================================================= -module com { module sun { module star { module awt { module grid { +module com { module sun { module star { module awt { module tab { //============================================================================= +/** An event used by a <type>XTabPageContainer</type> to notify changes in tab page activation. -struct GridControlEvent: com::sun::star::lang::EventObject + @since OOo 3.4 + */ +struct TabPageActivatedEvent: com::sun::star::lang::EventObject { - //------------------------------------------------------------------------- - - string ActionCommand; + /** Contains the ID of the tab page + */ + short TabPageID; }; diff --git a/offapi/com/sun/star/awt/tab/UnoControlTabPage.idl b/offapi/com/sun/star/awt/tab/UnoControlTabPage.idl new file mode 100644 index 000000000000..6244b18e0c77 --- /dev/null +++ b/offapi/com/sun/star/awt/tab/UnoControlTabPage.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_tab_UnoControlTabPage_idl__ +#define __com_sun_star_awt_tab_UnoControlTabPage_idl__ + +#include <com/sun/star/awt/UnoControlContainer.idl> +#include <com/sun/star/awt/tab/XTabPage.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module tab { + +//============================================================================= + +/** specifies a TabPage control. + + @since OOo 3.4 +*/ + +service UnoControlTabPage +{ + service com::sun::star::awt::UnoControlContainer; + + interface XTabPage; + +}; + +//============================================================================= + + }; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/tab/UnoControlTabPageContainer.idl b/offapi/com/sun/star/awt/tab/UnoControlTabPageContainer.idl new file mode 100644 index 000000000000..488ce4b5354a --- /dev/null +++ b/offapi/com/sun/star/awt/tab/UnoControlTabPageContainer.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_tab_UnoControlTabPageContainer_idl__ +#define __com_sun_star_awt_tab_UnoControlTabPageContainer_idl__ + +#include <com/sun/star/awt/UnoControl.idl> +#include <com/sun/star/awt/tab/XTabPageContainer.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module tab { + +//============================================================================= + +/** specifies a TabPageContainer control. + + @since OOo 3.4 + */ +service UnoControlTabPageContainer +{ + service com::sun::star::awt::UnoControl; + + interface com::sun::star::awt::tab::XTabPageContainer; + +}; + +//============================================================================= + + }; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/chart2/ViewLegendEntry.idl b/offapi/com/sun/star/awt/tab/UnoControlTabPageContainerModel.idl index 0e5ea231628c..b97b7881b416 100644 --- a/offapi/com/sun/star/chart2/ViewLegendEntry.idl +++ b/offapi/com/sun/star/awt/tab/UnoControlTabPageContainerModel.idl @@ -24,35 +24,32 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef com_sun_star_chart2_ViewLegendEntry_idl -#define com_sun_star_chart2_ViewLegendEntry_idl +#ifndef __com_sun_star_awt_tab_UnoControlTabPageContainerModel_idl__ +#define __com_sun_star_awt_tab_UnoControlTabPageContainerModel_idl__ -#include <com/sun/star/drawing/XShape.idl> -#include <com/sun/star/chart2/XFormattedString.idl> +#include <com/sun/star/awt/UnoControlModel.idl> +#include <com/sun/star/awt/tab/XTabPageContainerModel.idl> //============================================================================= -module com { module sun { module star { module chart2 { +module com { module sun { module star { module awt { module tab { //============================================================================= -/** +/** specifies a model for a UnoControlTabPageContainer control. + + @since OOo 3.4 */ -struct ViewLegendEntry +service UnoControlTabPageContainerModel { - /** The legend symbol that represents a data series or other - information contained in the legend - */ - ::com::sun::star::drawing::XShape aSymbol; - - /** The descriptive text for a legend entry. - */ - sequence< XFormattedString > aLabel; + service com::sun::star::awt::UnoControlModel; + + interface com::sun::star::awt::tab::XTabPageContainerModel; + }; //============================================================================= -}; }; }; }; + }; }; }; }; }; #endif - diff --git a/offapi/com/sun/star/awt/tab/UnoControlTabPageModel.idl b/offapi/com/sun/star/awt/tab/UnoControlTabPageModel.idl new file mode 100644 index 000000000000..3508e33260c7 --- /dev/null +++ b/offapi/com/sun/star/awt/tab/UnoControlTabPageModel.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_tab_UnoControlTabPageModel_idl__ +#define __com_sun_star_awt_tab_UnoControlTabPageModel_idl__ + +#include <com/sun/star/awt/tab/XTabPageModel.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module tab { + +//============================================================================= + +/** specifies the standard model of a XTabPageModel. + @since OOo 3.4 + */ +service UnoControlTabPageModel : XTabPageModel +{ + /** Creates a new XTabPageModel with a given ID. + */ + create([in] short tabPageID); + + /** Creates a new XTabPageModel with a given ID and a url which is used to load teh tab page model. + */ + load([in] short tabPageID,[in] string url); +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridControlListener.idl b/offapi/com/sun/star/awt/tab/XTabPage.idl index 6f4fdf68ccd4..616820071f5b 100644 --- a/offapi/com/sun/star/awt/grid/XGridControlListener.idl +++ b/offapi/com/sun/star/awt/tab/XTabPage.idl @@ -24,20 +24,23 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef __com_sun_star_awt_grid_XGridControlListener_idl__ -#define __com_sun_star_awt_grid_XGridControlListener_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#ifndef __com_sun_star_awt_tab_XTabPage_idl__ +#define __com_sun_star_awt_tab_XTabPage_idl__ +#include <com/sun/star/awt/tab/XTabPageModel.idl> //============================================================================= -module com { module sun { module star { module awt { module grid { +module com { module sun { module star { module awt { module tab { //============================================================================= -interface XGridControlListener +/** An interface to a control that displays a tab page. + + @see UnoControlTabPage + + @since OOo 3.4 + */ +interface XTabPage { }; diff --git a/offapi/com/sun/star/awt/tab/XTabPageContainer.idl b/offapi/com/sun/star/awt/tab/XTabPageContainer.idl new file mode 100644 index 000000000000..e62cf4c365c1 --- /dev/null +++ b/offapi/com/sun/star/awt/tab/XTabPageContainer.idl @@ -0,0 +1,109 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_tab_XTabPageContainer_idl__ +#define __com_sun_star_awt_tab_XTabPageContainer_idl__ + +#include <com/sun/star/awt/tab/XTabPageContainerListener.idl> +#include <com/sun/star/awt/tab/XTabPage.idl> +//============================================================================= + +module com { module sun { module star { module awt { module tab { + +//============================================================================= + +/** An interface to a control that displays tab pages. + + @see UnoControlTabPageContainer + + @since OOo 3.4 + */ +interface XTabPageContainer +{ + /** Returns the number of tab pages. + @returns + the number of tab pages. + */ + long getTabPageCount(); + + //------------------------------------------------------------------------- + + /** Checks whether a tab page is activated. + @param + the tab page to be checked. + @returns + <TRUE/> if tab page is activated, else <FALSE/>. + */ + boolean isTabPageActive([in] short tabPageIndex); + + //------------------------------------------------------------------------- + + /** Returns tab page for the given index. + @param + tabPageIndex - index of the tab page in the IndexContainer. + @returns + tab page which has tabPageIndex. + */ + XTabPage getTabPage([in] short tabPageIndex); + + //------------------------------------------------------------------------- + + /** Returns tab page for the given ID. + @param + tabPageID - ID of the tab page. + @returns + tab page which has tabPageID. + */ + XTabPage getTabPageByID([in] short tabPageID); + + //------------------------------------------------------------------------- + + /** Adds a listener for the <type>TabPageActivedEvent</type> posted after + the tab page was activated. + @param listener + the listener to add. + */ + [oneway] void addTabPageListener( [in] XTabPageContainerListener listener); + + //------------------------------------------------------------------------- + + /** Removes a listener previously added with <method>addTabPageListener()</method>. + @param listener + the listener to remove. + */ + [oneway] void removeTabPageListener( [in] XTabPageContainerListener listener); + + //------------------------------------------------------------------------- + /** Specifies the ID of the current active tab page. + */ + [attribute] short ActiveTabPageID; +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/tab/XTabPageContainerListener.idl b/offapi/com/sun/star/awt/tab/XTabPageContainerListener.idl new file mode 100644 index 000000000000..f46951231513 --- /dev/null +++ b/offapi/com/sun/star/awt/tab/XTabPageContainerListener.idl @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_tab_XTabPageContainerListener_idl__ +#define __com_sun_star_awt_tab_XTabPageContainerListener_idl__ + +#include <com/sun/star/lang/XEventListener.idl> +#include <com/sun/star/awt/tab/TabPageActivatedEvent.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module tab { + +//============================================================================= + +/** An instance of this interface is used by the <type>XTabPageContainer</type> to + get notifications about changes in activation of tab pages. + + @since OOo 3.4 + */ +interface XTabPageContainerListener: com::sun::star::lang::XEventListener +{ + //------------------------------------------------------------------------- + /** Invoked after a tab page was activated. + */ + [oneway] void tabPageActivated( [in] TabPageActivatedEvent tabPageActivatedEvent); + +}; + +//============================================================================= + +}; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/tab/XTabPageContainerModel.idl b/offapi/com/sun/star/awt/tab/XTabPageContainerModel.idl new file mode 100644 index 000000000000..cc815209a01d --- /dev/null +++ b/offapi/com/sun/star/awt/tab/XTabPageContainerModel.idl @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_tab_XTabPageContainerModel_idl__ +#define __com_sun_star_awt_tab_XTabPageContainerModel_idl__ + +#include <com/sun/star/container/XIndexContainer.idl> +#include <com/sun/star/container/XContainer.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module tab { + +//============================================================================= + +/** specifies an interface for a UnoControlTabPageContainerModel. + + @since OOo 3.4 + */ +interface XTabPageContainerModel +{ + interface com::sun::star::container::XIndexContainer; + interface com::sun::star::container::XContainer; +}; + +//============================================================================= + + }; }; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/tab/XTabPageModel.idl b/offapi/com/sun/star/awt/tab/XTabPageModel.idl new file mode 100644 index 000000000000..15fae422bb17 --- /dev/null +++ b/offapi/com/sun/star/awt/tab/XTabPageModel.idl @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_awt_tab_XTabPageModel_idl__ +#define __com_sun_star_awt_tab_XTabPageModel_idl__ + +#include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/lang/XMultiServiceFactory.idl> +#include <com/sun/star/container/XContainer.idl> +#include <com/sun/star/container/XNameContainer.idl> + +//============================================================================= + +module com { module sun { module star { module awt { module tab { + +//============================================================================= + +/** specifies an XTabPageModel interface. + + @since OOo 3.4 +*/ + +interface XTabPageModel +{ + //interface com::sun::star::lang::XMultiServiceFactory; + + //interface com::sun::star::container::XNameContainer; + + //interface com::sun::star::container::XContainer; + + /**ID for tab page. + */ + [attribute, readonly] short TabPageID; + //------------------------------------------------------------------------- + + /** determines whether a tab page is enabled or disabled. + */ + [attribute] boolean Enabled; + + //------------------------------------------------------------------------- + + /** specifies the text that is displayed in the tab bar of the tab page. + */ + [attribute] string Title; + + //------------------------------------------------------------------------- + + /** specifies a URL that references a graphic that should be displayed in the tab bar. + */ + [attribute] string ImageURL; + + //------------------------------------------------------------------------- + + /** specifies a tooltip text that should be displayed in the tab bar. + */ + [attribute] string Tooltip; +}; + + +//============================================================================= + + }; }; }; }; }; + +#endif diff --git a/bridges/source/remote/context/makefile.mk b/offapi/com/sun/star/awt/tab/makefile.mk index a192f81d3eed..249760988b61 100644 --- a/bridges/source/remote/context/makefile.mk +++ b/offapi/com/sun/star/awt/tab/makefile.mk @@ -25,39 +25,29 @@ # #************************************************************************* -PRJ=..$/..$/.. +PRJ=..$/..$/..$/..$/.. -PRJNAME=bridges -TARGET=rmcxt -ENABLE_EXCEPTIONS=TRUE -USE_DEFFILE=TRUE +PRJNAME=api -UNIXVERSIONNAMES=UDK +TARGET=cssawttab +PACKAGE=com$/sun$/star$/awt$/tab # --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/util$/makefile.pmk + +# ------------------------------------------------------------------------ +IDLFILES=\ + TabPageActivatedEvent.idl\ + XTabPageContainerListener.idl\ + XTabPageModel.idl\ + XTabPage.idl\ + XTabPageContainerModel.idl\ + XTabPageContainer.idl\ + UnoControlTabPage.idl\ + UnoControlTabPageModel.idl\ + UnoControlTabPageContainer.idl\ + UnoControlTabPageContainerModel.idl # ------------------------------------------------------------------ -UNOUCRDEP=$(SOLARUCRDIR)$/uce.rdb -UNOUCRRDB=$(SOLARUCRDIR)$/uce.rdb - -SLOFILES= $(SLO)$/context.obj - -SHL1TARGET= $(TARGET) - -SHL1STDLIBS= \ - $(SALLIB) - -SHL1DEPN= -SHL1IMPLIB= i$(TARGET) -SHL1LIBS= $(SLB)$/$(TARGET).lib -SHL1DEF= $(MISC)$/$(SHL1TARGET).def -SHL1RPATH=URELIB - -SHL1VERSIONMAP= $(TARGET).map - -DEF1NAME= $(SHL1TARGET) - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk +.INCLUDE : target.mk +.INCLUDE : $(PRJ)$/util$/target.pmk diff --git a/offapi/com/sun/star/awt/tree/XTreeControl.idl b/offapi/com/sun/star/awt/tree/XTreeControl.idl index 83bb319312bc..edc135021fc4 100644 --- a/offapi/com/sun/star/awt/tree/XTreeControl.idl +++ b/offapi/com/sun/star/awt/tree/XTreeControl.idl @@ -154,7 +154,7 @@ interface XTreeControl @throws ::com::sun::star::lang::IllegalArgumentException if <var>Node</var> is not a valid node of the corresponding <type>XTreeDataModel</type>. - @raises ExpandVetoException + @throws ExpandVetoException if collapsing <var>Node</var> failed because at least one of the registered <type>XTreeExpansionListener</type> raised a <type>ExpandVetoException</type>. */ diff --git a/offapi/com/sun/star/chart/ChartAxis.idl b/offapi/com/sun/star/chart/ChartAxis.idl index 05d90b02df53..ed338645fb03 100644 --- a/offapi/com/sun/star/chart/ChartAxis.idl +++ b/offapi/com/sun/star/chart/ChartAxis.idl @@ -55,6 +55,18 @@ #include <com/sun/star/chart/ChartAxisMarkPosition.idl> #endif +#ifndef __com_sun_star_chart_ChartAxisType_idl__ +#include <com/sun/star/chart/ChartAxisType.idl> +#endif + +#ifndef __com_sun_star_chart_TimeIncrement_idl__ +#include <com/sun/star/chart/TimeIncrement.idl> +#endif + +#ifndef __com_sun_star_chart_XAxis_idl__ +#include <com/sun/star/chart/XAxis.idl> +#endif + #ifndef _com_sun_star_xml_UserDefinedAttributeSupplier_idl_ #include <com/sun/star/xml/UserDefinedAttributeSupplier.idl> #endif @@ -72,8 +84,6 @@ */ published service ChartAxis { - - /** set the properties for the entire axis line as well as for the tick marks. */ @@ -83,14 +93,19 @@ published service ChartAxis */ service com::sun::star::style::CharacterProperties; - /** If a <type>ChartAxis</type> may be stored as XML element, this - service should be supported in order to preserve unparsed XML - attributes. + /** If a <type>ChartAxis</type> may be stored as XML element, this + service should be supported in order to preserve unparsed XML + attributes. @since OOo 1.1.2 */ [optional] service com::sun::star::xml::UserDefinedAttributeSupplier; + /** Access to the sub elements of an axis like title and grids. + @since OOo 3.4 + */ + [optional] interface com::sun::star::chart::XAxis; + interface com::sun::star::beans::XPropertySet; //------------------------------------------------------------------------- @@ -169,6 +184,20 @@ published service ChartAxis //------------------------------------------------------------------------- + /** determines which type of axis this is, e.g. a date-axis or a category-axis @see ChartAxisType + @since OOo 3.4 + */ + [optional, property] long AxisType; + + //------------------------------------------------------------------------- + + /** if the current axis is a date-axis the intervals are choosen as given with TimeIncrement + @since OOo 3.4 + */ + [optional, maybevoid, property] TimeIncrement TimeIncrement; + + //------------------------------------------------------------------------- + /** Determines if the axis orientation is mathematical or reversed. */ [optional, property] boolean ReverseDirection; diff --git a/offapi/com/sun/star/chart2/XUndoSupplier.idl b/offapi/com/sun/star/chart/ChartAxisType.idl index 901ca49ad74f..e705424115e8 100644 --- a/offapi/com/sun/star/chart2/XUndoSupplier.idl +++ b/offapi/com/sun/star/chart/ChartAxisType.idl @@ -24,10 +24,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef com_sun_star_chart2_XUndoSupplier_idl -#define com_sun_star_chart2_XUndoSupplier_idl - -#include <com/sun/star/chart2/XUndoManager.idl> +#ifndef com_sun_star_chart_ChartAxisType_idl +#define com_sun_star_chart_ChartAxisType_idl module com { @@ -35,23 +33,25 @@ module sun { module star { -module chart2 +module chart { - -/** An interface for providing an UndoManager based on frame::XModel - objects. - */ -interface XUndoSupplier : ::com::sun::star::uno::XInterface +/** @since OOo 3.4 +*/ +published constants ChartAxisType { - /** @return an undo manager that allows doing undo and redo of a - frame::XModel based object + /** the type of the axis is choosen automatically dependent on the chart type, the dimension and the underlying data + */ + const long AUTOMATIC = 0; + + /** the axis represent discrete category texts if chart type and the dimension allows + */ + const long CATEGORY = 1; + + /** the axis shows dates if the given data and chart type and the dimension allows */ - XUndoManager getUndoManager(); + const long DATE = 2; }; -} ; // chart2 -} ; // com -} ; // sun -} ; // star +}; }; }; }; #endif diff --git a/offapi/com/sun/star/chart2/LegendExpansion.idl b/offapi/com/sun/star/chart/ChartLegendExpansion.idl index 8a51a47bb3a1..3808c7ea9ad1 100644..100755 --- a/offapi/com/sun/star/chart2/LegendExpansion.idl +++ b/offapi/com/sun/star/chart/ChartLegendExpansion.idl @@ -24,8 +24,8 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef com_sun_star_chart_LegendExpansion_idl -#define com_sun_star_chart_LegendExpansion_idl +#ifndef com_sun_star_chart_ChartLegendExpansion_idl +#define com_sun_star_chart_ChartLegendExpansion_idl module com { @@ -33,41 +33,37 @@ module sun { module star { -module chart2 +module chart { -/** +/** Specifies sizing aspects of the legend */ -enum LegendExpansion +enum ChartLegendExpansion { - /** The legend is laid out such that it is wider that high. The - aspect ratio is greater than 1. + /** The legend entries are arranged in a single row if possible. If not enough space is available further rows are added. <p>This is usually used for legends that are displayed at the top or bottom of the page.</p> */ WIDE, - /** The legend is laid out such that it is higher that wide. The - aspect ratio is less than 1. + /** The legend entries are stacked in a single column if possible. If not enough space is available further columns are added. <p>This is usually used for legends that are displayed on the left or right hand side of the page.</p> */ HIGH, - /** The legend is laid out such that height and width are not - differing too much. It is not guaranteed to have an aspect - ratio of 1. + /** The legend entries are arranged in a way that the aspect ratio of the resulting legend is as near to 1 as possible. */ BALANCED, - /** The aspect ratio of the legend is given explicitly + /** The size of the legend is given explicitly */ CUSTOM }; -} ; // chart2 +} ; // chart } ; // com } ; // sun } ; // star diff --git a/offapi/com/sun/star/chart/Diagram.idl b/offapi/com/sun/star/chart/Diagram.idl index b57fc88f3804..854baadb38cc 100644 --- a/offapi/com/sun/star/chart/Diagram.idl +++ b/offapi/com/sun/star/chart/Diagram.idl @@ -31,6 +31,10 @@ #include <com/sun/star/chart/XDiagram.idl> #endif +#ifndef __com_sun_star_chart_XAxisSupplier_idl__ +#include <com/sun/star/chart/XAxisSupplier.idl> +#endif + #ifndef __com_sun_star_chart_XDiagramPositioning_idl__ #include <com/sun/star/chart/XDiagramPositioning.idl> #endif @@ -72,8 +76,12 @@ published service Diagram interface com::sun::star::chart::XDiagram; - /** Provides access to the titles of the secondary X axis and Y axis. + /** Provides easier access to the differnet axes and their sub elements. + @since OOo 3.4 + */ + [optional] interface com::sun::star::chart::XAxisSupplier; + /** Provides access to the titles of the secondary X axis and Y axis. @since OOo 3.0 */ [optional] interface com::sun::star::chart::XSecondAxisTitleSupplier; diff --git a/offapi/com/sun/star/chart/TimeIncrement.idl b/offapi/com/sun/star/chart/TimeIncrement.idl new file mode 100644 index 000000000000..3eba8d903c63 --- /dev/null +++ b/offapi/com/sun/star/chart/TimeIncrement.idl @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef com_sun_star_chart_TimeIncrement_idl +#define com_sun_star_chart_TimeIncrement_idl + +#include <com/sun/star/chart/TimeInterval.idl> + +//============================================================================= + +module com { module sun { module star { module chart { + +//============================================================================= + +/** A TimeIncrement describes how tickmarks are positioned on the scale of a date-time axis. +@since OOo 3.4 +*/ +published struct TimeIncrement +{ + /** if the any contains a struct of type <type>::com::sun::star::chart::TimeInterval</type> + this is used as a fixed distance value for the major tickmarks. Otherwise, if the any is empty or contains an + incompatible type, the distance between major tickmarks is calculated automatically by the application. + */ + any MajorTimeInterval; + + /** if the any contains a struct of type <type>::com::sun::star::chart::TimeInterval</type> + this is used as a fixed distance value for the minor tickmarks. Otherwise, if the any is empty or contains an + incompatible type, the distance between minor tickmarks is calculated automatically by the application. + */ + any MinorTimeInterval; + + /** if the any contains a constant of type <type>::com::sun::star::chart::TimeUnit</type> + this is the smallest time unit that is displayed on the date-time axis. + Otherwise, if the any is empty or contains an incompatible type, + the resolution is choosen automatically by the application. + */ + any TimeResolution; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/chart/TimeInterval.idl b/offapi/com/sun/star/chart/TimeInterval.idl new file mode 100644 index 000000000000..c1280f815655 --- /dev/null +++ b/offapi/com/sun/star/chart/TimeInterval.idl @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef com_sun_star_chart_TimeInterval_idl +#define com_sun_star_chart_TimeInterval_idl + +#include <com/sun/star/chart/TimeUnit.idl> + +//============================================================================= + +module com { module sun { module star { module chart { + +//============================================================================= + +/** Describes an interval on a date-axis +@since OOo 3.4 +*/ +published struct TimeInterval +{ + /** specifies the number of units + */ + long Number; + + /** specifies a unit for the interval + <p>is a value out of the constant group <type>::com::sun::star::chart::TimeUnit</type>.</p> + */ + long TimeUnit; +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl b/offapi/com/sun/star/chart/TimeUnit.idl index 7f9fa28c3307..37cbd55d1a94 100644 --- a/offapi/com/sun/star/awt/grid/XGridCellRenderer.idl +++ b/offapi/com/sun/star/chart/TimeUnit.idl @@ -24,29 +24,27 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef __com_sun_star_awt_grid_XGridCellRenderer_idl__ -#define __com_sun_star_awt_grid_XGridCellRenderer_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#ifndef __com_sun_star_chart_TimeUnit_idl__ +#define __com_sun_star_chart_TimeUnit_idl__ //============================================================================= -module com { module sun { module star { module awt { module grid { + module com { module sun { module star { module chart { //============================================================================= -/** renderer for cells +/** Specifies a unit for intervals on a date-time axis +@since OOo 3.4 */ -interface XGridCellRenderer +published constants TimeUnit { - //------------------------------------------------------------------------- - + const long DAY = 0; + const long MONTH = 1; + const long YEAR = 2; }; //============================================================================= -}; }; }; }; }; +}; }; }; }; #endif diff --git a/offapi/com/sun/star/chart/XAxis.idl b/offapi/com/sun/star/chart/XAxis.idl new file mode 100755 index 000000000000..763e2f45412b --- /dev/null +++ b/offapi/com/sun/star/chart/XAxis.idl @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef com_sun_star_chart_XAxis_idl +#define com_sun_star_chart_XAxis_idl + +#ifndef __com_sun_star_beans_XPropertySet_idl__ +#include <com/sun/star/beans/XPropertySet.idl> +#endif + +module com { module sun { module star { module chart { + +/** Allows easier access to the different subelements of an axis. +@since OOo 3.4 +*/ + +interface XAxis : ::com::sun::star::uno::XInterface +{ + /** @returns + the title of the axis. The returned object supports the properties described in service <type>ChartTitle</type>. + */ + com::sun::star::beans::XPropertySet getAxisTitle(); + + /** @returns + the properties of the major grid of the axis. The returned object supports service <type>ChartGrid</type>. + */ + com::sun::star::beans::XPropertySet getMajorGrid(); + + /** @returns + the properties of the minor grid of the axis. The returned object supports service <type>ChartGrid</type>. + */ + com::sun::star::beans::XPropertySet getMinorGrid(); +}; + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/chart/XAxisSupplier.idl b/offapi/com/sun/star/chart/XAxisSupplier.idl new file mode 100755 index 000000000000..cf2bde2e310d --- /dev/null +++ b/offapi/com/sun/star/chart/XAxisSupplier.idl @@ -0,0 +1,61 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef com_sun_star_chart_XAxisSupplier_idl +#define com_sun_star_chart_XAxisSupplier_idl + +#ifndef __com_sun_star_chart_XAxis_idl__ +#include <com/sun/star/chart/XAxis.idl> +#endif + +module com { module sun { module star { module chart { + +/** Easier access to the different axes within a chart. +@since OOo 3.4 +*/ + +interface XAxisSupplier : ::com::sun::star::uno::XInterface +{ + /** @returns + the primary axis of the specified dimension. The returned object supports service <type>ChartAxis</type>. + + @param nDimensionIndex + Parameter nDimensionIndex says wether it is a x, y or z-axis (0 for x). + */ + com::sun::star::chart::XAxis getAxis( [in] long nDimensionIndex ); + + /** @returns + the secondary axis of the specified dimension. The returned object supports service <type>ChartAxis</type>. + + @param nDimensionIndex + Parameter nDimensionIndex says wether it is a x, y or z-axis (0 for x). + */ + com::sun::star::chart::XAxis getSecondaryAxis( [in] long nDimensionIndex ); +}; + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/chart/XChartDocument.idl b/offapi/com/sun/star/chart/XChartDocument.idl index 14322c6edf4a..1ffd268be59d 100644 --- a/offapi/com/sun/star/chart/XChartDocument.idl +++ b/offapi/com/sun/star/chart/XChartDocument.idl @@ -144,9 +144,12 @@ published interface XChartDocument: com::sun::star::frame::XModel <p>Since OOo 3.3 the returned object also supports interface <type>XComplexDescriptionAccess</type> which can be used to access complex hierarchical axis descriptions.</p> + <p>Since OOo 3.4 the returned object also supports interface <type>XDateCategories</type>.</p> + @see XChartData @see XChartDataArray @see XComplexDescriptionAccess + @see XDateCategories */ com::sun::star::chart::XChartData getData(); @@ -159,12 +162,16 @@ published interface XChartDocument: com::sun::star::frame::XModel <p>Since OOo 3.3 if the given object might support interface <type>XComplexDescriptionAccess</type> which allows to set complex hierarchical axis descriptions.</p> + <p>Since OOo 3.4 if the given object might support interface <type>XDateCategories</type> + which allows to set date values as x values for category charts.</p> + <p>The given data is copied before it is applied to the chart. So changing xData after this call will have no effect on the chart.</p> @see XChartData @see XChartDataArray @see XComplexDescriptionAccess + @see XDateCategories @param xData the object that provides the new data. diff --git a/offapi/com/sun/star/chart/XDateCategories.idl b/offapi/com/sun/star/chart/XDateCategories.idl new file mode 100755 index 000000000000..868670cb9c6f --- /dev/null +++ b/offapi/com/sun/star/chart/XDateCategories.idl @@ -0,0 +1,70 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_chart_XDateCategories_idl__ +#define __com_sun_star_chart_XDateCategories_idl__ + +#include <com/sun/star/uno/XInterface.idl> + +//============================================================================= + + module com { module sun { module star { module chart { + +//============================================================================= + +/** Allows to set date values as categories. + +<p>Can be obtained from interface <type>XChartDocument</type> via method getData().</p> + +@since OOo 3.4 +*/ + +published interface XDateCategories +{ + //------------------------------------------------------------------------- + + /** sets dates as categories + + @param rDates + a sequence of sequences of doubles representing dates. + */ + void setDateCategories( [in] sequence< double > rDates ); + + //------------------------------------------------------------------------- + + /** retrieves the date values if the category x-axis id a date axis + + @returns + a sequence of doubles representing dates. + */ + sequence< double > getDateCategories(); +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/chart/XSecondAxisTitleSupplier.idl b/offapi/com/sun/star/chart/XSecondAxisTitleSupplier.idl index fcd347eeed47..9f1009e3381a 100644 --- a/offapi/com/sun/star/chart/XSecondAxisTitleSupplier.idl +++ b/offapi/com/sun/star/chart/XSecondAxisTitleSupplier.idl @@ -21,4 +21,4 @@ interface XSecondAxisTitleSupplier: com::sun::star::uno::XInterface }; }; }; }; -#endif
\ No newline at end of file +#endif diff --git a/offapi/com/sun/star/chart/makefile.mk b/offapi/com/sun/star/chart/makefile.mk index fdbf07173c5e..94592e0d70e9 100644 --- a/offapi/com/sun/star/chart/makefile.mk +++ b/offapi/com/sun/star/chart/makefile.mk @@ -52,6 +52,7 @@ IDLFILES=\ ChartAxisPosition.idl\ ChartAxisLabelPosition.idl\ ChartAxisMarkPosition.idl\ + ChartAxisType.idl\ ChartAxisXSupplier.idl\ ChartAxisYSupplier.idl\ ChartAxisZSupplier.idl\ @@ -72,6 +73,7 @@ IDLFILES=\ ChartGrid.idl\ ChartLegend.idl\ ChartLegendPosition.idl\ + ChartLegendExpansion.idl \ ChartLine.idl\ ChartPieSegmentProperties.idl\ ChartRegressionCurveType.idl\ @@ -84,6 +86,7 @@ IDLFILES=\ ChartTwoAxisXSupplier.idl\ ChartTwoAxisYSupplier.idl\ DataLabelPlacement.idl\ + TimeIncrement.idl \ Diagram.idl\ Dim3DDiagram.idl\ DonutDiagram.idl\ @@ -94,8 +97,12 @@ IDLFILES=\ PieDiagram.idl\ StackableDiagram.idl\ StockDiagram.idl\ + TimeUnit.idl\ + TimeInterval.idl\ X3DDefaultSetter.idl\ X3DDisplay.idl\ + XAxis.idl\ + XAxisSupplier.idl\ XAxisXSupplier.idl\ XAxisYSupplier.idl\ XAxisZSupplier.idl\ @@ -104,6 +111,7 @@ IDLFILES=\ XChartDataChangeEventListener.idl\ XChartDocument.idl\ XComplexDescriptionAccess.idl\ + XDateCategories.idl\ XDiagram.idl\ XDiagramPositioning.idl\ XStatisticDisplay.idl\ diff --git a/offapi/com/sun/star/chart2/AxisType.idl b/offapi/com/sun/star/chart2/AxisType.idl index 16d977c34801..47cebc96388e 100644 --- a/offapi/com/sun/star/chart2/AxisType.idl +++ b/offapi/com/sun/star/chart2/AxisType.idl @@ -50,6 +50,9 @@ constants AxisType /** the axis shows the series names (z axis) */ const long SERIES = 3; + /** the axis shows dates + */ + const long DATE = 4; }; } ; // chart2 diff --git a/offapi/com/sun/star/chart2/CustomLegendEntry.idl b/offapi/com/sun/star/chart2/CustomLegendEntry.idl deleted file mode 100644 index 9668eaf90de4..000000000000 --- a/offapi/com/sun/star/chart2/CustomLegendEntry.idl +++ /dev/null @@ -1,50 +0,0 @@ -#ifndef com_sun_star_chart_CustomLegendEntry_idl -#define com_sun_star_chart_CustomLegendEntry_idl - -#include <com/sun/star/beans/XPropertySet.idl> -#include <com/sun/star/chart2/XLegendSymbolProvider.idl> - -module com -{ -module sun -{ -module star -{ -module chart2 -{ - -/** A legend entry that does not depend on data series or other chart - objects. It may contain any text a user specifies. - */ -service CustomLegendEntry -{ - /** Is used to identify an object as one that may be shown in a - legend. - */ - interface XLegendEntry; - - /** Is used to display a legend text - */ - interface XTitled; - - /** If the legend entry should contain a user-defined symbol, you - have to implement this interface. - */ - [optional] interface XLegendSymbolProvider; - - /** must be supported, if properties are implemented - */ - [optional] service ::com::sun::star::beans::XPropertySet; - - /** determines what kind of symbol is displayed next to the entry - in the legend. - */ - [optional, property] LegendSymbolStyle SymbolStyle; -}; - -} ; // chart2 -} ; // com -} ; // sun -} ; // star - -#endif diff --git a/offapi/com/sun/star/chart2/ExplicitIncrementData.idl b/offapi/com/sun/star/chart2/ExplicitIncrementData.idl deleted file mode 100644 index be0f315161d4..000000000000 --- a/offapi/com/sun/star/chart2/ExplicitIncrementData.idl +++ /dev/null @@ -1,96 +0,0 @@ -#ifndef com_sun_star_chart2_ExplicitIncrementData_idl -#define com_sun_star_chart2_ExplicitIncrementData_idl - -#include <com/sun/star/chart2/ExplicitSubIncrement.idl> - -//============================================================================= - -module com { module sun { module star { module chart2 { - -//============================================================================= - -/** An Increment describes how tickmarks are positioned on the scale of an axis. - -@see <type>Axis</type> -@see <type>Grid</type> -@see <type>Scale</type> -@see <type>XScaling</type> -*/ -struct ExplicitIncrementData -{ - /** <member>Distance</member> describes the distance between two - neighboring main tickmarks on a <type>Scale</type> of an axis. - All neighboring main tickmarks have the same constant distance. - - <p>If the Scale has a <type>XScaling</type> the <member>Distance</member> - may be measured in two different ways - that is - before or after the - scaling is applied.</p> - - <p>On a logarithmic scale for example the distance between two main - tickmarks is typically measured after the scaling is applied: - Distance = log(tick2)-log(tick1) - ( log(1000)-log(100)==log(100)-log(10)==log(10)-log(1)==1==Distance ). - The resulting tickmarks will always look equidistant on the screen. - The other possibility is to have a Distance = tick2-tick1 measured constant - before a scaling is applied, which may lead to non equidistant tickmarks - on the screen.</p> - - <p><member>PostEquidistant</member> rules whether the <member>Distance</member> - is meant to be a value before or after scaling.</p> - */ - double Distance; - - /** - <member>PostEquidistant</member> rules whether the member <member>Distance</member> - describes a distance before or after the scaling is applied. - - <p>If <member>PostEquidistant</member> equals <TRUE/> <member>Distance</member> - is given in values after <type>XScaling</type> is applied, thus resulting - main tickmarks will always look equidistant on the screen. - If <member>PostEquidistant</member> equals <FALSE/> <member>Distance</member> - is given in values before <type>XScaling</type> is applied.</p> - */ - boolean PostEquidistant; - - /** The <member>BaseValue</member> gives a starting point on the scale - to which all further main tickmarks are relatively positioned. - - <p>The <member>BaseValue</member> is always a value on the scale before - a possible scaling is applied. If the given value is not valid in the - associated scaling the minimum of the scaling is assumed, - if there is no minimum any other obvious value will be assumed.</p> - - <p>E.g.: assume a scale from 0 to 6 with identical scaling. - Further assume this Increment to have Distance==2 and PostEquidistant==false. - Setting BaseValue=0 would lead to main tickmarks 0; 2; 4; 6; - Setting BaseValue=1,3 would lead to main tickmarks 1,3; 3,3; 5,3; - Setting BaseValue=-0,7 would also lead to main tickmarks 1,3; 3,3; 5,3; - And setting BaseValue to 2, -2, 4, -4 etc. in this example - leads to the same result as BaseValue=0.</p> - */ - double BaseValue; - - /** <member>SubIncrements</member> describes the positioning of further - sub tickmarks on the scale of an axis. - - <p>The first SubIncrement in this sequence determines how the - distance between two neighboring main tickmarks is divided for positioning - of further sub tickmarks. Every following SubIncrement determines the - positions of subsequent tickmarks in relation to their parent tickmarks - given by the preceding SubIncrement.</p> - */ - sequence< ::com::sun::star::chart2::ExplicitSubIncrement > SubIncrements; - - /** If ShiftedPosition is false all ticks are set at the positions as described above. - E.g. having tickmarks for whole numbers 1, 2 and 3 the ticks are exactly placed on positions for the values 1, 2 and 3. - In contrast it is possible to have the tickmarks shifted thus they are placed between the indicated values. - So if ShiftedPosition is set to true the tickmarks in the example are placed at 0.5 1.5 2.5 and 3.5. - */ - boolean ShiftedPosition; -}; - -//============================================================================= - -}; }; }; }; - -#endif diff --git a/offapi/com/sun/star/chart2/ExplicitScaleData.idl b/offapi/com/sun/star/chart2/ExplicitScaleData.idl deleted file mode 100644 index 7639a4d33378..000000000000 --- a/offapi/com/sun/star/chart2/ExplicitScaleData.idl +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef com_sun_star_chart2_ExplicitScaleData_idl -#define com_sun_star_chart2_ExplicitScaleData_idl - -#ifndef com_sun_star_chart2_Break_idl -#include <com/sun/star/chart2/Break.idl> -#endif - -#ifndef com_sun_star_chart2_XScaling_idl -#include <com/sun/star/chart2/XScaling.idl> -#endif - -#ifndef com_sun_star_chart2_AxisOrientation_idl -#include <com/sun/star/chart2/AxisOrientation.idl> -#endif - -//============================================================================= - -module com { module sun { module star { module chart2 { - -//============================================================================= - -/** This structure contains the explicit values for a scale like Minimum and Maximum. - In contrast these values may also be implicit (automatically - calculated) as indicated within the structure <type>ScaleData</type>. - */ -struct ExplicitScaleData -{ - double Minimum; - double Maximum; - double Origin; - - AxisOrientation Orientation; - - XScaling Scaling; - - sequence< Break > Breaks; - - long AxisType; -}; - -//============================================================================= - -}; }; }; }; - -#endif diff --git a/offapi/com/sun/star/chart2/ExplicitSubIncrement.idl b/offapi/com/sun/star/chart2/ExplicitSubIncrement.idl deleted file mode 100644 index c1af626c5db1..000000000000 --- a/offapi/com/sun/star/chart2/ExplicitSubIncrement.idl +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef com_sun_star_chart2_ExplicitSubIncrement_idl -#define com_sun_star_chart2_ExplicitSubIncrement_idl - -//============================================================================= - -module com { module sun { module star { module chart2 { - -//============================================================================= - -struct ExplicitSubIncrement -{ - /** Numbers of intervals between two superior ticks. For an axis - this usually means, that <code>IntervalCount - 1</code> - sub-tick-marks are displayed between two superior ticks. - - */ - long IntervalCount; - - /** If <TRUE/>, the distance between two sub-tick-marks on the - screen is always the same. If <FALSE/>, the distances may - differ depending on the <type>XScaling</type>. - */ - boolean PostEquidistant; -}; - -//============================================================================= - -}; }; }; }; - -#endif diff --git a/offapi/com/sun/star/chart2/IncrementData.idl b/offapi/com/sun/star/chart2/IncrementData.idl index f37145ad75ff..0342a1c150c6 100644 --- a/offapi/com/sun/star/chart2/IncrementData.idl +++ b/offapi/com/sun/star/chart2/IncrementData.idl @@ -23,8 +23,6 @@ struct IncrementData incompatible type, the Distance is meant to be calculated automatically by the view component representing the model containing this increment. - - @see <type>ExplicitIncrementData</type> */ any Distance; @@ -45,8 +43,6 @@ struct IncrementData incompatible type, the BaseValue is meant to be calculated automatically by the view component representing the model containing this increment. - - @see <type>ExplicitIncrementData</type> */ any BaseValue; diff --git a/offapi/com/sun/star/chart2/Legend.idl b/offapi/com/sun/star/chart2/Legend.idl index bec63de04c27..0285f014fd0b 100644 --- a/offapi/com/sun/star/chart2/Legend.idl +++ b/offapi/com/sun/star/chart2/Legend.idl @@ -29,7 +29,7 @@ #include <com/sun/star/chart2/XLegend.idl> #include <com/sun/star/chart2/LegendPosition.idl> -#include <com/sun/star/chart2/LegendExpansion.idl> +#include <com/sun/star/chart/ChartLegendExpansion.idl> #include <com/sun/star/beans/PropertySet.idl> #include <com/sun/star/drawing/LineProperties.idl> @@ -63,12 +63,12 @@ service Legend /** Determines how the aspect ratio of the legend should roughly be. - <p>Set the Expansion to <member>LegendExpansion::HIGH</member> + <p>Set the Expansion to <member>::com::sun::star::chart::ChartLegendExpansion::HIGH</member> for a legend that is positioned on the right or left hand side. Use <member>LegendExpansion::WIDE</member> for a legend that is positioned on top or the bottom.</p> */ - [property] LegendExpansion Expansion; + [property] ::com::sun::star::chart::ChartLegendExpansion Expansion; /** Determines, whether the legend should be rendered by the view. */ diff --git a/offapi/com/sun/star/chart2/LegendSymbolStyle.idl b/offapi/com/sun/star/chart2/LegendSymbolStyle.idl deleted file mode 100644 index 13d47ee3a7c9..000000000000 --- a/offapi/com/sun/star/chart2/LegendSymbolStyle.idl +++ /dev/null @@ -1,107 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef com_sun_star_chart_LegendSymbolStyle_idl -#define com_sun_star_chart_LegendSymbolStyle_idl - -#include <com/sun/star/uno/XInterface.idl> - -#include <com/sun/star/chart2/XTitle.idl> - -module com -{ -module sun -{ -module star -{ -module chart2 -{ - -/** - */ -enum LegendSymbolStyle -{ - /** A square box with border. - */ - BOX, - - /** A rectangle that is wider than high with border. - */ - BAR, - - /** A square box with border, that may change its aspect ratio if - the layout of the legend requires this. - */ - RECTANGLE, - - /** A filled rectangle with no border that uses all the space - available for the legend entry's symbol, leaving no padding - space. This is especially useful for legends representing a - color-scale. - */ - STRETCHED_RECTANGLE, - - /** A line extending from the left edge to the right edge - */ - HORIZONTAL_LINE, - - /** A line extending from the top edge to the bottom edge - */ - VERTICAL_LINE, - - /** A line spanning the diagonal of the box you would get with - <member>BOX</member>. - */ - DIAGONAL_LINE, - - /** A line like with <member>LINE</member>, but with a small - bordered square box in the middle. - */ - LINE_WITH_BOX, - - /** A line like with <member>LINE</member>, but with the symbol - that is returned by <member>XLegendEntry::getSymbol</member> - (see also <member>USER_DEFINED</member>). - */ - LINE_WITH_SYMBOL, - - /** A bordered circle which has the same bounding-box as the - <member>BOX</member>. - */ - CIRCLE, - - /** Use the symbol that is returned by - <member>XLegendEntry::getSymbol</member>. - */ - USER_DEFINED -}; - -} ; // chart2 -} ; // com -} ; // sun -} ; // star - -#endif diff --git a/offapi/com/sun/star/chart2/ScaleData.idl b/offapi/com/sun/star/chart2/ScaleData.idl index addd66e10320..9bb51005e206 100644 --- a/offapi/com/sun/star/chart2/ScaleData.idl +++ b/offapi/com/sun/star/chart2/ScaleData.idl @@ -1,29 +1,12 @@ #ifndef com_sun_star_chart2_ScaleData_idl #define com_sun_star_chart2_ScaleData_idl -#ifndef com_sun_star_chart2_Break_idl -#include <com/sun/star/chart2/Break.idl> -#endif - -#ifndef com_sun_star_chart2_XScaling_idl #include <com/sun/star/chart2/XScaling.idl> -#endif - -#ifndef com_sun_star_chart2_AxisOrientation_idl #include <com/sun/star/chart2/AxisOrientation.idl> -#endif - -#ifndef com_sun_star_chart2_data_XLabeledDataSequence_idl #include <com/sun/star/chart2/data/XLabeledDataSequence.idl> -#endif - -#ifndef com_sun_star_chart2_AxisType_idl #include <com/sun/star/chart2/AxisType.idl> -#endif - -#ifndef com_sun_star_chart_IncrementData_idl #include <com/sun/star/chart2/IncrementData.idl> -#endif +#include <com/sun/star/chart/TimeIncrement.idl> //============================================================================= @@ -76,8 +59,6 @@ struct ScaleData XScaling Scaling; - sequence< Break > Breaks; - data::XLabeledDataSequence Categories; /** describes the type of the axis. @@ -87,7 +68,22 @@ struct ScaleData */ long AxisType; + /** if true an AxisType CATEGORY is interpreted as DATE if the underlying data given in Categories are dates + */ + boolean AutoDateAxis; + + /** describes wether data points on category or date axis are placed between tickmarks or not + if true the maximum on the scale will be expanded for one interval + */ + boolean ShiftedCategoryPosition; + + /** increment data to be used for not date-time axis + */ IncrementData IncrementData; + + /** increment data to be used in case of date-time axis + */ + ::com::sun::star::chart::TimeIncrement TimeIncrement; }; //============================================================================= diff --git a/offapi/com/sun/star/chart2/StandardDiagramCreationParameters.idl b/offapi/com/sun/star/chart2/StandardDiagramCreationParameters.idl index e5bc31759ace..6733715f1703 100644 --- a/offapi/com/sun/star/chart2/StandardDiagramCreationParameters.idl +++ b/offapi/com/sun/star/chart2/StandardDiagramCreationParameters.idl @@ -49,6 +49,11 @@ service StandardDiagramCreationParameters a data-source is used as categories. */ [optional, property] boolean HasCategories; + + /** If categories are given they should be used as x values also if a chart type requires x values. + Default is true. + */ + [optional, property] boolean UseCategoriesAsX; }; } ; // chart2 diff --git a/offapi/com/sun/star/chart2/SubIncrement.idl b/offapi/com/sun/star/chart2/SubIncrement.idl index f076db0eef92..b886f2c531fb 100644 --- a/offapi/com/sun/star/chart2/SubIncrement.idl +++ b/offapi/com/sun/star/chart2/SubIncrement.idl @@ -11,15 +11,11 @@ struct SubIncrement { /** should contain nothing for <em>auto</em>, or an integer value for an explicit interval count. - - @see <type>ExplicitSubIncrement</type> */ any IntervalCount; /** should contain nothing for <em>auto</em>, or a boolean value for an explicit setting. - - @see <type>ExplicitSubIncrement</type> */ any PostEquidistant; }; diff --git a/offapi/com/sun/star/chart2/XAnyDescriptionAccess.idl b/offapi/com/sun/star/chart2/XAnyDescriptionAccess.idl new file mode 100755 index 000000000000..ca455c401264 --- /dev/null +++ b/offapi/com/sun/star/chart2/XAnyDescriptionAccess.idl @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_chart2_XAnyDescriptionAccess_idl__ +#define __com_sun_star_chart2_XAnyDescriptionAccess_idl__ + +#ifndef __com_sun_star_chart_XComplexDescriptionAccess_idl__ +#include <com/sun/star/chart/XComplexDescriptionAccess.idl> +#endif + +//============================================================================= + + module com { module sun { module star { module chart2 { + +//============================================================================= + +/** Offers any access to column and row descriptions. +This allows to set date values as categories. + +<p>Can be obtained from interface <type>XChartDocument</type> via method getData().</p> + +@since OOo 3.4 +*/ + +interface XAnyDescriptionAccess : ::com::sun::star::chart::XComplexDescriptionAccess +{ + //------------------------------------------------------------------------- + + /** retrieves the descriptions for all rows. + + @returns + a sequence of sequences of anys representing the descriptions + of all rows. The outer index represents different rows. + The inner index represents the different levels (usually there is only one). + The any might be strings for category text axis or doubles for date axis. + */ + sequence< sequence< any > > getAnyRowDescriptions(); + + //------------------------------------------------------------------------- + + /** sets the descriptions for all rows. + + @param rRowDescriptions + a sequence of sequences of anys representing the descriptions of all + rows. The outer index represents different rows. + The inner index represents the different levels (usually there is only one). + The any might be strings for category text axis or doubles for date axis. + */ + void setAnyRowDescriptions( [in] sequence< sequence< any > > rRowDescriptions ); + + //------------------------------------------------------------------------- + + /** retrieves the descriptions for all columns. + + @returns + a sequence of sequences of anys representing the descriptions + of all columns. The outer index represents different columns. + The inner index represents the different levels (usually there is only one). + The any might be strings for category text axis or doubles for date axis. + */ + sequence< sequence< any > > getAnyColumnDescriptions(); + + //------------------------------------------------------------------------- + + /** sets the descriptions for all columns. + + @param rColumnDescriptions + a sequence of sequences of anys which represent the descriptions of + all columns. The outer index represents different columns. + The inner index represents the different levels (usually there is only one). + The any might be strings for category text axis or doubles for date axis. + */ + void setAnyColumnDescriptions( [in] sequence< sequence< any > > rColumnDescriptions ); +}; + +//============================================================================= + +}; }; }; }; + +#endif diff --git a/offapi/com/sun/star/chart2/XAxis.idl b/offapi/com/sun/star/chart2/XAxis.idl index 9a116c1a3bd4..55a9089da0cf 100644 --- a/offapi/com/sun/star/chart2/XAxis.idl +++ b/offapi/com/sun/star/chart2/XAxis.idl @@ -1,3 +1,29 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ #ifndef com_sun_star_chart_XAxis_idl #define com_sun_star_chart_XAxis_idl diff --git a/offapi/com/sun/star/chart2/XCoordinateSystem.idl b/offapi/com/sun/star/chart2/XCoordinateSystem.idl index 9ae7217387cf..e747562e59c2 100644 --- a/offapi/com/sun/star/chart2/XCoordinateSystem.idl +++ b/offapi/com/sun/star/chart2/XCoordinateSystem.idl @@ -1,3 +1,29 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ #ifndef com_sun_star_chart2_XCoordinateSystem_idl #define com_sun_star_chart2_XCoordinateSystem_idl diff --git a/offapi/com/sun/star/chart2/XDiagram.idl b/offapi/com/sun/star/chart2/XDiagram.idl index 3836489b7aed..23b256e63349 100644 --- a/offapi/com/sun/star/chart2/XDiagram.idl +++ b/offapi/com/sun/star/chart2/XDiagram.idl @@ -32,9 +32,10 @@ #endif #include <com/sun/star/beans/XPropertySet.idl> - +#include <com/sun/star/beans/PropertyValue.idl> #include <com/sun/star/chart2/XLegend.idl> #include <com/sun/star/chart2/XColorScheme.idl> +#include <com/sun/star/chart2/data/XDataSource.idl> #include <com/sun/star/chart2/data/XLabeledDataSequence.idl> module com @@ -48,11 +49,6 @@ module chart2 interface XDiagram : ::com::sun::star::uno::XInterface { - /** gets the component that creates a new diagram or modifies - an existing diagram according to its rules. - */ -// string getChartTypeTemplateServiceName(); - /** returns the property set that determines the visual appearance of the wall. @@ -87,6 +83,25 @@ interface XDiagram : ::com::sun::star::uno::XInterface colors for data series (or data points) in the diagram. */ void setDefaultColorScheme( [in] XColorScheme xColorScheme ); + + /** sets new data to the diagram. + + @param xDataSource + This data source will be interpreted in a chart-type + specific way and the <type>DataSeries</type> found in + <code>xDiagram</code> will be adapted to the new data. + Missing data series will be created and unused ones will + be deleted. + + @param aArguments + Arguments tells how to slice the given data. + + <p>For standard parameters that may be used, see the + service <type>StandardDiagramCreationParameters</type>. + </p> + */ + void setDiagramData( [in] data::XDataSource xDataSource, + [in] sequence< com::sun::star::beans::PropertyValue > aArguments ); }; } ; // chart2 diff --git a/offapi/com/sun/star/chart2/XLegend.idl b/offapi/com/sun/star/chart2/XLegend.idl index 309aa148dd2a..1cc8666ef20d 100644 --- a/offapi/com/sun/star/chart2/XLegend.idl +++ b/offapi/com/sun/star/chart2/XLegend.idl @@ -3,15 +3,6 @@ #include <com/sun/star/uno/XInterface.idl> -#ifndef __com_sun_star_lang_IllegalArgumentException_idl__ -#include <com/sun/star/lang/IllegalArgumentException.idl> -#endif -#ifndef __com_sun_star_container_NoSuchElementException_idl__ -#include <com/sun/star/container/NoSuchElementException.idl> -#endif - -#include <com/sun/star/chart2/XLegendEntry.idl> - module com { module sun @@ -25,30 +16,6 @@ module chart2 */ interface XLegend : ::com::sun::star::uno::XInterface { - /** The entry added is appended to the list, such that it appears - at the end of the legend. - - @param xEntry - - If it supports <type>CustomLegendEntry</type>, - the <type>XTitle</type> is used for displaying a text, and - the symbol is displayed according to the - <member>CustomLegendEntry::SymbolStyle</member> property. - */ - void registerEntry( [in] XLegendEntry xEntry ) - raises( com::sun::star::lang::IllegalArgumentException ); - - /** Removes an entry that was registered before - - <p>(see <member>registerEntry</member>)</p> - */ - void revokeEntry( [in] XLegendEntry xEntry ) - raises( com::sun::star::container::NoSuchElementException ); - - /** Returns a list of all legend entries in the order in which - they were registered. - */ - sequence< XLegendEntry > getEntries(); }; } ; // chart2 diff --git a/offapi/com/sun/star/chart2/XLegendEntry.idl b/offapi/com/sun/star/chart2/XLegendEntry.idl deleted file mode 100644 index 579c453dbd6a..000000000000 --- a/offapi/com/sun/star/chart2/XLegendEntry.idl +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef com_sun_star_chart_XLegendEntry_idl -#define com_sun_star_chart_XLegendEntry_idl - -#include <com/sun/star/uno/XInterface.idl> - -#include "com/sun/star/chart2/XTitle.idl" -#include "com/sun/star/chart2/LegendSymbolStyle.idl" - -module com -{ -module sun -{ -module star -{ -module chart2 -{ - -/** Object type for Legend. - */ -interface XLegendEntry : ::com::sun::star::uno::XInterface -{ - // no methods, currently only used for type safety -}; - -} ; // chart2 -} ; // com -} ; // sun -} ; // star - -#endif diff --git a/offapi/com/sun/star/chart2/XLegendSymbolProvider.idl b/offapi/com/sun/star/chart2/XLegendSymbolProvider.idl deleted file mode 100644 index 56b2b082d317..000000000000 --- a/offapi/com/sun/star/chart2/XLegendSymbolProvider.idl +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef com_sun_star_chart_XLegendSymbolProvider_idl -#define com_sun_star_chart_XLegendSymbolProvider_idl - -#include <com/sun/star/uno/XInterface.idl> -#include <com/sun/star/drawing/XShape.idl> - -module com -{ -module sun -{ -module star -{ -module chart2 -{ - -/** - */ -interface XLegendSymbolProvider : ::com::sun::star::uno::XInterface -{ - /** The returned shape is used for display in the legend. It may - also be used for display at a data points. - - <p>The shape returned here, will be resized using - <member scope="com::sun::star::drawing">XShape::setSize</member> - to fit the available space in the legend.</p> - */ - com::sun::star::drawing::XShape getSymbol(); -}; - -} ; // chart2 -} ; // com -} ; // sun -} ; // star - -#endif diff --git a/offapi/com/sun/star/chart2/XPlotter.idl b/offapi/com/sun/star/chart2/XPlotter.idl deleted file mode 100644 index 32e3535a912a..000000000000 --- a/offapi/com/sun/star/chart2/XPlotter.idl +++ /dev/null @@ -1,128 +0,0 @@ -#ifndef com_sun_star_chart2_XPlotter_idl -#define com_sun_star_chart2_XPlotter_idl - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif - -#ifndef __com_sun_star_drawing_XShapes_idl__ -#include <com/sun/star/drawing/XShapes.idl> -#endif - -#ifndef _com_sun_star_drawing_XShapeGrouper_idl_ -#include <com/sun/star/drawing/XShapeGrouper.idl> -#endif - -#ifndef _com_sun_star_lang_xmultiservicefactory_idl_ -#include <com/sun/star/lang/XMultiServiceFactory.idl> -#endif - -#ifndef com_sun_star_chart2_CoordinateSystemTypeID_idl -#include <com/sun/star/chart2/CoordinateSystemTypeID.idl> -#endif - -#ifndef com_sun_star_chart2_ScaleData_idl -#include <com/sun/star/chart2/ScaleData.idl> -#endif - -#ifndef com_sun_star_chart2_XTransformation_idl -#include <com/sun/star/chart2/XTransformation.idl> -#endif - -//============================================================================= - -module com { module sun { module star { module chart2 { - -//============================================================================= - -/** The main task of a Plotter is to create graphic objects which have a certain - logic place within a coordinate system. For example the bars of a bar chart - are such graphic objects. The created graphic objects need to be of type - com::sun::star::drawing::Shape. - - <p> - Within the chart application we differentiate between two "types" of shapes - which can be created by a Plotter. - The first type are shapes which are completely defined by coordinates - in the logic coordinate system and will be positioned within this logic - coordinate system. Those shapes are called "logic shapes" - or "logically placed shapes". For example a rectangle of a bar chart - is a "logic shape". - </p> - - <p> - The second type of shapes are those who can not or should not - be placed in the logic coordinate system. For example consider a three - dimensional bar chart with text labels for each data point. You probably - would not like to place the text shapes as three dimensional objects within - the logic coordinate system, rather you would like to position the texts as - two dimensional objects on the two dimensional final page. Those shapes are - called "illogic shapes" in contrast to "logic shapes". - "Illogic shapes" are always two dimensional and placed on the documents page. - </p> - - <p> - For each type of shapes the Plotter gets one Target where it can add - or remove shapes. - </p> - - <p> A Plotter is not allowed to set the property "Transformation" on a - shape as this will be done elsewhere. - </p> -*/ - -//@ todo ? should this be a XComponent? -interface XPlotter : ::com::sun::star::uno::XInterface -{ - //------------------------------------------------------------------------- - /** Each Plotter implicit uses a certain type of logic coordinate - system for interpreting data as coordinates. - For example a bar-chart uses a Cartesian coordinate system for - interpreting x- and y-values from a spreadsheet as Cartesian - coordinates. In contrast the pie chart assumes a polar coordinate - system. - The type of this implicit used source coordinate system has to be - returned here. - The returned type of an implementation never changes. - */ - CoordinateSystemTypeID getCoordinateSystemTypeID(); - - //------------------------------------------------------------------------- - /** For each type of shapes ("logic" or "illogic") there exists one - container. The Plotter will create shapes and then add (or remove) - them from these containers. - - <p> - The lifetime of the container has to be handled by the calling object. The - calling object must assure that the container will exist longer than the - XPlotter Object. - </p> - ... - */ - void init( [in] com::sun::star::drawing::XShapes xLogicTarget - , [in] com::sun::star::drawing::XShapes xFinalTarget - , [in] com::sun::star::lang::XMultiServiceFactory xFactory ); - - //------------------------------------------------------------------------- - /** For each dimension of the "logic source coordinate system" the - XPlotter object needs a Scale to decide which shapes - need to be created and maybe logically clipped. The XPlotter object - becomes the new owner of the given scales and directions and needs to keep - them alive. Nobody else will change them. - Pay attention that a "Scale" can have several breaks. - */ - void setScales( [in] sequence< ScaleData > rScales); - - //------------------------------------------------------------------------- - /** - */ - void setTransformation( [in] XTransformation xTransformationToLogicTarget - , [in] XTransformation xTransformationToFinalPage ); -}; - -//============================================================================= - -}; }; }; }; - -#endif - diff --git a/offapi/com/sun/star/chart2/XUndoHelper.idl b/offapi/com/sun/star/chart2/XUndoHelper.idl deleted file mode 100644 index a269c43cd251..000000000000 --- a/offapi/com/sun/star/chart2/XUndoHelper.idl +++ /dev/null @@ -1,89 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef com_sun_star_chart2_XUndoHelper_idl -#define com_sun_star_chart2_XUndoHelper_idl - -#include <com/sun/star/uno/XInterface.idl> -#include <com/sun/star/frame/XModel.idl> - -module com -{ -module sun -{ -module star -{ -module chart2 -{ - -/** An interface for storing frame::XModel objects for container undo. - */ -interface XUndoHelper : ::com::sun::star::uno::XInterface -{ - /** call this before you change the xCurrentModel - - @return a clone of the current model that can later be used to - restore the state of a changed model - */ - ::com::sun::star::frame::XModel getModelCloneForUndo( - [in] ::com::sun::star::frame::XModel xModelBeforeChange ); - - /** call this before you change the xCurrentModel. You can pass - parameters to refine the information that is cloned. - - @return a clone of the current model that can later be used to - restore the state of a changed model using the same - arguments in applyModelContentWithArguments. - */ -// ::com::sun::star::frame::XModel getModelCloneForUndoWithArguments( -// [in] ::com::sun::star::frame::XModel xModelBeforeChange, -// [in] sequence< ::com::sun::star::beans::PropertyValue > aArguments ); - - /** apply the content of xModelToCopyFrom to the XModel in xModelToChange - */ - void applyModelContent( [inout] ::com::sun::star::frame::XModel xModelToChange, - [in] ::com::sun::star::frame::XModel xModelToCopyFrom ); - - /** apply the content of xModelToCopyFrom to the XModel in - xModelToChange. You can pass parameters to refine the - information that is applied. - - <p>Note that xModelToCopyFrom should have been created with - getModelCloneForUndoWithArguments using the same arguments as - are passed here.</p> - */ -// void applyModelContentWithArguments( -// [inout] ::com::sun::star::frame::XModel xModelToChange, -// [in] ::com::sun::star::frame::XModel xModelToCopyFrom, -// [in] sequence< ::com::sun::star::beans::PropertyValue > aArguments ); -}; - -} ; // chart2 -} ; // com -} ; // sun -} ; // star - -#endif diff --git a/offapi/com/sun/star/chart2/XUndoManager.idl b/offapi/com/sun/star/chart2/XUndoManager.idl deleted file mode 100644 index 2d0ca4bd4977..000000000000 --- a/offapi/com/sun/star/chart2/XUndoManager.idl +++ /dev/null @@ -1,111 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#ifndef com_sun_star_chart2_XUndoManager_idl -#define com_sun_star_chart2_XUndoManager_idl - -#include <com/sun/star/uno/XInterface.idl> -#include <com/sun/star/frame/XModel.idl> -#include <com/sun/star/beans/PropertyValue.idl> - -module com -{ -module sun -{ -module star -{ -module chart2 -{ - -/** An interface for undo functionality based on passing frame::XModel - objects. - */ -interface XUndoManager : ::com::sun::star::uno::XInterface -{ - /** call this before you change the xCurrentModel - */ - void preAction( [in] ::com::sun::star::frame::XModel xModelBeforeChange ); - - /** call this before you change the xCurrentModel. You can pass - parameters to refine the undo action. - */ - void preActionWithArguments( [in] ::com::sun::star::frame::XModel xModelBeforeChange, - [in] sequence< ::com::sun::star::beans::PropertyValue > aArguments ); - - /** call this after you successfully did changes to your current model - */ - void postAction( [in] string aUndoText ); - /** call this if you aborted the current action. - */ - void cancelAction(); - - /** same as cancelAction() but restores the given model to the - state set in preAction. This is useful for cancellation in - live-preview dialogs. - */ - void cancelActionWithUndo( [inout] ::com::sun::star::frame::XModel xModelToRestore ); - - /** give the current model to be put into the redo-stack - */ - void undo( [inout] ::com::sun::star::frame::XModel xCurrentModel ); - - /** give the current model to be put into the undo-stack - */ - void redo( [inout] ::com::sun::star::frame::XModel xCurrentModel ); - - /** @return <TRUE/> if the undo stack is not empty, i.e. a call to undo() will succeed - */ - boolean undoPossible(); - - /** @return <TRUE/> if the redo stack is not empty, i.e. a call to redo() will succeed - */ - boolean redoPossible(); - - /** Retrieves the undo string for the most recent undo step - */ - string getCurrentUndoString(); - - /** Retrieves the redo string for the most recent undo step - */ - string getCurrentRedoString(); - - /** Retrieves the undo strings of all stored undo actions in - chronological order starting with the most recent. - */ - sequence< string > getAllUndoStrings(); - - /** Retrieves the redo strings of all stored undo actions in - chronological order starting with the most recent. - */ - sequence< string > getAllRedoStrings(); -}; - -} ; // chart2 -} ; // com -} ; // sun -} ; // star - -#endif diff --git a/offapi/com/sun/star/chart2/makefile.mk b/offapi/com/sun/star/chart2/makefile.mk index dcce7e71d4d2..873bb985d566 100644 --- a/offapi/com/sun/star/chart2/makefile.mk +++ b/offapi/com/sun/star/chart2/makefile.mk @@ -41,20 +41,14 @@ PRJNAME=offapi IDLFILES= \ AxisType.idl \ AxisOrientation.idl \ - Break.idl \ CoordinateSystemTypeID.idl \ CurveStyle.idl \ DataPointGeometry3D.idl \ DataPointLabel.idl \ - ExplicitIncrementData.idl \ - ExplicitScaleData.idl \ - ExplicitSubIncrement.idl \ FillBitmap.idl \ IncrementData.idl \ InterpretedData.idl \ - LegendExpansion.idl \ LegendPosition.idl \ - LegendSymbolStyle.idl \ LightSource.idl \ PieChartOffsetMode.idl \ RelativePosition.idl \ @@ -66,7 +60,7 @@ IDLFILES= \ SymbolStyle.idl \ TickmarkStyle.idl \ TransparencyStyle.idl \ - ViewLegendEntry.idl \ + XAnyDescriptionAccess.idl\ XAxis.idl \ XCoordinateSystem.idl \ XCoordinateSystemContainer.idl \ @@ -89,9 +83,6 @@ IDLFILES= \ XInternalDataProvider.idl \ XLabeled.idl \ XLegend.idl \ - XLegendEntry.idl \ - XLegendSymbolProvider.idl \ - XPlotter.idl \ XRegressionCurve.idl \ XRegressionCurveCalculator.idl \ XRegressionCurveContainer.idl \ @@ -101,9 +92,6 @@ IDLFILES= \ XTitle.idl \ XTitled.idl \ XTransformation.idl \ - XUndoManager.idl \ - XUndoSupplier.idl \ - XUndoHelper.idl # --- Targets ------------------------------------------------------ diff --git a/offapi/com/sun/star/deployment/XExtensionManager.idl b/offapi/com/sun/star/deployment/XExtensionManager.idl index 0b8307f0e291..991e4b476db7 100644 --- a/offapi/com/sun/star/deployment/XExtensionManager.idl +++ b/offapi/com/sun/star/deployment/XExtensionManager.idl @@ -281,6 +281,8 @@ interface XExtensionManager Added extensions will be added to the database and removed extensions will be removed from the database. + The active extensions are determined. That is, shared or bundled extensions + are not necessaryly registered (<member>XPackage::registerPackage</member>). @return If true - then at least one extension was removed or added. Otherwise @@ -295,6 +297,25 @@ interface XExtensionManager com::sun::star::lang::IllegalArgumentException); + /** synchronizes the special bundled_prereg repository, which is based on + the bundled extensions and has its registration data folder at + $BUNDLED_EXTENSIONS_PREREG (for example openoffice.org3/share/prereg). + + All bundled extensions are registered (<member>XPackage::registerPackage</member>). + The active extensions are NOT determined, because this function only works + with bundled extensions. + + This function is intended to be called during the installation of OOo. + OOo will copy parts of the registration data folder to the user installation at the + first startup. + */ + + void synchronizeBundledPrereg( + [in] com::sun::star::task::XAbortChannel xAbortChannel, + [in] com::sun::star::ucb::XCommandEnvironment xCmdEnv ) + raises (DeploymentException); + + /** returns all extensions which are currently not in use because the user did not accept the license. diff --git a/offapi/com/sun/star/deployment/XPackage.idl b/offapi/com/sun/star/deployment/XPackage.idl index 8a2b1711f1be..a87708596943 100644..100755 --- a/offapi/com/sun/star/deployment/XPackage.idl +++ b/offapi/com/sun/star/deployment/XPackage.idl @@ -262,6 +262,14 @@ interface XPackage string getDescription() raises (ExtensionRemovedException); + /** returns a string containing the license text. + + @return + license + */ + string getLicenseText() + raises (ExtensionRemovedException); + /** returns a sequence of update information URLs. The sequence may be empty in case no update information is available. diff --git a/offapi/com/sun/star/deployment/XPackageRegistry.idl b/offapi/com/sun/star/deployment/XPackageRegistry.idl index 9cc4c6f92afc..98501de6c6fa 100644 --- a/offapi/com/sun/star/deployment/XPackageRegistry.idl +++ b/offapi/com/sun/star/deployment/XPackageRegistry.idl @@ -115,6 +115,13 @@ interface XPackageRegistry supported <type>XPackageTypeInfo</type>s. */ sequence<XPackageTypeInfo> getSupportedPackageTypes(); + + void packageRemoved( + [in] string url, + [in] string mediaType) + raises (DeploymentException, + com::sun::star::lang::IllegalArgumentException); + }; }; }; }; }; diff --git a/offapi/com/sun/star/document/EmptyUndoStackException.idl b/offapi/com/sun/star/document/EmptyUndoStackException.idl new file mode 100755 index 000000000000..e003d6af71b9 --- /dev/null +++ b/offapi/com/sun/star/document/EmptyUndoStackException.idl @@ -0,0 +1,51 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_document_EmptyUndoStackException_idl__ +#define __com_sun_star_document_EmptyUndoStackException_idl__ + +#include <com/sun/star/util/InvalidStateException.idl> + +//================================================================================================================== + +module com { module sun { module star { module document { + +//================================================================================================================== + +/** is raised when an operation is attemption at an XUndoManager which requires a non-empty stack + of undo actions, and this requirement is not fullfilled. + */ +exception EmptyUndoStackException : ::com::sun::star::util::InvalidStateException +{ +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/document/MediaDescriptor.idl b/offapi/com/sun/star/document/MediaDescriptor.idl index 25297abc444e..1332d016d4d3 100644 --- a/offapi/com/sun/star/document/MediaDescriptor.idl +++ b/offapi/com/sun/star/document/MediaDescriptor.idl @@ -39,6 +39,10 @@ #include <com/sun/star/awt/Rectangle.idl> #endif +#ifndef __com_sun_star_beans_NamedValue_idl__ +#include <com/sun/star/beans/NamedValue.idl> +#endif + #ifndef __com_sun_star_util_URL_idl__ #include <com/sun/star/util/URL.idl> #endif @@ -144,7 +148,7 @@ published service MediaDescriptor <p> For extensibility, it is recommended to use values of type - sequence<com.sun.star.beans.PropertyValue> with this property. + sequence<com.sun.star.beans.NamedValue> with this property. </p> */ [optional,property] any ComponentData; @@ -164,6 +168,23 @@ published service MediaDescriptor [optional,property] string DocumentTitle; //------------------------------------------------------------------------- + /** encryption information for encryption/decryption of documents + + <p> + It contains the necessary information for encryption/decryption of + a component (if necessary). + If neither password nor encryption data is specified, loading of + a password protected document will fail, storing will be done without + encryption. If both are provided, the encryption data is used + ( if the filter supports it ). + </p> + <p> + The encryption data is generated based on the password. + </p> + */ + [optional,property] sequence< ::com::sun::star::beans::NamedValue > EncryptionData; + + //------------------------------------------------------------------------- /** same as <member>MediaDescriptor::URL</member> <p> @@ -366,8 +387,10 @@ published service MediaDescriptor <p> It contains a password for loading or storing a component (if necessary). - If no password is specified, loading of a password protected document - will fail, storing will be done without encryption. + If neither password nor encryption data is specified, loading of + a password protected document will fail, storing will be done without + encryption. If both are provided, the encryption data is used + ( if the filter supports it ). </p> */ [optional,property] string Password; diff --git a/offapi/com/sun/star/document/OfficeDocument.idl b/offapi/com/sun/star/document/OfficeDocument.idl index fe0e3476e5b8..33b3f510c906 100644 --- a/offapi/com/sun/star/document/OfficeDocument.idl +++ b/offapi/com/sun/star/document/OfficeDocument.idl @@ -27,53 +27,19 @@ #ifndef __com_sun_star_document_OfficeDocument_idl__ #define __com_sun_star_document_OfficeDocument_idl__ -#ifndef __com_sun_star_frame_XModel_idl__ #include <com/sun/star/frame/XModel.idl> -#endif - -#ifndef __com_sun_star_util_XModifiable_idl__ #include <com/sun/star/util/XModifiable.idl> -#endif - -#ifndef __com_sun_star_frame_XStorable_idl__ #include <com/sun/star/frame/XStorable.idl> -#endif - -#ifndef __com_sun_star_view_XPrintable_idl__ #include <com/sun/star/view/XPrintable.idl> -#endif - -#ifndef __com_sun_star_view_XPrintJobBroadcaster_idl__ #include <com/sun/star/view/XPrintJobBroadcaster.idl> -#endif - -#ifndef __com_sun_star_document_XEventBroadcaster_idl__ #include <com/sun/star/document/XEventBroadcaster.idl> -#endif - -#ifndef __com_sun_star_document_XEventsSupplier_idl__ #include <com/sun/star/document/XEventsSupplier.idl> -#endif - -#ifndef __com_sun_star_document_XDocumentInfoSupplier_idl__ #include <com/sun/star/document/XDocumentInfoSupplier.idl> -#endif - -#ifndef __com_sun_star_document_XViewDataSupplier_idl__ #include <com/sun/star/document/XViewDataSupplier.idl> -#endif - -#ifndef __com_sun_star_document_XDocumentEventBroadcaster_idl__ #include <com/sun/star/document/XDocumentEventBroadcaster.idl> -#endif - -#ifndef __com_sun_star_document_XEmbeddedScripts_idl__ #include <com/sun/star/document/XEmbeddedScripts.idl> -#endif - -#ifndef __com_sun_star_document_XDocumentPropertiesSupplier_idl__ #include <com/sun/star/document/XDocumentPropertiesSupplier.idl> -#endif +#include <com/sun/star/document/XUndoManagerSupplier.idl> //============================================================================= @@ -192,6 +158,10 @@ published service OfficeDocument */ [optional] interface XDocumentPropertiesSupplier; + /** provides access to the document's undo manager. + */ + [optional] interface XUndoManagerSupplier; + //------------------------------------------------------------------------- /** controls the focus behavior of the form controls in the document diff --git a/offapi/com/sun/star/document/UndoContextNotClosedException.idl b/offapi/com/sun/star/document/UndoContextNotClosedException.idl new file mode 100755 index 000000000000..4f7d746bad1a --- /dev/null +++ b/offapi/com/sun/star/document/UndoContextNotClosedException.idl @@ -0,0 +1,51 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_document_UndoContextNotClosedException_idl__ +#define __com_sun_star_document_UndoContextNotClosedException_idl__ + +#include <com/sun/star/util/InvalidStateException.idl> + +//================================================================================================================== + +module com { module sun { module star { module document { + +//================================================================================================================== + +/** is thrown when an operation is attempted at an <type>XUndoManager</type> which requires all undo + contexts to be closed, but this requirement is not fullfilled. + */ +exception UndoContextNotClosedException : ::com::sun::star::util::InvalidStateException +{ +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/document/UndoFailedException.idl b/offapi/com/sun/star/document/UndoFailedException.idl new file mode 100755 index 000000000000..4489ac5a0e0d --- /dev/null +++ b/offapi/com/sun/star/document/UndoFailedException.idl @@ -0,0 +1,56 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_document_UndoFailedException_idl__ +#define __com_sun_star_document_UndoFailedException_idl__ + +#include <com/sun/star/uno/Exception.idl> + +//================================================================================================================== + +module com { module sun { module star { module document { + +//================================================================================================================== + +/** thrown when reverting to re-applying an undoable action fails. + + @see XUndoAction::undo + @see XUndoManager::undo + */ +exception UndoFailedException : ::com::sun::star::uno::Exception +{ + /** describes the reason why the operation failed. Usually, this member will carry an exception. + */ + any Reason; +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/document/UndoManagerEvent.idl b/offapi/com/sun/star/document/UndoManagerEvent.idl new file mode 100755 index 000000000000..e587669e4fbd --- /dev/null +++ b/offapi/com/sun/star/document/UndoManagerEvent.idl @@ -0,0 +1,63 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_document_UndoManagerEvent_idl__ +#define __com_sun_star_document_UndoManagerEvent_idl__ + +#include <com/sun/star/lang/EventObject.idl> + +//================================================================================================================== + +module com { module sun { module star { module document { + +//================================================================================================================== + +/** is an event sent by an <type>XUndoManager</type> implementation when the Undo/Redo stacks of the manager are + modified. + @see XUndoManager + @see XUndoManagerListener + @see XUndoAction + */ +struct UndoManagerEvent : ::com::sun::star::lang::EventObject +{ + /** the title of the undo action which is described by the event + @see XUndoAction::Title + */ + string UndoActionTitle; + + /** denotes the number of Undo contexts which are open, and not yet closed, at the time the event is fired. + @see XUndoManager::enterUndoContext + */ + long UndoContextDepth; +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/document/XDocumentEventBroadcaster.idl b/offapi/com/sun/star/document/XDocumentEventBroadcaster.idl index c0e10ac1e99c..61f4e49b886b 100644 --- a/offapi/com/sun/star/document/XDocumentEventBroadcaster.idl +++ b/offapi/com/sun/star/document/XDocumentEventBroadcaster.idl @@ -123,3 +123,4 @@ interface XDocumentEventBroadcaster //============================================================================= #endif + diff --git a/offapi/com/sun/star/document/XUndoAction.idl b/offapi/com/sun/star/document/XUndoAction.idl new file mode 100755 index 000000000000..b47550a3f52f --- /dev/null +++ b/offapi/com/sun/star/document/XUndoAction.idl @@ -0,0 +1,76 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_document_XUndoAction_idl__ +#define __com_sun_star_document_XUndoAction_idl__ + +#include <com/sun/star/uno/XInterface.idl> +#include <com/sun/star/document/UndoFailedException.idl> + +//================================================================================================================== + +module com { module sun { module star { module document { + +//================================================================================================================== + +/** represents a single (undoable) action on a document + */ +interface XUndoAction +{ + /** reverts the action represented by the instance + + @throws UndoFailedException + if reverting the action failed. In this case, the caller should assume that this is a permanent failure, + and take appropriate action, such as discarding the <code>XUndoAction</code> instance, and any possibly + depending instances. + */ + void undo() + raises ( ::com::sun::star::document::UndoFailedException + ); + + /** repeats the action represented by the instance, after it had previously been reverted. + + @throws UndoFailedException + if repeating the action failed. In this case, the caller should assume that this is a permanent failure, + and take appropriate action, such as discarding the <code>XUndoAction</code> instance, and any possibly + depending instances. + */ + void redo() + raises ( ::com::sun::star::document::UndoFailedException + ); + + /** is the human-readable, localized description of the action. + */ + [attribute, readonly] string Title; +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/document/XUndoManager.idl b/offapi/com/sun/star/document/XUndoManager.idl new file mode 100755 index 000000000000..be43ca899b94 --- /dev/null +++ b/offapi/com/sun/star/document/XUndoManager.idl @@ -0,0 +1,337 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_document_XUndoManager_idl__ +#define __com_sun_star_document_XUndoManager_idl__ + +#include <com/sun/star/document/EmptyUndoStackException.idl> +#include <com/sun/star/document/UndoContextNotClosedException.idl> +#include <com/sun/star/document/UndoFailedException.idl> +#include <com/sun/star/util/InvalidStateException.idl> +#include <com/sun/star/util/XLockable.idl> +#include <com/sun/star/container/XChild.idl> +#include <com/sun/star/lang/IllegalArgumentException.idl> +#include <com/sun/star/lang/WrappedTargetException.idl> + +//================================================================================================================== + +module com { module sun { module star { module document { + +interface XUndoAction; +interface XUndoManagerListener; + +//================================================================================================================== + +/** provides access to the undo/redo stacks of a document + + <h3>Undo</h3> + <p>Changes to a document usually result in recording of information how to undo those changes, if desired. A so-called + undo action records the information how to undo a single change. Undo actions are maintained in a stack, so that + the changes they represent can be undo in the reverse order they have originally been applied.</p> + + <h3>Redo</h3> + <p>Additionally, the Undo manager manages a Redo stack: Actions which are undone are moved from the Undo to the Redo + stack, so it is possible to re-apply the changes to the document.</p> + + <h3>Undo contexts</h3> + <p>For collecting multiple changes in a single undo action, so-called Undo contexts are provided. When an Undo + context is entered, all subsequently added Undo actions are not pushed onto the undo stack directly, but considered + a sub action of the Undo context. Once the Undo context is left, a single undo action is pushed onto the undo stack, + which comprises all those single Undo actions.<br/> + Undo contexts can be arbitrarily nested.</p> + + <h3>Hidden Undo actions</h3> + <p>Hidden Undo actions are those which in no observable way contribute to the undo stack. That is, + any method retrieving information about the stack will behave as if the undo action does not exist. Nonetheless, + calling <member>undo</member> respectively <member>redo</member> will include those actions.<br/> + Hidden Undo actions can be created by calling <member>enterHiddenUndoContext</member>, following by + <member>leaveUndoContext</member>.</p> + + <a name="locking"></a> + <h3>Locking</h3> + <p>An Undo manager can be locked and unlocked, using the <member>XLockable::lock</member> and + <member>XLockable::unlock</member> methods. When it is locked, then every attempt to add an undo action, or to + enter or leave an Undo context, will be silently ignored.</p> + */ +interface XUndoManager +{ + /** allows <a href="#locking">locking</a> the undo manager. + */ + interface ::com::sun::star::util::XLockable; + + /** allows accessing the component, usually a document, which the undo manager works for. + + <p><member scope="com::sun::star::container">XChild::setParent</member> is not supported, and will throw + an <type scope="com::sun::star::lang">NoSupportException</type>.</p> + */ + interface ::com::sun::star::container::XChild; + + /** enters a new undo context. + + <p>A new undo action will be added to the undo stack, with the title given as <code>i_title</code>. As long + as the context is not left, every undo action added to the stack will be treated as sub action. This means + it will not be directly accessible at the Undo manager, not appear in any user interface, and cannot be + separately undone or re-done.</p> + + <p>Each call to <code>enterUndoContext</code> must be paired by a call to <member>leaveUndoContext</member>, + otherwise, the document's undo stack is left in an inconsistent state.</p> + + <p>Undo contexts can be nested, i.e. it is legitimate to call <code>enterUndoContext</code> and + <member>enterHiddenUndoContext</member> multiple times without calling <member>leaveUndoContext</member> inbetween.</p> + + @see leaveUndoContext + */ + void enterUndoContext( + [in] string i_title + ); + + /** enters a new undo context, creating a hidden undo action. + + <p>A hidden undo action does not, in any visible way, contribute to the undo stack. This means + that + <ul><li>Calling <member>undo</member> when the top-element is a hidden undo action will transparently + undo this action, and also undo the new top element of the stack.</li> + <li>Calling <member>redo</member> when the top-element is a hidden action will transparently + redo this action, and also redo the new top element of the stack.</li> + <li>In any user interface presenting the current Undo or Redo actions to the user, a hidden + action will not be listed.</p> + </ul> + + <p>A new undo action will be added to the undo stack. As long as the context is not left, every undo action + added to the stack will be treated as sub action. This means it will not be directly accessible at the undo + manager, not appear in any user interface, and cannot be separately undone or re-done.</p> + + <p>Each call to <code>enterHiddenUndoContext</code> must be paired by a call to <member>leaveUndoContext</member>, + otherwise, the document's undo stack is left in an inconsistent state.</p> + + <p>Undo contexts can be nested, i.e. it is legitimate to call <member>enterUndoContext</member> and + <code>enterHiddenUndoContext</code> multiple times without calling <member>leaveUndoContext</member> inbetween.</p> + + @throws EmptyUndoStackException + if the undo stack is currently empty, in which case it is impossible to push a hidden undo action onto + it. + + @see enterUndoContext + @see leaveUndoContext + */ + void enterHiddenUndoContext() + raises( EmptyUndoStackException ); + + /** leaves the undo context previously opened via <member>enterUndoContext</member> respectively + <member>enterHiddenUndoContext</member>. + + <p>If no undo action has been added since the context has been opened, the context is not only left, + but silently removed, and does not contribute to the undo stack at all. In this case, possible + listeners will be notified via <member>XUndoManagerListener::cancelledContext</member>.</p> + + <p>Otherwise, the undo context will be closed, and added to the Undo stack; the redo stack will be cleared, + and listeners will be notified via <member>XUndoManagerListener::leftContext</member> resp. + <member>XUndoManagerListener::leftHiddenContext</member></p> + + @throws ::com::sun::star::util::InvalidStateException + if no undo context is currently open. + + @see enterUndoContext + @see enterHiddenUndoContext + */ + void leaveUndoContext() + raises( ::com::sun::star::util::InvalidStateException ); + + /** adds the given undo action to the undo stack. + + <p>The redo stack is cleared when a new action is pushed onto the undo stack.</p> + + <p>The Undo manager takes ownership of any actions pushed onto the undo stack. This means that if the + action is finally removed from the Undo manager's control (e.g. by calling <member>clear</member> resp. + <member>clearRedo</member>), it will be disposed, as long as it supports the <member scope="com::sun::star::lang">XComponent</member> + interface.</p> + + <p>If the Undo manager is <a href="#locking">locked</a> at the moment the method is called, the call will be ignored, and the undo action + will immediately be disposed, if applicable.</p> + + @throws ::com::sun::star::lang::IllegalArgumentException + if the given undo action is <NULL/>. + */ + void addUndoAction( + [in] XUndoAction i_action + ) + raises( ::com::sun::star::lang::IllegalArgumentException ); + + /** reverts the most recent action on the document. + + <p>Effectively, invoking this method will + <ul><li>invoke <member>XUndoAction::undo</member> on the top-most action of the undo stack</li> + <li>move this undo action from the undo stack to the redo stack</li> + </ul></p> + + @throws EmptyUndoStackException + if the undo stack is currently empty + + @throws UndoContextNotClosedException + if there currently is an open undo context + + @throws UndoFailedException + if the invocation of <member>XUndoAction::undo</member> raised this exception. In this case, the undo stack + of the undo manager will have been cleared. + + @see redo + @see enterUndoContext + */ + void undo() + raises( ::com::sun::star::document::EmptyUndoStackException, + ::com::sun::star::document::UndoContextNotClosedException, + ::com::sun::star::document::UndoFailedException ); + + /** replays the action on the document which has most recently been undone + + <p>Effectively, invoking this method will + <ul><li>invoke <member>XUndoAction::redo</member> on the top-most action of the redo stack</li> + <li>move this action from the redo stack to the undo stack</li> + </ul></p> + + @throws EmptyUndoStackException + when the Redo stack is currently empty + + @throws UndoContextNotClosedException + if there currently is an open undo context + + @throws UndoFailedException + if the invocation of <member>XUndoAction::redo</member> raised this exception. In this case, the redo stack + of the undo manager will have been cleared. + + @see undo + */ + void redo() + raises( ::com::sun::star::document::EmptyUndoStackException, + ::com::sun::star::document::UndoContextNotClosedException, + ::com::sun::star::document::UndoFailedException ); + + /** determines whether <member>undo</member> can reasonably be expected to succeed. + + @return + <FALSE/> if and only if the undo stack is currently empty, or there is an open and not-yet-closed + undo context. + */ + boolean isUndoPossible(); + + /** determines whether <member>redo</member> can reasonably be expected to succeed. + + @return + <FALSE/> if and only if the redo stack is currently empty, or there is an open and not-yet-closed + undo context. + */ + boolean isRedoPossible(); + + /** returns the title of the top-most action on the undo stack + + @throws EmptyUndoStackException + when the undo stack is currently empty + + @see XUndoAction::Title + */ + string getCurrentUndoActionTitle() + raises( ::com::sun::star::document::EmptyUndoStackException ); + + /** returns the title of the top-most action on the Redo stack + + @throws EmptyUndoStackException + when the Redo stack is currently empty + @see XUndoAction::Title + */ + string getCurrentRedoActionTitle() + raises( ::com::sun::star::document::EmptyUndoStackException ); + + /** returns the titles of all actions currently on the undo stack, from top to bottom + @see XUndoAction::Title + */ + sequence< string > + getAllUndoActionTitles(); + + /** returns the titles of all actions currently on the Redo stack, from top to bottom + + @see XUndoAction::Title + */ + sequence< string > + getAllRedoActionTitles(); + + /** clears the undo and the redo stack. + + <p>All actions will be removed from both the Undo and the Redo stack. Actions which implement the + <type scope="com::sun::star::lang">XComponent</type> interface will be disposed.</p> + + @throws UndoContextNotClosedException + if the method is invoked while an undo context is still open + */ + void clear() + raises( ::com::sun::star::document::UndoContextNotClosedException ); + + /** clears the redo stack. + + <p>All actions will be removed from the Redo stack. Actions which implement the <type scope="com::sun::star::lang">XComponent</type> + interface will be disposed.</p> + + @throws UndoContextNotClosedException + if the method is invoked while an undo context is still open + */ + void clearRedo() + raises( ::com::sun::star::document::UndoContextNotClosedException ); + + /** resets the Undo manager + + <p>In particular, this method will + <ul><li>remove all locks from the undo manager</li> + <li>close all open undo contexts</li> + <li>clear the undo stack</li> + <li>clear the redo stack</li> + </ul></p> + + <p>Note that possible listeners will not get notifications for the single parts of the reset, i.e. there + will be no single <member>XUndoManagerListener::allActionsCleared</member>, + <member>XUndoManagerListener::leftContext</member>, etc., notifications. Instead, listeners will be + notified of the reset by calling their <member>XUndoManagerListener::resetAll</member> method.</p> + */ + void reset(); + + /** adds a listener to be notified of changes in the Undo/Redo stacks. + */ + void addUndoManagerListener( + [in] XUndoManagerListener i_listener + ); + + /** removes a previously added listener + */ + void removeUndoManagerListener( + [in] XUndoManagerListener i_listener + ); +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/document/XUndoManagerListener.idl b/offapi/com/sun/star/document/XUndoManagerListener.idl new file mode 100755 index 000000000000..783e8e7014d8 --- /dev/null +++ b/offapi/com/sun/star/document/XUndoManagerListener.idl @@ -0,0 +1,144 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_document_XUndoManagerListener_idl__ +#define __com_sun_star_document_XUndoManagerListener_idl__ + +#include <com/sun/star/document/UndoManagerEvent.idl> +#include <com/sun/star/lang/XEventListener.idl> + +//================================================================================================================== + +module com { module sun { module star { module document { + +//================================================================================================================== + +/** implemented by components which want to be notified of changes in the Undo/Redo stacks of an Undo manager. + + @see XUndoManager + */ +interface XUndoManagerListener : ::com::sun::star::lang::XEventListener +{ + /** is called when an undo action is added to the undo stack. + + <p>Note that the action must not necessarily be the new top element of the stack: In case there's an + open Undo context, <member>UndoManagerEvent::UndoContextDepth</member> will be greater <code>0</code>, + and the newly added action will be subordinate of the context action.</p> + + @see XUndoManager::addUndoAction + */ + void undoActionAdded( [in] UndoManagerEvent i_event ); + + /** is called when the top-most action of the undo stack has been undone. + + @see XUndoManager::undo + */ + void actionUndone( [in] UndoManagerEvent i_event ); + + /** is called when the top-most action of the Redo stack has been re-applied. + + @see XUndoManager::redo + */ + void actionRedone( [in] UndoManagerEvent i_event ); + + /** is called when both the Undo and the Redo stack have been cleared from all Undo actions. + + @see XUndoManager::clear + */ + void allActionsCleared( [in] ::com::sun::star::lang::EventObject i_event ); + + /** is called when the the Redo stack has been cleared. + + @see XUndoManager::clearRedo + */ + void redoActionsCleared( [in] ::com::sun::star::lang::EventObject i_event ); + + /** called when the complete undo manager has been reset + */ + void resetAll( [in] ::com::sun::star::lang::EventObject i_event ); + + /** is called when a new Undo context has been entered. + + <p><member>UndoManagerEvent::UndoActionTitle</member> carries the title of the Undo context, and + <member>UndoManagerEvent::UndoContextDepth</member> the number of open Undo contexts, including the + one just entered.</p> + + @see XUndoManager::enterUndoContext + */ + void enteredContext( [in] UndoManagerEvent i_event ); + + /** is called when a new hidden Undo context has been entered. + + <p><member>UndoManagerEvent::UndoActionTitle</member> carries the title of the Undo context, and + <member>UndoManagerEvent::UndoContextDepth</member> the number of open Undo contexts, including the + one just entered.</p> + + @see XUndoManager::enterUndoContext + */ + void enteredHiddenContext( [in] UndoManagerEvent i_event ); + + /** is called when an Undo context has been left. + + <p><member>UndoManagerEvent::UndoActionTitle</member> carries the title of the Undo context, and + <member>UndoManagerEvent::UndoContextDepth</member> the number of open Undo contexts, exluding the + one just left.</p> + + @see XUndoManager::leaveUndoContext + @see leftHiddenUndocontext + @see cancelledContext + */ + void leftContext( [in] UndoManagerEvent i_event ); + + /** is calledn when a hidden Undo context has been left. + + <p><member>UndoManagerEvent::UndoActionTitle</member> is empty, as hidden Undo contexts don't have + a title.</p> + + @see XUndoManager::leaveHiddenUndoContext + @see leftContext + @see cancelledContext + */ + void leftHiddenContext( [in] UndoManagerEvent i_event ); + + /** is called when an Undo context has been left, but no actions have been added within this context. + + <p>In such a case, the context which has just been left will not contribute to the undo stack, but instead + be silently removed. Consequently, the <member>UndoManagerEvent::UndoActionTitle</member> is empty.</p> + + @see XUndoManager::leaveUndoContext + @see leftContext + @see leftHiddenContext + */ + void cancelledContext( [in] UndoManagerEvent i_event ); +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/document/XUndoManagerSupplier.idl b/offapi/com/sun/star/document/XUndoManagerSupplier.idl new file mode 100755 index 000000000000..88a082259413 --- /dev/null +++ b/offapi/com/sun/star/document/XUndoManagerSupplier.idl @@ -0,0 +1,55 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_document_XUndoManagerSupplier_idl__ +#define __com_sun_star_document_XUndoManagerSupplier_idl__ + +#include <com/sun/star/uno/XInterface.idl> + +//================================================================================================================== + +module com { module sun { module star { module document { + +interface XUndoManager; + +//================================================================================================================== + +/** provides access to an XUndoManager. + */ +interface XUndoManagerSupplier +{ + /** returns the Undo manager associated with the component. + */ + XUndoManager getUndoManager(); +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/document/makefile.mk b/offapi/com/sun/star/document/makefile.mk index 7932c6ef34e2..d97c508c94b0 100644 --- a/offapi/com/sun/star/document/makefile.mk +++ b/offapi/com/sun/star/document/makefile.mk @@ -117,6 +117,14 @@ IDLFILES=\ XCodeNameQuery.idl \ XCompatWriterDocProperties.idl \ XVbaMethodParameter.idl \ + XUndoAction.idl \ + XUndoManager.idl \ + XUndoManagerListener.idl \ + XUndoManagerSupplier.idl \ + UndoManagerEvent.idl \ + EmptyUndoStackException.idl \ + UndoContextNotClosedException.idl \ + UndoFailedException.idl \ # ------------------------------------------------------------------ diff --git a/offapi/com/sun/star/embed/XEncryptionProtectedSource2.idl b/offapi/com/sun/star/embed/XEncryptionProtectedSource2.idl new file mode 100644 index 000000000000..e590a5764178 --- /dev/null +++ b/offapi/com/sun/star/embed/XEncryptionProtectedSource2.idl @@ -0,0 +1,65 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_embed_XEncryptionProtectedSource2_idl__ +#define __com_sun_star_embed_XEncryptionProtectedSource2_idl__ + +#ifndef __com_sun_star_embed_XEncryptionProtectedSource_idl__ +#include <com/sun/star/embed/XEncryptionProtectedSource.idl> +#endif + +#ifndef __com_sun_star_beans_NamedValue_idl__ +#include <com/sun/star/beans/NamedValue.idl> +#endif + +//============================================================================ + +module com { module sun { module star { module embed { + +//============================================================================ +/** This interface allows to set a password for an object. + */ +published interface XEncryptionProtectedSource2: XEncryptionProtectedSource +{ + // ----------------------------------------------------------------------- + /** sets an encryption data for the object. + + @param aEncryptionData + the new encryption data + + @throws ::com::sun::star::io::IOException + in case the data could not be set + */ + void setEncryptionData( [in] sequence< ::com::sun::star::beans::NamedValue > aEncryptionData ) + raises( ::com::sun::star::io::IOException ); +}; + +//============================================================================ + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/embed/XHierarchicalStorageAccess2.idl b/offapi/com/sun/star/embed/XHierarchicalStorageAccess2.idl new file mode 100644 index 000000000000..0df83ea33580 --- /dev/null +++ b/offapi/com/sun/star/embed/XHierarchicalStorageAccess2.idl @@ -0,0 +1,109 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_embed_XHierarchicalStorageAccess2_idl__ +#define __com_sun_star_embed_XHierarchicalStorageAccess2_idl__ + +#ifndef __com_sun_star_embed_XHierarchicalStorageAccess_idl__ +#include <com/sun/star/embed/XHierarchicalStorageAccess.idl> +#endif + +#ifndef __com_sun_star_beans_NamedValue_idl__ +#include <com/sun/star/beans/NamedValue.idl> +#endif + +//============================================================================ + + module com { module sun { module star { module embed { + +//============================================================================ +/** This interface extends XHierarchicalStorageAccess interface. + */ +interface XHierarchicalStorageAccess2 : XHierarchicalStorageAccess +{ + // ----------------------------------------------------------------------- + /** allows to get access to a child encrypted stream with encryption data + using hierarchical path. + + <p> + If storage does not allow any encryption this method will always throw + <type scope="com::sun::star::packages">NoEncryptionException</type>. + </p> + + <p> + In case the stream is open in readonly mode the + <method scope="com::sun::star::io">XStream::getOutputStream</method> + method will return an empty reference. + </p> + + @param sStreamPath + the path to the substream that should be open + + @param nOpenMode + a mode the stream should be open in, + can be a combination of <type>ElementModes</type> values + + @param aEncryptionData + this parameter allowes to specify an encryption data for the + stream, the data must be correct, otherwise an + exception will be thrown + + @throws ::com::sun::star::embed::InvalidStorageException + this storage is in invalid state for any reason + + @throws ::com::sun::star::lang::IllegalArgumentException + one of provided arguments is illegal + + @throws ::com::sun::star::packages::NoEncryptionException + the stream is not encrypted + + @throws ::com::sun::star::packages::WrongPasswordException + the provided password is wrong + + @throws ::com::sun::star::io::IOException + in case of io errors during stream opening + + @throws ::com::sun::star::embed::StorageWrappedTargetException + wraps other exceptions + */ + XExtendedStorageStream openEncryptedStreamByHierarchicalName( + [in] string sStreamName, + [in] long nOpenMode, + [in] sequence< ::com::sun::star::beans::NamedValue > aEncryptionData ) + raises( ::com::sun::star::embed::InvalidStorageException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::packages::NoEncryptionException, + ::com::sun::star::packages::WrongPasswordException, + ::com::sun::star::io::IOException, + ::com::sun::star::embed::StorageWrappedTargetException ); +}; + +//============================================================================ + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/embed/XStorage2.idl b/offapi/com/sun/star/embed/XStorage2.idl new file mode 100644 index 000000000000..cf4f9907b66e --- /dev/null +++ b/offapi/com/sun/star/embed/XStorage2.idl @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_embed_XStorage2_idl__ +#define __com_sun_star_embed_XStorage2_idl__ + +#ifndef __com_sun_star_embed_XStorage_idl__ +#include <com/sun/star/embed/XStorage.idl> +#endif + +#ifndef __com_sun_star_beans_NamedValue_idl__ +#include <com/sun/star/beans/NamedValue.idl> +#endif + + +//============================================================================ + + module com { module sun { module star { module embed { + +//============================================================================ +/** This interface extends the base XStorage interface. + */ +interface XStorage2 : XStorage +{ + // ----------------------------------------------------------------------- + /** allows to get access to a child encrypted stream with EncryptionData. + + <p> + If storage does not allow any encryption this method will always throw + <type scope="com::sun::star::packages">NoEncryptionException</type>. + </p> + + <p> + In case the stream is open in readonly mode the + <method scope="com::sun::star::io">XStream::getOutputStream</method> + method will return an empty reference. + </p> + + @param sStreamName + the name of the substream that should be open + + @param nOpenMode + a mode the stream should be open in, + can be a combination of <type>ElementModes</type> values + + @param aEncryptionData + this parameter allowes to specify an encryption data to decrypt the + stream, the encryption data must be correct, otherwise an + exception will be thrown + + @throws ::com::sun::star::embed::InvalidStorageException + this storage is in invalid state for any reason + + @throws ::com::sun::star::lang::IllegalArgumentException + one of provided arguments is illegal + + @throws ::com::sun::star::packages::NoEncryptionException + the stream is not encrypted + + @throws ::com::sun::star::packages::WrongPasswordException + the provided encryption data is wrong + + @throws ::com::sun::star::io::IOException + in case of io errors during stream opening + + @throws ::com::sun::star::embed::StorageWrappedTargetException + wraps other exceptions + */ + ::com::sun::star::io::XStream openEncryptedStream( + [in] string sStreamName, + [in] long nOpenMode, + [in] sequence< ::com::sun::star::beans::NamedValue > aEncryptionData ) + raises( ::com::sun::star::embed::InvalidStorageException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::packages::NoEncryptionException, + ::com::sun::star::packages::WrongPasswordException, + ::com::sun::star::io::IOException, + ::com::sun::star::embed::StorageWrappedTargetException ); + + // ----------------------------------------------------------------------- + /** allows to get readonly copy of a child encrypted stream with encryption + data. + + <p> + If storage does not allow any encryption this method will always throw + <type scope="com::sun::star::packages">NoEncryptionException</type>. + </p> + + <p> + The stream is open in readonly mode so the + <method scope="com::sun::star::io">XStream::getOutputStream</method> + method will return an empty reference. + </p> + + <p> + This method allows to specify encryption data for the child stream + explicitly. + </p> + + @param sStreamName + the name of the substream that should be copied + + @param aEncryptionData + this parameter allowes to specify an encryption data for the + stream, the encryption data must be correct, otherwise an + exception will be thrown + + @throws ::com::sun::star::embed::InvalidStorageException + this storage is in invalid state for any reason + + @throws ::com::sun::star::lang::IllegalArgumentException + one of provided arguments is illegal + + @throws ::com::sun::star::packages::NoEncryptionException + the stream is not encrypted + + @throws ::com::sun::star::packages::WrongPasswordException + the provided encryption data is wrong + + @throws ::com::sun::star::io::IOException + in case of io errors during stream opening + + @throws ::com::sun::star::embed::StorageWrappedTargetException + wraps other exceptions + */ + ::com::sun::star::io::XStream cloneEncryptedStream( + [in] string sStreamName, + [in] sequence< ::com::sun::star::beans::NamedValue > aEncryptionData ) + raises( ::com::sun::star::embed::InvalidStorageException, + ::com::sun::star::lang::IllegalArgumentException, + ::com::sun::star::packages::NoEncryptionException, + ::com::sun::star::packages::WrongPasswordException, + ::com::sun::star::io::IOException, + ::com::sun::star::embed::StorageWrappedTargetException ); +}; + +//============================================================================ + +}; }; }; }; + +#endif + diff --git a/offapi/com/sun/star/embed/makefile.mk b/offapi/com/sun/star/embed/makefile.mk index 349017452ef3..8ee156af48ba 100644 --- a/offapi/com/sun/star/embed/makefile.mk +++ b/offapi/com/sun/star/embed/makefile.mk @@ -77,6 +77,7 @@ IDLFILES=\ XLinkCreator.idl\ XLinkFactory.idl\ XEncryptionProtectedSource.idl\ + XEncryptionProtectedSource2.idl\ XInplaceClient.idl\ XInsertObjectDialog.idl\ XWindowSupplier.idl\ @@ -89,9 +90,11 @@ IDLFILES=\ XTransferableSupplier.idl\ XComponentSupplier.idl\ XStorage.idl\ + XStorage2.idl\ XStorageRawAccess.idl\ XExtendedStorageStream.idl\ XHierarchicalStorageAccess.idl\ + XHierarchicalStorageAccess2.idl\ XHatchWindowController.idl\ XHatchWindowFactory.idl\ XHatchWindow.idl\ diff --git a/offapi/com/sun/star/formula/FormulaProperties.idl b/offapi/com/sun/star/formula/FormulaProperties.idl index a5106038db29..8ae400096bf3 100644 --- a/offapi/com/sun/star/formula/FormulaProperties.idl +++ b/offapi/com/sun/star/formula/FormulaProperties.idl @@ -338,6 +338,14 @@ published service FormulaProperties /** contains the metric value of the right margin of the formula. */ [property] short RightMargin; + + //------------------------------------------------------------------------- + + /** contains the baselines offset in respect to the top of the formula rectangle + + @since OOo 3.4 + */ + [property, optional] short BaseLine; }; //============================================================================= diff --git a/offapi/com/sun/star/i18n/TransliterationModules.idl b/offapi/com/sun/star/i18n/TransliterationModules.idl index 683650e4df32..605152d02134 100644 --- a/offapi/com/sun/star/i18n/TransliterationModules.idl +++ b/offapi/com/sun/star/i18n/TransliterationModules.idl @@ -33,8 +33,12 @@ module com { module sun { module star { module i18n { //============================================================================= -/** Old transliteration module enumeration to use with - <member>XTransliteration::loadModule()</member> +/** Old transliteration module enumeration. + + <p> Use with <member>XTransliteration::loadModule()</member> and + <member scope="com::sun::star::util">SearchOptions::transliterateFlags</member> </p> + + <p> Note that values >=0x100 are logically or'ed with other values! </p> */ published enum TransliterationModules diff --git a/offapi/com/sun/star/inspection/LineDescriptor.idl b/offapi/com/sun/star/inspection/LineDescriptor.idl index 3efb9885f5b8..ac532045a070 100644 --- a/offapi/com/sun/star/inspection/LineDescriptor.idl +++ b/offapi/com/sun/star/inspection/LineDescriptor.idl @@ -94,7 +94,7 @@ struct LineDescriptor <p>If a primary button exists for a property's UI representation (<member>HasPrimaryButton</member>), it gets the ID specified herein.</p> */ - long PrimaryButtonId; + string PrimaryButtonId; /** describes the URL of an image to display on the primary button, if any. @@ -139,7 +139,7 @@ struct LineDescriptor @see PrimaryButtonId */ - long SecondaryButtonId; + string SecondaryButtonId; /** describes the URL of an image to display on the secondary button, if any. diff --git a/offapi/com/sun/star/linguistic2/XLanguageGuessing.idl b/offapi/com/sun/star/linguistic2/XLanguageGuessing.idl index e2fc3fceb69a..4b859bd58dbd 100644 --- a/offapi/com/sun/star/linguistic2/XLanguageGuessing.idl +++ b/offapi/com/sun/star/linguistic2/XLanguageGuessing.idl @@ -81,6 +81,7 @@ module com { module sun { module star { module linguistic2 { <li>ka : Georgian</li> <li>ko : Korean</li> <li>la : Latin</li> + <li>lb : Luxembourgish (added with OOo 3.3)</li> <li>lt : Lithuanian</li> <li>lv : Latvian</li> <li>mr : Marathi</li> @@ -96,10 +97,11 @@ module com { module sun { module star { module linguistic2 { <li>ru : Russian</li> <li>sa : Sanskrit</li> <li>sco : Scots</li> - <li>sh-YU : Serbian (written with Latin characters)</li> + <li>sh : Serbian (written with latin characters)</li> <li>sk-SK : Slovak (written with Latin characters)</li> <li>sl : Slovenian</li> <li>sq : Albanian</li> + <li>sr : Serbian (written with cyrillic characters) (added with OOo 3.4)</li> <li>sv : Swedish</li> <li>sw : Swahili</li> <li>ta : Tamil</li> diff --git a/offapi/com/sun/star/chart2/Break.idl b/offapi/com/sun/star/script/NativeObjectWrapper.idl index b5dbe80d2933..93281a061d6e 100644..100755 --- a/offapi/com/sun/star/chart2/Break.idl +++ b/offapi/com/sun/star/script/NativeObjectWrapper.idl @@ -24,19 +24,15 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef com_sun_star_chart2_Break_idl -#define com_sun_star_chart2_Break_idl -//============================================================================= - -module com { module sun { module star { module chart2 { +#ifndef __com_sun_star_script_NativeObjectWrapper_idl__ +#define __com_sun_star_script_NativeObjectWrapper_idl__ //============================================================================= - -struct Break +module com { module sun { module star { module script { +struct NativeObjectWrapper { - double Min; - double Max; + any ObjectId; }; //============================================================================= diff --git a/offapi/com/sun/star/script/makefile.mk b/offapi/com/sun/star/script/makefile.mk index 8c46453df552..53c95e99782f 100644 --- a/offapi/com/sun/star/script/makefile.mk +++ b/offapi/com/sun/star/script/makefile.mk @@ -51,7 +51,8 @@ IDLFILES=\ XLibraryQueryExecutable.idl \ ModuleSizeExceededRequest.idl\ ModuleInfo.idl\ - ModuleType.idl + ModuleType.idl\ + NativeObjectWrapper.idl # ------------------------------------------------------------------ diff --git a/offapi/com/sun/star/awt/grid/XGridCell.idl b/offapi/com/sun/star/script/vba/VBAMacroResolver.idl index 08f3cfd1b2d5..62f6e8ce0c2a 100644..100755 --- a/offapi/com/sun/star/awt/grid/XGridCell.idl +++ b/offapi/com/sun/star/script/vba/VBAMacroResolver.idl @@ -24,33 +24,26 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef __com_sun_star_awt_grid_XGridCell_idl__ -#define __com_sun_star_awt_grid_XGridCell_idl__ - -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif +#ifndef __com_sun_star_script_vba_VBAMacroResolver_idl__ +#define __com_sun_star_script_vba_VBAMacroResolver_idl__ +#include <com/sun/star/script/vba/XVBAMacroResolver.idl> //============================================================================= -module com { module sun { module star { module awt { module grid { +module com { module sun { module star { module script { module vba { //============================================================================= -interface XGridCell +service VBAMacroResolver : XVBAMacroResolver { - - [attribute] string Value; - - [attribute] boolean Editable; - - [attribute] any Data; }; //============================================================================= }; }; }; }; }; +//============================================================================= + #endif diff --git a/offapi/com/sun/star/script/vba/XVBAMacroResolver.idl b/offapi/com/sun/star/script/vba/XVBAMacroResolver.idl new file mode 100755 index 000000000000..378219268010 --- /dev/null +++ b/offapi/com/sun/star/script/vba/XVBAMacroResolver.idl @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_script_vba_XVBAMacroResolver_idl__ +#define __com_sun_star_script_vba_XVBAMacroResolver_idl__ + +#include <com/sun/star/lang/IllegalArgumentException.idl> + +//============================================================================= + +module com { module sun { module star { module script { module vba { + +//============================================================================= + +/** Converts VBA macro names to script URLs and vice versa. + */ +interface XVBAMacroResolver +{ + //------------------------------------------------------------------------- + + /** Returns the script URL representing the passed VBA macro name. + + @param aVBAMacroName + The VBA macro name to be resolved to a script URL. The macro name + may consist of up to three parts, divided by periods. The first two + parts are optional. The first part represents the VBA project name. + The second part represents the module name. The third part + represents the procedure name. Example: All the VBA macro names + "VBAProject.Module1.TestMacro", "Module1.TestMacro", + "VBAProject.TestMacro", and "TestMacro" may refer to the same VBA + procedure located in "Module" of the project "VBAProject". If the + module name is missing, then all modules are searched for a macro + with the specified name. + + @return + The script URL referring to the passed VBA macro. + + @throws <type scope="::com::sun::star::lang">IllegalArgumentException</type> + if a macro with the passed name does not exist. + **/ + string resolveVBAMacroToScriptURL( [in] string aVBAMacroName ) + raises (::com::sun::star::lang::IllegalArgumentException); + + //------------------------------------------------------------------------- + + /** Returns the VBA macro name for a macro with the passed script URL. + + @param aScriptURL + The script URL to be resolved to a VBA macro name. Must be a + document-local script. + + @return + The VBA macro name referring to a macro with the passed script URL. + + @throws <type scope="::com::sun::star::lang">IllegalArgumentException</type> + if a macro with the passed name does not exist. + **/ + string resolveScriptURLtoVBAMacro( [in] string aScriptURL ) + raises (::com::sun::star::lang::IllegalArgumentException); + + //------------------------------------------------------------------------- +}; + +//============================================================================= + +}; }; }; }; }; + +//============================================================================= + +#endif diff --git a/offapi/com/sun/star/script/vba/makefile.mk b/offapi/com/sun/star/script/vba/makefile.mk index 4657b587d7d8..336be1b5e7a6 100644 --- a/offapi/com/sun/star/script/vba/makefile.mk +++ b/offapi/com/sun/star/script/vba/makefile.mk @@ -40,10 +40,12 @@ PACKAGE=com$/sun$/star$/script$/vba IDLFILES=\ VBAEventId.idl \ VBAEventProcessor.idl \ + VBAMacroResolver.idl \ VBASpreadsheetEventProcessor.idl \ VBATextEventProcessor.idl \ XVBACompatibility.idl \ XVBAEventProcessor.idl \ + XVBAMacroResolver.idl \ XVBAModuleInfo.idl # ------------------------------------------------------------------ diff --git a/offapi/com/sun/star/sdb/XSubDocument.idl b/offapi/com/sun/star/sdb/XSubDocument.idl index 0592c6cffa0a..120280fd7ef3 100644 --- a/offapi/com/sun/star/sdb/XSubDocument.idl +++ b/offapi/com/sun/star/sdb/XSubDocument.idl @@ -52,7 +52,7 @@ interface XSubDocument or an <type scope="com::sun::star::frame">XController</type> if the sub document does not have an own model. - @raises ::com::sun::star::lang::WrappedTargetException + @throws ::com::sun::star::lang::WrappedTargetException if an error occurs during opening the document */ ::com::sun::star::lang::XComponent @@ -66,7 +66,7 @@ interface XSubDocument or an <type scope="com::sun::star::frame">XController</type> if the sub document does not have an own model. - @raises ::com::sun::star::lang::WrappedTargetException + @throws ::com::sun::star::lang::WrappedTargetException if an error occurs during opening the document */ ::com::sun::star::lang::XComponent @@ -75,7 +75,7 @@ interface XSubDocument /** stores the sub document, if it had previously been opened in either mode - @raises ::com::sun::star::lang::WrappedTargetException + @throws ::com::sun::star::lang::WrappedTargetException if an error occurs during storing the document */ void store() @@ -86,7 +86,7 @@ interface XSubDocument @return <TRUE/> if and only if the document could be closed, <FALSE/> otherwise, e.g. if the closing has been vetoed by the user. - @raises ::com::sun::star::lang::WrappedTargetException + @throws ::com::sun::star::lang::WrappedTargetException if an error occurs during closing the document */ boolean close() diff --git a/offapi/com/sun/star/sheet/FormulaMapGroupSpecialOffset.idl b/offapi/com/sun/star/sheet/FormulaMapGroupSpecialOffset.idl index fda64a588279..b5e18cd84f8e 100644 --- a/offapi/com/sun/star/sheet/FormulaMapGroupSpecialOffset.idl +++ b/offapi/com/sun/star/sheet/FormulaMapGroupSpecialOffset.idl @@ -56,7 +56,7 @@ constants FormulaMapGroupSpecialOffset constants.</li> <li>A <atom>string</atom> for literal text.</li> <li>A <atom dim="[][]">any</atom> for a literal array. The contained - values shall be of type <atom>double</atom> or atom>string</atom>. + values shall be of type <atom>double</atom> or <atom>string</atom>. Floating-point values and strings may occur together in an array.</li> <li>A struct of type <type>SingleReference</type> for a reference to a single cell in the own document.</li> @@ -142,7 +142,7 @@ constants FormulaMapGroupSpecialOffset able to parse. <p>The <member>FormulaToken::Data</member> member shall contain a - <atom>string</string> with the bad data. This string will be displayed + <atom>string</atom> with the bad data. This string will be displayed literally in the formula.</p> */ const long BAD = 7; diff --git a/offapi/com/sun/star/sheet/SheetFilterDescriptor.idl b/offapi/com/sun/star/sheet/SheetFilterDescriptor.idl index 58734ee18cf0..66c20dc151e3 100644 --- a/offapi/com/sun/star/sheet/SheetFilterDescriptor.idl +++ b/offapi/com/sun/star/sheet/SheetFilterDescriptor.idl @@ -28,21 +28,11 @@ #ifndef __com_sun_star_sheet_SheetFilterDescriptor_idl__ #define __com_sun_star_sheet_SheetFilterDescriptor_idl__ -#ifndef __com_sun_star_sheet_XSheetFilterDescriptor_idl__ #include <com/sun/star/sheet/XSheetFilterDescriptor.idl> -#endif - -#ifndef __com_sun_star_beans_XPropertySet_idl__ +#include <com/sun/star/sheet/XSheetFilterDescriptor2.idl> #include <com/sun/star/beans/XPropertySet.idl> -#endif - -#ifndef __com_sun_star_table_TableOrientation_idl__ #include <com/sun/star/table/TableOrientation.idl> -#endif - -#ifndef __com_sun_star_table_CellAddress_idl__ #include <com/sun/star/table/CellAddress.idl> -#endif //============================================================================= @@ -62,7 +52,20 @@ published service SheetFilterDescriptor /** provides access to the collection of filter fields. */ - interface com::sun::star::sheet::XSheetFilterDescriptor; + interface XSheetFilterDescriptor; + + //------------------------------------------------------------------------- + + /** provides access to the collection of filter fields. + + <p>This interface provides a sequence of <type>TableFilterField2</type> + structures supporting a wider range of comparison operators, compared + to the <type>TableFilterField</type> structure provided by interface + <type>XSheetFilterDescriptor</type>. + + @since OOo 3.2 + */ + [optional] interface XSheetFilterDescriptor2; //------------------------------------------------------------------------- diff --git a/offapi/com/sun/star/awt/grid/ScrollBarMode.idl b/offapi/com/sun/star/sheet/SpreadsheetViewObjectsMode.idl index d22cd8f30c78..d672dd8931e9 100644..100755 --- a/offapi/com/sun/star/awt/grid/ScrollBarMode.idl +++ b/offapi/com/sun/star/sheet/SpreadsheetViewObjectsMode.idl @@ -24,47 +24,38 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef __com_sun_star_awt_grid_ScrollBarMode_idl__ -#define __com_sun_star_awt_grid_ScrollBarMode_idl__ +#ifndef __com_sun_star_sheet_SpreadsheetViewObjectsMode_idl__ +#define __com_sun_star_sheet_SpreadsheetViewObjectsMode_idl__ //============================================================================= -module com { module sun { module star { module awt { module grid { +module com { module sun { module star { module sheet { //============================================================================= -/** specifies the adjustment type. +/** Constants that control how embedded objects are shown in the view. */ -enum ScrollBarMode +published constants SpreadsheetViewObjectsMode { //------------------------------------------------------------------------- - /** adjustment is originated by a line jump. - - <p>A line jump can, for example, be caused by a click on - one of the pointer buttons.</p> + /** Specifies to display a specific set of objects in the spreadsheet view. */ - AUTO, + const short SHOW = 0; //------------------------------------------------------------------------- - /** adjustment is originated by a page jump. - - <p>A page jump can, for example, be caused by a click in the - background area of the scrollbar (neither one of the pointer - buttons, nor the thumb).</p> + /** Specifies to hide a specific set of objects from the spreadsheet view. */ - ON, - - OFF - - + const short HIDE = 1; + //------------------------------------------------------------------------- }; //============================================================================= -}; }; }; }; }; +}; }; }; }; #endif + diff --git a/offapi/com/sun/star/sheet/SpreadsheetViewSettings.idl b/offapi/com/sun/star/sheet/SpreadsheetViewSettings.idl index e40ea1dd8fe4..c1b56ff7ffc6 100644 --- a/offapi/com/sun/star/sheet/SpreadsheetViewSettings.idl +++ b/offapi/com/sun/star/sheet/SpreadsheetViewSettings.idl @@ -149,18 +149,24 @@ published service SpreadsheetViewSettings //------------------------------------------------------------------------- /** enables display of embedded objects in the view. + + @see SpreadsheetViewObjectsMode */ [property] short ShowObjects; //------------------------------------------------------------------------- /** enables the display of charts in the view. + + @see SpreadsheetViewObjectsMode */ [property] short ShowCharts; //------------------------------------------------------------------------- /** enables the display of drawing objects in the view. + + @see SpreadsheetViewObjectsMode */ [property] short ShowDrawing; @@ -175,14 +181,14 @@ published service SpreadsheetViewSettings @see com::sun::star::view::DocumentZoomType */ - [property] short ZoomType; + [property] short ZoomType; //------------------------------------------------------------------------- /** Defines the zoom value to use. Valid only if the ZoomType is set to <member scope="com::sun::star::view::DocumentZoomType">BY_VALUE</member>. */ - [property] short ZoomValue; + [property] short ZoomValue; }; //============================================================================= diff --git a/offapi/com/sun/star/sheet/TableFilterField.idl b/offapi/com/sun/star/sheet/TableFilterField.idl index 6000a1c0247e..69d9a5bcc6ee 100644 --- a/offapi/com/sun/star/sheet/TableFilterField.idl +++ b/offapi/com/sun/star/sheet/TableFilterField.idl @@ -28,13 +28,8 @@ #ifndef __com_sun_star_sheet_TableFilterField_idl__ #define __com_sun_star_sheet_TableFilterField_idl__ -#ifndef __com_sun_star_sheet_FilterConnection_idl__ #include <com/sun/star/sheet/FilterConnection.idl> -#endif - -#ifndef __com_sun_star_sheet_FilterOperator_idl__ #include <com/sun/star/sheet/FilterOperator.idl> -#endif //============================================================================= @@ -44,7 +39,7 @@ module com { module sun { module star { module sheet { /** describes a single condition in a filter descriptor. - @see com::sun::star::sheet::SheetFilterDescriptor + @see SheetFilterDescriptor */ published struct TableFilterField { @@ -52,7 +47,7 @@ published struct TableFilterField /** specifies how the condition is connected to the previous condition. */ - com::sun::star::sheet::FilterConnection Connection; + FilterConnection Connection; //------------------------------------------------------------------------- @@ -64,7 +59,7 @@ published struct TableFilterField /** specifies the type of the condition. */ - com::sun::star::sheet::FilterOperator Operator; + FilterOperator Operator; //------------------------------------------------------------------------- diff --git a/offapi/com/sun/star/sheet/TableFilterField2.idl b/offapi/com/sun/star/sheet/TableFilterField2.idl index cfbcfa4d143c..d7383f477bdc 100644 --- a/offapi/com/sun/star/sheet/TableFilterField2.idl +++ b/offapi/com/sun/star/sheet/TableFilterField2.idl @@ -28,14 +28,8 @@ #ifndef __com_sun_star_sheet_TableFilterField2_idl__ #define __com_sun_star_sheet_TableFilterField2_idl__ - -#ifndef __com_sun_star_sheet_FilterConnection_idl__ #include <com/sun/star/sheet/FilterConnection.idl> -#endif - -#ifndef __com_sun_star_sheet_FilterOperator2_idl__ #include <com/sun/star/sheet/FilterOperator2.idl> -#endif //============================================================================= @@ -49,7 +43,7 @@ module com { module sun { module star { module sheet { member, whereas the <type>TableFilterField</type> struct uses the <type>FilterOperator</type> enum.</p> - @see com::sun::star::sheet::SheetFilterDescriptor + @see SheetFilterDescriptor @since OOo 3.2 */ published struct TableFilterField2 @@ -58,7 +52,7 @@ published struct TableFilterField2 /** specifies how the condition is connected to the previous condition. */ - com::sun::star::sheet::FilterConnection Connection; + FilterConnection Connection; //------------------------------------------------------------------------- @@ -69,7 +63,7 @@ published struct TableFilterField2 //------------------------------------------------------------------------- /** specifies the type of the condition as defined in - <type>FilterOperator2</type>. + <type>FilterOperator2</type>. */ long Operator; diff --git a/offapi/com/sun/star/sheet/XDatabaseRange.idl b/offapi/com/sun/star/sheet/XDatabaseRange.idl index 573578f0c355..9826ab8278e6 100644 --- a/offapi/com/sun/star/sheet/XDatabaseRange.idl +++ b/offapi/com/sun/star/sheet/XDatabaseRange.idl @@ -77,7 +77,7 @@ published interface XDatabaseRange: com::sun::star::uno::XInterface /** returns the sort descriptor stored with the database range. - @see com::sun::star::sheet::SheetSortDescriptor2 + @see SheetSortDescriptor2 */ sequence< com::sun::star::beans::PropertyValue > getSortDescriptor(); @@ -88,8 +88,10 @@ published interface XDatabaseRange: com::sun::star::uno::XInterface <p>If the filter descriptor is modified, the new filtering is carried out when <member>XDatabaseRange::refresh()</member> is called.</p> + + @see SheetFilterDescriptor */ - com::sun::star::sheet::XSheetFilterDescriptor getFilterDescriptor(); + XSheetFilterDescriptor getFilterDescriptor(); //------------------------------------------------------------------------- @@ -98,15 +100,17 @@ published interface XDatabaseRange: com::sun::star::uno::XInterface <p>If the subtotal descriptor is modified, the new subtotals are inserted when <member>XDatabaseRange::refresh()</member> is called.</p> + + @see SubTotalDescriptor */ - com::sun::star::sheet::XSubTotalDescriptor getSubTotalDescriptor(); + XSubTotalDescriptor getSubTotalDescriptor(); //------------------------------------------------------------------------- /** returns the database import descriptor stored with this database range. - @see com::sun::star::sheet::DatabaseImportDescriptor + @see DatabaseImportDescriptor */ sequence< com::sun::star::beans::PropertyValue > getImportDescriptor(); diff --git a/offapi/com/sun/star/sheet/XSheetFilterDescriptor.idl b/offapi/com/sun/star/sheet/XSheetFilterDescriptor.idl index 49f44fd534d8..b3864f373c8a 100644 --- a/offapi/com/sun/star/sheet/XSheetFilterDescriptor.idl +++ b/offapi/com/sun/star/sheet/XSheetFilterDescriptor.idl @@ -28,13 +28,8 @@ #ifndef __com_sun_star_sheet_XSheetFilterDescriptor_idl__ #define __com_sun_star_sheet_XSheetFilterDescriptor_idl__ -#ifndef __com_sun_star_uno_XInterface_idl__ -#include <com/sun/star/uno/XInterface.idl> -#endif - -#ifndef __com_sun_star_sheet_TableFilterField_idl__ #include <com/sun/star/sheet/TableFilterField.idl> -#endif +#include <com/sun/star/uno/XInterface.idl> //============================================================================= @@ -44,7 +39,7 @@ module com { module sun { module star { module sheet { /** provides access to a collection of filter conditions (filter fields). - @see com::sun::star::sheet::SheetFilterDescriptor + @see SheetFilterDescriptor */ published interface XSheetFilterDescriptor: com::sun::star::uno::XInterface { @@ -52,14 +47,13 @@ published interface XSheetFilterDescriptor: com::sun::star::uno::XInterface /** returns the collection of filter fields. */ - sequence< com::sun::star::sheet::TableFilterField > getFilterFields(); + sequence< TableFilterField > getFilterFields(); //------------------------------------------------------------------------- /** sets a new collection of filter fields. */ - void setFilterFields( - [in] sequence< com::sun::star::sheet::TableFilterField > aFilterFields ); + void setFilterFields( [in] sequence< TableFilterField > aFilterFields ); }; diff --git a/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl b/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl index 8f94ee65fc8e..ba8b7904366e 100644 --- a/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl +++ b/offapi/com/sun/star/sheet/XSheetFilterDescriptor2.idl @@ -28,13 +28,8 @@ #ifndef __com_sun_star_sheet_XSheetFilterDescriptor2_idl__ #define __com_sun_star_sheet_XSheetFilterDescriptor2_idl__ -#ifndef __com_sun_star_sheet_TableFilterField2_idl__ #include <com/sun/star/sheet/TableFilterField2.idl> -#endif - -#ifndef __com_sun_star_uno_XInterface_idl__ #include <com/sun/star/uno/XInterface.idl> -#endif //============================================================================= @@ -48,7 +43,7 @@ module com { module sun { module star { module sheet { whereas the <type>XSheetFilterDescriptor</type> interface uses the <type>TableFilterField</type> struct.</p> - @see com::sun::star::sheet::SheetFilterDescriptor + @see SheetFilterDescriptor @since OOo 3.2 */ published interface XSheetFilterDescriptor2: com::sun::star::uno::XInterface @@ -57,14 +52,13 @@ published interface XSheetFilterDescriptor2: com::sun::star::uno::XInterface /** returns the collection of filter fields. */ - sequence< com::sun::star::sheet::TableFilterField2 > getFilterFields2(); + sequence< TableFilterField2 > getFilterFields2(); //------------------------------------------------------------------------- /** sets a new collection of filter fields. */ - void setFilterFields2( - [in] sequence< com::sun::star::sheet::TableFilterField2 > aFilterFields ); + void setFilterFields2( [in] sequence< TableFilterField2 > aFilterFields ); }; diff --git a/offapi/com/sun/star/sheet/makefile.mk b/offapi/com/sun/star/sheet/makefile.mk index 33d06c32d20a..37a0cadacacd 100644 --- a/offapi/com/sun/star/sheet/makefile.mk +++ b/offapi/com/sun/star/sheet/makefile.mk @@ -199,6 +199,7 @@ IDLFILES=\ SpreadsheetDocumentSettings.idl\ SpreadsheetDrawPage.idl\ SpreadsheetView.idl\ + SpreadsheetViewObjectsMode.idl\ SpreadsheetViewPane.idl\ SpreadsheetViewPanesEnumeration.idl\ SpreadsheetViewSettings.idl\ diff --git a/offapi/com/sun/star/task/PDFExportException.idl b/offapi/com/sun/star/task/PDFExportException.idl new file mode 100644 index 000000000000..8547aea76418 --- /dev/null +++ b/offapi/com/sun/star/task/PDFExportException.idl @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_task_PDFExportException_idl__ +#define __com_sun_star_task_PDFExportException_idl__ + +#ifndef __com_sun_star_uno_Exception_idl__ +#include <com/sun/star/uno/Exception.idl> +#endif + + module com { module sun { module star { module task { + + +/** is an exception that provides information on an error during PDF export. + */ +published exception PDFExportException: com::sun::star::uno::Exception +{ + /** contains a number of errors that occured during PDFExport + */ + sequence< long > ErrorCodes; +}; + +//============================================================================= + +}; }; }; }; + +/*=========================================================================== +===========================================================================*/ +#endif diff --git a/offapi/com/sun/star/task/makefile.mk b/offapi/com/sun/star/task/makefile.mk index 16b0be56e36c..cd9db6b5a738 100644 --- a/offapi/com/sun/star/task/makefile.mk +++ b/offapi/com/sun/star/task/makefile.mk @@ -59,6 +59,7 @@ IDLFILES=\ PasswordContainerInteractionHandler.idl\ PasswordRequest.idl\ PasswordRequestMode.idl\ + PDFExportException.idl\ OfficeRestartManager.idl\ UnsupportedOverwriteRequest.idl\ UrlRecord.idl\ diff --git a/offapi/com/sun/star/text/DocumentSettings.idl b/offapi/com/sun/star/text/DocumentSettings.idl index 6addc8f0d76d..7ea0e48779ae 100644 --- a/offapi/com/sun/star/text/DocumentSettings.idl +++ b/offapi/com/sun/star/text/DocumentSettings.idl @@ -195,6 +195,16 @@ published service DocumentSettings */ [optional, property] boolean ConsiderTextWrapOnObjPos; + // ------------------------------------------------------------ + /** specifies if Math objects should automatically vertically aligned to + match the baseline of the surrounding text. + + <p>If activated formula object that are anchored 'As Character' will be + vertically aligned to have their baseline match with the one from the text.</p> + + @since OOo 3.4 + */ + [optional, property] boolean MathBaselineAlignment; }; //============================================================================= diff --git a/offapi/com/sun/star/text/PrintPreviewSettings.idl b/offapi/com/sun/star/text/PrintPreviewSettings.idl index d4d519241631..eb57288200fb 100644..100755 --- a/offapi/com/sun/star/text/PrintPreviewSettings.idl +++ b/offapi/com/sun/star/text/PrintPreviewSettings.idl @@ -39,6 +39,8 @@ //============================================================================= /** These properties describe the printing of the content of a text document. + * + * @deprecated since OOo 3.3 */ published service PrintPreviewSettings { diff --git a/offapi/com/sun/star/text/TextMarkupType.idl b/offapi/com/sun/star/text/TextMarkupType.idl index b6c3bb7bfd9f..0787dfefb456 100644 --- a/offapi/com/sun/star/text/TextMarkupType.idl +++ b/offapi/com/sun/star/text/TextMarkupType.idl @@ -44,23 +44,28 @@ module com { module sun { module star { module text { constants TextMarkupType { - /// Markup originates from spell checking. + /** Markup originates from spell checking. + */ const long SPELLCHECK = 1; - /// Markup originates from proofreading - /// @since OOo 3.0.1 + /** Markup originates from proofreading + @since OOo 3.0.1 + */ const long PROOFREADING = 2; - /// Markup originates from smart tag checking. + /** Markup originates from smart tag checking. + */ const long SMARTTAG = 3; - /// Markup originates from proofreading - /// An invisible markup used to identify sentence boundaries. - /// @since OOo 3.0.1 + /** Markup originates from proofreading + An inivisible markup type used in proofreading API calls. + @since OOo 3.0.1 + */ const long SENTENCE = 4; - /// Markups originates from change tracking. - /// @since OOo 3.3 + /** Markups originates from change tracking. + @since OOo 3.3 + */ const long TRACK_CHANGE_INSERTION = 5; const long TRACK_CHANGE_DELETION = 6; const long TRACK_CHANGE_FORMATCHANGE = 7; diff --git a/offapi/com/sun/star/ui/UIElementType.idl b/offapi/com/sun/star/ui/UIElementType.idl index 63fb62186747..a3a32dff7935 100644 --- a/offapi/com/sun/star/ui/UIElementType.idl +++ b/offapi/com/sun/star/ui/UIElementType.idl @@ -2,10 +2,13 @@ * * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * - * Copyright 2000, 2010 Oracle and/or its affiliates. + * Copyright 2008 by Sun Microsystems, Inc. * * OpenOffice.org - a multi-platform office productivity suite * + * $RCSfile: UIElementType.idl,v $ + * $Revision: 1.4 $ + * * This file is part of OpenOffice.org. * * OpenOffice.org is free software: you can redistribute it and/or modify @@ -78,6 +81,11 @@ constants UIElementType const short TOOLPANEL = 7; //------------------------------------------------------------------------- + /** specifies a window that can be docked. + */ + const short DOCKINGWINDOW = 7; + + //------------------------------------------------------------------------- /** specifies the number of constants. */ const short COUNT = 8; diff --git a/offapi/com/sun/star/util/DiskFullException.idl b/offapi/com/sun/star/util/DiskFullException.idl index 385a5d1f590a..43eda08302a2 100644 --- a/offapi/com/sun/star/util/DiskFullException.idl +++ b/offapi/com/sun/star/util/DiskFullException.idl @@ -38,7 +38,7 @@ module com { module sun { module star { module util { //============================================================================= -/** is thrown when a disk full error occurs. +/** @deprecated */ published exception DiskFullException: com::sun::star::util::FileIOException { diff --git a/offapi/com/sun/star/util/FileIOException.idl b/offapi/com/sun/star/util/FileIOException.idl index 2b1d2ae31400..804c18094704 100644 --- a/offapi/com/sun/star/util/FileIOException.idl +++ b/offapi/com/sun/star/util/FileIOException.idl @@ -37,7 +37,7 @@ module com { module sun { module star { module util { //============================================================================= -/** thrown when file I/O error occurs. +/** @deprecated */ published exception FileIOException: com::sun::star::uno::Exception { @@ -48,3 +48,4 @@ published exception FileIOException: com::sun::star::uno::Exception }; }; }; }; #endif + diff --git a/offapi/com/sun/star/util/NotLockedException.idl b/offapi/com/sun/star/util/NotLockedException.idl new file mode 100755 index 000000000000..b0917e0bdca6 --- /dev/null +++ b/offapi/com/sun/star/util/NotLockedException.idl @@ -0,0 +1,50 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_util_NotLockedException_idl__ +#define __com_sun_star_util_NotLockedException_idl__ + +#include <com/sun/star/util/InvalidStateException.idl> + +//================================================================================================================== + +module com { module sun { module star { module util { + +//================================================================================================================== + +/** is raised when attempt is made to unlock a lockable component which actually is not locked. + */ +exception NotLockedException : ::com::sun::star::util::InvalidStateException +{ +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/util/OfficeInstallationDirectories.idl b/offapi/com/sun/star/util/OfficeInstallationDirectories.idl index c25ee0ccfd7c..06b9665d26a5 100644 --- a/offapi/com/sun/star/util/OfficeInstallationDirectories.idl +++ b/offapi/com/sun/star/util/OfficeInstallationDirectories.idl @@ -52,7 +52,7 @@ module com { module sun { module star { module util { @since OOo 2.0.0 */ -service OfficeInstallationDirectories +published service OfficeInstallationDirectories { /** provides access to the current office installation directories (office base installation and user data). @@ -67,7 +67,7 @@ service OfficeInstallationDirectories @see OfficeInstallationDirectories */ -singleton theOfficeInstallationDirectories +published singleton theOfficeInstallationDirectories { service com::sun::star::util::OfficeInstallationDirectories; }; diff --git a/offapi/com/sun/star/util/XBroadcaster.idl b/offapi/com/sun/star/util/XBroadcaster.idl index a71fe2ef23a5..ba97b5b5f4f6 100644 --- a/offapi/com/sun/star/util/XBroadcaster.idl +++ b/offapi/com/sun/star/util/XBroadcaster.idl @@ -50,7 +50,7 @@ interface XBroadcaster: com::sun::star::uno::XInterface <member>XBroadcaster::unlockBroadcasts()</member> may be nested and even overlapping, but they must be in pairs. While there is at least one lock remaining, no broadcasts are - send to registered listeners. + sent to registered listeners. </p> */ [oneway] void lockBroadcasts(); @@ -64,10 +64,10 @@ interface XBroadcaster: com::sun::star::uno::XInterface <member>XBroadcaster::unlockBroadcasts()</member> may be nested and even overlapping, but they must be in pairs. While there is at least one lock remaining, no broadcasts are - send to registered listeners. + sent to registered listeners. </p> - <p> Pending broadcasts will be send immediately after the last + <p> Pending broadcasts will be sent immediately after the last call to <member>XBroadcaster::lockBroadcast()</member> is matched by a call to <member>XBroadcaster::unlockBroadcasts()</member>. An implementation can decide to broadcast all pending notification in diff --git a/offapi/com/sun/star/util/XLockable.idl b/offapi/com/sun/star/util/XLockable.idl new file mode 100755 index 000000000000..e3da8025a034 --- /dev/null +++ b/offapi/com/sun/star/util/XLockable.idl @@ -0,0 +1,79 @@ +/************************************************************************* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __com_sun_star_util_XLockable_idl__ +#define __com_sun_star_util_XLockable_idl__ + +#include <com/sun/star/util/NotLockedException.idl> + +//================================================================================================================== + +module com { module sun { module star { module util { + +//================================================================================================================== + +/** allows locking a component + + <p><code>lock</code> and <code>unlock</code> calls can be nested. However, they must be in + pairs. As long as there has been one more call to <code>lock</code> than to <code>unlock</code>, the + component is considered locked, which is reflected by <member>isLocked</member> returning <TRUE/>.</p> + */ +interface XLockable +{ + /** locks</a> the component + + @see unlock + @see isLocked + */ + void lock(); + + /** unlocks the component + + @throws NotLockedException + if the component is not currently locked. + + @see lock + @see isLocked + */ + void unlock() + raises ( NotLockedException + ); + + /** determines whether the component is currently locked. + + @see lock + @see unlock + */ + boolean isLocked(); +}; + +//================================================================================================================== + +}; }; }; }; + +//================================================================================================================== + +#endif diff --git a/offapi/com/sun/star/util/XOfficeInstallationDirectories.idl b/offapi/com/sun/star/util/XOfficeInstallationDirectories.idl index 0299304a5cfb..889cd5c89ed8 100644 --- a/offapi/com/sun/star/util/XOfficeInstallationDirectories.idl +++ b/offapi/com/sun/star/util/XOfficeInstallationDirectories.idl @@ -47,7 +47,7 @@ module com { module sun { module star { module util { @since OOo 2.0.0 */ -interface XOfficeInstallationDirectories : com::sun::star::uno::XInterface +published interface XOfficeInstallationDirectories : com::sun::star::uno::XInterface { //------------------------------------------------------------------------ /** returns the absolute URL containing the directory of the current office @@ -61,7 +61,8 @@ interface XOfficeInstallationDirectories : com::sun::star::uno::XInterface //------------------------------------------------------------------------ /** returns the absolute URL containing the directory where the current - office installation expects its user data (e.g. "file:///home/kso".) + office installation expects its user data (e.g. + "file:///home/kso/.openoffice.org".) @returns the absolute URL containing the directory of the current office diff --git a/offapi/com/sun/star/util/XTextSearch.idl b/offapi/com/sun/star/util/XTextSearch.idl index 4b035282c4bb..e76d286eec46 100644 --- a/offapi/com/sun/star/util/XTextSearch.idl +++ b/offapi/com/sun/star/util/XTextSearch.idl @@ -35,97 +35,151 @@ module com { module sun { module star { module util { -published enum SearchAlgorithms { - ABSOLUTE, // "normal" a kind of Boyer-Moore - REGEXP, // regular expression - APPROXIMATE // Levenshtein distance +published enum SearchAlgorithms +{ + /// Literal + ABSOLUTE, // implemented as a kind of Boyer-Moore + /// Regular expression + REGEXP, + /// Weighted Levenshtein Distance + APPROXIMATE }; +/// Flags for search methods published constants SearchFlags { - //Flag for all search methods - /** - @deprecated : the constant ALL_IGNORE_CASE is never supported - - it must use the transliteration flags of - the SearchOptions. - <p>@see TransliterationModulesNew + @deprecated The constant ALL_IGNORE_CASE is never supported - use + <const scope="com::sun::star::i18n">TransliterationModules::IGNORE_CASE</const> + with + <member>SearchOptions::transliterateFlags</member> + instead. + + @see <type scope="com::sun::star::i18n">TransliterationModules</type> */ const long ALL_IGNORE_CASE = 0x00000001; - /// Flag for normal (Boyer-Moore) search + /** Flag for normal (Boyer-Moore) search / Search for word only. */ const long NORM_WORD_ONLY = 0x00000010; - /// Flag for "regular expression" search / interpret as extended regular expression + /** Flag for "regular expression" search / Interpret as extended + regular expression. + + @deprecated The flag is currently not supported by OOo. + */ const long REG_EXTENDED = 0x00000100; - /** Flag for "regular expression" search / No replace, i.e., avoid sub regular - expressions, return true/false to match -<!-- JRH: Check this for sense of the expression. --> + /** Flag for "regular expression" search / No register information + or backreferences, i.e., avoid sub expressions. Return only + true/false if matched or not. + + @deprecated The flag is currently not supported by OOo. + */ + const long REG_NOSUB = 0x00000200; + + /** Flag for "regular expression" search / Special new line + treatment. + + @deprecated The flag is currently not supported by OOo. + + <p> A NEWLINE character in string will not be matched by a + period outside bracket expression or by any form of a non + matching list. </p> + + <p> A circumflex (^) in pattern when used to specify expression + anchoring will match the zero length string immediately after a + newline in string, regardless of the setting of + REG_NOT_BEGINOFLINE. </p> + + <p> A dollar-sign ($) in pattern when used to specify expression + anchoring, will match zero-length string immediately before a + new line in string, regardless of the setting of + REG_NOT_ENDOFLINE. </p> + */ + const long REG_NEWLINE = 0x00000400; + + /** The first character in the string is not the beginning of the + line therefore ^ will not match with first character of the + string. */ - const long REG_NOSUB = 0x00000200; - - /// Flag for "regular expression" search / Special new line treatment - const long REG_NEWLINE = 0x00000400; - - /** A NEWLINE character in string will not be matched by a period outside bracket - expression or by any form of a non matching list. - A circumflex (^) in pattern when used to specify expression anchoring -<!-- JRH: anhoring to anchoring. --> - will match the zero length string immediately after a newline in string, - regardless of the setting of REG_NOTBOL - A dollar-sign ($) in pattern when used to specify expression anchoring, - will match zero-length string immediately before a new line in string, - regardless of the setting of REG_NOTEOL -*/ const long REG_NOT_BEGINOFLINE = 0x00000800; - /** The first character in the string is not the beginning of the line therefore ^ will not - match with first character of the string + /** The last character in the string is not the end of the line + therefore $ will not match with last character of the string. */ const long REG_NOT_ENDOFLINE = 0x00001000; - - /// Flags for "Weight Levenshtein-Distance" search + /** Flag for "Weighted Levenshtein Distance" search / Relaxed + checking of limit, split weigh pools. + + <p> If not specified (<b>strict</b>), the search is sucessful if + the WLD is within a calculated limit where each insertion, + deletion and replacement adds a weight to a common pool of + weights. This is the mathematically correct WLD. </p> + + <p> From a user's point of view the strict WLD is an + exclusive-OR of the arguments given, for example if allowed + insertions=2 and allowed replacements=2, the search fails if 2 + characters had been inserted and an additional operation would + be needed to match. Depending on the weights it may also fail if + 1 character was inserted and 1 character replaced and an + additional operation would be needed to match. The strict + algorithm may match less than expected from a first glance of + the specified arguments, but does not return false positives. </p> + + <p> If specified (<b>relaxed</b>), the search is also successful + if the combined pool for insertions and deletions is below a + doubled calculated limit and replacements are treated + differently. Additionally, swapped characters are counted as one + replacement. </p> + + <p> From a user's point of view the relaxed WLD is an + inclusive-OR of the arguments given, for example if allowed + insertions=2 and allowed replacements=2, the search succeeds if + 2 characters had been inserted and an additional replacement is + needed to match. The relaxed algorithm may return false + positives, but meets user expectation better. </p> + */ const long LEV_RELAXED = 0x00010000; }; published struct SearchOptions { //------------------------------------------------------------------------- - /// search type, can be: ABSOLUTE, REGEXP, APPROXIMATE + /** search type */ SearchAlgorithms algorithmType; /** some flags - can be mixed - @see SearchFlags + @see <type>SearchFlags</type> */ long searchFlag; - /// the search text + /** The text or pattern to be searched. */ string searchString; - /** the replace text - (is for optional replacing - SearchOption is only the data container for it)*/ + /** The replacement text + (is for optional replacing - SearchOption is only the data container for it) */ string replaceString; - /// this is the language for case insensitive search + /** The locale for case insensitive search. */ ::com::sun::star::lang::Locale Locale; - /** this many characters can be different between the found and search word - in a "Weight Levenshtein-Distance"*/ + /** This many characters can be different (as a replacement) between + the found word and the search pattern in a "Weighted Levenshtein + Distance" search. */ long changedChars; - /** this many characters can be missed in the found word - in a "Weight Levenshtein-Distance"*/ + /** This many characters can be missing in the found word in a + "Weighted Levenshtein Distance" search. */ long deletedChars; - /// this many characters can be additional in the found word in a "Weight Levenshtein-Distance" + /** This many characters can be additional in the found word in a + "Weighted Levenshtein Distance" search. */ long insertedChars; - /** Asian flags for the transliteration. Same meaning as the enum of TransliteratorModule - - @see com/sun/star/i18n/XTransliteration.idl + /** Flags for the transliteration. Same meaning as the enum of + <type scope="com::sun::star::i18n">TransliterationModules</type> */ long transliterateFlags; }; diff --git a/offapi/com/sun/star/util/makefile.mk b/offapi/com/sun/star/util/makefile.mk index aa0374296ddb..87dc2d078037 100644 --- a/offapi/com/sun/star/util/makefile.mk +++ b/offapi/com/sun/star/util/makefile.mk @@ -145,6 +145,8 @@ IDLFILES=\ UriAbbreviation.idl\ XJobManager.idl\ JobManager.idl\ + XLockable.idl\ + NotLockedException.idl\ # ------------------------------------------------------------------ diff --git a/offapi/com/sun/star/view/XMultiSelectionSupplier.idl b/offapi/com/sun/star/view/XMultiSelectionSupplier.idl index 8d5d7e07fb52..3557b3c47fae 100644 --- a/offapi/com/sun/star/view/XMultiSelectionSupplier.idl +++ b/offapi/com/sun/star/view/XMultiSelectionSupplier.idl @@ -66,7 +66,7 @@ interface XMultiSelectionSupplier: XSelectionSupplier added to the current selection. For example, if the selection already contains objects that are forbidden to be selected together with <var>Selection</var> - @raises com::sun::star::lang::IllegalArgumentException + @throws com::sun::star::lang::IllegalArgumentException If <var>Selection</var> is not a selectable object for this <type>XMultiSelectionSupplier</type>. <p>Adding an object to the selection that is already part of the selection should not raise this exception</p> */ @@ -87,7 +87,7 @@ interface XMultiSelectionSupplier: XSelectionSupplier added to the current selection. For example, if the selection already contains objects that are forbidden to be selected together with <var>Selection</var>. - @raises com::sun::star::lang::IllegalArgumentException + @throws com::sun::star::lang::IllegalArgumentException If <var>Selection</var> is not a selectable object for this <type>XMultiSelectionSupplier</type>. <p>Removing an object from the selection that is not part of the selection should not raise this exception</p> */ diff --git a/offapi/com/sun/star/xml/sax/XFastAttributeList.idl b/offapi/com/sun/star/xml/sax/XFastAttributeList.idl index 4b514e1791bb..ad991568d738 100644 --- a/offapi/com/sun/star/xml/sax/XFastAttributeList.idl +++ b/offapi/com/sun/star/xml/sax/XFastAttributeList.idl @@ -92,7 +92,7 @@ interface XFastAttributeList: com::sun::star::uno::XInterface @returns The integer token of the value from the attribute or <const>FastToken::Invalid</const> - @raises SAXException + @throws SAXEXception if the attribute is not available */ @@ -137,7 +137,7 @@ interface XFastAttributeList: com::sun::star::uno::XInterface @returns The string value from the attribute. - @raises SAXException + @throws SAXEXception if the attribute is not available */ diff --git a/offapi/prj/build.lst b/offapi/prj/build.lst index bc6dda566031..a4ed8a8ceaf8 100644 --- a/offapi/prj/build.lst +++ b/offapi/prj/build.lst @@ -9,6 +9,7 @@ oa offapi\com\sun\star\accessibility nmake - all oa_accessibility oa_awt N oa offapi\com\sun\star\awt nmake - all oa_awt NULL oa offapi\com\sun\star\awt\tree nmake - all oa_awttree NULL oa offapi\com\sun\star\awt\grid nmake - all oa_awtgrid NULL +oa offapi\com\sun\star\awt\tab nmake - all oa_awttab NULL oa offapi\com\sun\star\chart nmake - all oa_chart NULL oa offapi\com\sun\star\chart2 nmake - all oa_chart2 NULL oa offapi\com\sun\star\chart2\data nmake - all oa_chart2_data NULL @@ -106,4 +107,4 @@ oa offapi\com\sun\star\rendering nmake - all oa_rendering oa_geometry NU oa offapi\com\sun\star\rdf nmake - all oa_rdf oa_datatransfer oa_text NULL oa offapi\com\sun\star\office nmake - all oa_office oa_text NULL oa offapi\drafts\com\sun\star\form nmake - all oa_drafts_form NULL -oa offapi\util nmake - all oa_util oa_auth oa_awt oa_awttree oa_awtgrid oa_chart oa_chart2 oa_chart2_data oa_config oa_configbootstrap oa_configbackend oa_configbackend_xml oa_datatrans_clip oa_datatrans_dnd oa_datatransfer oa_docu oa_draw oa_draw_framework oa_embed oa_fcomp oa_finsp oa_fcontr oa_fieldmaster oa_form oa_xforms oa_formula oa_frame oa_i18n oa_inst oa_ldap oa_ling2 oa_logging oa_mail oa_media oa_mozilla oa_packages oa_manifest oa_zippackage oa_plug oa_pres oa_animations oa_putil oa_resrc oa_sax oa_xml_input oa_scan oa_sdb oa_sdbtools oa_sdbapp oa_sdbc oa_sdbcx oa_setup oa_sheet oa_style oa_svg oa_sync oa_sync2 oa_system oa_table oa_task oa_text oa_textfield oa_docinfo oa_ucb oa_view oa_xml oa_xml_dom oa_xml_xpath oa_xml_views oa_xml_events oa_image oa_xsd oa_inspection oa_ui oa_ui_dialogs oa_accessibility oa_form_binding oa_form_validation oa_form_submission oa_fruntime oa_geometry oa_rendering oa_sfprovider oa_sfbrowse oa_drafts_form oa_deployment oa_deploymenttest oa_deployment_ui oa_frame_status oa_gallery oa_graphic oa_security oa_crypto_sax oa_crypto oa_csax oa_wrapper oa_script oa_script_vba oa_smarttags oa_report oa_reportins oa_reportmeta oa_rdf oa_oooimprovement oa_office oa_prestextfield oa_starme NULL +oa offapi\util nmake - all oa_util oa_auth oa_awt oa_awttree oa_awtgrid oa_awttab oa_chart oa_chart2 oa_chart2_data oa_config oa_configbootstrap oa_configbackend oa_configbackend_xml oa_datatrans_clip oa_datatrans_dnd oa_datatransfer oa_docu oa_draw oa_draw_framework oa_embed oa_fcomp oa_finsp oa_fcontr oa_fieldmaster oa_form oa_xforms oa_formula oa_frame oa_i18n oa_inst oa_ldap oa_ling2 oa_logging oa_mail oa_media oa_mozilla oa_packages oa_manifest oa_zippackage oa_plug oa_pres oa_animations oa_putil oa_resrc oa_sax oa_xml_input oa_scan oa_sdb oa_sdbtools oa_sdbapp oa_sdbc oa_sdbcx oa_setup oa_sheet oa_style oa_svg oa_sync oa_sync2 oa_system oa_table oa_task oa_text oa_textfield oa_docinfo oa_ucb oa_view oa_xml oa_xml_dom oa_xml_xpath oa_xml_views oa_xml_events oa_image oa_xsd oa_inspection oa_ui oa_ui_dialogs oa_accessibility oa_form_binding oa_form_validation oa_form_submission oa_fruntime oa_geometry oa_rendering oa_sfprovider oa_sfbrowse oa_drafts_form oa_deployment oa_deploymenttest oa_deployment_ui oa_frame_status oa_gallery oa_graphic oa_security oa_crypto_sax oa_crypto oa_csax oa_wrapper oa_script oa_smarttags oa_report oa_reportins oa_reportmeta oa_rdf oa_oooimprovement oa_office oa_prestextfield oa_starme oa_script_vba NULL diff --git a/offapi/prj/d.lst b/offapi/prj/d.lst index 764521f3e944..a271a7159130 100644 --- a/offapi/prj/d.lst +++ b/offapi/prj/d.lst @@ -13,6 +13,7 @@ mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\auth mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\awt mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\tree mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\grid +mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\tab mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\chart mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\chart2 mkdir: %COMMON_DEST%\idl%_EXT%\com\sun\star\chart2\data @@ -130,6 +131,7 @@ mkdir: %COMMON_DEST%\idl%_EXT%\drafts\com\sun\star\form ..\com\sun\star\awt\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\awt ..\com\sun\star\awt\tree\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\tree ..\com\sun\star\awt\grid\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\grid +..\com\sun\star\awt\tab\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\awt\tab ..\com\sun\star\chart\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\chart ..\com\sun\star\chart2\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\chart2 ..\com\sun\star\chart2\data\*.idl %COMMON_DEST%\idl%_EXT%\com\sun\star\chart2\data diff --git a/offapi/type_reference/typelibrary_history.txt b/offapi/type_reference/typelibrary_history.txt index 7dcd438d5517..16745ab9f7eb 100644 --- a/offapi/type_reference/typelibrary_history.txt +++ b/offapi/type_reference/typelibrary_history.txt @@ -158,3 +158,7 @@ Update reference type library with the version of OOo 3.2.1. The new reference type library is taken from the release source tree OOO320 m19. +01/28/11 (JSC): TaskID=116682 + Update css.awt.UnoControlDialog to reflect the supported XDialog2 interface + additionally to XDialog + diff --git a/offapi/type_reference/types.rdb b/offapi/type_reference/types.rdb Binary files differindex 6d9f761331f4..02cd79c9eb4f 100644 --- a/offapi/type_reference/types.rdb +++ b/offapi/type_reference/types.rdb diff --git a/offapi/util/makefile.mk b/offapi/util/makefile.mk index fedb64480369..ae4558499e37 100644 --- a/offapi/util/makefile.mk +++ b/offapi/util/makefile.mk @@ -42,6 +42,7 @@ UNOIDLDBFILES= \ $(UCR)$/cssawt.db \ $(UCR)$/cssawttree.db \ $(UCR)$/cssawtgrid.db \ + $(UCR)$/cssawttab.db \ $(UCR)$/csschart.db \ $(UCR)$/csschart2.db \ $(UCR)$/csschart2data.db \ diff --git a/offuh/prj/build.lst b/offuh/prj/build.lst index f8f8ca45ba1a..e98f3565b60c 100644 --- a/offuh/prj/build.lst +++ b/offuh/prj/build.lst @@ -1,4 +1,4 @@ -ou offuh :: offapi codemaker NULL +ou offuh :: offapi oovbaapi codemaker NULL ou offuh usr1 - all ou_mkout NULL ou offuh\prj get - all ou_prj NULL ou offuh\source nmake - all ou_source NULL diff --git a/offuh/prj/d.lst b/offuh/prj/d.lst index a88257dc695d..464dfca14075 100644 --- a/offuh/prj/d.lst +++ b/offuh/prj/d.lst @@ -8,6 +8,7 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\accessibility mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\awt mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\tree mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\grid +mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\tab mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\beans mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\bridge mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\bridge\oleautomation @@ -134,6 +135,21 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\xml\wrapper #i20156 - end mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf +mkdir: %_DEST%\inc%_EXT%\offuh\ooo +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\access +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\adodb +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\dao +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\excel +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\msforms +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\office +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\powerpoint +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\stdole +mkdir: %_DEST%\inc%_EXT%\offuh\ooo\vba\word +mkdir: %_DEST%\inc%_EXT%\offuh\msforms + + + ..\%__SRC%\inc\offuh\com\sun\star\auth\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\auth\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\auth\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\auth\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\accessibility\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\accessibility\*.hpp @@ -144,6 +160,8 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf ..\%__SRC%\inc\offuh\com\sun\star\awt\tree\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\tree\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\awt\grid\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\grid\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\awt\grid\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\grid\*.hpp +..\%__SRC%\inc\offuh\com\sun\star\awt\tab\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\tab\*.hdl +..\%__SRC%\inc\offuh\com\sun\star\awt\tab\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\awt\tab\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\beans\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\beans\*.hdl ..\%__SRC%\inc\offuh\com\sun\star\beans\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\beans\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\bridge\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\bridge\*.hdl @@ -377,3 +395,29 @@ mkdir: %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf ..\%__SRC%\inc\offuh\com\sun\star\rdf\*.hpp %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf\*.hpp ..\%__SRC%\inc\offuh\com\sun\star\rdf\*.hdl %_DEST%\inc%_EXT%\offuh\com\sun\star\rdf\*.hdl + +..\%__SRC%\inc\offuh\ooo\vba\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\access\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\access\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\access\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\access\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\adodb\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\adodb\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\adodb\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\adodb\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\dao\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\dao\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\dao\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\dao\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\excel\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\excel\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\excel\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\excel\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\msforms\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\msforms\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\msforms\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\msforms\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\office\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\office\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\office\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\office\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\powerpoint\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\powerpoint\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\powerpoint\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\powerpoint\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\stdole\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\stdole\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\stdole\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\stdole\*.hdl +..\%__SRC%\inc\offuh\ooo\vba\word\*.hpp %_DEST%\inc%_EXT%\offuh\ooo\vba\word\*.hpp +..\%__SRC%\inc\offuh\ooo\vba\word\*.hdl %_DEST%\inc%_EXT%\offuh\ooo\vba\word\*.hdl +..\%__SRC%\inc\offuh\msforms\*.hpp %_DEST%\inc%_EXT%\offuh\msforms\*.hpp +..\%__SRC%\inc\offuh\msforms\*.hdl %_DEST%\inc%_EXT%\offuh\msforms\*.hdl + diff --git a/offuh/source/makefile.mk b/offuh/source/makefile.mk index e773d7ff3a69..230dc750aa90 100644 --- a/offuh/source/makefile.mk +++ b/offuh/source/makefile.mk @@ -33,12 +33,16 @@ TARGET= offuh .INCLUDE : settings.mk -# ------------------------------------------------------------------ +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk + +ALLTAR : $(MISC)$/oovbaapi.don $(MISC)$/$(TARGET).don $(MISC)$/$(TARGET).don : $(UNOUCRRDB) @@-$(RM) $@ $(CPPUMAKER) -Gc $(CPPUMAKERFLAGS) -B$(UNOUCRBASE) -O$(UNOUCROUT) $(UNOUCRRDB) && echo > $@ -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk +$(MISC)$/oovbaapi.don : $(SOLARBINDIR)$/oovbaapi.rdb + @@-$(RM) $@ + $(CPPUMAKER) -Gc $(CPPUMAKERFLAGS) -B$(UNOUCRBASE) -O$(UNOUCROUT) $(SOLARBINDIR)$/oovbaapi.rdb -X$(SOLARBINDIR)$/types.rdb && echo > $@ + echo $@ diff --git a/pyuno/demo/pyunoenv.tcsh b/pyuno/demo/pyunoenv.tcsh index 1a831996325f..038cf2ddb45b 100644 --- a/pyuno/demo/pyunoenv.tcsh +++ b/pyuno/demo/pyunoenv.tcsh @@ -17,7 +17,12 @@ if( ! $?LD_LIBRARY_PATH ) then setenv LD_LIBRARY_PATH endif -setenv PYTHONPATH .:$OOOHOME/program:$OOOHOME/program/pydemo:$OOOHOME/program/python/lib:$PYTHONPATH +if( "$PYTHONPATH" != "" ) then + setenv PYTHONPATH $OOOHOME/program:$OOOHOME/program/pydemo:$OOOHOME/program/python/lib:$PYTHONPATH +else + setenv PYTHONPATH $OOOHOME/program:$OOOHOME/program/pydemo:$OOOHOME/program/python/lib +endif + setenv LD_LIBRARY_PATH $OOOHOME/program:$LD_LIBRARY_PATH if( $?PYTHONHOME ) then diff --git a/pyuno/prj/build.lst b/pyuno/prj/build.lst index 92449162071d..5a3b2c179e7d 100644 --- a/pyuno/prj/build.lst +++ b/pyuno/prj/build.lst @@ -1,4 +1,4 @@ -bgpu pyuno : stoc cpputools cppuhelper bridges tools PYTHON:python NULL +bgpu pyuno : stoc cpputools cppuhelper bridges tools PYTHON:python LIBXSLT:libxslt NULL pu pyuno usr1 - all br_mkout NULL pu pyuno\zipcore nmake - all pu_zipcore NULL pu pyuno\source\module nmake - all pu_module NULL diff --git a/pyuno/prj/d.lst b/pyuno/prj/d.lst index 5fe7400a8d58..1dd212ea9cf4 100644 --- a/pyuno/prj/d.lst +++ b/pyuno/prj/d.lst @@ -9,12 +9,11 @@ mkdir: %_DEST%\lib%_EXT%\pyuno ..\%__SRC%\lib\unohelper.py %_DEST%\lib%_EXT%\pyuno\unohelper.py ..\%__SRC%\lib\pythonloader.py %_DEST%\lib%_EXT%\pyuno\pythonloader.py ..\%__SRC%\lib\uno.py %_DEST%\lib%_EXT%\pyuno\uno.py -..\%__SRC%\lib\pyuno_services.rdb %_DEST%\bin%_EXT%\pyuno_services.rdb +..\%__SRC%\misc\pythonloader.component %_DEST%\xml\pythonloader.component ..\%__SRC%\bin\unohelper.py %_DEST%\bin%_EXT%\pyuno\unohelper.py ..\%__SRC%\bin\pythonloader.py %_DEST%\bin%_EXT%\pyuno\pythonloader.py ..\%__SRC%\bin\uno.py %_DEST%\bin%_EXT%\pyuno\uno.py -..\%__SRC%\bin\pyuno_services.rdb %_DEST%\bin%_EXT%\pyuno_services.rdb ..\%__SRC%\bin\pyuno.pyd %_DEST%\bin%_EXT%\pyuno.pyd ..\%__SRC%\bin\pyuno.dll %_DEST%\bin%_EXT%\pyuno.dll ..\%__SRC%\bin\pythonl*.dll %_DEST%\bin%_EXT%\pythonl*.dll diff --git a/pyuno/source/loader/makefile.mk b/pyuno/source/loader/makefile.mk index c706a7700dba..65ec8116f9c5 100644 --- a/pyuno/source/loader/makefile.mk +++ b/pyuno/source/loader/makefile.mk @@ -73,30 +73,22 @@ SHL1DEF= $(MISC)$/$(SHL1TARGET).def DEF1NAME= $(SHL1TARGET) SLOFILES= $(SLO)$/pyuno_loader.obj -COMPONENTS= \ - stocservices.uno \ - invocation.uno \ - introspection.uno \ - invocadapt.uno \ - proxyfac.uno \ - reflection.uno \ - .$/pythonloader.uno - # --- Targets ------------------------------------------------------ ALL : ALLTAR \ - $(DLLDEST)$/pythonloader.py \ - $(DLLDEST)$/pyuno_services.rdb + $(DLLDEST)$/pythonloader.py .ENDIF # L10N_framework .INCLUDE : target.mk .IF "$(L10N_framework)"=="" $(DLLDEST)$/%.py: %.py cp $? $@ - -$(DLLDEST)$/pyuno_services.rdb : makefile.mk $(DLLDEST)$/$(DLLPRE)$(TARGET)$(DLLPOST) - -rm -f $@ $(DLLDEST)$/pyuno_services.tmp $(DLLDEST)$/pyuno_services.rdb - cd $(DLLDEST) && $(REGCOMP) -register -r pyuno_services.tmp -wop $(foreach,i,$(COMPONENTS) -c $(i)) - cd $(DLLDEST) && mv pyuno_services.tmp pyuno_services.rdb .ENDIF # L10N_framework +ALLTAR : $(MISC)/pythonloader.component + +$(MISC)/pythonloader.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt pythonloader.component + $(XSLTPROC) --nonet --stringparam uri \ + 'vnd.sun.star.expand:$$OOO_BASE_DIR/program/$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt pythonloader.component diff --git a/pyuno/source/loader/pythonloader.component b/pyuno/source/loader/pythonloader.component new file mode 100644 index 000000000000..583b6ed38771 --- /dev/null +++ b/pyuno/source/loader/pythonloader.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="org.openoffice.comp.pyuno.Loader"> + <service name="com.sun.star.loader.Python"/> + </implementation> +</component> diff --git a/pyuno/source/loader/pyuno_loader.cxx b/pyuno/source/loader/pyuno_loader.cxx index 73d6086c0119..e743c480ccb2 100644 --- a/pyuno/source/loader/pyuno_loader.cxx +++ b/pyuno/source/loader/pyuno_loader.cxx @@ -230,12 +230,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return cppu::component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/remotebridges/prj/build.lst b/remotebridges/prj/build.lst index 30a376462d7c..5f2a661dd5de 100644 --- a/remotebridges/prj/build.lst +++ b/remotebridges/prj/build.lst @@ -1,6 +1,2 @@ -rb remotebridges : bridges rdbmaker NULL -rb remotebridges usr1 - all rb_mkout NULL -rb remotebridges\source\bridge nmake - all rb_iiop NULL -rb remotebridges\source\factory nmake - all rb_factory NULL +rb remotebridges : LIBXSLT:libxslt cppu cppuhelper offuh rdbmaker sal NULL rb remotebridges\source\unourl_resolver nmake - all rb_urlresolv NULL -rb remotebridges\source\dynamicloader nmake - all rb_dynloader NULL diff --git a/remotebridges/prj/d.lst b/remotebridges/prj/d.lst index 04b8bf4f7a61..b8b46ae7089c 100644..100755 --- a/remotebridges/prj/d.lst +++ b/remotebridges/prj/d.lst @@ -1,17 +1,4 @@ -..\%__SRC%\bin\bridgefa*.dll %_DEST%\bin%_EXT%\bridgefa*.dll -..\%__SRC%\bin\remotebr*.dll %_DEST%\bin%_EXT%\remotebr*.dll -..\%__SRC%\bin\dynamicl*.dll %_DEST%\bin%_EXT%\dynamicl*.dll -..\%__SRC%\bin\uuresolv*.dll %_DEST%\bin%_EXT%\uuresolv*.dll -..\%__SRC%\bin\brdgfctr.rdb %_DEST%\rdb%_EXT%\brdgfctr.rdb -..\%__SRC%\bin\remotebridge.rdb %_DEST%\rdb%_EXT%\remotebridge.rdb -..\%__SRC%\bin\dynamicloader.rdb %_DEST%\rdb%_EXT%\dynamicloader.rdb -..\%__SRC%\bin\uuresolver.rdb %_DEST%\rdb%_EXT%\uuresolver.rdb -..\source\factory\brdgfctr.xml %_DEST%\xml%_EXT%\bridgefac.uno.xml -..\source\bridge\remotebridge.xml %_DEST%\xml%_EXT%\remotebridge.uno.xml -..\source\dynamicloader\dynamicloader.xml %_DEST%\xml%_EXT%\dynamicloader.uno.xml -..\source\unourl_resolver\uuresolver.xml %_DEST%\xml%_EXT%\uuresolver.uno.xml -..\%__SRC%\lib\bridgefac.uno.so %_DEST%\lib%_EXT%\bridgefac.uno.so -..\%__SRC%\lib\remotebridge.uno.so %_DEST%\lib%_EXT%\remotebridge.uno.so -..\%__SRC%\lib\dynamicloader.uno.so %_DEST%\lib%_EXT%\dynamicloader.uno.so +..\%__SRC%\bin\uuresolver.uno.dll %_DEST%\bin%_EXT%\uuresolver.uno.dll +..\%__SRC%\lib\uuresolver.uno.dylib %_DEST%\lib%_EXT%\uuresolver.uno.dylib ..\%__SRC%\lib\uuresolver.uno.so %_DEST%\lib%_EXT%\uuresolver.uno.so -..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\* +..\%__SRC%\misc\uuresolver.component %_DEST%\xml%_EXT%\uuresolver.component diff --git a/remotebridges/source/bridge/bridge_connection.cxx b/remotebridges/source/bridge/bridge_connection.cxx deleted file mode 100644 index 7fd40f244cf3..000000000000 --- a/remotebridges/source/bridge/bridge_connection.cxx +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include "bridge_connection.hxx" -#include "remote_bridge.hxx" -#include <rtl/byteseq.hxx> -#include <string.h> - -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::connection; - -namespace remotebridges_bridge -{ - OConnectionWrapper::OConnectionWrapper( const Reference < XConnection > &r ) : - m_r( r ), - m_nRef( 0 ) - { - g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); - acquire = thisAcquire; - release = thisRelease; - read = thisRead; - write = thisWrite; - flush = thisFlush; - close = thisClose; - } - - OConnectionWrapper::~OConnectionWrapper() - { - g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); -} - - void OConnectionWrapper::thisAcquire( remote_Connection *p) - { - OConnectionWrapper * m = ( OConnectionWrapper * ) p; - osl_incrementInterlockedCount( &(m->m_nRef ) ); - } - - void OConnectionWrapper::thisRelease( remote_Connection * p) - { - OConnectionWrapper * m = ( OConnectionWrapper * ) p; - if( ! osl_decrementInterlockedCount( &( m->m_nRef ) ) ) - { - delete m; - } - } - - sal_Int32 OConnectionWrapper::thisRead( remote_Connection *p , sal_Int8 *pDest , sal_Int32 nSize ) - { - // guard the C-Code - OConnectionWrapper * m = ( OConnectionWrapper * ) p; - try - { - // TODO possible optimization : give - Sequence<sal_Int8> seq = toUnoSequence( ::rtl::ByteSequence(nSize, ::rtl::BYTESEQ_NODEFAULT) ); - sal_Int32 nRead = m->m_r->read( seq , nSize ); - memcpy( pDest , seq.getConstArray() , nRead ); - return nRead; - } - catch ( Exception & ) - { - return 0; - } - catch (::std::bad_alloc &) - { - return 0; - } - } - - sal_Int32 OConnectionWrapper::thisWrite( remote_Connection *p , - const sal_Int8 *pSource , - sal_Int32 nSize ) - { - // guard the C-Code - OConnectionWrapper * m = ( OConnectionWrapper * ) p; - try - { - Sequence< sal_Int8 > seq( pSource , nSize ); - m->m_r->write( seq ); - return nSize; - } - catch ( Exception & ) - { - return 0; - } - } - - void OConnectionWrapper::thisFlush( remote_Connection *p ) - { - // guard the C-Code - try - { - OConnectionWrapper * m = ( OConnectionWrapper * ) p; - m->m_r->flush(); - } - catch ( Exception & ) - { - } - } - - void OConnectionWrapper::thisClose( remote_Connection * p) - { - // guard the C-Code - try - { - OConnectionWrapper * m = ( OConnectionWrapper * ) p; - m->m_r->close(); - } - catch( Exception & ) - { - - } - } -} - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/bridge/bridge_connection.hxx b/remotebridges/source/bridge/bridge_connection.hxx deleted file mode 100644 index 629f99190af2..000000000000 --- a/remotebridges/source/bridge/bridge_connection.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <osl/interlck.h> - -#include <bridges/remote/connection.h> - -#include <com/sun/star/connection/XConnection.hpp> - -namespace remotebridges_bridge -{ - - class OConnectionWrapper : - public remote_Connection - { - public: - OConnectionWrapper( const ::com::sun::star::uno::Reference < - ::com::sun::star::connection::XConnection > & ); - ~OConnectionWrapper(); - - static void SAL_CALL thisAcquire( remote_Connection *); - static void SAL_CALL thisRelease( remote_Connection *); - static sal_Int32 SAL_CALL thisRead( remote_Connection * , sal_Int8 *pDest , sal_Int32 nSize ); - static sal_Int32 SAL_CALL thisWrite( remote_Connection * , - const sal_Int8 *pSource , - sal_Int32 nSize ); - static void SAL_CALL thisFlush( remote_Connection * ); - static void SAL_CALL thisClose( remote_Connection * ); - - ::com::sun::star::uno::Reference < ::com::sun::star::connection::XConnection > m_r; - oslInterlockedCount m_nRef; - }; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/bridge/bridge_provider.cxx b/remotebridges/source/bridge/bridge_provider.cxx deleted file mode 100644 index d3f86917416e..000000000000 --- a/remotebridges/source/bridge/bridge_provider.cxx +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <stdio.h> - -#include "remote_bridge.hxx" - -#include <osl/diagnose.h> -#include <rtl/ustrbuf.hxx> - -#include <uno/mapping.hxx> -#include <uno/environment.h> - -#include <bridges/remote/remote.h> - -using namespace ::rtl; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::bridge; - -namespace remotebridges_bridge -{ - - OInstanceProviderWrapper::OInstanceProviderWrapper( - const Reference <XInstanceProvider > & rProvider, - ORemoteBridge * pBridgeCallback ) : - m_rProvider( rProvider ), - m_nRef( 0 ), - m_pBridgeCallback( pBridgeCallback ) - { - g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); - acquire = thisAcquire; - release = thisRelease; - getInstance = thisGetInstance; - } - - OInstanceProviderWrapper::~OInstanceProviderWrapper() - { - g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); - } - - void OInstanceProviderWrapper::thisAcquire( remote_InstanceProvider *p ) - { - OInstanceProviderWrapper * m = (OInstanceProviderWrapper *) p; - osl_incrementInterlockedCount( &(m->m_nRef ) ); - } - - void OInstanceProviderWrapper::thisRelease( remote_InstanceProvider *p ) - { - OInstanceProviderWrapper * m = ( OInstanceProviderWrapper *) p; - if( ! osl_decrementInterlockedCount( &(m->m_nRef ) ) ) - { - delete m; - } - } - - static void convertToRemoteRuntimeException ( uno_Any **ppException, - const ::rtl::OUString &sMessage, - const Reference< XInterface > &rContext, - Mapping &map ) - { - - uno_type_any_construct( *ppException , - 0 , - getCppuType( (RuntimeException *)0 ).getTypeLibType() , - 0 ); - - typelib_CompoundTypeDescription * pCompType = 0 ; - getCppuType( (Exception*)0 ).getDescription( (typelib_TypeDescription **) &pCompType ); - if( ! ((typelib_TypeDescription *)pCompType)->bComplete ) - { - typelib_typedescription_complete( (typelib_TypeDescription**) &pCompType ); - } - - char *pValue = (char*) (*ppException)->pData; - rtl_uString_assign( (rtl_uString ** ) pValue , sMessage.pData ); - - *((remote_Interface**) pValue+pCompType->pMemberOffsets[1]) = - (remote_Interface*) map.mapInterface( - rContext.get(), getCppuType( &rContext) ); - - typelib_typedescription_release( (typelib_TypeDescription *) pCompType ); - } - - void OInstanceProviderWrapper::thisGetInstance( - remote_InstanceProvider * pProvider , - uno_Environment *pEnvRemote, - remote_Interface **ppRemoteI, - rtl_uString *pInstanceName, - typelib_InterfaceTypeDescription *pType, - uno_Any **ppException - ) - { - OInstanceProviderWrapper * m = (OInstanceProviderWrapper *)pProvider; - - OSL_ASSERT( ppRemoteI ); - if( *ppRemoteI ) - { - (*ppRemoteI)->release( *ppRemoteI ); - *ppRemoteI = 0; - } - - OUString sCppuName( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) ); - - uno_Environment *pEnvThis = 0; - uno_getEnvironment( &pEnvThis , - sCppuName.pData , - 0 ); - Mapping map( pEnvThis , pEnvRemote ); - pEnvThis->release( pEnvThis ); - - if( OUString( pType->aBase.pTypeName ) == - getCppuType( (Reference<XInterface>*)0).getTypeName() ) - { - try - { - Reference< XInterface > r = m->m_rProvider->getInstance( - OUString( pInstanceName ) ); - - *ppRemoteI = (remote_Interface*) map.mapInterface ( - r.get(), - getCppuType( (Reference< XInterface > *) 0 ) - ); - - if( *ppRemoteI && m->m_pBridgeCallback ) - { - m->m_pBridgeCallback->objectMappedSuccesfully(); - m->m_pBridgeCallback = 0; - } - *ppException = 0; - } - catch( ::com::sun::star::container::NoSuchElementException &e ) - { - // NoSuchElementException not specified, so convert it to a runtime exception - convertToRemoteRuntimeException( - ppException , e.Message.pData , e.Context.get(), map ); - } - catch( ::com::sun::star::uno::RuntimeException &e ) - { - convertToRemoteRuntimeException( - ppException , e.Message.pData , e.Context.get(), map ); - } - - } - else - { - OUStringBuffer msg; - msg.appendAscii( - RTL_CONSTASCII_STRINGPARAM( - "getInstance expected XInterface but got ")); - msg.append(pType->aBase.pTypeName); - convertToRemoteRuntimeException( - ppException, msg.getStr(), Reference< XInterface >(), map); - } - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/bridge/makefile.mk b/remotebridges/source/bridge/makefile.mk deleted file mode 100644 index 1b712bef1913..000000000000 --- a/remotebridges/source/bridge/makefile.mk +++ /dev/null @@ -1,64 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=remotebridges -TARGET = remotebridge.uno -ENABLE_EXCEPTIONS=TRUE -COMP1TYPELIST = remotebridge - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk -.IF "$(L10N_framework)"=="" -DLLPRE = -# ------------------------------------------------------------------ - -SLOFILES= \ - $(SLO)$/remote_bridge.obj \ - $(SLO)$/bridge_connection.obj\ - $(SLO)$/bridge_provider.obj -SHL1TARGET= $(TARGET) -SHL1VERSIONMAP = $(SOLARENV)/src/unloadablecomponent.map - -SHL1STDLIBS= \ - $(SALLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(RMCXTLIB) - -SHL1DEPN= -SHL1IMPLIB= i$(TARGET) -SHL1LIBS= $(SLB)$/$(TARGET).lib -SHL1DEF= $(MISC)$/$(SHL1TARGET).def -SHL1RPATH= URELIB - -DEF1NAME= $(SHL1TARGET) -.ENDIF # L10N_framework - -# --- Targets ------------------------------------------------------ -.INCLUDE : target.mk diff --git a/remotebridges/source/bridge/remote_bridge.cxx b/remotebridges/source/bridge/remote_bridge.cxx deleted file mode 100644 index ac6d5a2770ee..000000000000 --- a/remotebridges/source/bridge/remote_bridge.cxx +++ /dev/null @@ -1,475 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <stdio.h> - -#include "remote_bridge.hxx" -#include "bridge_connection.hxx" -#include <cppuhelper/implementationentry.hxx> - -#include <com/sun/star/lang/IllegalArgumentException.hpp> -#include <com/sun/star/bridge/BridgeExistsException.hpp> - -#define IMPLEMENTATION_NAME "com.sun.star.comp.remotebridges.Bridge.various" - - -using namespace ::rtl; -using namespace ::cppu; -using namespace ::osl; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::bridge; -using namespace ::com::sun::star::registry; -using namespace ::com::sun::star::connection; - -namespace remotebridges_bridge -{ - rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; - - ORemoteBridge::ORemoteBridge() : - OComponentHelper( m_mutex ), - m_pContext( 0 ), - m_pEnvRemote(0 ) - { - g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); - remote_DisposingListener::acquire = thisAcquire; - remote_DisposingListener::release = thisRelease; - remote_DisposingListener::disposing = thisDisposing; - } - - ORemoteBridge::~ORemoteBridge() - { - if( m_pContext ) - { - m_pContext->aBase.release( (uno_Context *) m_pContext ); - } - if( m_pEnvRemote ) - { - m_pEnvRemote->release( m_pEnvRemote ); - } - g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); - } - - void ORemoteBridge::objectMappedSuccesfully() - { - MutexGuard guard( m_mutex ); - - if( m_pEnvRemote ) - { - m_pEnvRemote->release( m_pEnvRemote ); - m_pEnvRemote = 0; - } - } - - Any ORemoteBridge::queryInterface( const Type & aType ) throw(RuntimeException) - { - Any a = ::cppu::queryInterface( - aType , - SAL_STATIC_CAST( XInitialization * , this ) , - SAL_STATIC_CAST( XBridge * , this ), - SAL_STATIC_CAST( XTypeProvider * , this ) ); - if( a.hasValue() ) - { - return a; - } - - return OComponentHelper::queryInterface( aType ); - } - - - void ORemoteBridge::initialize( const Sequence< Any >& aArguments ) - throw( Exception, RuntimeException) - { - - MutexGuard guard( m_mutex ); - - if( 4 != aArguments.getLength() ) - { - throw IllegalArgumentException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("wrong number of arguments")) , - Reference< XInterface >(), - 0 ); - } - - OUString swName; - OUString swProtocol; - Reference < XConnection > rConnection; - Reference < XInstanceProvider > rProvider; - - aArguments.getConstArray()[0] >>= swName; - aArguments.getConstArray()[1] >>= swProtocol; - aArguments.getConstArray()[2] >>= rConnection; - aArguments.getConstArray()[3] >>= rProvider; - - if( ! rConnection.is() ) - { - throw IllegalArgumentException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("connection is missing")) , - Reference < XInterface > (), - 2 ); - } - - remote_Connection *pConnection = new OConnectionWrapper( rConnection ); - remote_InstanceProvider *pProvider = 0; - if( rProvider.is( )) - { - pProvider = new OInstanceProviderWrapper( rProvider , this ); - } - - OUString sName = swName; - m_sDescription = swProtocol; - m_sDescription += OUString( RTL_CONSTASCII_USTRINGPARAM(":")); - m_sDescription += rConnection->getDescription(); - - if( 0 == sName.getLength() ) - { - sName = m_sDescription; - } - else - { - m_sName = sName; - } - - m_pContext = remote_createContext( pConnection, - sName.pData, - m_sDescription.pData, - swProtocol.pData, - pProvider ); - if( ! m_pContext ) - { - throw BridgeExistsException(); - } - - m_pContext->addDisposingListener( m_pContext , - (remote_DisposingListener *) this ); - - // environment will be released by the first succesfull mapping - OUString sRemoteEnv; - if( swProtocol.indexOf( ',') == -1 ) - { - sRemoteEnv = swProtocol; - } - else - { - sRemoteEnv = swProtocol.copy( 0 , swProtocol.indexOf( ',' ) ); - } - m_sProtocol = sRemoteEnv; - uno_getEnvironment( &m_pEnvRemote , - sRemoteEnv.pData , - m_pContext ); - if( ! m_pEnvRemote ) - { - m_pContext->removeDisposingListener( m_pContext , - (remote_DisposingListener*) this ); - m_pContext->aBase.release( (uno_Context * ) m_pContext ); - m_pContext = 0; - - // forgotten exception when specifying the interface - throw RuntimeException( rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("couldn't create uno-remote-environment")) , - Reference < XInterface > () ); - } - } - - Reference< XInterface > ORemoteBridge::getInstance( const ::rtl::OUString& sInstanceName ) - throw(::com::sun::star::uno::RuntimeException) - { - Reference < XInterface > rReturn; - - remote_Context *pContext = 0; - { - MutexGuard guard( m_mutex ); - if( m_pContext && m_pContext->getRemoteInstance ) - { - pContext = m_pContext; - pContext->aBase.acquire( (uno_Context*)pContext ); - } - } - if( pContext ) - { - // get the appropriate remote environment - uno_Environment *pEnvRemote = 0; - uno_getEnvironment( &pEnvRemote , m_sProtocol.pData , pContext ); - - if( ! pEnvRemote ) - { - pContext->aBase.release( (uno_Context*) pContext ); - throw RuntimeException( - OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoteBridge: bridge already disposed" ) ), - Reference< XInterface > () ); - } - - Type type = getCppuType( (Reference < XInterface > * ) 0 ); - - remote_Interface *pRemoteI = 0; - uno_Any exception; - uno_Any *pException = &exception; - - pContext->getRemoteInstance( - pEnvRemote, - &pRemoteI, - sInstanceName.pData, - type.getTypeLibType(), - &pException ); - pContext->aBase.release( (uno_Context*) pContext ); - pContext = 0; - - uno_Environment *pEnvCpp =0; - OUString sCppuName( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) ); - uno_getEnvironment( &pEnvCpp , - sCppuName.pData , - 0 ); - Mapping map( pEnvRemote , pEnvCpp ); - - pEnvCpp->release( pEnvCpp ); - pEnvRemote->release( pEnvRemote ); - - if( pException ) - { - typelib_CompoundTypeDescription * pCompType = 0 ; - getCppuType( (Exception*)0 ).getDescription( (typelib_TypeDescription **) &pCompType ); - - if( ! ((typelib_TypeDescription *)pCompType)->bComplete ) - { - typelib_typedescription_complete( (typelib_TypeDescription**) &pCompType ); - } - XInterface *pXInterface = (XInterface *) map.mapInterface( - *(remote_Interface**) ( ((char*)pException->pData)+pCompType->pMemberOffsets[1] ), - getCppuType( (Reference< XInterface > *)0 ) ); - RuntimeException myException( - *((rtl_uString **)pException->pData), - Reference< XInterface > ( pXInterface , SAL_NO_ACQUIRE) ); - uno_any_destruct( pException , 0 ); - - throw myException; - } - else if( pRemoteI ) - { - // got an interface ! - XInterface * pCppI = ( XInterface * ) map.mapInterface( pRemoteI, type ); - rReturn = Reference<XInterface > ( pCppI, SAL_NO_ACQUIRE ); - pRemoteI->release( pRemoteI ); - objectMappedSuccesfully(); - } - } - else - { - throw RuntimeException( - OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoteBridge: bridge already disposed." ) ), - Reference< XInterface > () ); - } - - return rReturn; - } - - - ::rtl::OUString SAL_CALL ORemoteBridge::getName( ) - throw(::com::sun::star::uno::RuntimeException) - { - return m_sName; - } - - ::rtl::OUString SAL_CALL ORemoteBridge::getDescription( ) - throw(::com::sun::star::uno::RuntimeException) - { - return m_sDescription; - } - - // XTypeProvider - Sequence< Type > SAL_CALL ORemoteBridge::getTypes(void) throw( RuntimeException ) - { - static OTypeCollection *pCollection = 0; - if( ! pCollection ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pCollection ) - { - static OTypeCollection collection( - getCppuType( (Reference< XTypeProvider> * )0), - getCppuType( (Reference< XBridge > * ) 0 ), - getCppuType( (Reference< XInitialization > * ) 0 ), - OComponentHelper::getTypes() ); - pCollection = &collection; - } - } - - return (*pCollection).getTypes(); - } - - Sequence< sal_Int8 > SAL_CALL ORemoteBridge::getImplementationId( ) throw( RuntimeException) - { - static OImplementationId *pId = 0; - if( ! pId ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pId ) - { - static OImplementationId id( sal_False ); - pId = &id; - } - } - return (*pId).getImplementationId(); - } - - void ORemoteBridge::disposing() - { - MutexGuard guard( m_mutex ); - if( m_pContext ) - { - m_pContext->removeDisposingListener( m_pContext , ( remote_DisposingListener * )this); - if( ! m_pEnvRemote ) - { - if( m_pContext->m_pConnection ) - { - sal_Int32 nIndex = 0; - OUString sProtocol = OUString( m_pContext->m_pProtocol ).getToken( 0 , ',' , nIndex ); - uno_getEnvironment( &m_pEnvRemote , sProtocol.pData , m_pContext ); - OSL_ASSERT( m_pEnvRemote ); - } - else - { - // within disposing from the context, no further dispose necessary ! - } - } - - if( m_pEnvRemote ) - { - m_pEnvRemote->dispose( m_pEnvRemote ); - m_pEnvRemote->release( m_pEnvRemote ); - m_pEnvRemote = 0; - } - - m_pContext->aBase.release( (uno_Context*)m_pContext ); - m_pContext = 0; - } - } - - - //---------------------- - // static methods - //---------------------- - void ORemoteBridge::thisAcquire( remote_DisposingListener *p ) - { - ORemoteBridge *m = (ORemoteBridge * ) p; - m->acquire(); - } - - void ORemoteBridge::thisRelease( remote_DisposingListener *p ) - { - ORemoteBridge *m = (ORemoteBridge * ) p; - m->release(); - } - - void ORemoteBridge::thisDisposing( remote_DisposingListener * p, - rtl_uString * ) - { - ORemoteBridge *m = (ORemoteBridge * ) p; - m->dispose(); - } - - Reference< XInterface > SAL_CALL CreateInstance( const Reference< XComponentContext > &) - { - return Reference< XInterface > ( ( OWeakObject * ) new ORemoteBridge ); - } - - OUString getImplementationName() - { - static OUString *pImplName = 0; - if( ! pImplName ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pImplName ) - { - static OUString implName( - RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); - pImplName = &implName; - } - } - return *pImplName; - } - - Sequence< OUString > getSupportedServiceNames() - { - static Sequence < OUString > *pNames = 0; - if( ! pNames ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( !pNames ) - { - static Sequence< OUString > seqNames(3); - seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.Bridge")); - seqNames.getArray()[1] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.IiopBridge")); - seqNames.getArray()[2] = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.UrpBridge")); - - pNames = &seqNames; - } - } - return *pNames; - } -} - -using namespace remotebridges_bridge; - -static struct ImplementationEntry g_entries[] = -{ - { - remotebridges_bridge::CreateInstance, remotebridges_bridge::getImplementationName, - remotebridges_bridge::getSupportedServiceNames, createSingleComponentFactory, - &g_moduleCount.modCnt , 0 - }, - { 0, 0, 0, 0, 0, 0 } -}; - -extern "C" -{ -sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) -{ - return g_moduleCount.canUnload( &g_moduleCount , pTime ); -} - -//================================================================================================== -void SAL_CALL component_getImplementationEnvironment( - const sal_Char ** ppEnvTypeName, uno_Environment ** ) -{ - *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; -} -//================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== -void * SAL_CALL component_getFactory( - const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) -{ - return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); -} -} - - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/bridge/remote_bridge.hxx b/remotebridges/source/bridge/remote_bridge.hxx deleted file mode 100644 index 53cdb0d7b766..000000000000 --- a/remotebridges/source/bridge/remote_bridge.hxx +++ /dev/null @@ -1,149 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <osl/mutex.hxx> -#include <osl/diagnose.h> - -#include <uno/mapping.hxx> -#include <uno/environment.h> - -#include <bridges/remote/context.h> -#include <bridges/remote/remote.h> - -#include <cppuhelper/factory.hxx> -#include <cppuhelper/component.hxx> -#include <cppuhelper/typeprovider.hxx> - -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/lang/XInitialization.hpp> - -#include <com/sun/star/bridge/XBridge.hpp> -#include <com/sun/star/bridge/XInstanceProvider.hpp> - - -namespace remotebridges_bridge -{ - extern rtl_StandardModuleCount g_moduleCount; - - struct MyMutex - { - ::osl::Mutex m_mutex; - }; - - class ORemoteBridge : - public MyMutex, - public remote_DisposingListener, - public ::com::sun::star::lang::XInitialization, - public ::com::sun::star::bridge::XBridge, - public ::cppu::OComponentHelper - { - public: - ORemoteBridge(); - ~ORemoteBridge(); - - // XInterface - public: - ::com::sun::star::uno::Any SAL_CALL - queryInterface( const ::com::sun::star::uno::Type & aType ) throw(::com::sun::star::uno::RuntimeException); - - void SAL_CALL acquire() throw() - { OComponentHelper::acquire(); } - void SAL_CALL release() throw() - { OComponentHelper::release(); } - - public: - virtual void SAL_CALL disposing(); // called by OComponentHelper - - public: - // Methods - virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< - ::com::sun::star::uno::Any >& aArguments ) - throw( ::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); - - public: - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL - getInstance( const ::rtl::OUString& sInstanceName ) - throw(::com::sun::star::uno::RuntimeException); - - virtual ::rtl::OUString SAL_CALL getName( ) - throw(::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getDescription( ) - throw(::com::sun::star::uno::RuntimeException); - - public: - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL - getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL - getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - public: - static void SAL_CALL thisAcquire( remote_DisposingListener * ); - static void SAL_CALL thisRelease( remote_DisposingListener * ); - static void SAL_CALL thisDisposing( remote_DisposingListener * , - rtl_uString * pBridgeName ); - - public: - void objectMappedSuccesfully(); - - public: - remote_Context *m_pContext; - uno_Environment *m_pEnvRemote; - ::rtl::OUString m_sName; - ::rtl::OUString m_sDescription; - ::rtl::OUString m_sProtocol; - }; - - class OInstanceProviderWrapper : - public remote_InstanceProvider - { - public: - OInstanceProviderWrapper( const ::com::sun::star::uno::Reference < - ::com::sun::star::bridge::XInstanceProvider > & rProvider , - ORemoteBridge * pBridgeCallback ); - - ~OInstanceProviderWrapper(); - public: - static void SAL_CALL thisAcquire( remote_InstanceProvider * ); - static void SAL_CALL thisRelease( remote_InstanceProvider * ); - static void SAL_CALL thisGetInstance( remote_InstanceProvider * pProvider , - uno_Environment *pEnvRemote, - remote_Interface **ppRemoteI, - rtl_uString *pInstanceName, - typelib_InterfaceTypeDescription *pType, - uno_Any **ppException ); - - private: - ::com::sun::star::uno::Reference < - ::com::sun::star::bridge::XInstanceProvider > m_rProvider; - oslInterlockedCount m_nRef; - ORemoteBridge *m_pBridgeCallback; - }; - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/bridge/remotebridge.xml b/remotebridges/source/bridge/remotebridge.xml deleted file mode 100644 index be5e60b59eef..000000000000 --- a/remotebridges/source/bridge/remotebridge.xml +++ /dev/null @@ -1,47 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name> remotebridge.uno </module-name> - <component-description> - <author> Joerg Budischewski </author> - <name> com.sun.star.comp.remotebridges.Bridge.various </name> - <description> - This component initializes the bridge between two processes - using either iiop or urp (UnoRemoteProtocol) protocol. - </description> - <loader-name> com.sun.star.loader.SharedLibrary </loader-name> - <language> c++ </language> - <status value="final"/> - <supported-service> com.sun.star.bridge.Bridge </supported-service> - <supported-service> com.sun.star.bridge.IiopBridge </supported-service> - <supported-service> com.sun.star.bridge.UrpBridge </supported-service> - <service-dependency> ... </service-dependency> - <type> com.sun.star.bridge.XBridgeFactory </type> - <type> com.sun.star.bridge.XInstanceProvider </type> - <type> com.sun.star.bridge.XBridge </type> - <type> com.sun.star.bridge.BridgeExistsException </type> - <type> com.sun.star.lang.DisposedException </type> - <type> com.sun.star.lang.XMultiServiceFactory </type> - <type> com.sun.star.lang.XSingleServiceFactory </type> - <type> com.sun.star.lang.XInitialization </type> - <type> com.sun.star.lang.XComponent </type> - <type> com.sun.star.lang.XServiceInfo </type> - <type> com.sun.star.lang.XTypeProvider </type> - <type> com.sun.star.lang.IllegalArgumentException </type> - <type> com.sun.star.lang.XInitialization </type> - <type> com.sun.star.registry.XRegistryKey </type> - <type> com.sun.star.lang.XSingleComponentFactory </type> - <type> com.sun.star.uno.XComponentContext </type> - <type> com.sun.star.uno.XWeak </type> - <type> com.sun.star.uno.TypeClass </type> - <type> com.sun.star.uno.XAggregation </type> - </component-description> - <project-build-dependency> cppuhelper </project-build-dependency> - <project-build-dependency> cppu </project-build-dependency> - <project-build-dependency> sal </project-build-dependency> - <runtime-module-dependency> rmcxt </runtime-module-dependency> - <runtime-module-dependency> cppuhelper3 </runtime-module-dependency> - <runtime-module-dependency> cppu3 </runtime-module-dependency> - <runtime-module-dependency> sal3 </runtime-module-dependency> - <runtime-module-dependency> rmcxt3 </runtime-module-dependency> -</module-description> diff --git a/remotebridges/source/dynamicloader/dynamicloader.cxx b/remotebridges/source/dynamicloader/dynamicloader.cxx deleted file mode 100644 index cc656662fb17..000000000000 --- a/remotebridges/source/dynamicloader/dynamicloader.cxx +++ /dev/null @@ -1,434 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -#include <stdio.h> - -#include <cppuhelper/factory.hxx> - -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> - - -#include <com/sun/star/bridge/XUnoUrlResolver.hpp> - -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> -#include <com/sun/star/loader/XImplementationLoader.hpp> -#include <com/sun/star/registry/XRegistryKey.hpp> - - -using namespace ::com::sun::star::bridge; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::loader; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::registry; - - -using namespace ::cppu; -using namespace ::rtl; - -namespace dynamic_loader { - - class SingleServiceFactory : public WeakImplHelper2<XServiceInfo, XSingleServiceFactory> { - Reference<XMultiServiceFactory> _xServiceManager; - OUString _serviceName; - OUString _link; - OUString _resolver; - - Reference<XSingleServiceFactory> getRemoteFactory() throw(Exception, RuntimeException); - - public: - - SingleServiceFactory(const Reference<XMultiServiceFactory > & xServiceManager, - const OUString & serviceName, - const OUString & link, - const OUString & resolver) - : _xServiceManager(xServiceManager), - _serviceName(serviceName), - _link(link), - _resolver(resolver) - {} - - // XSingleServiceFactory - Reference<XInterface> SAL_CALL createInstance() throw(Exception, RuntimeException); - Reference<XInterface> SAL_CALL createInstanceWithArguments(const Sequence<Any>& Arguments) - throw(::com::sun::star::uno::Exception, - ::com::sun::star::uno::RuntimeException); - - // XServiceInfo - OUString SAL_CALL getImplementationName() throw(RuntimeException); - sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(RuntimeException); - Sequence<OUString> SAL_CALL getSupportedServiceNames(void) throw(RuntimeException); - }; - - - Reference<XSingleServiceFactory> SingleServiceFactory::getRemoteFactory() throw(Exception, RuntimeException) { - Reference<XUnoUrlResolver> xResolver(_xServiceManager->createInstance(_resolver), UNO_QUERY); - if(!xResolver.is()) { - OUString message(RTL_CONSTASCII_USTRINGPARAM("dynamic_loader::singleServiceFactory.createInstance - couldn't create resolver: ")); - message += _resolver; - - throw Exception(message, Reference<XInterface>()); - } - - Reference<XInterface> remoteObject = xResolver->resolve(_link); - if(!remoteObject.is()) { - OUString message(RTL_CONSTASCII_USTRINGPARAM("dynamic_loader::singleServiceFactory.createInstance - couldn't resolve link: ")); - message += _link; - - throw Exception(message, Reference<XInterface>()); - } - - Reference<XSingleServiceFactory> remoteFactory(remoteObject, UNO_QUERY); - if(!remoteFactory.is()) { - OUString message(RTL_CONSTASCII_USTRINGPARAM("dynamic_loader::singleServiceFactory.createInstance - couldn't get XSingleServiceFactory from: ")); - message += _link; - - throw Exception(message, Reference<XInterface>()); - } - - return remoteFactory; - } - - // XSingleServiceFactory - Reference<XInterface> SAL_CALL SingleServiceFactory::createInstance() throw(Exception, RuntimeException) { - OSL_TRACE("dynamic_loader::singleServiceFactory::createInstance"); - - return getRemoteFactory()->createInstance(); - } - - Reference<XInterface> SAL_CALL SingleServiceFactory::createInstanceWithArguments(const Sequence<Any>& Arguments) - throw(Exception, RuntimeException) - { - OSL_TRACE("dynamic_loader::singleServiceFactory::createInstanceWithArguments"); - - return getRemoteFactory()->createInstanceWithArguments(Arguments); - } - - // XServiceInfo - OUString SAL_CALL SingleServiceFactory::getImplementationName() throw(RuntimeException) { - return _link; - } - - sal_Bool SAL_CALL SingleServiceFactory::supportsService(const OUString & ServiceName) throw(RuntimeException) { - return _serviceName.equals(ServiceName); - } - - Sequence<OUString> SAL_CALL SingleServiceFactory::getSupportedServiceNames(void) throw(RuntimeException) { - return Sequence<OUString>(&_serviceName, 1); - } - - - - class DynamicLoader : public WeakImplHelper2<XImplementationLoader, XServiceInfo> { - Reference<XMultiServiceFactory> _xSMgr; - - protected: - DynamicLoader(const Reference<XMultiServiceFactory> & rXSMgr) throw(RuntimeException); - ~DynamicLoader() throw(); - - public: - static const OUString implname; - static const OUString servname; - - static Reference<XInterface> SAL_CALL createInstance(const Reference<XMultiServiceFactory> & rSMgr) throw(Exception); - static Sequence<OUString> SAL_CALL getSupportedServiceNames_Static() throw(); - - static void parseUrl(const OUString & url, OUString * serviceName, OUString * link, OUString * resolver) throw(RuntimeException); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName() throw(RuntimeException); - virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw(RuntimeException); - virtual Sequence<OUString> SAL_CALL getSupportedServiceNames() throw(RuntimeException); - - // XImplementationLoader - virtual Reference<XInterface> SAL_CALL activate(const OUString & implementationName, - const OUString & implementationLoaderUrl, - const OUString& locationUrl, - const Reference<XRegistryKey>& xKey) throw(CannotActivateFactoryException, RuntimeException); - virtual sal_Bool SAL_CALL writeRegistryInfo(const Reference<XRegistryKey>& xKey, - const OUString& implementationLoaderUrl, - const OUString& locationUrl) throw(CannotRegisterImplementationException, RuntimeException); - }; - - const OUString DynamicLoader::implname (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.DynamicLoader")); - const OUString DynamicLoader::servname (RTL_CONSTASCII_USTRINGPARAM("com.sun.star.loader.Dynamic")); - - Sequence<OUString> SAL_CALL DynamicLoader::getSupportedServiceNames_Static() throw() { - return Sequence<OUString>(&servname, 1); - } - - Reference<XInterface> SAL_CALL DynamicLoader::createInstance(const Reference<XMultiServiceFactory> & rSMgr) throw(Exception) { - Reference<XInterface> xRet; - - try { - XImplementationLoader *pXLoader = (XImplementationLoader *)new DynamicLoader(rSMgr); - - xRet = Reference<XInterface>::query(pXLoader); - } - catch(RuntimeException & runtimeException) { - OString message = OUStringToOString(runtimeException.Message, RTL_TEXTENCODING_ASCII_US); - osl_trace("dynamic loader - could not init cause of %s", message.getStr()); - } - - OSL_TRACE("DynamicLoader - createInstance: %d", xRet.is()); - - - return xRet; - } - - DynamicLoader::DynamicLoader(const Reference<XMultiServiceFactory> & xSMgr) throw(RuntimeException) - : _xSMgr(xSMgr) - { - } - - - DynamicLoader::~DynamicLoader() throw() { - } - - // XServiceInfo - OUString SAL_CALL DynamicLoader::getImplementationName() throw(RuntimeException) { - return implname; - } - - sal_Bool SAL_CALL DynamicLoader::supportsService(const OUString & ServiceName) throw(RuntimeException) { - sal_Bool bSupport = sal_False; - - Sequence<OUString> aSNL = getSupportedServiceNames(); - const OUString * pArray = aSNL.getArray(); - for(sal_Int32 i = 0; i < aSNL.getLength() && !bSupport; ++ i) - bSupport = pArray[i] == ServiceName; - - return bSupport; - } - - Sequence<OUString> SAL_CALL DynamicLoader::getSupportedServiceNames() throw(RuntimeException) { - return getSupportedServiceNames_Static(); - } - - - void DynamicLoader::parseUrl(const OUString & locationUrl, OUString * serviceName, OUString * link, OUString * resolver) throw(RuntimeException) { -#if OSL_DEBUG_LEVEL > 1 - OString tmp = OUStringToOString(locationUrl, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE("DynamicLoader - locationUrl %s", tmp.getStr()); -#endif - - // This is the default resolver - *resolver = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.UnoUrlResolver")); - - const OUString bSlash(OUString(RTL_CONSTASCII_USTRINGPARAM("\\"))); - const OUString tuedle(OUString(RTL_CONSTASCII_USTRINGPARAM("\""))); - const OUString separator(OUString(RTL_CONSTASCII_USTRINGPARAM(","))); - const OUString emptyString(OUString(RTL_CONSTASCII_USTRINGPARAM(""))); - const OUString equalSign(OUString(RTL_CONSTASCII_USTRINGPARAM("="))); - - sal_Int32 index = 0; - sal_Bool left = sal_True; - sal_Bool quote = sal_False; - sal_Bool inString = sal_False; - - const sal_Unicode * raw_url = locationUrl.getStr(); - OUString token; - OUString attribute; - - while(index <= locationUrl.getLength()) { - if(index >= locationUrl.getLength() || (raw_url[index] == separator.getStr()[0] && !quote && !inString)) { // a separator or end? - OUString value; - - if(left) - attribute = token.trim(); - - else - value = token.trim(); - -#if OSL_DEBUG_LEVEL > 1 - OString attribute_tmp = OUStringToOString(attribute, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE("DynamicLoader - attribute %s", attribute_tmp.getStr()); - OString value_tmp = OUStringToOString(value, RTL_TEXTENCODING_ASCII_US); - OSL_TRACE("DynamicLoader - value %s", value_tmp.getStr()); -#endif - - if(attribute.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("servicename")))) - *serviceName = value; - - else if(attribute.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("link")))) - *link = value; - - else if(attribute.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("resolver")))) - *resolver = value; - - else { - OUString message(RTL_CONSTASCII_USTRINGPARAM("help called")); - - if(!attribute.equals(OUString(RTL_CONSTASCII_USTRINGPARAM("help")))) { - message = OUString(RTL_CONSTASCII_USTRINGPARAM("DynamicLoader - unknown attribute: ")); - message += attribute; - } - - fprintf(stdout, "DynamicLoader - help\n"); - fprintf(stdout, "attributes:\n"); - fprintf(stdout, "\tservicename: service name of dynamic component\n"); - fprintf(stdout, "\tlink: link to a single service factory for dynamic component\n"); - fprintf(stdout, "\tresolver: the service which resolves the link\n"); - fprintf(stdout, "\thelp: this help\n"); - - throw RuntimeException(message, Reference<XInterface>()); - } - - left = sal_True; // reset state to be left - token = emptyString; - } - else if(raw_url[index] == bSlash.getStr()[0] && !quote) // a back slash? - quote = sal_True; - - else if(raw_url[index] == equalSign.getStr()[0] && !quote && !inString) { // equalSign (switch from left to right)? - left = sal_False; - - attribute = token.trim(); - token = emptyString; - } - else if(raw_url[index] == tuedle.getStr()[0] && !quote) // begin or end of string? - inString = !inString; - - else { // no special handling - token += OUString(raw_url + index, 1); - quote = sal_False; - } - - ++ index; - } - - // enshure, that attributes are set properly - if(!(*serviceName).getLength()) - throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("dynamic_loader::DynamicLoader.parseUrl - missing or empty attribute: servicename")), - Reference<XInterface>()); - - if(!(*link).getLength()) - throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("dynamic_loader::DynamicLoader.parseUrl - missing or empty attribute: link")), - Reference<XInterface>()); - - if(!(*resolver).getLength()) - throw RuntimeException(OUString(RTL_CONSTASCII_USTRINGPARAM("dynamic_loader::DynamicLoader.parseUrl - missing or empty attribute: resolver")), - Reference<XInterface>()); - } - - - // XImplementationLoader - sal_Bool SAL_CALL DynamicLoader::writeRegistryInfo(const Reference<XRegistryKey> & xKey, - const OUString & implementationLoaderUrl, - const OUString & locationUrl) - throw(CannotRegisterImplementationException, RuntimeException) - { - OSL_TRACE("DynamicLoader::writeRegistryInfo"); - - OUString serviceName; - OUString link; - OUString resolver; - - try { - parseUrl(locationUrl, &serviceName, &link, &resolver); - } - catch(RuntimeException & runtimeException) { - throw CannotRegisterImplementationException(runtimeException.Message, Reference<XInterface>()); - } - - // create the keys - OUString keyName (RTL_CONSTASCII_USTRINGPARAM("/")); - keyName += implementationLoaderUrl; - keyName += OUString(RTL_CONSTASCII_USTRINGPARAM("_")); - keyName += serviceName; - keyName += OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); - - Reference<XRegistryKey> xNewKey(xKey->createKey(keyName)); - xNewKey->createKey(serviceName); - - sal_Bool bSuccess = sal_True; - - return bSuccess; - } - - Reference<XInterface> SAL_CALL DynamicLoader::activate(const OUString &, - const OUString &, - const OUString & locationUrl, - const Reference<XRegistryKey> &) - throw(CannotActivateFactoryException, RuntimeException) - { - OSL_TRACE("DynamicLoader::activate"); - - OUString serviceName; - OUString link; - OUString resolver; - - parseUrl(locationUrl, &serviceName, &link, &resolver); - - XSingleServiceFactory * xFactory = (XSingleServiceFactory *)new SingleServiceFactory(_xSMgr, - serviceName, - link, - resolver); - - Reference<XInterface> xReturn; - - if(xFactory) - xReturn = Reference<XInterface>::query(xFactory); - - return xReturn; - } -} - - - - -extern "C" { - void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment **) { - *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; - } - - sal_Bool SAL_CALL component_writeInfo(XMultiServiceFactory *, XRegistryKey * pRegistryKey) { - sal_Bool bRes = sal_False; - - if (pRegistryKey) { - try { - OUString x (RTL_CONSTASCII_USTRINGPARAM("/")); - x += ::dynamic_loader::DynamicLoader::implname; - x += OUString(RTL_CONSTASCII_USTRINGPARAM("/UNO/SERVICES")); - - - Reference<XRegistryKey> xNewKey(pRegistryKey->createKey(x)); - - const Sequence<OUString> rSNL = ::dynamic_loader::DynamicLoader::getSupportedServiceNames_Static(); - const OUString * pArray = rSNL.getConstArray(); - for (sal_Int32 nPos = rSNL.getLength(); nPos--;) - xNewKey->createKey(pArray[nPos]); - - - bRes = sal_True; - } - catch (InvalidRegistryException &) { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - - return bRes; - } - - void * SAL_CALL component_getFactory(const sal_Char * pImplName, XMultiServiceFactory * pServiceManager, XRegistryKey *) { - void * pRet = 0; - - if (pServiceManager && OUString::createFromAscii(pImplName).equals(::dynamic_loader::DynamicLoader::implname)) { - Reference<XSingleServiceFactory> xFactory(createOneInstanceFactory(pServiceManager, - ::dynamic_loader::DynamicLoader::implname, - ::dynamic_loader::DynamicLoader::createInstance, - ::dynamic_loader::DynamicLoader::getSupportedServiceNames_Static())); - - if (xFactory.is()) { - xFactory->acquire(); - pRet = xFactory.get(); - } - } - else - OSL_TRACE("DynamicLoader - warning - given wrong implName: %s", pImplName); - - return pRet; - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/dynamicloader/dynamicloader.xml b/remotebridges/source/dynamicloader/dynamicloader.xml deleted file mode 100644 index 9735629b8a09..000000000000 --- a/remotebridges/source/dynamicloader/dynamicloader.xml +++ /dev/null @@ -1,36 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name> dynamicloader.uno </module-name> - <component-description> - <author> Kay Ramme </author> - <name> com.sun.star.loader.Dynamic </name> - <description> - This service allows the delegation of the resolution - of a SingleServiceFactory for a service to be - delegated to a resolver (e.g. UnoUrlResolver). - </description> - <loader-name> com.sun.star.loader.SharedLibrary </loader-name> - <language> c++ </language> - <status value="final"/> - <supported-service> com.sun.star.loader.Dynamic </supported-service> - <service-dependency> com.sun.star.bridge.UnoUrlResolver </service-dependency> - <type> com.sun.star.bridge.XUnoUrlResolver </type> - <type> com.sun.star.lang.XMultiServiceFactory </type> - <type> com.sun.star.lang.XServiceInfo </type> - <type> com.sun.star.lang.XSingleServiceFactory </type> - <type> com.sun.star.lang.XTypeProvider </type> - <type> com.sun.star.lang.XSingleComponentFactory </type> - <type> com.sun.star.uno.XComponentContext </type> - <type> com.sun.star.loader.XImplementationLoader </type> - <type> com.sun.star.registry.XRegistryKey </type> - <type> com.sun.star.uno.XWeak </type> - <type> com.sun.star.uno.XAggregation </type> - </component-description> - <project-build-dependency> cppuhelper </project-build-dependency> - <project-build-dependency> cppu </project-build-dependency> - <project-build-dependency> sal </project-build-dependency> - <runtime-module-dependency> cppuhelper3 </runtime-module-dependency> - <runtime-module-dependency> cppu3 </runtime-module-dependency> - <runtime-module-dependency> sal3 </runtime-module-dependency> -</module-description> diff --git a/remotebridges/source/factory/brdgfctr.xml b/remotebridges/source/factory/brdgfctr.xml deleted file mode 100644 index 9e2abf8eef1e..000000000000 --- a/remotebridges/source/factory/brdgfctr.xml +++ /dev/null @@ -1,44 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE module-description PUBLIC "-//StarOffice//DTD ComponentDescription 1.0//EN" "module-description.dtd"> -<module-description xmlns:xlink="http://www.w3.org/1999/xlink"> - <module-name> bridgefac.uno </module-name> - <component-description> - <author> Joerg Budischewski </author> - <name> com.sun.star.comp.remotebridges.BridgeFactory </name> - <description> - This component allows - to establish a connection to another process. - </description> - <loader-name> com.sun.star.loader.SharedLibrary </loader-name> - <language> c++ </language> - <status value="final"/> - <supported-service> com.sun.star.bridge.BridgeFactory </supported-service> - <service-dependency> ... </service-dependency> - <type> com.sun.star.bridge.XBridgeFactory </type> - <type> com.sun.star.bridge.XInstanceProvider </type> - <type> com.sun.star.bridge.XBridge </type> - <type> com.sun.star.bridge.BridgeExistsException </type> - <type> com.sun.star.container.XContentEnumerationAccess </type> - <type> com.sun.star.lang.DisposedException </type> - <type> com.sun.star.lang.XMultiServiceFactory </type> - <type> com.sun.star.lang.XSingleServiceFactory </type> - <type> com.sun.star.lang.XInitialization </type> - <type> com.sun.star.lang.XComponent </type> - <type> com.sun.star.lang.XServiceInfo </type> - <type> com.sun.star.lang.XTypeProvider </type> - <type> com.sun.star.lang.IllegalArgumentException </type> - <type> com.sun.star.lang.XInitialization </type> - <type> com.sun.star.registry.XRegistryKey </type> - <type> com.sun.star.lang.XSingleComponentFactory </type> - <type> com.sun.star.uno.XComponentContext </type> - <type> com.sun.star.uno.XWeak </type> - <type> com.sun.star.uno.TypeClass </type> - <type> com.sun.star.uno.XAggregation </type> - </component-description> - <project-build-dependency> cppuhelper </project-build-dependency> - <project-build-dependency> cppu </project-build-dependency> - <project-build-dependency> sal </project-build-dependency> - <runtime-module-dependency> cppuhelper3 </runtime-module-dependency> - <runtime-module-dependency> cppu3 </runtime-module-dependency> - <runtime-module-dependency> sal3 </runtime-module-dependency> -</module-description> diff --git a/remotebridges/source/factory/bridgefactory.cxx b/remotebridges/source/factory/bridgefactory.cxx deleted file mode 100644 index b6ef55d18a1c..000000000000 --- a/remotebridges/source/factory/bridgefactory.cxx +++ /dev/null @@ -1,501 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <boost/unordered_map.hpp> - -#include <rtl/alloc.h> - -#include <uno/mapping.hxx> -#include <osl/mutex.hxx> - -#include <bridges/remote/context.h> - -#include <cppuhelper/implementationentry.hxx> -#include <cppuhelper/component.hxx> -#include <cppuhelper/typeprovider.hxx> -#include "cppuhelper/unourl.hxx" -#include "rtl/malformeduriexception.hxx" - -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> - -#include <com/sun/star/bridge/XBridgeFactory.hpp> - -#include <com/sun/star/registry/XRegistryKey.hpp> - -#include <com/sun/star/container/XContentEnumerationAccess.hpp> - - -#include "bridgeimpl.hxx" - -using namespace ::rtl; -using namespace ::osl; -using namespace ::cppu; -using namespace ::std; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::bridge; -using namespace ::com::sun::star::connection; -using namespace ::com::sun::star::registry; -using namespace ::com::sun::star::container; - -#define SERVICE_NAME "com.sun.star.bridge.BridgeFactory" -#define IMPLEMENTATION_NAME "com.sun.star.comp.remotebridges.BridgeFactory" - -namespace remotebridges_factory -{ - rtl_StandardModuleCount g_moduleCount = MODULE_COUNT_INIT; - - struct hashOUString - { - size_t operator()(const OUString & s) const - { return s.hashCode(); } - }; - - struct equalOUString - { - sal_Bool operator()(const OUString & s1 , const OUString &s2 ) const - { - return s1 == s2; - } - }; - - typedef ::boost::unordered_map - < - OUString, - WeakReference< XBridge >, - hashOUString, - equalOUString - > BridgeHashMap; - - - typedef ::boost::unordered_map - < - OUString, - OUString, - hashOUString, - equalOUString - > ServiceHashMap; - - class OBridgeFactory : - public MyMutex, - public OComponentHelper, - public XBridgeFactory, - public XServiceInfo - { - public: - OBridgeFactory( const Reference < XComponentContext > &rCtx ); - ~OBridgeFactory(); - - public: // XInterface - ::com::sun::star::uno::Any SAL_CALL - queryInterface( const ::com::sun::star::uno::Type & aType ) throw(RuntimeException); - - void SAL_CALL acquire() throw() - { OComponentHelper::acquire(); } - void SAL_CALL release() throw() - { OComponentHelper::release(); } - - public: - virtual ::com::sun::star::uno::Reference< ::com::sun::star::bridge::XBridge > SAL_CALL - createBridge( - const ::rtl::OUString& sName, - const ::rtl::OUString& sProtocol, - const ::com::sun::star::uno::Reference< ::com::sun::star::connection::XConnection >& aConnection, - const ::com::sun::star::uno::Reference< ::com::sun::star::bridge::XInstanceProvider >& anInstanceProvider ) - throw(::com::sun::star::bridge::BridgeExistsException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException); - - virtual ::com::sun::star::uno::Reference< ::com::sun::star::bridge::XBridge > SAL_CALL - getBridge( const ::rtl::OUString& sName ) - throw(::com::sun::star::uno::RuntimeException ); - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::bridge::XBridge > > SAL_CALL - getExistingBridges( ) throw(::com::sun::star::uno::RuntimeException); - - public: //XTypeProvider - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL - getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL - getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - public: //XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); - - public: - static OUString getImplementationNameStatic( ) SAL_THROW( () ); - static Sequence< OUString > getSupportedServiceNamesStatic() SAL_THROW( () ); - - private: - void init(); - OUString getServiceNameForProtocol( const OUString &sProtocol ); - - private: - Reference < XMultiComponentFactory > m_rSMgr; - Reference < XComponentContext > m_rCtx; - BridgeHashMap m_mapBridge; - ServiceHashMap m_mapProtocolToService; - sal_Bool m_bInitialized; - ::osl::Mutex m_mutexInit; - }; - - OBridgeFactory::OBridgeFactory( const Reference < XComponentContext > &rCtx ) - : OComponentHelper( m_mutex ) - , m_rSMgr( rCtx->getServiceManager() ) - , m_rCtx( rCtx ) - , m_bInitialized( sal_False ) - { - g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); - } - - OBridgeFactory::~OBridgeFactory() - { - g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); - } - - void OBridgeFactory::init() - { - MutexGuard guard( m_mutexInit ); - if( ! m_bInitialized ) - { - Reference< XContentEnumerationAccess > rContent( m_rSMgr , UNO_QUERY ); - if( rContent.is() ) - { - OUString sMetaService = OUString( - RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.bridge.Bridge" ) ); - Reference < XEnumeration > rEnum = - rContent->createContentEnumeration( sMetaService ); - if ( rEnum.is() ) - while( rEnum->hasMoreElements() ) - { - Any a = rEnum->nextElement(); - Reference <XServiceInfo> rInfo; - if( a >>= rInfo ) - { - Sequence< OUString > seq = rInfo->getSupportedServiceNames(); - sal_Int32 i; - for( i = 0 ; i < seq.getLength() ; i ++ ) - { - if( seq.getConstArray()[i] != sMetaService ) - { - sal_Int32 nIndex = seq.getConstArray()[i].lastIndexOf( '.' ); - OUString sSuffix = seq.getConstArray()[i].copy(nIndex+1); - if( sSuffix.getLength() > 6 && - 0 == sSuffix.copy( sSuffix.getLength() - 6 ).compareToAscii( "Bridge" ) ) - { - OUString sProtocol = sSuffix.copy(0 , sSuffix.getLength()-6 ).toAsciiLowerCase(); - m_mapProtocolToService[ sProtocol ] = seq.getConstArray()[i]; - } - } - } - } - } - } - m_bInitialized = sal_True; - } - } - - OUString OBridgeFactory::getServiceNameForProtocol( const OUString & sProtocol ) - { - init(); - OUString sService; - OUString sProtocolName; - try - { - sProtocolName = cppu::UnoUrlDescriptor(sProtocol).getName(); - } - catch (rtl::MalformedUriException &) - { - OSL_ENSURE(false, "MalformedUriException"); - } - ServiceHashMap::iterator ii = m_mapProtocolToService.find( sProtocolName ); - if( ii != m_mapProtocolToService.end() ) - { - sService = (*ii).second; - } - else - { - // fallback to the old solution, deprecated, should be removed ! - sService = OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.bridge.Bridge.")); - sService += sProtocolName; - } - return sService; - } - - Any OBridgeFactory::queryInterface( const Type &aType ) throw(RuntimeException) - { - Any a = ::cppu::queryInterface( - aType , - ( XBridgeFactory * ) this ); - if( a.hasValue() ) - { - return a; - } - - return OComponentHelper::queryInterface( aType ); - - } - - Reference< XBridge > OBridgeFactory::createBridge( - const OUString& sName, - const OUString& sProtocol, - const Reference< XConnection >& aConnection, - const Reference< XInstanceProvider >& anInstanceProvider ) - throw(::com::sun::star::bridge::BridgeExistsException, - ::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException) - { - OUString sService = getServiceNameForProtocol( sProtocol ); - - Reference < XInterface > rXInterface = - m_rSMgr->createInstanceWithContext(sService, m_rCtx ); - Reference < XInitialization > rInit(rXInterface, UNO_QUERY ); - Reference < XBridge > rBridge( rInit , UNO_QUERY ); - - if( rInit.is() && rBridge.is() ) - { - Sequence < Any > seqAny( 4 ); - seqAny.getArray()[0] <<= sName; - seqAny.getArray()[1] <<= sProtocol; - seqAny.getArray()[2] <<= aConnection; - seqAny.getArray()[3] <<= anInstanceProvider; - - // let the Exceptions fly .... - rInit->initialize( seqAny ); - } - else - { - throw IllegalArgumentException(); - } - - if( sName.getLength() ) - { - MutexGuard guard( m_mutex ); - // put the bridge into the hashmap - m_mapBridge[ sName ] = rBridge; - } - return rBridge; - } - - Reference< XBridge > OBridgeFactory::getBridge( const ::rtl::OUString& sName ) - throw(::com::sun::star::uno::RuntimeException ) - - { - MutexGuard guard( m_mutex ); - BridgeHashMap::iterator ii = m_mapBridge.find( sName ); - - Reference < XBridge > rBridge; - - if( ii != m_mapBridge.end() ) - { - rBridge = (*ii).second; - if( ! rBridge.is() ) - { - m_mapBridge.erase( ii ); - } - } - - if( ! rBridge.is() ) - { - // try to get it via the C-Context - remote_Context * pRemoteC = remote_getContext( sName.pData ); - - if( pRemoteC ) - { - rBridge = Reference < XBridge > ((XBridge *) new OBridge( pRemoteC ) ); - pRemoteC->aBase.release( (uno_Context * )pRemoteC ); - m_mapBridge[ sName ] = rBridge; - } - } - return rBridge; - } - - Sequence< Reference< XBridge > > OBridgeFactory::getExistingBridges( ) - throw(::com::sun::star::uno::RuntimeException) - { - MutexGuard guard( m_mutex ); - - sal_Int32 nCount; - - rtl_uString **ppName = remote_getContextList( - &nCount, - rtl_allocateMemory ); - - Sequence < Reference < XBridge > > seq( nCount ); - if( nCount ) - { - - for( sal_Int32 i = 0; - i < nCount ; - i ++ ) - { - seq.getArray()[i] = getBridge( OUString( ppName[i]) ); - rtl_uString_release( ppName[i] ); - } - rtl_freeMemory( ppName ); - } - - return seq; - } - - // XTypeProvider - Sequence< Type > SAL_CALL OBridgeFactory::getTypes(void) throw( RuntimeException ) - { - static OTypeCollection *pCollection = 0; - if( ! pCollection ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pCollection ) - { - static OTypeCollection collection( - getCppuType( (Reference< XBridgeFactory > * ) 0 ), - OComponentHelper::getTypes() ); - pCollection = &collection; - } - } - return (*pCollection).getTypes(); - } - - Sequence< sal_Int8 > SAL_CALL OBridgeFactory::getImplementationId( ) throw( RuntimeException) - { - static OImplementationId *pId = 0; - if( ! pId ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pId ) - { - static OImplementationId id( sal_False ); - pId = &id; - } - } - return (*pId).getImplementationId(); - } - - OUString OBridgeFactory::getImplementationNameStatic() - { - static OUString *pName = 0; - if( ! pName ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pName ) - { - static OUString name( RTL_CONSTASCII_USTRINGPARAM( IMPLEMENTATION_NAME ) ); - pName = &name; - } - } - return *pName; - } - - Sequence< OUString > OBridgeFactory::getSupportedServiceNamesStatic() - { - static Sequence < OUString > *pNames = 0; - if( ! pNames ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( !pNames ) - { - static Sequence< OUString > seqNames(1); - seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM( SERVICE_NAME )); - pNames = &seqNames; - } - } - return *pNames; - } - - OUString OBridgeFactory::getImplementationName( ) throw(RuntimeException) - { - return getImplementationNameStatic(); - } - - sal_Bool SAL_CALL OBridgeFactory::supportsService( const OUString& ServiceName ) throw(RuntimeException) - { - Sequence< OUString > seq = getSupportedServiceNamesStatic(); - sal_Bool bReturn = sal_False; - for( sal_Int32 i = 0 ; i < seq.getLength() ; i ++ ) - { - if( seq.getConstArray()[i] == ServiceName ) - { - bReturn = sal_True; - break; - } - } - return bReturn; - } - - Sequence< OUString > SAL_CALL OBridgeFactory::getSupportedServiceNames( ) throw(RuntimeException) - { - return getSupportedServiceNamesStatic(); - } - - - Reference< XInterface > SAL_CALL CreateInstance(Reference< XComponentContext > const & xContext) - { - return Reference < XInterface > ( *new OBridgeFactory( xContext ) ); - } -} - -using namespace remotebridges_factory; -static ImplementationEntry g_entries[] = -{ - { CreateInstance, OBridgeFactory::getImplementationNameStatic, - OBridgeFactory::getSupportedServiceNamesStatic, createSingleComponentFactory , - &g_moduleCount.modCnt , 0 - }, - { 0, 0, 0, 0, 0, 0 } -}; - -extern "C" -{ -sal_Bool SAL_CALL component_canUnload( TimeValue *pTime ) -{ - return g_moduleCount.canUnload( &g_moduleCount , pTime ); -} - -//================================================================================================== -void SAL_CALL component_getImplementationEnvironment( - const sal_Char ** ppEnvTypeName, uno_Environment ** ) -{ - *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; -} -//================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== -void * SAL_CALL component_getFactory( - const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) -{ - return component_getFactoryHelper( pImplName, pServiceManager, pRegistryKey , g_entries ); -} -} - - - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/factory/bridgeimpl.cxx b/remotebridges/source/factory/bridgeimpl.cxx deleted file mode 100644 index a6029a7c247e..000000000000 --- a/remotebridges/source/factory/bridgeimpl.cxx +++ /dev/null @@ -1,273 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include "bridgeimpl.hxx" - -using namespace ::rtl; -using namespace ::osl; -using namespace ::cppu; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::lang; -using namespace ::com::sun::star::bridge; - -namespace remotebridges_factory { - - - OBridge::OBridge( remote_Context *pContext ) : - OComponentHelper( m_mutex ), - m_pContext( pContext ) - { - g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); - - remote_DisposingListener::acquire = thisAcquire; - remote_DisposingListener::release = thisRelease; - remote_DisposingListener::disposing = thisDisposing; - - m_pContext->aBase.acquire( (uno_Context*)m_pContext ); - m_pContext->addDisposingListener( m_pContext, ( remote_DisposingListener * ) this ); - } - - OBridge::~OBridge() - { - if( m_pContext ) - { - m_pContext->aBase.release( (uno_Context * ) m_pContext ); - } - g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); - } - - ::com::sun::star::uno::Any OBridge::queryInterface( const ::com::sun::star::uno::Type & aType ) throw(RuntimeException) - { - Any a = ::cppu::queryInterface( - aType , - SAL_STATIC_CAST( XBridge * , this ), - SAL_STATIC_CAST( XTypeProvider * , this ) ); - if( a.hasValue() ) - { - return a; - } - - return OComponentHelper::queryInterface( aType ); - } - - void OBridge::disposing() - { - if( m_pContext ) - { - m_pContext->removeDisposingListener( m_pContext , ( remote_DisposingListener * )this); - - uno_Environment *pEnvRemote = 0; - if( m_pContext->m_pConnection ) - { - sal_Int32 nIndex = 0; - OUString sProtocol = OUString( m_pContext->m_pProtocol ).getToken( 0 , ',' , nIndex ); - uno_getEnvironment( &pEnvRemote , sProtocol.pData , m_pContext ); - OSL_ASSERT( pEnvRemote ); - } - else - { - // within disposing from the context, no further dispose necessary ! - } - - if( pEnvRemote ) - { - pEnvRemote->dispose( pEnvRemote ); - pEnvRemote->release( pEnvRemote ); - pEnvRemote = 0; - } - - m_pContext->aBase.release( (uno_Context*)m_pContext ); - m_pContext = 0; - } - } - - - Reference< XInterface > OBridge::getInstance( const ::rtl::OUString& sInstanceName ) - throw(::com::sun::star::uno::RuntimeException) - { - Reference < XInterface > rReturn; - - remote_Context *pContext = 0; - { - MutexGuard guard( m_mutex ); - if( m_pContext && m_pContext->getRemoteInstance ) - { - pContext = m_pContext; - pContext->aBase.acquire( (uno_Context*)pContext ); - } - } - if( pContext ) - { - sal_Int32 nIndex = 0; - OUString sProtocol = OUString( m_pContext->m_pProtocol ).getToken( 0 , ',' , nIndex ); - - // get the appropriate remote environment - uno_Environment *pEnvRemote = 0; - uno_getEnvironment( &pEnvRemote , sProtocol.pData , pContext ); - - if( ! pEnvRemote ) - { - pContext->aBase.release( (uno_Context*) pContext ); - throw RuntimeException( - OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoteBridge: bridge already disposed" ) ), - Reference< XInterface > () ); - } - - Type type = getCppuType( (Reference < XInterface > * ) 0 ); - - remote_Interface *pRemoteI = 0; - uno_Any exception; - uno_Any *pException = &exception; - - pContext->getRemoteInstance( - pEnvRemote, - &pRemoteI, - sInstanceName.pData, - type.getTypeLibType(), - &pException ); - pContext->aBase.release( (uno_Context*) pContext ); - pContext = 0; - - uno_Environment *pEnvCpp =0; - OUString sCppuName( RTL_CONSTASCII_USTRINGPARAM( CPPU_CURRENT_LANGUAGE_BINDING_NAME ) ); - uno_getEnvironment( &pEnvCpp , - sCppuName.pData , - 0 ); - Mapping map( pEnvRemote , pEnvCpp ); - - pEnvCpp->release( pEnvCpp ); - pEnvRemote->release( pEnvRemote ); - - if( pException ) - { - typelib_CompoundTypeDescription * pCompType = 0 ; - getCppuType( (Exception*)0 ).getDescription( (typelib_TypeDescription **) &pCompType ); - - if( ! ((typelib_TypeDescription *)pCompType)->bComplete ) - { - typelib_typedescription_complete( (typelib_TypeDescription**) &pCompType ); - } - XInterface *pXInterface = (XInterface *) map.mapInterface( - *(remote_Interface**) ( ((char*)pException->pData)+pCompType->pMemberOffsets[1] ), - getCppuType( (Reference< XInterface > *)0 ) ); - RuntimeException myException( - *((rtl_uString **)pException->pData), - Reference< XInterface > ( pXInterface , SAL_NO_ACQUIRE) ); - uno_any_destruct( pException , 0 ); - - throw myException; - } - else if( pRemoteI ) - { - // got an interface ! - XInterface * pCppI = ( XInterface * ) map.mapInterface( pRemoteI, type ); - rReturn = Reference<XInterface > ( pCppI, SAL_NO_ACQUIRE ); - pRemoteI->release( pRemoteI ); - } - } - else - { - throw RuntimeException( - OUString( RTL_CONSTASCII_USTRINGPARAM( "RemoteBridge: bridge already disposed." ) ), - Reference< XInterface > () ); - } - - return rReturn; - } - - ::rtl::OUString SAL_CALL OBridge::getName( ) - throw(::com::sun::star::uno::RuntimeException) - - { - return OUString( m_pContext->m_pName ); - } - - ::rtl::OUString OBridge::getDescription( ) - throw(::com::sun::star::uno::RuntimeException) - { - return OUString( m_pContext->m_pDescription ); - } - - // XTypeProvider - Sequence< Type > SAL_CALL OBridge::getTypes(void) throw( RuntimeException ) - { - static OTypeCollection *pCollection = 0; - if( ! pCollection ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pCollection ) - { - static OTypeCollection collection( - getCppuType( (Reference< XTypeProvider> * )0), - getCppuType( (Reference< XBridge > * ) 0 ), - OComponentHelper::getTypes() ); - pCollection = &collection; - } - } - - return (*pCollection).getTypes(); - } - - Sequence< sal_Int8 > SAL_CALL OBridge::getImplementationId( ) throw( RuntimeException) - { - static OImplementationId *pId = 0; - if( ! pId ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pId ) - { - static OImplementationId id( sal_False ); - pId = &id; - } - } - return (*pId).getImplementationId(); - } - - //---------------------- - // static methods - //---------------------- - void OBridge::thisAcquire( remote_DisposingListener *p ) - { - OBridge *m = (OBridge * ) p; - m->acquire(); - } - - void OBridge::thisRelease( remote_DisposingListener *p ) - { - OBridge *m = (OBridge * ) p; - m->release(); - } - - void OBridge::thisDisposing( remote_DisposingListener * p, rtl_uString * ) - { - OBridge *m = (OBridge * ) p; - m->dispose(); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/factory/bridgeimpl.hxx b/remotebridges/source/factory/bridgeimpl.hxx deleted file mode 100644 index 54daea064ae0..000000000000 --- a/remotebridges/source/factory/bridgeimpl.hxx +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <osl/mutex.hxx> -#include <osl/diagnose.h> - -#include <uno/mapping.hxx> -#include <uno/environment.h> - -#include <bridges/remote/context.h> -#include <bridges/remote/remote.h> - -#include <cppuhelper/factory.hxx> -#include <cppuhelper/component.hxx> -#include <cppuhelper/typeprovider.hxx> - -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/lang/XInitialization.hpp> - -#include <com/sun/star/bridge/XBridge.hpp> -#include <com/sun/star/bridge/XInstanceProvider.hpp> - -namespace remotebridges_factory { - extern rtl_StandardModuleCount g_moduleCount; - - struct MyMutex - { - ::osl::Mutex m_mutex; - }; - - class OBridge : - public MyMutex, - public remote_DisposingListener, - public ::com::sun::star::bridge::XBridge, - public ::cppu::OComponentHelper - { - public: - OBridge( remote_Context *pContext ); - ~OBridge(); - - // XInterface - public: - ::com::sun::star::uno::Any SAL_CALL - queryInterface( const ::com::sun::star::uno::Type & aType ) throw(com::sun::star::uno::RuntimeException); - - void SAL_CALL acquire() throw() - { OComponentHelper::acquire(); } - void SAL_CALL release() throw() - { OComponentHelper::release(); } - - public: - virtual void SAL_CALL disposing(); // called by OComponentHelper - - public: - virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL - getInstance( const ::rtl::OUString& sInstanceName ) - throw(::com::sun::star::uno::RuntimeException); - - virtual ::rtl::OUString SAL_CALL getName( ) - throw(::com::sun::star::uno::RuntimeException); - virtual ::rtl::OUString SAL_CALL getDescription( ) - throw(::com::sun::star::uno::RuntimeException); - - public: - virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL - getTypes( ) throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL - getImplementationId( ) throw(::com::sun::star::uno::RuntimeException); - - public: - static void SAL_CALL thisAcquire( remote_DisposingListener * ); - static void SAL_CALL thisRelease( remote_DisposingListener * ); - static void SAL_CALL thisDisposing( remote_DisposingListener * , - rtl_uString * pBridgeName ); - - public: - remote_Context *m_pContext; - ::rtl::OString m_sName; - ::rtl::OString m_sDescription; - }; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/remotebridges/source/factory/makefile.mk b/remotebridges/source/factory/makefile.mk deleted file mode 100644 index 11e19e125acb..000000000000 --- a/remotebridges/source/factory/makefile.mk +++ /dev/null @@ -1,65 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=remotebridges -TARGET = bridgefac.uno -ENABLE_EXCEPTIONS=TRUE -COMP1TYPELIST = brdgfctr - -# --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk -.IF "$(L10N_framework)"=="" -DLLPRE = -# ------------------------------------------------------------------ - -SLOFILES= \ - $(SLO)$/bridgefactory.obj\ - $(SLO)$/bridgeimpl.obj - -SHL1TARGET= $(TARGET) -SHL1VERSIONMAP = $(SOLARENV)/src/unloadablecomponent.map - -SHL1STDLIBS= \ - $(SALLIB) \ - $(CPPULIB) \ - $(CPPUHELPERLIB) \ - $(RMCXTLIB) - -SHL1IMPLIB= i$(TARGET) -SHL1LIBS= $(SLB)$/$(TARGET).lib -SHL1DEF= $(MISC)$/$(SHL1TARGET).def -SHL1RPATH= URELIB - -DEF1NAME= $(SHL1TARGET) -.ENDIF # L10N_framework - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - diff --git a/remotebridges/source/unourl_resolver/makefile.mk b/remotebridges/source/unourl_resolver/makefile.mk index a3e4af7f0d91..edf5aa72c128 100644 --- a/remotebridges/source/unourl_resolver/makefile.mk +++ b/remotebridges/source/unourl_resolver/makefile.mk @@ -62,3 +62,11 @@ DEF1NAME= $(SHL1TARGET) # --- Targets ------------------------------------------------------ .INCLUDE : target.mk + +ALLTAR : $(MISC)/uuresolver.component + +$(MISC)/uuresolver.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + uuresolver.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt uuresolver.component diff --git a/remotebridges/source/unourl_resolver/unourl_resolver.cxx b/remotebridges/source/unourl_resolver/unourl_resolver.cxx index 4c9f20f7ddfa..1cc5efdbded9 100644 --- a/remotebridges/source/unourl_resolver/unourl_resolver.cxx +++ b/remotebridges/source/unourl_resolver/unourl_resolver.cxx @@ -241,12 +241,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/remotebridges/source/unourl_resolver/uuresolver.component b/remotebridges/source/unourl_resolver/uuresolver.component new file mode 100644 index 000000000000..f9dcd71d8956 --- /dev/null +++ b/remotebridges/source/unourl_resolver/uuresolver.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.bridge.UnoUrlResolver"> + <service name="com.sun.star.bridge.UnoUrlResolver"/> + </implementation> +</component> diff --git a/sal/cppunittester/makefile.mk b/sal/cppunittester/makefile.mk index 938b63d90ae9..61fe7868c9f3 100644 --- a/sal/cppunittester/makefile.mk +++ b/sal/cppunittester/makefile.mk @@ -33,6 +33,13 @@ ENABLE_EXCEPTIONS = TRUE .INCLUDE: settings.mk +#building with stlport, but cppunit was not built with stlport +.IF "$(USE_SYSTEM_STL)"!="YES" +.IF "$(SYSTEM_CPPUNIT)"=="YES" +CFLAGSCXX+=-DADAPT_EXT_STL +.ENDIF +.ENDIF + CFLAGSCXX += $(CPPUNIT_CFLAGS) OBJFILES = $(APP1OBJS) diff --git a/sal/inc/osl/thread.h b/sal/inc/osl/thread.h index 1b160f09eef9..14b4cbfd8b7e 100644 --- a/sal/inc/osl/thread.h +++ b/sal/inc/osl/thread.h @@ -160,6 +160,18 @@ sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread); */ void SAL_CALL osl_yieldThread(void); +/** Attempts to set the name of the current thread. + + The name of a thread is usually evaluated for debugging purposes. Not all + platforms support this. On Linux, a set thread name can be observed with + "ps -L". On Windows with the Microsoft compiler, a thread name set while a + debugger is attached can be observed within the debugger. + + @param name the name of the thread; must not be null; on Linux, only the + first 16 characters are used +*/ +void SAL_CALL osl_setThreadName(char const * name); + /* Callback when data stored in a thread key is no longer needed */ typedef void (SAL_CALL *oslThreadKeyCallbackFunction)(void *); diff --git a/sal/inc/osl/thread.hxx b/sal/inc/osl/thread.hxx index 923c68ecd41d..2bcc82fd07eb 100644 --- a/sal/inc/osl/thread.hxx +++ b/sal/inc/osl/thread.hxx @@ -151,6 +151,9 @@ public: osl_yieldThread(); } + static inline void setName(char const * name) throw () { + osl_setThreadName(name); + } virtual sal_Bool SAL_CALL schedule() { diff --git a/sal/inc/rtl/malformeduriexception.hxx b/sal/inc/rtl/malformeduriexception.hxx index e67e3187e5a0..a119e44f601d 100644 --- a/sal/inc/rtl/malformeduriexception.hxx +++ b/sal/inc/rtl/malformeduriexception.hxx @@ -54,8 +54,8 @@ public: inline SAL_EXCEPTION_DLLPRIVATE ~MalformedUriException() {} inline SAL_EXCEPTION_DLLPRIVATE MalformedUriException operator =( - MalformedUriException const & other) - { m_aMessage = other.m_aMessage; return *this; } + MalformedUriException const & rOther) + { m_aMessage = rOther.m_aMessage; return *this; } /** Get the message. diff --git a/sal/inc/rtl/math.h b/sal/inc/rtl/math.h index dc51d9900ff8..26a1029095b1 100644 --- a/sal/inc/rtl/math.h +++ b/sal/inc/rtl/math.h @@ -320,7 +320,9 @@ void SAL_CALL rtl_math_doubleToUString(rtl_uString ** pResult, @param pParsedEnd If non-null, returns one past the position of the last character parsed away. Thus if [pBegin..pEnd) only contains the numerical string to be - parsed, *pParsedEnd == pEnd on return. + parsed, *pParsedEnd == pEnd on return. If no numerical (sub-)string is + found, *pParsedEnd == pBegin on return, even if there was leading + whitespace. */ double SAL_CALL rtl_math_stringToDouble( sal_Char const * pBegin, sal_Char const * pEnd, sal_Char cDecSeparator, @@ -358,7 +360,9 @@ double SAL_CALL rtl_math_stringToDouble( @param pParsedEnd If non-null, returns one past the position of the last character parsed away. Thus if [pBegin..pEnd) only contains the numerical string to be - parsed, *pParsedEnd == pEnd on return. + parsed, *pParsedEnd == pEnd on return. If no numerical (sub-)string is + found, *pParsedEnd == pBegin on return, even if there was leading + whitespace. */ double SAL_CALL rtl_math_uStringToDouble( sal_Unicode const * pBegin, sal_Unicode const * pEnd, diff --git a/bridges/inc/bridges/remote/counter.hxx b/sal/inc/sal/cppunit.h index 8bcb547008af..cd6645b51aee 100644 --- a/bridges/inc/bridges/remote/counter.hxx +++ b/sal/inc/sal/cppunit.h @@ -25,35 +25,20 @@ * for a copy of the LGPLv3 License. * ************************************************************************/ -#ifndef _BRIDGES_REMOTE_COUNTER_H_ -#define _BRIDGES_REMOTE_COUNTER_H_ -#include <stdio.h> -#if OSL_DEBUG_LEVEL > 1 -struct MyCounter -{ - MyCounter( sal_Char const *pName ) : - m_nCounter( 0 ), - m_pName ( pName ) - { - } - ~MyCounter() - { - if( m_nCounter ) { - printf( - "%s : %ld left\n", m_pName, - sal::static_int_cast< long >(m_nCounter) ); - } - } - void acquire() - { m_nCounter ++; } - void release() - { m_nCounter --; } +#ifndef _SAL_CPPUNIT_H_ +#define _SAL_CPPUNIT_H_ - sal_Int32 m_nCounter; - sal_Char const *m_pName; -}; -#endif +#include <sal/types.h> + +#include "preextstl.h" +#include <cppunit/TestAssert.h> +#include <cppunit/TestFixture.h> +#include <cppunit/extensions/HelperMacros.h> +#include <cppunit/plugin/TestPlugIn.h> +#undef CPPUNIT_PLUGIN_EXPORT +#define CPPUNIT_PLUGIN_EXPORT extern "C" SAL_DLLPUBLIC_EXPORT +#include "postextstl.h" #endif diff --git a/sal/inc/sal/types.h b/sal/inc/sal/types.h index fdaaab18ba1e..d33e545dbac7 100644 --- a/sal/inc/sal/types.h +++ b/sal/inc/sal/types.h @@ -297,7 +297,7 @@ typedef void * sal_Handle; These macros are used for inline declarations of exception classes, as in rtl/malformeduriexception.hxx. */ -#if defined __GNUC__ +#if defined(__GNUC__) && ! defined(__MINGW32__) #define SAL_EXCEPTION_DLLPUBLIC_EXPORT SAL_DLLPUBLIC_EXPORT #define SAL_EXCEPTION_DLLPRIVATE SAL_DLLPRIVATE #else diff --git a/sal/osl/all/makefile.mk b/sal/osl/all/makefile.mk index 84edd954dc48..2d1b7ec822f8 100644 --- a/sal/osl/all/makefile.mk +++ b/sal/osl/all/makefile.mk @@ -55,13 +55,15 @@ SLOFILES= \ $(SLO)$/utility.obj\ $(SLO)$/filepath.obj\ $(SLO)$/debugbase.obj\ - $(SLO)$/loadmodulerelative.obj + $(SLO)$/loadmodulerelative.obj \ + $(SLO)/printtrace.obj OBJFILES= \ $(OBJ)$/utility.obj\ $(OBJ)$/filepath.obj\ $(OBJ)$/debugbase.obj\ - $(OBJ)$/loadmodulerelative.obj + $(OBJ)$/loadmodulerelative.obj \ + $(OBJ)/printtrace.obj # --- Targets ------------------------------------------------------ diff --git a/sal/osl/all/printtrace.cxx b/sal/osl/all/printtrace.cxx new file mode 100644 index 000000000000..5d79d9b1de5a --- /dev/null +++ b/sal/osl/all/printtrace.cxx @@ -0,0 +1,65 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_sal.hxx" + +#include "sal/config.h" + +#include <cstdarg> +#include <cstdio> +#include <cstring> + +#include <stdio.h> // snprintf, vsnprintf + +#include "osl/diagnose.h" +#include "osl/thread.hxx" +#include "rtl/string.h" +#include "sal/types.h" + +#include "printtrace.h" + +void printTrace(unsigned long pid, char const * format, std::va_list arguments) +{ + char buf[1024]; + int n1 = snprintf( + buf, sizeof buf, "Trace %lu/%" SAL_PRIuUINT32 ": \"", pid, + osl::Thread::getCurrentIdentifier()); + OSL_ASSERT( + n1 >= 0 && + (static_cast< unsigned int >(n1) < + sizeof buf - RTL_CONSTASCII_LENGTH("\"...\n"))); + int n2 = sizeof buf - n1 - RTL_CONSTASCII_LENGTH("\"...\n"); + int n3 = vsnprintf(buf + n1, n2, format, arguments); + if (n3 < 0) { + std::strcpy(buf + n1, "\"???\n"); + } else if (n3 < n2) { + std::strcpy(buf + n1 + n3, "\"\n"); + } else { + std::strcpy(buf + n1 + n2 - 1, "\"...\n"); + } + std::fputs(buf, stderr); +} diff --git a/sal/osl/inc/printtrace.h b/sal/osl/inc/printtrace.h new file mode 100644 index 000000000000..9e1d514b0d08 --- /dev/null +++ b/sal/osl/inc/printtrace.h @@ -0,0 +1,46 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_SAL_OSL_INC_PRINTTRACE_H +#define INCLUDED_SAL_OSL_INC_PRINTTRACE_H + +#include "sal/config.h" + +#include <stdarg.h> + +#if defined __cplusplus +extern "C" { +#endif + +/* called internally by osl_trace */ +void printTrace(unsigned long pid, char const * format, va_list arguments); + +#if defined __cplusplus +} +#endif + +#endif diff --git a/sal/osl/os2/diagnose.c b/sal/osl/os2/diagnose.c index 538f8d3fb95a..999c304ae77e 100644 --- a/sal/osl/os2/diagnose.c +++ b/sal/osl/os2/diagnose.c @@ -36,6 +36,8 @@ #include <osl/diagnose.h> #include <osl/thread.h> +#include "printtrace.h" + BYTE oslTraceEnv[] = "OSL_TRACE_TO_FILE"; typedef pfunc_osl_printDebugMessage oslDebugMessageFunc; @@ -54,29 +56,11 @@ void SAL_CALL osl_breakDebug() /************************************************************************/ /* osl_trace */ /************************************************************************/ -/* comment this define to stop output thread identifier*/ -#define OSL_TRACE_THREAD 1 -void SAL_CALL osl_trace ( - const sal_Char* lpszFormat, ...) -{ +void osl_trace(char const * pszFormat, ...) { va_list args; - -#if defined(OSL_PROFILING) - fprintf(stderr, "Time: %06lu : ", osl_getGlobalTimer() ); -#else -#if defined(OSL_TRACE_THREAD) - fprintf(stderr,"Thread: %6d :",osl_getThreadIdentifier(NULL)); -#else - fprintf(stderr, "Trace Message: "); -#endif -#endif - - va_start(args, lpszFormat); - vfprintf(stderr, lpszFormat, args); + va_start(args, pszFormat); + printTrace(0, pszFormat, args); /* TODO: pid */ va_end(args); - - fprintf(stderr,"\n"); - fflush(stderr); } /*----------------------------------------------------------------------------*/ diff --git a/sal/osl/os2/system.h b/sal/osl/os2/system.h index 0782384a127f..fbff1e900df4 100644 --- a/sal/osl/os2/system.h +++ b/sal/osl/os2/system.h @@ -298,8 +298,7 @@ char *macxp_tempnam( const char *tmpdir, const char *prefix ); #if !defined(_WIN32) && !defined(OS2) && \ !defined(LINUX) && !defined(NETBSD) && !defined(FREEBSD) && \ !defined(AIX) && \ - !defined(SOLARIS) && !defined(MAC) && \ - !defined(MACOSX) + !defined(SOLARIS) && !defined(MACOSX) # error "Target plattform not specified !" #endif diff --git a/sal/osl/os2/thread.c b/sal/osl/os2/thread.c index d4b01a98ad78..df66d354addc 100644 --- a/sal/osl/os2/thread.c +++ b/sal/osl/os2/thread.c @@ -550,6 +550,10 @@ void SAL_CALL osl_yieldThread() DosSleep(0); } +void osl_setThreadName(char const * name) { + (void) name; +} + typedef struct _TLS { PULONG pulPtr; diff --git a/sal/osl/unx/diagnose.c b/sal/osl/unx/diagnose.c index 83f4e90da733..36c9c0d5fec1 100644 --- a/sal/osl/unx/diagnose.c +++ b/sal/osl/unx/diagnose.c @@ -29,7 +29,6 @@ #include "osl/diagnose.h" #include "system.h" - #ifndef HAVE_DLFCN_H #if defined(LINUX) || defined(SOLARIS) @@ -59,6 +58,8 @@ #define INCLUDED_STDDEF_H #endif +#include "printtrace.h" + /************************************************************************/ /* Internal data structures and functions */ /************************************************************************/ @@ -302,33 +303,11 @@ pfunc_osl_printDetailedDebugMessage SAL_CALL osl_setDetailedDebugMessageFunc ( /************************************************************************/ /* osl_trace */ /************************************************************************/ -/* comment this define to stop output thread identifier*/ -#define OSL_TRACE_THREAD 1 -void SAL_CALL osl_trace ( - const sal_Char* lpszFormat, ...) -{ +void osl_trace(char const * pszFormat, ...) { va_list args; - -#if defined(OSL_PROFILING) - fprintf(stderr, "Time: %06lu : ", osl_getGlobalTimer() ); -#else -#if defined(OSL_TRACE_THREAD) - fprintf( - stderr, "Thread: %6lu :", - SAL_INT_CAST(unsigned long, osl_getThreadIdentifier(NULL))); -#else - fprintf(stderr, "Trace Message: "); -#endif -#endif - - va_start(args, lpszFormat); - vfprintf(stderr, lpszFormat, args); + va_start(args, pszFormat); + printTrace((unsigned long) getpid(), pszFormat, args); va_end(args); - - fprintf(stderr,"\n"); - fflush(stderr); } -/************************************************************************/ - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file diff --git a/sal/osl/unx/nlsupport.c b/sal/osl/unx/nlsupport.c index 543e499a00a1..481caaf399b4 100644 --- a/sal/osl/unx/nlsupport.c +++ b/sal/osl/unx/nlsupport.c @@ -879,9 +879,9 @@ void _imp_getProcessLocale( rtl_Locale ** ppLocale ) if ( NULL == locale ) { - locale = (char *)malloc( 20 ); + locale = (char *)malloc( 128 ); if ( locale ) - macosx_getLocale( locale, 20 ); + macosx_getLocale( locale, 128 ); else fprintf( stderr, "nlsupport.c: locale allocation returned NULL!\n" ); } diff --git a/sal/osl/unx/pipe.c b/sal/osl/unx/pipe.c index b2f01dd27374..e8ab52431744 100644 --- a/sal/osl/unx/pipe.c +++ b/sal/osl/unx/pipe.c @@ -482,7 +482,7 @@ sal_Int32 SAL_CALL osl_receivePipe(oslPipe pPipe, (sal_Char*)pBuffer, BytesToRead, 0); - if ( nRet <= 0 ) + if ( nRet < 0 ) { OSL_TRACE("osl_receivePipe failed : %i '%s'",nRet,strerror(errno)); } diff --git a/sal/osl/unx/process_impl.cxx b/sal/osl/unx/process_impl.cxx index 941a87776519..ac043339b899 100644 --- a/sal/osl/unx/process_impl.cxx +++ b/sal/osl/unx/process_impl.cxx @@ -408,10 +408,10 @@ oslProcessError SAL_CALL osl_clearEnvironment(rtl_uString* pustrEnvVar) result = osl_Process_E_None; else rtl_string_release(pBuffer); -#elif defined(MACOSX) +#elif (defined(MACOSX) || defined(NETBSD) || defined(FREEBSD)) //MacOSX baseline is 10.4, which has an old-school void return //for unsetenv. - //See: http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/10.4/man3/unsetenv.3.html?useVersion=10.4 + //See: http://developer.apple.com/mac/library/documentation/Darwin/Reference/ManPages/10.4/man3/unsetenv.3.html?useVersion=10.4 unsetenv(rtl_string_getStr(pstr_env_var)); result = osl_Process_E_None; #else diff --git a/sal/osl/unx/thread.c b/sal/osl/unx/thread.c index 689b78dc748a..cf3d13e4b244 100644 --- a/sal/osl/unx/thread.c +++ b/sal/osl/unx/thread.c @@ -37,6 +37,10 @@ #include <rtl/textenc.h> #include <sal/macros.h> +#if defined LINUX +#include <sys/prctl.h> +#endif + /**************************************************************************** * @@@ TODO @@@ * @@ -590,6 +594,18 @@ void SAL_CALL osl_yieldThread() sched_yield(); } +void SAL_CALL osl_setThreadName(char const * name) { +#if defined LINUX + if (prctl(PR_SET_NAME, (unsigned long) name, 0, 0, 0) != 0) { + OSL_TRACE( + "%s prctl(PR_SET_NAME) failed with errno %d", OSL_LOG_PREFIX, + errno); + } +#else + (void) name; +#endif +} + /*****************************************************************************/ /* osl_getThreadIdentifier @@@ see TODO @@@ */ /*****************************************************************************/ diff --git a/sal/osl/w32/diagnose.c b/sal/osl/w32/diagnose.c index e9caaf2b504e..e25c60e8c886 100644..100755 --- a/sal/osl/w32/diagnose.c +++ b/sal/osl/w32/diagnose.c @@ -33,6 +33,8 @@ #include <osl/diagnose.h> #include <osl/thread.h> +#include "printtrace.h" + #define NO_DEBUG_CRT static pfunc_osl_printDebugMessage _pPrintDebugMessage = NULL; @@ -62,45 +64,21 @@ void SAL_CALL osl_breakDebug(void) DebugBreak(); } - - -/* Uncomment this define to get profiling time output */ -/* #define OSL_PROFILING */ -/* comment this define to stop output thread identifier*/ -#define OSL_TRACE_THREAD 1 -void SAL_CALL osl_trace(const sal_Char* lpszFormat, ...) -{ +void osl_trace(char const * pszFormat, ...) { va_list args; - - va_start(args, lpszFormat); - -#if defined(OSL_PROFILING) - fprintf(stderr, "time : %06lu : ", osl_getGlobalTimer() ); -#else -#if defined(OSL_TRACE_THREAD) - fprintf(stderr,"Thread: %6d :",osl_getThreadIdentifier(NULL)); -#else - fprintf(stderr,"Trace Message : "); -#endif -#endif - + va_start(args, pszFormat); if ( IsDebuggerPresent() ) { sal_Char szMessage[512]; - int written = _vsnprintf( szMessage, sizeof(szMessage) - 2, lpszFormat, args ); + int written = _vsnprintf( + szMessage, sizeof(szMessage) - 2, pszFormat, args ); if ( written == -1 ) written = sizeof(szMessage) - 2; szMessage[ written++ ] = '\n'; szMessage[ written ] = 0; OutputDebugString( szMessage ); } - - vfprintf(stderr,lpszFormat, args); - - fprintf(stderr,"\n"); - - fflush(stderr); - + printTrace((unsigned long) _getpid(), pszFormat, args); va_end(args); } diff --git a/sal/osl/w32/thread.c b/sal/osl/w32/thread.c index 92ac312d5a4e..02a67050083d 100644..100755 --- a/sal/osl/w32/thread.c +++ b/sal/osl/w32/thread.c @@ -395,6 +395,31 @@ void SAL_CALL osl_yieldThread(void) Sleep(0); } +void SAL_CALL osl_setThreadName(char const * name) { +#ifdef _MSC_VER + /* See <http://msdn.microsoft.com/en-us/library/xcb2z8hs.aspx>: */ +#pragma pack(push, 8) + struct { + DWORD dwType; + LPCSTR szName; + DWORD dwThreadID; + DWORD dwFlags; + } info; +#pragma pack(pop) + info.dwType = 0x1000; + info.szName = name; + info.dwThreadID = (DWORD) -1; + info.dwFlags = 0; + __try { + RaiseException( + 0x406D1388, 0, sizeof info / sizeof (ULONG_PTR), + (ULONG_PTR *) &info); + } __except (EXCEPTION_EXECUTE_HANDLER) {} +#else + (void) name; +#endif +} + typedef struct _TLS { DWORD dwIndex; diff --git a/sal/prj/build.lst b/sal/prj/build.lst index ddbc44673a49..dcbe44853026 100644 --- a/sal/prj/build.lst +++ b/sal/prj/build.lst @@ -17,12 +17,15 @@ sa sal\cppunittester nmake - all sa_cppunittester sa_cpprt.u sa_util NULL sa sal\qa\ByteSequence nmake - all sa_qa_ByteSequence sa_cppunittester sa_util NULL sa sal\qa\OStringBuffer nmake - all sa_qa_OStringBuffer sa_cppunittester sa_util NULL sa sal\qa\osl\mutex nmake - all sa_qa_osl_mutex sa_cppunittester sa_util NULL +sa sal\qa\osl\pipe nmake - all sa_qa_osl_pipe sa_cppunittester sa_util NULL sa sal\qa\osl\profile nmake - all sa_qa_osl_profile sa_cppunittester sa_util NULL sa sal\qa\osl\file nmake - u sa_qa_osl_file sa_cppunittester sa_util NULL sa sal\qa\osl\module nmake - u sa_qa_osl_module sa_cppunittester sa_util NULL sa sal\qa\osl\condition nmake - all sa_qa_osl_condition sa_cppunittester sa_util NULL sa sal\qa\osl\security nmake - all sa_qa_osl_security sa_cppunittester sa_util NULL sa sal\qa\osl\process nmake - all sa_qa_osl_process sa_cppunittester sa_util NULL +sa sal\qa\osl\setthreadname nmake - all sa_qa_osl_setthreadname sa_cppunittester sa_util NULL +sa sal\qa\rtl\math nmake - all sa_qa_rtl_math sa_cppunittester sa_util NULL sa sal\qa\rtl\strings nmake - all sa_qa_rt_strings sa_cppunittester sa_util NULL sa sal\qa\rtl\oustringbuffer nmake - all sa_qa_rt_oustringbuffer sa_cppunittester sa_util NULL sa sal\qa\rtl\alloc nmake - all sa_qa_rt_alloc sa_cppunittester sa_util NULL diff --git a/sal/qa/OStringBuffer/makefile.mk b/sal/qa/OStringBuffer/makefile.mk index 297221bdc4d9..2b29878ec20a 100644 --- a/sal/qa/OStringBuffer/makefile.mk +++ b/sal/qa/OStringBuffer/makefile.mk @@ -29,8 +29,6 @@ PRJ=..$/.. PRJNAME=sal TARGET=qa_ostringbuffer -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx index fb49c34af41a..b01862f1bb86 100644 --- a/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx +++ b/sal/qa/OStringBuffer/rtl_OStringBuffer.cxx @@ -14435,11 +14435,7 @@ namespace rtl_OStringBuffer { ::rtl::OStringBuffer aStrBuf( *arrOUS[0] ); OString expVal( kTestStr116 ); -#if defined(UNX) || defined(OS2) - sal_Int64 input = 9223372036854775807LL; -#else - sal_Int64 input = 9223372036854775807; -#endif + sal_Int64 input = SAL_CONST_INT64(9223372036854775807); aStrBuf.append( input ); CPPUNIT_ASSERT_MESSAGE @@ -14519,11 +14515,7 @@ namespace rtl_OStringBuffer { ::rtl::OStringBuffer aStrBuf( *arrOUS[1] ); OString expVal( kTestStr118 ); -#if defined(UNX) || defined(OS2) - sal_Int64 input = 9223372036854775807LL; -#else - sal_Int64 input = 9223372036854775807; -#endif + sal_Int64 input = SAL_CONST_INT64(9223372036854775807); aStrBuf.append( input ); CPPUNIT_ASSERT_MESSAGE @@ -14602,11 +14594,7 @@ namespace rtl_OStringBuffer { ::rtl::OStringBuffer aStrBuf( *arrOUS[2] ); OString expVal( kTestStr118 ); -#if defined(UNX) || defined(OS2) - sal_Int64 input = 9223372036854775807LL; -#else - sal_Int64 input = 9223372036854775807; -#endif + sal_Int64 input = SAL_CONST_INT64(9223372036854775807); aStrBuf.append( input ); CPPUNIT_ASSERT_MESSAGE @@ -14685,11 +14673,7 @@ namespace rtl_OStringBuffer { ::rtl::OStringBuffer aStrBuf( *arrOUS[3] ); OString expVal( kTestStr118 ); -#if defined(UNX) || defined(OS2) - sal_Int64 input = 9223372036854775807LL; -#else - sal_Int64 input = 9223372036854775807; -#endif + sal_Int64 input = SAL_CONST_INT64(9223372036854775807); aStrBuf.append( input ); CPPUNIT_ASSERT_MESSAGE @@ -14768,11 +14752,7 @@ namespace rtl_OStringBuffer { ::rtl::OStringBuffer aStrBuf( *arrOUS[4] ); OString expVal( kTestStr120 ); -#if defined(UNX) || defined(OS2) - sal_Int64 input = 9223372036854775807LL; -#else - sal_Int64 input = 9223372036854775807; -#endif + sal_Int64 input = SAL_CONST_INT64(9223372036854775807); aStrBuf.append( input ); CPPUNIT_ASSERT_MESSAGE diff --git a/sal/qa/OStringBuffer/rtl_String_Const.h b/sal/qa/OStringBuffer/rtl_String_Const.h index 7b9ad1c83f07..7841e4fd164c 100644 --- a/sal/qa/OStringBuffer/rtl_String_Const.h +++ b/sal/qa/OStringBuffer/rtl_String_Const.h @@ -317,11 +317,7 @@ static const sal_Int16 kSInt16Max = SHRT_MAX; static const sal_Int32 kUInt16Max = USHRT_MAX; static const sal_Int32 kSInt32Max = INT_MAX; static const sal_Int64 kUInt32Max = UINT_MAX; -#if defined(UNX) || defined(OS2) -static const sal_Int64 kSInt64Max = 9223372036854775807LL; -#else -static const sal_Int64 kSInt64Max = 9223372036854775807; -#endif +static const sal_Int64 kSInt64Max = SAL_CONST_INT64(9223372036854775807); //------------------------------------------------------------------------ diff --git a/sal/qa/osl/pipe/makefile.mk b/sal/qa/osl/pipe/makefile.mk index fc6728abfe3b..8e91738d0669 100644 --- a/sal/qa/osl/pipe/makefile.mk +++ b/sal/qa/osl/pipe/makefile.mk @@ -51,7 +51,7 @@ SHL1OBJS= \ $(SLO)$/osl_Pipe.obj SHL1TARGET= osl_Pipe -SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) +SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) $(TESTLIB) SHL1IMPLIB= i$(SHL1TARGET) # SHL1DEF= $(MISC)$/$(SHL1TARGET).def diff --git a/sal/qa/osl/pipe/osl_Pipe.cxx b/sal/qa/osl/pipe/osl_Pipe.cxx index 6edf247e5061..055c1440ecee 100644 --- a/sal/qa/osl/pipe/osl_Pipe.cxx +++ b/sal/qa/osl/pipe/osl_Pipe.cxx @@ -37,6 +37,7 @@ #include "cppunit/TestFixture.h" #include "cppunit/extensions/HelperMacros.h" #include "cppunit/plugin/TestPlugIn.h" +#include "test/uniquepipename.hxx" #include <sal/types.h> #include <rtl/ustring.hxx> @@ -184,8 +185,8 @@ namespace osl_Pipe void ctors_name_option( ) { /// create a named pipe. - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); - ::osl::Pipe aAssignPipe( aTestPipeName, osl_Pipe_OPEN ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); + ::osl::Pipe aAssignPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN ); bRes = aPipe.is( ) && aAssignPipe.is( ); @@ -197,7 +198,7 @@ namespace osl_Pipe { /// create a security pipe. const ::osl::Security rSecurity; - ::osl::Pipe aSecurityPipe( aTestPipeName, osl_Pipe_CREATE, rSecurity ); + ::osl::Pipe aSecurityPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSecurity ); bRes = aSecurityPipe.is( ); @@ -208,7 +209,7 @@ namespace osl_Pipe void ctors_copy( ) { /// create a pipe. - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); /// create a pipe using copy constructor. ::osl::Pipe aCopyPipe( aPipe ); @@ -231,7 +232,7 @@ namespace osl_Pipe void ctors_no_acquire( ) { /// create a pipe. - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); /// constructs a pipe reference without acquiring the handle. ::osl::Pipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE ); @@ -247,7 +248,7 @@ namespace osl_Pipe void ctors_acquire( ) { /// create a base pipe. - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); /// constructs two pipes without acquiring the handle on the base pipe. ::osl::Pipe aAcquirePipe( aPipe.getHandle( ) ); ::osl::Pipe aAcquirePipe1( NULL ); @@ -285,14 +286,14 @@ namespace osl_Pipe void is_002( ) { - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), a normal pipe creation.", sal_True == aPipe.is( ) ); } void is_003( ) { - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test is(), an invalid case.", sal_False == aPipe.is( ) ); @@ -335,8 +336,8 @@ namespace osl_Pipe { const Security rSec; ::osl::Pipe aPipe; - bRes = aPipe.create( aTestPipeName, osl_Pipe_CREATE, rSec ); - bRes1 = aPipe.create( aTestPipeName, osl_Pipe_CREATE, rSec ); + bRes = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec ); + bRes1 = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec ); aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", @@ -347,8 +348,8 @@ namespace osl_Pipe { const Security rSec; ::osl::Pipe aPipe, aPipe1; - bRes = aPipe.create( aTestPipeName, osl_Pipe_CREATE, rSec ); - bRes1 = aPipe1.create( aTestPipeName, osl_Pipe_OPEN, rSec ); + bRes = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSec ); + bRes1 = aPipe1.create( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN, rSec ); aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", @@ -358,8 +359,8 @@ namespace osl_Pipe void create_named_001( ) { ::osl::Pipe aPipe; - bRes = aPipe.create( aTestPipeName, osl_Pipe_CREATE ); - bRes1 = aPipe.create( aTestPipeName, osl_Pipe_CREATE ); + bRes = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); + bRes1 = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation.", @@ -369,8 +370,8 @@ namespace osl_Pipe void create_named_002( ) { ::osl::Pipe aPipe, aPipe1; - bRes = aPipe.create( aTestPipeName, osl_Pipe_CREATE ); - bRes1 = aPipe1.create( aTestPipeName, osl_Pipe_OPEN ); + bRes = aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); + bRes1 = aPipe1.create( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN ); aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test creation and open.", @@ -380,7 +381,7 @@ namespace osl_Pipe void create_named_003( ) { ::osl::Pipe aPipe; - bRes = aPipe.create( aTestPipeName ); + bRes = aPipe.create( test::uniquePipeName(aTestPipeName) ); aPipe.clear( ); CPPUNIT_ASSERT_MESSAGE( "#test comment#: test default option is open.", @@ -408,7 +409,7 @@ namespace osl_Pipe void clear_001( ) { ::osl::Pipe aPipe; - aPipe.create( aTestPipeName, osl_Pipe_CREATE ); + aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); aPipe.clear( ); bRes = aPipe.is( ); @@ -434,7 +435,7 @@ namespace osl_Pipe void assign_ref( ) { ::osl::Pipe aPipe, aPipe1; - aPipe.create( aTestPipeName, osl_Pipe_CREATE ); + aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); aPipe1 = aPipe; bRes = aPipe1.is( ); bRes1 = aPipe == aPipe1; @@ -448,7 +449,7 @@ namespace osl_Pipe void assign_handle( ) { ::osl::Pipe aPipe, aPipe1; - aPipe.create( aTestPipeName, osl_Pipe_CREATE ); + aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); aPipe1 = aPipe.getHandle( ); bRes = aPipe1.is( ); bRes1 = aPipe == aPipe1; @@ -498,7 +499,7 @@ namespace osl_Pipe void isEqual_001( ) { ::osl::Pipe aPipe; - aPipe.create( aTestPipeName, osl_Pipe_CREATE ); + aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); bRes = aPipe == aPipe; aPipe.close( ); @@ -509,10 +510,10 @@ namespace osl_Pipe void isEqual_002( ) { ::osl::Pipe aPipe, aPipe1, aPipe2; - aPipe.create( aTestPipeName, osl_Pipe_CREATE ); + aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); aPipe1 = aPipe; - aPipe2.create( aTestPipeName, osl_Pipe_CREATE ); + aPipe2.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); bRes = aPipe == aPipe1; bRes1 = aPipe == aPipe2; @@ -541,7 +542,7 @@ namespace osl_Pipe void close_001( ) { - ::osl::Pipe aPipe( aTestPipe1, osl_Pipe_CREATE ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipe1), osl_Pipe_CREATE ); aPipe.close( ); bRes = aPipe.is( ); @@ -554,7 +555,7 @@ namespace osl_Pipe void close_002( ) { - ::osl::StreamPipe aPipe( aTestPipe1, osl_Pipe_CREATE ); + ::osl::StreamPipe aPipe( test::uniquePipeName(aTestPipe1), osl_Pipe_CREATE ); aPipe.close( ); int nRet = aPipe.send( m_pTestString1.getStr(), 3 ); @@ -622,7 +623,7 @@ namespace osl_Pipe void getError_001( ) { - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_OPEN ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN ); oslPipeError nError = aPipe.getError( ); printPipeError( aPipe ); aPipe.clear( ); @@ -633,8 +634,8 @@ namespace osl_Pipe void getError_002( ) { - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); - ::osl::Pipe aPipe1( aTestPipeName, osl_Pipe_CREATE ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); + ::osl::Pipe aPipe1( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); oslPipeError nError = aPipe.getError( ); printPipeError( aPipe ); aPipe.clear( ); @@ -661,7 +662,7 @@ namespace osl_Pipe void getHandle_001( ) { - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_OPEN ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN ); bRes = aPipe == aPipe.getHandle( ); aPipe.clear( ); @@ -671,7 +672,7 @@ namespace osl_Pipe void getHandle_002( ) { - ::osl::Pipe aPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); ::osl::Pipe aPipe1( aPipe.getHandle( ) ); bRes = aPipe == aPipe1; aPipe.clear( ); @@ -724,7 +725,7 @@ namespace osl_StreamPipe void ctors_none( ) { // create a pipe. - ::osl::StreamPipe aStreamPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); // create an unattached pipe. ::osl::StreamPipe aStreamPipe1; bRes = aStreamPipe1.is( ); @@ -742,7 +743,7 @@ namespace osl_StreamPipe void ctors_handle( ) { // create a pipe. - ::osl::StreamPipe aStreamPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); // create a pipe with last handle. ::osl::StreamPipe aStreamPipe1( aStreamPipe.getHandle( ) ); bRes = aStreamPipe1.is( ) && aStreamPipe == aStreamPipe1; @@ -756,7 +757,7 @@ namespace osl_StreamPipe void ctors_copy( ) { // create a pipe. - ::osl::StreamPipe aStreamPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); // create an unattached pipe. ::osl::StreamPipe aStreamPipe1( aStreamPipe ); bRes = aStreamPipe1.is( ) && aStreamPipe == aStreamPipe1; @@ -770,9 +771,9 @@ namespace osl_StreamPipe void ctors_name_option( ) { // create a pipe. - ::osl::StreamPipe aStreamPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); // create an unattached pipe. - ::osl::StreamPipe aStreamPipe1( aTestPipeName, osl_Pipe_OPEN ); + ::osl::StreamPipe aStreamPipe1( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN ); bRes = aStreamPipe1.is( ) && aStreamPipe.is( ); aStreamPipe.clear( ); aStreamPipe1.clear( ); @@ -785,7 +786,7 @@ namespace osl_StreamPipe { /// create a security pipe. const ::osl::Security rSecurity; - ::osl::StreamPipe aSecurityPipe( aTestPipeName, osl_Pipe_CREATE, rSecurity ); + ::osl::StreamPipe aSecurityPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE, rSecurity ); bRes = aSecurityPipe.is( ); aSecurityPipe.clear( ); @@ -807,7 +808,7 @@ namespace osl_StreamPipe void ctors_no_acquire( ) { // create a pipe. - ::osl::StreamPipe aPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::StreamPipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); // constructs a pipe reference without acquiring the handle. ::osl::StreamPipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE ); @@ -844,7 +845,7 @@ namespace osl_StreamPipe void assign_ref( ) { ::osl::StreamPipe aPipe, aPipe1; - aPipe.create( aTestPipeName, osl_Pipe_CREATE ); + aPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); aPipe1 = aPipe; bRes = aPipe1.is( ); bRes1 = aPipe == aPipe1; @@ -857,7 +858,7 @@ namespace osl_StreamPipe void assign_handle( ) { - ::osl::StreamPipe * pPipe = new ::osl::StreamPipe( aTestPipeName, osl_Pipe_CREATE ); + ::osl::StreamPipe * pPipe = new ::osl::StreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); ::osl::StreamPipe * pAssignPipe = new ::osl::StreamPipe; *pAssignPipe = pPipe->getHandle( ); @@ -912,7 +913,7 @@ namespace osl_StreamPipe sal_Int32 nChars = 0; printf("open pipe\n"); - ::osl::StreamPipe aSenderPipe( aTestPipeName, osl_Pipe_OPEN ); // aTestPipeName is a string = "TestPipe" + ::osl::StreamPipe aSenderPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_OPEN ); // test::uniquePipeName(aTestPipeName) is a string = "TestPipe" if ( aSenderPipe.is() == sal_False ) { printf("pipe open failed! \n"); @@ -945,13 +946,13 @@ namespace osl_StreamPipe { public: sal_Char buf[256]; - //::osl::StreamPipe aListenPipe; //( aTestPipeName, osl_Pipe_CREATE ); + //::osl::StreamPipe aListenPipe; //( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); ::osl::Pipe aListenPipe; ::osl::StreamPipe aConnectionPipe; Pipe_DataSource_Thread( ) { printf("create pipe\n"); - aListenPipe.create( aTestPipeName, osl_Pipe_CREATE ); + aListenPipe.create( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); } ~Pipe_DataSource_Thread( ) { @@ -962,7 +963,7 @@ namespace osl_StreamPipe { //create pipe. sal_Int32 nChars; - //::osl::StreamPipe aListenPipe( aTestPipeName, osl_Pipe_CREATE ); + //::osl::StreamPipe aListenPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); printf("listen\n"); if ( aListenPipe.is() == sal_False ) { diff --git a/sal/qa/osl/profile/makefile.mk b/sal/qa/osl/profile/makefile.mk index 8379783e19f6..6f7d3e8d34cf 100644 --- a/sal/qa/osl/profile/makefile.mk +++ b/sal/qa/osl/profile/makefile.mk @@ -33,7 +33,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_osl_profile -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/osl/setthreadname/makefile.mk b/sal/qa/osl/setthreadname/makefile.mk new file mode 100644 index 000000000000..f2d9da15c468 --- /dev/null +++ b/sal/qa/osl/setthreadname/makefile.mk @@ -0,0 +1,57 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#***********************************************************************/ + +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE + +PRJ = ..$/..$/.. +PRJNAME = sal +TARGET = qa_osl_setthreadname + +ENABLE_EXCEPTIONS = TRUE + +.INCLUDE: settings.mk + +CFLAGSCXX += $(CPPUNIT_CFLAGS) + +DLLPRE = + +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLO)/test-setthreadname.obj +SHL1RPATH = NONE +SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) +SHL1TARGET = test-setthreadname +SHL1VERSIONMAP = version.map +DEF1NAME = $(SHL1TARGET) + +SLOFILES = $(SHL1OBJS) + +.INCLUDE: target.mk +.INCLUDE: _cppunit.mk + +.END diff --git a/sal/qa/osl/setthreadname/test-setthreadname.cxx b/sal/qa/osl/setthreadname/test-setthreadname.cxx new file mode 100755 index 000000000000..0f0f618395a8 --- /dev/null +++ b/sal/qa/osl/setthreadname/test-setthreadname.cxx @@ -0,0 +1,87 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2011 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_sal.hxx" +#include "sal/config.h" + +#include <cstdlib> +#include <iostream> +#include <limits> + +#include "boost/noncopyable.hpp" +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "osl/thread.hxx" + +namespace { + +class TestThread: public osl::Thread, private boost::noncopyable { +private: + virtual void SAL_CALL run(); +}; + +void TestThread::run() { +#if defined WNT + if (std::getenv("URE_TEST_SETTHREADNAME") != 0) { + // On Windows, setting thread names appears to only take effect when the + // process is being debugged, so attach a debugger now: + std::cout << "set: "; + std::cin.ignore(std::numeric_limits< int >::max(), '\n'); + } +#endif + setName("TestThread"); + if (std::getenv("URE_TEST_SETTHREADNAME") != 0) { + // On Linux, the thread name can now be observed with "ps -L"; on + // Windows with the Microsoft compiler, the thread name can now be + // observed in a debugger. + std::cout << "stop: "; + std::cin.ignore(std::numeric_limits< int >::max(), '\n'); + } +} + +class Test: public CppUnit::TestFixture { +private: + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(test); + CPPUNIT_TEST_SUITE_END(); + + void test(); +}; + +void Test::test() { + TestThread t; + t.create(); + t.join(); +} + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sal/qa/osl/setthreadname/version.map b/sal/qa/osl/setthreadname/version.map new file mode 100644 index 000000000000..ef2ab497cb5e --- /dev/null +++ b/sal/qa/osl/setthreadname/version.map @@ -0,0 +1,34 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2011 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#***********************************************************************/ + +UDK_3_0_0 { + global: + cppunitTestPlugIn; + + local: + *; +}; diff --git a/sal/qa/rtl/crc32/makefile.mk b/sal/qa/rtl/crc32/makefile.mk index b8b33a5cfa46..149e82eb81b7 100755 --- a/sal/qa/rtl/crc32/makefile.mk +++ b/sal/qa/rtl/crc32/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_rtl_crc32 -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/doublelock/makefile.mk b/sal/qa/rtl/doublelock/makefile.mk index 50f65839a6ec..02283c9c1da0 100644 --- a/sal/qa/rtl/doublelock/makefile.mk +++ b/sal/qa/rtl/doublelock/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_rtl_doublelock -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/locale/makefile.mk b/sal/qa/rtl/locale/makefile.mk index 2256a7057eb2..32e1471eecdf 100644 --- a/sal/qa/rtl/locale/makefile.mk +++ b/sal/qa/rtl/locale/makefile.mk @@ -28,8 +28,6 @@ PRJ=..$/..$/.. PRJNAME=sal TARGET=qa_rtl_locale -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/qa/rtl/math/export.exp b/sal/qa/rtl/math/export.exp deleted file mode 100644 index a13529da5876..000000000000 --- a/sal/qa/rtl/math/export.exp +++ /dev/null @@ -1 +0,0 @@ -registerAllTestFunction diff --git a/sal/qa/rtl/math/makefile.mk b/sal/qa/rtl/math/makefile.mk index a978849fd627..ffe8d6444846 100644 --- a/sal/qa/rtl/math/makefile.mk +++ b/sal/qa/rtl/math/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -23,74 +23,33 @@ # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. # -#************************************************************************* -PRJ=..$/..$/.. -INCPRE+= $(PRJ)$/qa$/inc - -PRJNAME=sal -TARGET=rtl_math -# this is removed at the moment because we need some enhancements -# TESTDIR=TRUE +#***********************************************************************/ -ENABLE_EXCEPTIONS=TRUE +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE -# --- Settings ----------------------------------------------------- +PRJ = ../../.. +PRJNAME = sal +TARGET = qa_rtl_profile -.INCLUDE : settings.mk +ENABLE_EXCEPTIONS = TRUE -CFLAGS+= $(LFS_CFLAGS) -CXXFLAGS+= $(LFS_CFLAGS) +.INCLUDE: settings.mk CFLAGSCXX += $(CPPUNIT_CFLAGS) -#----------------------------------- OStringBuffer ----------------------------------- - -SHL1OBJS= \ - $(SLO)$/test_rtl_math.obj - -SHL1TARGET= rtl_math -SHL1STDLIBS= $(SALLIB) $(CPPUNITLIB) - -SHL1IMPLIB= i$(SHL1TARGET) -# SHL1DEF= $(MISC)$/$(SHL1TARGET).def - -DEF1NAME =$(SHL1TARGET) -# DEF1EXPORTFILE= export.exp -SHL1VERSIONMAP = $(PRJ)$/qa$/export.map - -# --- BEGIN -------------------------------------------------------- -SHL2OBJS= \ - $(SLO)$/rtl_math.obj -SHL2TARGET= rtl_math2 -SHL2STDLIBS= $(SALLIB) $(CPPUNITLIB) - -SHL2IMPLIB= i$(SHL2TARGET) -DEF2NAME= $(SHL2TARGET) -SHL2VERSIONMAP = $(PRJ)$/qa$/export.map +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLO)/test-rtl-math.obj +SHL1RPATH = NONE +SHL1STDLIBS = $(CPPUNITLIB) $(SALLIB) +SHL1TARGET = test-rtl-math +SHL1VERSIONMAP = $(PRJ)/qa/export.map +DEF1NAME = $(SHL1TARGET) +SLOFILES = $(SHL1OBJS) - -# # --- BEGIN -------------------------------------------------------- -# LLA: this is an old test, which seems not to work -# sal_setInt64() -# sal_getInt64() -# does not exist. -# -# SHL3OBJS= \ -# $(SLO)$/rtl_old_testint64.obj -# SHL3TARGET= rtl_old_testint64 -# SHL3STDLIBS= $(SALLIB) $(CPPUNITLIB) -# -# SHL3IMPLIB= i$(SHL3TARGET) -# DEF3NAME= $(SHL3TARGET) -# SHL3VERSIONMAP = $(PRJ)$/qa$/export.map -# - -#------------------------------- All object files ------------------------------- -# do this here, so we get right dependencies -# SLOFILES=$(SHL1OBJS) - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk +.INCLUDE: target.mk .INCLUDE : $(PRJ)$/qa$/cppunit_local.mk + +.END
\ No newline at end of file diff --git a/sal/qa/rtl/math/rtl_math.cxx b/sal/qa/rtl/math/rtl_math.cxx deleted file mode 100644 index 3391dbe2784e..000000000000 --- a/sal/qa/rtl/math/rtl_math.cxx +++ /dev/null @@ -1,628 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sal.hxx" -#ifdef WIN32 -// LLA: take a look into Microsofts math.h implementation, why this define is need -#define _USE_MATH_DEFINES -#endif - -#include <math.h> -#include <testshl/simpleheader.hxx> -#include <rtl/math.h> -#include <rtl/string.hxx> - -#include "valueequal.hxx" - -namespace rtl_math -{ - -class test : public CppUnit::TestFixture -{ -public: - // initialise your test code values here. - void setUp() - { - } - - void tearDown() - { - } - - - void equalCheck(double _nResult, double _nExpect) /* throws Exception */ - { - bool bEqualResult = is_double_equal(_nResult, _nExpect); - - rtl::OString sError = "rtl_math_round expected result is wrong should:("; - sError += rtl::OString::valueOf(_nExpect); - sError += ") but is:("; - sError += rtl::OString::valueOf(_nResult); - sError += ")"; - - CPPUNIT_ASSERT_MESSAGE(sError.getStr(), bEqualResult == true); - } - - // insert your test code here. - void round_000() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nValue = M_PI; - double nResult = 0.0; - - nResult = rtl_math_round(nValue, 0, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(3.0)); - - nResult = rtl_math_round(nValue, 2, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(3.14)); - - nResult = rtl_math_round(nValue, 3, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(3.142)); - - nResult = rtl_math_round(nValue, 10, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(3.1415926536)); - } - - // insert your test code here. - void round_001_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(0.2)); - } - - void round_001_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Corrected); - equalCheck(nResult, double(-0.2)); - } -// ----------------------------------------------------------------------------- - void round_002_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(0.1)); - } - - void round_002_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Down); - equalCheck(nResult, double(-0.1)); - } -// ----------------------------------------------------------------------------- - void round_003_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(0.2)); - } - - void round_003_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Up); - equalCheck(nResult, double(-0.2)); - } -// ----------------------------------------------------------------------------- - void round_004_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(0.1)); - } - - void round_004_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Floor); - equalCheck(nResult, double(-0.2)); - } -// ----------------------------------------------------------------------------- - void round_005_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(0.2)); - } - - void round_005_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_Ceiling); - equalCheck(nResult, double(-0.1)); - } -// ----------------------------------------------------------------------------- - void round_006_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(0.2)); - } - - void round_006_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_HalfDown); - equalCheck(nResult, double(-0.2)); - } -// ----------------------------------------------------------------------------- - void round_007_positiv() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(0.1, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.11, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.13, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.14, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.1499999, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.1)); - - nResult = rtl_math_round(0.15, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.151, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.16, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.2)); - - nResult = rtl_math_round(0.199999999, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(0.2)); - } - - void round_007_negativ() - { - // this is demonstration code - // CPPUNIT_ASSERT_MESSAGE("a message", 1 == 1); - - double nResult = 0.0; - - nResult = rtl_math_round(-0.1, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.11, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.13, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.14, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.1499999, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.1)); - - nResult = rtl_math_round(-0.15, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.151, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.16, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.2)); - - nResult = rtl_math_round(-0.19999999999, 1, rtl_math_RoundingMode_HalfUp); - equalCheck(nResult, double(-0.2)); - } - - // Change the following lines only, if you add, remove or rename - // member functions of the current class, - // because these macros are need by auto register mechanism. - - CPPUNIT_TEST_SUITE(test); - CPPUNIT_TEST(round_000); - - CPPUNIT_TEST(round_001_positiv); - CPPUNIT_TEST(round_001_negativ); - - CPPUNIT_TEST(round_002_positiv); - CPPUNIT_TEST(round_002_negativ); - - CPPUNIT_TEST(round_003_positiv); - CPPUNIT_TEST(round_003_negativ); - - CPPUNIT_TEST(round_004_positiv); - CPPUNIT_TEST(round_004_negativ); - - CPPUNIT_TEST(round_005_positiv); - CPPUNIT_TEST(round_005_negativ); - - CPPUNIT_TEST(round_006_positiv); - CPPUNIT_TEST(round_006_negativ); - - CPPUNIT_TEST(round_007_positiv); - CPPUNIT_TEST(round_007_negativ); - - CPPUNIT_TEST_SUITE_END(); -}; // class test - -// ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(rtl_math::test, "rtl_math"); -} // namespace rtl_math - - -// ----------------------------------------------------------------------------- - -// this macro creates an empty function, which will called by the RegisterAllFunctions() -// to let the user the possibility to also register some functions by hand. -NOADDITIONAL; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/rtl/math/rtl_old_testint64.cxx b/sal/qa/rtl/math/rtl_old_testint64.cxx deleted file mode 100644 index 2e17c241a4de..000000000000 --- a/sal/qa/rtl/math/rtl_old_testint64.cxx +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sal.hxx" - -// LLA: -// this file is converted to use with testshl2 -// original was placed in sal/test/textenc.cxx - -// fndef _OSL_DIAGNOSE_H_ -// nclude <osl/diagnose.h> -// #endif - -#include <sal/types.h> - -#define TEST_ENSURE(c, m) CPPUNIT_ASSERT_MESSAGE((m), (c)) - -// #if OSL_DEBUG_LEVEL > 0 -// #define TEST_ENSURE(c, m) OSL_ENSURE(c, m) -// #else -// #define TEST_ENSURE(c, m) OSL_VERIFY(c) -// #endif - -#include <testshl/simpleheader.hxx> - -// ----------------------------------------------------------------------------- -namespace rtl_math -{ - class int64 : public CppUnit::TestFixture - { - public: - void test_int64(); - - CPPUNIT_TEST_SUITE( int64 ); - CPPUNIT_TEST( test_int64 ); - CPPUNIT_TEST_SUITE_END( ); - }; - -void int64::test_int64() -{ -#ifndef SAL_INT64_IS_STRUCT -#ifdef UNX - sal_Int64 i1 = -3223372036854775807LL; - sal_uInt64 u1 = 5223372036854775807ULL; -#else - sal_Int64 i1 = -3223372036854775807; - sal_uInt64 u1 = 5223372036854775807; -#endif - sal_Int64 i2 = 0; - sal_uInt64 u2 = 0; -#else - sal_Int64 i1; - sal_setInt64(&i1, 3965190145L, -750499787L); - - sal_Int64 i2 = { 0, 0 }; - - sal_uInt64 u1; - sal_setUInt64(&u1, 1651507199UL, 1216161073UL); - - sal_uInt64 u2 = {0, 0 }; - -#endif - sal_uInt32 low = 0; - sal_Int32 high = 0; - - sal_getInt64(i1, &low, &high); - sal_setInt64(&i2, low, high); - - sal_uInt32 ulow = 0; - sal_uInt32 uhigh = 0; - - sal_getUInt64(u1, &ulow, &uhigh); - sal_setUInt64(&u2, ulow, uhigh); - -#ifndef SAL_INT64_IS_STRUCT - TEST_ENSURE( i1 == i2, "test_int64 error 1"); - - TEST_ENSURE( u1 == u2, "test_int64 error 2"); -#else - TEST_ENSURE( (i1.Part1 == i2.Part1) && (i1.Part2 == i2.Part2), - "test_int64 error 1"); - - TEST_ENSURE( (u1.Part1 == u2.Part1) && (u1.Part2 == u2.Part2), - "test_int64 error 2"); -#endif - return; -} - -} // namespace rtl_math - -// ----------------------------------------------------------------------------- -CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( rtl_math::int64, "rtl_math" ); - -// ----------------------------------------------------------------------------- -NOADDITIONAL; - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/rtl/math/test-rtl-math.cxx b/sal/qa/rtl/math/test-rtl-math.cxx new file mode 100644 index 000000000000..8e9875444280 --- /dev/null +++ b/sal/qa/rtl/math/test-rtl-math.cxx @@ -0,0 +1,76 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_sal.hxx" +#include "sal/config.h" + +#include "cppunit/TestAssert.h" +#include "cppunit/TestFixture.h" +#include "cppunit/extensions/HelperMacros.h" +#include "cppunit/plugin/TestPlugIn.h" +#include "rtl/math.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" + +namespace { + +class Test: public CppUnit::TestFixture { +public: + void test_stringToDouble_good() { + rtl_math_ConversionStatus status; + sal_Int32 end; + double res = rtl::math::stringToDouble( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +1.E01foo")), + sal_Unicode('.'), sal_Unicode(','), &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(RTL_CONSTASCII_LENGTH(" +1.E01")), end); + CPPUNIT_ASSERT_EQUAL(10.0, res); + } + + void test_stringToDouble_bad() { + rtl_math_ConversionStatus status; + sal_Int32 end; + double res = rtl::math::stringToDouble( + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(" +Efoo")), + sal_Unicode('.'), sal_Unicode(','), &status, &end); + CPPUNIT_ASSERT_EQUAL(rtl_math_ConversionStatus_Ok, status); + CPPUNIT_ASSERT_EQUAL(sal_Int32(0), end); + CPPUNIT_ASSERT_EQUAL(0.0, res); + } + + CPPUNIT_TEST_SUITE(Test); + CPPUNIT_TEST(test_stringToDouble_good); + CPPUNIT_TEST(test_stringToDouble_bad); + CPPUNIT_TEST_SUITE_END(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(Test); + +} + +CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sal/qa/rtl/math/test_rtl_math.cxx b/sal/qa/rtl/math/test_rtl_math.cxx deleted file mode 100644 index e81e4a12fcb4..000000000000 --- a/sal/qa/rtl/math/test_rtl_math.cxx +++ /dev/null @@ -1,677 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_sal.hxx" - -#include "rtl/math.h" -#include "rtl/math.hxx" -#include "rtl/strbuf.hxx" -#include "rtl/string.h" -#include "rtl/string.hxx" -#include "rtl/textenc.h" -#include <testshl/tresstatewrapper.hxx> -#include "rtl/ustring.hxx" -#include "sal/types.h" -#include <sal/macros.h> - -#include <stdlib.h> - -namespace { - -struct FloatTraits -{ - typedef float Number; - - static inline char const * getPrefix() { return "float"; } -}; - -struct DoubleTraits -{ - typedef double Number; - - static inline char const * getPrefix() { return "double"; } -}; - -struct StringTraits -{ - typedef rtl::OString String; - - static inline char const * getPrefix() { return "OString"; } - - static inline rtl::OString createFromAscii(char const * pString) - { return rtl::OString(pString); } - - static inline void appendBuffer(rtl::OStringBuffer & rBuffer, - rtl::OString const & rString) - { rBuffer.append(rString); } - - static inline rtl::OString doubleToString(double fValue, - rtl_math_StringFormat eFormat, - sal_Int32 nDecPlaces, - sal_Char cDecSeparator, - bool bEraseTrailingDecZeros) - { - return rtl::math::doubleToString(fValue, eFormat, nDecPlaces, - cDecSeparator, bEraseTrailingDecZeros); - } -}; - -struct UStringTraits -{ - typedef rtl::OUString String; - - static inline char const * getPrefix() { return "OUString"; } - - static inline rtl::OUString createFromAscii(char const * pString) - { return rtl::OUString::createFromAscii(pString); } - - static inline void appendBuffer(rtl::OStringBuffer & rBuffer, - rtl::OUString const & rString) - { rBuffer.append(rtl::OUStringToOString(rString, RTL_TEXTENCODING_UTF8)); } - - static inline rtl::OUString doubleToString(double fValue, - rtl_math_StringFormat eFormat, - sal_Int32 nDecPlaces, - sal_Unicode cDecSeparator, - bool bEraseTrailingDecZeros) - { - return rtl::math::doubleToUString(fValue, eFormat, nDecPlaces, - cDecSeparator, - bEraseTrailingDecZeros); - } -}; - -struct TestNumberToString -{ - double fValue; - rtl_math_StringFormat eFormat; - sal_Int32 nDecPlaces; - char cDecSeparator; - bool bEraseTrailingDecZeros; - char const * pResult; -}; - -template< typename StringT, typename NumberT > -bool testNumberToString(hTestResult pTestResult, - TestNumberToString const & rTest) -{ - typename NumberT::Number fValue = static_cast< typename NumberT::Number >(rTest.fValue); - if (fValue != rTest.fValue) - return true; - - // LLA: t_print("size: %d ", sizeof(fValue)); - typename StringT::String aResult1; - - aResult1 = StringT::doubleToString(fValue, rTest.eFormat, rTest.nDecPlaces, - rTest.cDecSeparator, - rTest.bEraseTrailingDecZeros); - - typename StringT::String aResult2(StringT::createFromAscii(rTest.pResult)); - - // LLA: rtl::OStringBuffer aBuf; - // LLA: StringT::appendBuffer(aBuf, aResult1); - // LLA: t_print("aResult1: %s ", aBuf.getStr()); - // LLA: - // LLA: rtl::OStringBuffer aBuf2; - // LLA: StringT::appendBuffer(aBuf2, aResult2); - // LLA: t_print("aResult2: %s\n", aBuf2.getStr()); - - bool bSuccess = aResult1 == aResult2; - - rtl::OStringBuffer aBuffer; - aBuffer.append(StringT::getPrefix()); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM("/")); - aBuffer.append(NumberT::getPrefix()); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(" doubleToString(")); - aBuffer.append(fValue); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(static_cast< sal_Int32 >(rTest.eFormat)); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.nDecPlaces); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.cDecSeparator); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(static_cast< sal_Int32 >(rTest.bEraseTrailingDecZeros)); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM("): ")); - StringT::appendBuffer(aBuffer, aResult1); - if (!bSuccess) - { - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(" != ")); - StringT::appendBuffer(aBuffer, aResult2); - } - // call to the real test checker - // pTestResult->pFuncs->state_(pTestResult, bSuccess, "test_rtl_math", - // aBuffer.getStr(), false); - c_rtl_tres_state(pTestResult, bSuccess, aBuffer.getStr(), "testNumberToString"); - return bSuccess; -} - -template< typename StringT, typename NumberT > -bool testNumberToString(hTestResult pTestResult, - TestNumberToString const * pTests, size_t nCount) -{ - bool bSuccess = true; - for (size_t i = 0; i < nCount; ++i) - bSuccess &= testNumberToString< StringT, NumberT >(pTestResult, - pTests[i]); - return bSuccess; -} - -struct TestStringToNumberToString -{ - char const * pValue; - rtl_math_StringFormat eFormat; - sal_Int32 nDecPlaces; - char cDecSeparator; - bool bEraseTrailingDecZeros; - char const * pResult; -}; - -template< typename StringT > -bool testStringToNumberToString(hTestResult pTestResult, - TestStringToNumberToString const & rTest) -{ - double d = rtl::math::stringToDouble(StringT::createFromAscii(rTest.pValue), - rTest.cDecSeparator, 0, 0, 0); - typename StringT::String aResult1( - StringT::doubleToString(d, rTest.eFormat, rTest.nDecPlaces, - rTest.cDecSeparator, - rTest.bEraseTrailingDecZeros)); - typename StringT::String aResult2(StringT::createFromAscii(rTest.pResult)); - bool bSuccess = aResult1 == aResult2; - rtl::OStringBuffer aBuffer; - aBuffer.append(StringT::getPrefix()); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM( - " doubleToString(stringToDouble(")); - aBuffer.append(rTest.pValue); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.cDecSeparator); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM("), ")); - aBuffer.append(static_cast< sal_Int32 >(rTest.eFormat)); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.nDecPlaces); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(rTest.cDecSeparator); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(", ")); - aBuffer.append(static_cast< sal_Int32 >(rTest.bEraseTrailingDecZeros)); - aBuffer.append(RTL_CONSTASCII_STRINGPARAM("): ")); - StringT::appendBuffer(aBuffer, aResult1); - if (!bSuccess) - { - aBuffer.append(RTL_CONSTASCII_STRINGPARAM(" != ")); - StringT::appendBuffer(aBuffer, aResult2); - } - // call to the real test checker - // pTestResult->pFuncs->state_(pTestResult, bSuccess, "test_rtl_math", - // aBuffer.getStr(), false); - c_rtl_tres_state(pTestResult, bSuccess, aBuffer.getStr(), "testStringToNumberToString"); - - return bSuccess; -} - -template< typename StringT > -bool testStringToNumberToString(hTestResult pTestResult, - TestStringToNumberToString const * pTests, - size_t nCount) -{ - bool bSuccess = true; - for (size_t i = 0; i < nCount; ++i) - bSuccess &= testStringToNumberToString< StringT >(pTestResult, - pTests[i]); - return bSuccess; -} - -} - -extern "C" sal_Bool SAL_CALL test_rtl_math(hTestResult pTestResult) -{ - bool bReturn = true; - - { - static TestNumberToString const aTest[] - = { // 1, 1+2^-1, ..., 1+2^-52 - // Too few decimal digits are printed, so that various different - // double values lead to the same output: - { 1, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { 1.5, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.5" }, - { 1.25, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.25" }, - { 1.125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.125" }, - { 1.0625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.0625" }, - { 1.03125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.03125" }, - { 1.015625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.015625" }, - { 1.0078125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.0078125" }, - { 1.00390625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00390625" }, - { 1.001953125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.001953125" }, - { 1.0009765625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.0009765625" }, - { 1.00048828125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00048828125" }, - { 1.000244140625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.000244140625" }, - { 1.0001220703125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.0001220703125" }, - { 1.00006103515625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00006103515625" }, - { 1.000030517578125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00003051757813" }, - { 1.0000152587890625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00001525878906" }, - { 1.00000762939453125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000762939453" }, - { 1.000003814697265625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000381469727" }, - { 1.0000019073486328125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000190734863" }, - { 1.00000095367431640625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000095367432" }, - { 1.000000476837158203125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000047683716" }, - { 1.0000002384185791015625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000023841858" }, - { 1.00000011920928955078125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000011920929" }, - { 1.000000059604644775390625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000005960464" }, - { 1.0000000298023223876953125, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000002980232" }, - { 1.00000001490116119384765625, rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1.00000001490116" }, - { 1.000000007450580596923828125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000745058" }, - { 1.0000000037252902984619140625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000372529" }, - { 1.00000000186264514923095703125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000186265" }, - { 1.000000000931322574615478515625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000093132" }, - { 1.0000000004656612873077392578125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000046566" }, - { 1.00000000023283064365386962890625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000023283" }, - { 1.000000000116415321826934814453125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000011642" }, - { 1.0000000000582076609134674072265625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000005821" }, - { 1.00000000002910383045673370361328125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.0000000000291" }, - { 1.000000000014551915228366851806640625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000001455" }, - { 1.0000000000072759576141834259033203125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000728" }, - { 1.00000000000363797880709171295166015625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000364" }, - { 1.000000000001818989403545856475830078125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000182" }, - { 1.0000000000009094947017729282379150390625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000091" }, - { 1.00000000000045474735088646411895751953125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000045" }, - { 1.000000000000227373675443232059478759765625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000023" }, - { 1.0000000000001136868377216160297393798828125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000011" }, - { 1.00000000000005684341886080801486968994140625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000006" }, - { 1.000000000000028421709430404007434844970703125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000003" }, - { 1.0000000000000142108547152020037174224853515625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000001" }, - { 1.00000000000000710542735760100185871124267578125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1.00000000000001" }, - { 1.000000000000003552713678800500929355621337890625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - { 1.0000000000000017763568394002504646778106689453125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - { 1.00000000000000088817841970012523233890533447265625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - { 1.000000000000000444089209850062616169452667236328125, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - { 1.0000000000000002220446049250313080847263336181640625, - rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max, - '.', true, "1" }, - - // 1, 1+2^-1, ..., 1+2^-52 - // Too few decimal digits are printed, so that various different - // double values lead to the same output: - { 1, rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.5, rtl_math_StringFormat_F, 53, '.', false, - "1.50000000000000000000000000000000000000000000000000000" }, - { 1.25, rtl_math_StringFormat_F, 53, '.', false, - "1.25000000000000000000000000000000000000000000000000000" }, - { 1.125, rtl_math_StringFormat_F, 53, '.', false, - "1.12500000000000000000000000000000000000000000000000000" }, - { 1.0625, rtl_math_StringFormat_F, 53, '.', false, - "1.06250000000000000000000000000000000000000000000000000" }, - { 1.03125, rtl_math_StringFormat_F, 53, '.', false, - "1.03125000000000000000000000000000000000000000000000000" }, - { 1.015625, rtl_math_StringFormat_F, 53, '.', false, - "1.01562500000000000000000000000000000000000000000000000" }, - { 1.0078125, rtl_math_StringFormat_F, 53, '.', false, - "1.00781250000000000000000000000000000000000000000000000" }, - { 1.00390625, rtl_math_StringFormat_F, 53, '.', false, - "1.00390625000000000000000000000000000000000000000000000" }, - { 1.001953125, rtl_math_StringFormat_F, 53, '.', false, - "1.00195312500000000000000000000000000000000000000000000" }, - { 1.0009765625, rtl_math_StringFormat_F, 53, '.', false, - "1.00097656250000000000000000000000000000000000000000000" }, - { 1.00048828125, rtl_math_StringFormat_F, 53, '.', false, - "1.00048828125000000000000000000000000000000000000000000" }, - { 1.000244140625, rtl_math_StringFormat_F, 53, '.', false, - "1.00024414062500000000000000000000000000000000000000000" }, - { 1.0001220703125, rtl_math_StringFormat_F, 53, '.', false, - "1.00012207031250000000000000000000000000000000000000000" }, - { 1.00006103515625, rtl_math_StringFormat_F, 53, '.', false, - "1.00006103515625000000000000000000000000000000000000000" }, - { 1.000030517578125, rtl_math_StringFormat_F, 53, '.', false, - "1.00003051757813000000000000000000000000000000000000000" }, - { 1.0000152587890625, rtl_math_StringFormat_F, 53, '.', false, - "1.00001525878906000000000000000000000000000000000000000" }, - { 1.00000762939453125, rtl_math_StringFormat_F, 53, '.', false, - "1.00000762939453000000000000000000000000000000000000000" }, - { 1.000003814697265625, rtl_math_StringFormat_F, 53, '.', false, - "1.00000381469727000000000000000000000000000000000000000" }, - { 1.0000019073486328125, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000190734863000000000000000000000000000000000000000" }, - { 1.00000095367431640625, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000095367432000000000000000000000000000000000000000" }, - { 1.000000476837158203125, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000047683716000000000000000000000000000000000000000" }, - { 1.0000002384185791015625, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000023841858000000000000000000000000000000000000000" }, - { 1.00000011920928955078125, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000011920929000000000000000000000000000000000000000" }, - { 1.000000059604644775390625, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000005960464000000000000000000000000000000000000000" }, - { 1.0000000298023223876953125, rtl_math_StringFormat_F, 53, '.', - false, - "1.00000002980232000000000000000000000000000000000000000" }, - { 1.00000001490116119384765625, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000001490116000000000000000000000000000000000000000" }, - { 1.000000007450580596923828125, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000000745058000000000000000000000000000000000000000" }, - { 1.0000000037252902984619140625, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000000372529000000000000000000000000000000000000000" }, - { 1.00000000186264514923095703125, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000000186265000000000000000000000000000000000000000" }, - { 1.000000000931322574615478515625, rtl_math_StringFormat_F, 53, - '.', false, - "1.00000000093132000000000000000000000000000000000000000" }, - { 1.0000000004656612873077392578125, rtl_math_StringFormat_F, - 53, '.', false, - "1.00000000046566000000000000000000000000000000000000000" }, - { 1.00000000023283064365386962890625, rtl_math_StringFormat_F, - 53, '.', false, - "1.00000000023283000000000000000000000000000000000000000" }, - { 1.000000000116415321826934814453125, rtl_math_StringFormat_F, - 53, '.', false, - "1.00000000011642000000000000000000000000000000000000000" }, - { 1.0000000000582076609134674072265625, rtl_math_StringFormat_F, - 53, '.', false, - "1.00000000005821000000000000000000000000000000000000000" }, - { 1.00000000002910383045673370361328125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000002910000000000000000000000000000000000000000" }, - { 1.000000000014551915228366851806640625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000001455000000000000000000000000000000000000000" }, - { 1.0000000000072759576141834259033203125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000728000000000000000000000000000000000000000" }, - { 1.00000000000363797880709171295166015625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000364000000000000000000000000000000000000000" }, - { 1.000000000001818989403545856475830078125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000182000000000000000000000000000000000000000" }, - { 1.0000000000009094947017729282379150390625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000091000000000000000000000000000000000000000" }, - { 1.00000000000045474735088646411895751953125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000045000000000000000000000000000000000000000" }, - { 1.000000000000227373675443232059478759765625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000023000000000000000000000000000000000000000" }, - { 1.0000000000001136868377216160297393798828125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000011000000000000000000000000000000000000000" }, - { 1.00000000000005684341886080801486968994140625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000006000000000000000000000000000000000000000" }, - { 1.000000000000028421709430404007434844970703125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000003000000000000000000000000000000000000000" }, - { 1.0000000000000142108547152020037174224853515625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000001000000000000000000000000000000000000000" }, - { 1.00000000000000710542735760100185871124267578125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000001000000000000000000000000000000000000000" }, - { 1.000000000000003552713678800500929355621337890625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.0000000000000017763568394002504646778106689453125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.00000000000000088817841970012523233890533447265625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.000000000000000444089209850062616169452667236328125, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" }, - { 1.0000000000000002220446049250313080847263336181640625, - rtl_math_StringFormat_F, 53, '.', false, - "1.00000000000000000000000000000000000000000000000000000" } }; - size_t const nCount = SAL_N_ELEMENTS(aTest); - -//LLA: the float tests are wrong here, due to the fact that -// we calculate with too less digits after the point - -// bReturn &= testNumberToString< StringTraits, FloatTraits >( -// pTestResult, aTest, nCount); - bReturn &= testNumberToString< StringTraits, DoubleTraits >( - pTestResult, aTest, nCount); -// bReturn &= testNumberToString< UStringTraits, FloatTraits >( -// pTestResult, aTest, nCount); - bReturn &= testNumberToString< UStringTraits, DoubleTraits >( - pTestResult, aTest, nCount); - } - - { - static TestStringToNumberToString const aTest[] - = { { "1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { " 1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { " 1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { "\t1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { "\t 1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - { " \t1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "1" }, - - { "-1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { " -1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { " -1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { "\t-1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { "\t -1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - { " \t-1", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', true, "-1" }, - - { "1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { " 1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { " 1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { "\t1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { "\t 1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - { " \t1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#INF" }, - - { "-1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { " -1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { " -1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { "\t-1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { "\t -1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - { " \t-1.#INF", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#INF" }, - - { "1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { " 1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { " 1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { "\t1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { "\t 1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - { " \t1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "1.#NAN" }, - - { "-1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { " -1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { " -1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { "\t-1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { "\t -1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - { " \t-1.#NAN", rtl_math_StringFormat_Automatic, - rtl_math_DecimalPlaces_Max, '.', false, "-1.#NAN" }, - - { "3.14E-2000", rtl_math_StringFormat_E, 4, '.', false, - "0.0000E+000" }, - { "3.14E-200", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E-200" }, - { "3.14E-20", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E-020" }, - { "3.14E-2", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E-002" }, - { "3.14E2", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E+002" }, - { "3.14E20", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E+020" }, - { "3.14E200", rtl_math_StringFormat_E, 4, '.', false, - "3.1400E+200" }, - { "3.14E2000", rtl_math_StringFormat_E, 4, '.', false, - "1.#INF" }, - }; - size_t const nCount = SAL_N_ELEMENTS(aTest); - bReturn &= testStringToNumberToString< StringTraits >( - pTestResult, aTest, nCount); - bReturn &= testStringToNumberToString< UStringTraits >( - pTestResult, aTest, nCount); - } - - return bReturn; -} - -// ----------------------------------------------------------------------------- -extern "C" void /* sal_Bool */ SAL_CALL test_rtl_math2( hTestResult hRtlTestResult ) -{ - c_rtl_tres_state_start(hRtlTestResult, "rtl_math" ); - - test_rtl_math( hRtlTestResult ); - - c_rtl_tres_state_end(hRtlTestResult, "rtl_math" ); -} -// ----------------------------------------------------------------------------- -void RegisterAdditionalFunctions(FktRegFuncPtr _pFunc) -{ - if (_pFunc) - { - (_pFunc)(&test_rtl_math2, ""); - } -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sal/qa/rtl_strings/makefile.mk b/sal/qa/rtl_strings/makefile.mk index ceb465aa169d..b319fbf6845b 100644 --- a/sal/qa/rtl_strings/makefile.mk +++ b/sal/qa/rtl_strings/makefile.mk @@ -28,7 +28,6 @@ PRJ=..$/.. PRJNAME=sal TARGET=qa_rtl_strings -# TESTDIR=TRUE ENABLE_EXCEPTIONS=TRUE diff --git a/sal/rtl/source/math.cxx b/sal/rtl/source/math.cxx index 8f949b3bf3d8..1aee95642936 100644 --- a/sal/rtl/source/math.cxx +++ b/sal/rtl/source/math.cxx @@ -924,7 +924,7 @@ inline double stringToDouble(CharT const * pBegin, CharT const * pEnd, if (pStatus != 0) *pStatus = eStatus; if (pParsedEnd != 0) - *pParsedEnd = p; + *pParsedEnd = p == p0 ? pBegin : p; return fVal; } diff --git a/sal/systools/win32/uwinapi/ResolveUnicows.cpp b/sal/systools/win32/uwinapi/ResolveUnicows.cpp index 5684cd5f8683..d38e75063ccf 100644 --- a/sal/systools/win32/uwinapi/ResolveUnicows.cpp +++ b/sal/systools/win32/uwinapi/ResolveUnicows.cpp @@ -2,6 +2,7 @@ #ifdef __MINGW32__ #define _GDI32_ #include "macros.h" +#include <w32api.h> #include <multimon.h> extern "C" { extern HMODULE hModuleUnicowsDLL; @@ -462,7 +463,11 @@ DEFINE_UNICOWS_THUNK( kernel32, BOOL, WINAPI, UpdateResourceW, (HANDLE,LPCWSTR,L DEFINE_UNICOWS_THUNK( version, DWORD, WINAPI, VerFindFileW, (DWORD,LPWSTR,LPWSTR,LPWSTR,LPWSTR,PUINT,LPWSTR,PUINT) ) DEFINE_UNICOWS_THUNK( version, DWORD, WINAPI, VerInstallFileW, (DWORD,LPWSTR,LPWSTR,LPWSTR,LPWSTR,LPWSTR,LPWSTR,PUINT) ) DEFINE_UNICOWS_THUNK( kernel32, DWORD, WINAPI, VerLanguageNameW, (DWORD,LPWSTR,DWORD) ) +#if ( __W32API_MAJOR_VERSION > 3 ) || ( __W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION > 13 ) +DEFINE_UNICOWS_THUNK( version, BOOL, WINAPI, VerQueryValueW, (const LPVOID,LPCWSTR,LPVOID*,PUINT) ) +#else DEFINE_UNICOWS_THUNK( version, BOOL, WINAPI, VerQueryValueW, (const LPVOID,LPWSTR,LPVOID*,PUINT) ) +#endif DEFINE_UNICOWS_THUNK( user32, SHORT, WINAPI, VkKeyScanExW, (WCHAR,HKL) ) DEFINE_UNICOWS_THUNK( user32, SHORT, WINAPI, VkKeyScanW, (WCHAR) ) DEFINE_UNICOWS_THUNK( user32, DWORD, WINAPI, SetupDecompressOrCopyFileW, (PCWSTR,PCWSTR,PUINT) ) diff --git a/sal/util/sal.map b/sal/util/sal.map index 8b1c079ec899..73ae4431100e 100755 --- a/sal/util/sal.map +++ b/sal/util/sal.map @@ -602,6 +602,7 @@ UDK_3.11 { # OOo 3.4 global: osl_setEnvironment; osl_clearEnvironment; + osl_setThreadName; } UDK_3.10; PRIVATE_1.0 { diff --git a/stoc/prj/build.lst b/stoc/prj/build.lst index 1fb7d34eeb32..256f094742f5 100644 --- a/stoc/prj/build.lst +++ b/stoc/prj/build.lst @@ -1,4 +1,4 @@ -tc stoc : rdbmaker cppuhelper cppu jvmaccess sal salhelper jvmfwk NULL +tc stoc : rdbmaker cppuhelper cppu jvmaccess sal salhelper jvmfwk xmlreader LIBXSTL:libxslt NULL tc stoc usr1 - all tc_mkout NULL tc stoc\inc nmake - all tc_inc NULL tc stoc\source\defaultregistry nmake - all tc_defr tc_boot tc_inc NULL diff --git a/stoc/prj/d.lst b/stoc/prj/d.lst index 1f01434bf58a..79b2d77348b4 100644 --- a/stoc/prj/d.lst +++ b/stoc/prj/d.lst @@ -4,6 +4,16 @@ mkdir: %_DEST%\inc%_EXT%\stoc ..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\* ..\%__SRC%\lib\*.dylib %_DEST%\lib%_EXT%\*.dylib ..\%__SRC%\bin\*.rdb %_DEST%\rdb%_EXT%\* +..\%__SRC%\misc\bootstrap.component %_DEST%\xml%_EXT%\bootstrap.component +..\%__SRC%\misc\introspection.component %_DEST%\xml%_EXT%\introspection.component +..\%__SRC%\misc\invocadapt.component %_DEST%\xml%_EXT%\invocadapt.component +..\%__SRC%\misc\invocation.component %_DEST%\xml%_EXT%\invocation.component +..\%__SRC%\misc\javaloader.component %_DEST%\xml%_EXT%\javaloader.component +..\%__SRC%\misc\javavm.component %_DEST%\xml%_EXT%\javavm.component +..\%__SRC%\misc\namingservice.component %_DEST%\xml%_EXT%\namingservice.component +..\%__SRC%\misc\proxyfac.component %_DEST%\xml%_EXT%\proxyfac.component +..\%__SRC%\misc\reflection.component %_DEST%\xml%_EXT%\reflection.component +..\%__SRC%\misc\stocservices.component %_DEST%\xml%_EXT%\stocservices.component ..\source\module-description.dtd %_DEST%\xml%_EXT%\module-description.dtd ..\source\corereflection\corefl.xml %_DEST%\xml%_EXT%\reflection.uno.xml diff --git a/stoc/source/bootstrap/services.cxx b/stoc/source/bootstrap/services.cxx index 53e9bdcce3aa..5e97e5802c0b 100644 --- a/stoc/source/bootstrap/services.cxx +++ b/stoc/source/bootstrap/services.cxx @@ -132,12 +132,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/stoc/source/corereflection/base.hxx b/stoc/source/corereflection/base.hxx index 405bf773e045..4388ce68c9d4 100644 --- a/stoc/source/corereflection/base.hxx +++ b/stoc/source/corereflection/base.hxx @@ -56,9 +56,6 @@ #include <com/sun/star/reflection/XIdlField2.hpp> #include <com/sun/star/reflection/XIdlMethod.hpp> -#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) ) - - using namespace std; using namespace osl; using namespace cppu; diff --git a/stoc/source/corereflection/crefl.cxx b/stoc/source/corereflection/crefl.cxx index 44655df15c5c..bf62d3e073fb 100644 --- a/stoc/source/corereflection/crefl.cxx +++ b/stoc/source/corereflection/crefl.cxx @@ -31,7 +31,6 @@ #include <cppuhelper/queryinterface.hxx> #include <cppuhelper/implementationentry.hxx> -#include <com/sun/star/registry/XRegistryKey.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/reflection/XTypeDescription.hpp> #include "com/sun/star/uno/RuntimeException.hpp" @@ -182,8 +181,6 @@ void IdlReflectionServiceImpl::dispose() MutexGuard aGuard( _aComponentMutex ); _aElements.clear(); - _xTDMgr.clear(); - _xMgr.clear(); #ifdef TEST_LIST_CLASSES OSL_ENSURE( g_aClassNames.size() == 0, "### idl classes still alive!" ); ClassNameList::const_iterator iPos( g_aClassNames.begin() ); @@ -511,35 +508,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - if (component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries )) - { - try - { - // register singleton - registry::XRegistryKey * pKey = - reinterpret_cast< registry::XRegistryKey * >( pRegistryKey ); - Reference< registry::XRegistryKey > xKey( - pKey->createKey( - OUSTR(IMPLNAME "/UNO/SINGLETONS/com.sun.star.reflection.theCoreReflection") ) ); - xKey->setStringValue( OUSTR("com.sun.star.reflection.CoreReflection") ); - return sal_True; - } - catch (Exception & exc) - { -#if OSL_DEBUG_LEVEL > 0 - OString cstr( OUStringToOString( exc.Message, RTL_TEXTENCODING_ASCII_US ) ); - OSL_ENSURE( 0, cstr.getStr() ); -#else - (void) exc; // unused -#endif - } - } - return sal_False; -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/stoc/source/corereflection/lrucache.hxx b/stoc/source/corereflection/lrucache.hxx index 4e44d537cdcf..35765ef43c8f 100644 --- a/stoc/source/corereflection/lrucache.hxx +++ b/stoc/source/corereflection/lrucache.hxx @@ -178,9 +178,9 @@ template< class t_Key, class t_Val, class t_KeyHash, class t_KeyEqual > inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::setValue( const t_Key & rKey, const t_Val & rValue ) { + ::osl::MutexGuard aGuard( _aCacheMutex ); if (_nCachedElements > 0) { - ::osl::MutexGuard aGuard( _aCacheMutex ); const typename t_Key2Element::const_iterator iFind( _aKey2Element.find( rKey ) ); CacheEntry * pEntry; @@ -222,6 +222,7 @@ inline void LRU_Cache< t_Key, t_Val, t_KeyHash, t_KeyEqual >::clear() _pBlock[nPos].aKey = t_Key(); _pBlock[nPos].aVal = t_Val(); } + _nCachedElements = 0; #ifdef __CACHE_DIAGNOSE OSL_TRACE( "> cleared cache <\n" ); #endif diff --git a/stoc/source/corereflection/makefile.mk b/stoc/source/corereflection/makefile.mk index b61eb13aa9ee..7156f6d63cc4 100644 --- a/stoc/source/corereflection/makefile.mk +++ b/stoc/source/corereflection/makefile.mk @@ -73,3 +73,10 @@ DEF1NAME= $(SHL1TARGET) .INCLUDE : target.mk +ALLTAR : $(MISC)/reflection.component + +$(MISC)/reflection.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + reflection.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt reflection.component diff --git a/stoc/source/corereflection/reflection.component b/stoc/source/corereflection/reflection.component new file mode 100644 index 000000000000..00772a448367 --- /dev/null +++ b/stoc/source/corereflection/reflection.component @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.CoreReflection"> + <service name="com.sun.star.reflection.CoreReflection"/> + <singleton name="com.sun.star.reflection.theCoreReflection"/> + </implementation> +</component> diff --git a/stoc/source/implementationregistration/implreg.cxx b/stoc/source/implementationregistration/implreg.cxx index 01f4df8b3552..9c91c43a0e5f 100644 --- a/stoc/source/implementationregistration/implreg.cxx +++ b/stoc/source/implementationregistration/implreg.cxx @@ -606,9 +606,9 @@ static void deleteUserLink(const Reference < XRegistryKey >& xRootKey, } else { oldImpl = implEntries.getConstArray()[0]; - + rtl::OUString path(xOldKey->getKeyName()); xOldKey->closeKey(); - xRootKey->deleteKey(xOldKey->getKeyName()); + xRootKey->deleteKey(path); } OUString oldTarget = searchLinkTargetForImpl(xRootKey, linkName, oldImpl); @@ -622,8 +622,9 @@ static void deleteUserLink(const Reference < XRegistryKey >& xRootKey, { bClean = sal_True; hasNoImplementations = sal_False; + rtl::OUString path(xOldKey->getKeyName()); xOldKey->closeKey(); - xRootKey->deleteKey(xOldKey->getKeyName()); + xRootKey->deleteKey(path); } } } else @@ -784,21 +785,24 @@ static void deleteAllImplementations( const Reference < XSimpleRegistry >& xRe if (hasLocationUrl) { hasLocationUrl = sal_False; + rtl::OUString path(xImplKey->getKeyName()); xImplKey->closeKey(); - xReg->getRootKey()->deleteKey(xImplKey->getKeyName()); + xReg->getRootKey()->deleteKey(path); } } subKeys = xSource->openKeys(); if (subKeys.getLength() == 0) { + rtl::OUString path(xSource->getKeyName()); xSource->closeKey(); - xReg->getRootKey()->deleteKey(xSource->getKeyName()); + xReg->getRootKey()->deleteKey(path); } } else { + rtl::OUString path(xSource->getKeyName()); xSource->closeKey(); - xReg->getRootKey()->deleteKey(xSource->getKeyName()); + xReg->getRootKey()->deleteKey(path); } } @@ -923,21 +927,24 @@ static void deleteAllServiceEntries( const Reference < XSimpleRegistry >& xRe if (hasNoImplementations) { hasNoImplementations = sal_False; + rtl::OUString path(xServiceKey->getKeyName()); xServiceKey->closeKey(); - xReg->getRootKey()->deleteKey(xServiceKey->getKeyName()); + xReg->getRootKey()->deleteKey(path); } } subKeys = xSource->openKeys(); if (subKeys.getLength() == 0) { + rtl::OUString path(xSource->getKeyName()); xSource->closeKey(); - xReg->getRootKey()->deleteKey(xSource->getKeyName()); + xReg->getRootKey()->deleteKey(path); } } else { + rtl::OUString path(xSource->getKeyName()); xSource->closeKey(); - xReg->getRootKey()->deleteKey(xSource->getKeyName()); + xReg->getRootKey()->deleteKey(path); } } @@ -1122,36 +1129,24 @@ static void prepareRegistry( { // update entries in SERVICES section Sequence< Reference < XRegistryKey > > serviceKeys = xKey->openKeys(); - OUString implName; - - if (serviceKeys.getLength()) - { - const Reference < XRegistryKey > * pServiceKeys = serviceKeys.getConstArray(); - - implName = OUString(xImplKey->getKeyName().getStr() + 1); - sal_Int32 firstDot = implName.indexOf('/'); + const Reference < XRegistryKey > * pServiceKeys = serviceKeys.getConstArray(); - if (firstDot >= 0) - implName = implName.copy(firstDot + 1); + OUString implName = OUString(xImplKey->getKeyName().getStr() + 1); + sal_Int32 firstDot = implName.indexOf('/'); - sal_Int32 offset = xKey->getKeyName().getLength() + 1; - - for (sal_Int32 j = 0; j < serviceKeys.getLength(); j++) - { - OUString serviceName = pServiceKeys[j]->getKeyName().copy(offset); + if (firstDot >= 0) + implName = implName.copy(firstDot + 1); - createUniqueSubEntry( - xDest->getRootKey()->createKey( - pool.slash_SERVICES + serviceName ), - implName); - } + sal_Int32 offset = xKey->getKeyName().getLength() + 1; - } - else + for (sal_Int32 j = 0; j < serviceKeys.getLength(); j++) { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM( "prepareRegistry(): no service names given by component" ) ), - Reference< XInterface > () ); + OUString serviceName = pServiceKeys[j]->getKeyName().copy(offset); + + createUniqueSubEntry( + xDest->getRootKey()->createKey( + pool.slash_SERVICES + serviceName ), + implName); } xKey = xImplKey->openKey( pool.slash_UNO ); @@ -1174,38 +1169,38 @@ static void prepareRegistry( } } } + } - // update LOCATION entry - xKey = xImplKey->createKey( pool.slash_UNO_slash_LOCATION ); + // update LOCATION entry + xKey = xImplKey->createKey( pool.slash_UNO_slash_LOCATION ); - if (xKey.is()) - { - xKey->setAsciiValue(locationUrl); - } + if (xKey.is()) + { + xKey->setAsciiValue(locationUrl); + } - // update ACTIVATOR entry - xKey = xImplKey->createKey( pool.slash_UNO_slash_ACTIVATOR ); + // update ACTIVATOR entry + xKey = xImplKey->createKey( pool.slash_UNO_slash_ACTIVATOR ); - if (xKey.is()) - { - xKey->setAsciiValue(implementationLoaderUrl); - } + if (xKey.is()) + { + xKey->setAsciiValue(implementationLoaderUrl); + } - xKey = xImplKey->openKey( pool.slash_UNO_slash_SERVICES ); + xKey = xImplKey->openKey( pool.slash_UNO_slash_SERVICES ); + + if (xKey.is() && (xKey->getValueType() == RegistryValueType_ASCIILIST)) + { + // update link entries in REGISTRY_LINKS section + Sequence<OUString> linkNames = xKey->getAsciiListValue(); - if (xKey.is() && (xKey->getValueType() == RegistryValueType_ASCIILIST)) + if (linkNames.getLength()) { - // update link entries in REGISTRY_LINKS section - Sequence<OUString> linkNames = xKey->getAsciiListValue(); + const OUString* pLinkNames = linkNames.getConstArray(); - if (linkNames.getLength()) + for (sal_Int32 j = 0; j < linkNames.getLength(); j++) { - const OUString* pLinkNames = linkNames.getConstArray(); - - for (sal_Int32 j = 0; j < linkNames.getLength(); j++) - { - prepareLink(xDest, xImplKey, pLinkNames[j]); - } + prepareLink(xDest, xImplKey, pLinkNames[j]); } } } diff --git a/stoc/source/inspect/introspection.component b/stoc/source/inspect/introspection.component new file mode 100644 index 000000000000..349fb0c9dfbe --- /dev/null +++ b/stoc/source/inspect/introspection.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.Introspection"> + <service name="com.sun.star.beans.Introspection"/> + </implementation> +</component> diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx index b700dab53c35..98d9a4c55d0a 100644 --- a/stoc/source/inspect/introspection.cxx +++ b/stoc/source/inspect/introspection.cxx @@ -72,7 +72,6 @@ #include <com/sun/star/container/XNameContainer.hpp> #include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/container/XEnumerationAccess.hpp> -#include <com/sun/star/registry/XRegistryKey.hpp> #include <rtl/ustrbuf.hxx> #include <rtl/strbuf.hxx> @@ -3055,32 +3054,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( void *, void * pRegistryKey ) -{ - if (pRegistryKey) - { - try - { - Reference< XRegistryKey > xNewKey( - reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey( - OUString(RTL_CONSTASCII_USTRINGPARAM("/" IMPLEMENTATION_NAME "/UNO/SERVICES" )) ) ); - - const Sequence< OUString > & rSNL = - stoc_inspect::ImplIntrospection::getSupportedServiceNames_Static(); - const OUString * pArray = rSNL.getConstArray(); - for ( sal_Int32 nPos = rSNL.getLength(); nPos--; ) - xNewKey->createKey( pArray[nPos] ); - - return sal_True; - } - catch (InvalidRegistryException &) - { - OSL_ENSURE( sal_False, "### InvalidRegistryException!" ); - } - } - return sal_False; -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * ) { diff --git a/stoc/source/inspect/makefile.mk b/stoc/source/inspect/makefile.mk index 80e87dbf7cab..60864eea2496 100644 --- a/stoc/source/inspect/makefile.mk +++ b/stoc/source/inspect/makefile.mk @@ -64,3 +64,10 @@ DEF1NAME= $(SHL1TARGET) .INCLUDE : target.mk +ALLTAR : $(MISC)/introspection.component + +$(MISC)/introspection.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt introspection.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt introspection.component diff --git a/stoc/source/invocation/invocation.component b/stoc/source/invocation/invocation.component new file mode 100644 index 000000000000..67178ef2e88d --- /dev/null +++ b/stoc/source/invocation/invocation.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.Invocation"> + <service name="com.sun.star.script.Invocation"/> + </implementation> +</component> diff --git a/stoc/source/invocation/invocation.cxx b/stoc/source/invocation/invocation.cxx index 41c516a741cf..fbd71123c54b 100644 --- a/stoc/source/invocation/invocation.cxx +++ b/stoc/source/invocation/invocation.cxx @@ -1247,12 +1247,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/stoc/source/invocation/makefile.mk b/stoc/source/invocation/makefile.mk index c170bf6b614e..72eeea37c659 100644 --- a/stoc/source/invocation/makefile.mk +++ b/stoc/source/invocation/makefile.mk @@ -62,4 +62,10 @@ DEF1NAME= $(SHL1TARGET) .INCLUDE : target.mk +ALLTAR : $(MISC)/invocation.component +$(MISC)/invocation.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + invocation.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt invocation.component diff --git a/stoc/source/invocation_adapterfactory/iafactory.cxx b/stoc/source/invocation_adapterfactory/iafactory.cxx index c1e6a55cb44a..f4b3d2d076a4 100644 --- a/stoc/source/invocation_adapterfactory/iafactory.cxx +++ b/stoc/source/invocation_adapterfactory/iafactory.cxx @@ -1017,14 +1017,6 @@ void SAL_CALL component_getImplementationEnvironment( } //============================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, g_entries ); -} - -//============================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/stoc/source/invocation_adapterfactory/invocadapt.component b/stoc/source/invocation_adapterfactory/invocadapt.component new file mode 100644 index 000000000000..64f7b2b3691a --- /dev/null +++ b/stoc/source/invocation_adapterfactory/invocadapt.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.InvocationAdapterFactory"> + <service name="com.sun.star.script.InvocationAdapterFactory"/> + </implementation> +</component> diff --git a/stoc/source/invocation_adapterfactory/makefile.mk b/stoc/source/invocation_adapterfactory/makefile.mk index 66568af039e7..4c3450ac8c8d 100644 --- a/stoc/source/invocation_adapterfactory/makefile.mk +++ b/stoc/source/invocation_adapterfactory/makefile.mk @@ -63,3 +63,11 @@ DEF1NAME= $(SHL1TARGET) # --- Targets ------------------------------------------------------ .INCLUDE : target.mk + +ALLTAR : $(MISC)/invocadapt.component + +$(MISC)/invocadapt.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + invocadapt.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt invocadapt.component diff --git a/stoc/source/javaloader/javaloader.component b/stoc/source/javaloader/javaloader.component new file mode 100644 index 000000000000..bdd3b82d5125 --- /dev/null +++ b/stoc/source/javaloader/javaloader.component @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.JavaComponentLoader"> + <service name="com.sun.star.loader.Java"/> + <service name="com.sun.star.loader.Java2"/> + </implementation> +</component> diff --git a/stoc/source/javaloader/javaloader.cxx b/stoc/source/javaloader/javaloader.cxx index a68538fa63d3..c8e3b0f612e6 100644 --- a/stoc/source/javaloader/javaloader.cxx +++ b/stoc/source/javaloader/javaloader.cxx @@ -473,12 +473,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/stoc/source/javaloader/makefile.mk b/stoc/source/javaloader/makefile.mk index 60eea6a23457..e53b90d5e6e7 100644 --- a/stoc/source/javaloader/makefile.mk +++ b/stoc/source/javaloader/makefile.mk @@ -70,3 +70,10 @@ all: .INCLUDE : target.mk +ALLTAR : $(MISC)/javaloader.component + +$(MISC)/javaloader.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + javaloader.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt javaloader.component diff --git a/stoc/source/javavm/javavm.component b/stoc/source/javavm/javavm.component new file mode 100644 index 000000000000..f78d8af3ac29 --- /dev/null +++ b/stoc/source/javavm/javavm.component @@ -0,0 +1,35 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.JavaVirtualMachine"> + <service name="com.sun.star.java.JavaVirtualMachine"/> + <singleton name="com.sun.star.java.theJavaVirtualMachine"/> + </implementation> +</component> diff --git a/stoc/source/javavm/javavm.cxx b/stoc/source/javavm/javavm.cxx index 6b97a619b34a..b2ad9c206725 100644 --- a/stoc/source/javavm/javavm.cxx +++ b/stoc/source/javavm/javavm.cxx @@ -227,15 +227,10 @@ rtl::OUString serviceGetImplementationName() "com.sun.star.comp.stoc.JavaVirtualMachine")); } -rtl::OUString serviceGetServiceName() -{ - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.java.JavaVirtualMachine")); -} - css::uno::Sequence< rtl::OUString > serviceGetSupportedServiceNames() { - rtl::OUString aServiceName = serviceGetServiceName(); + rtl::OUString aServiceName( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.java.JavaVirtualMachine")); return css::uno::Sequence< rtl::OUString >(&aServiceName, 1); } @@ -621,34 +616,6 @@ component_getImplementationEnvironment(sal_Char const ** pEnvTypeName, *pEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, - void * pRegistryKey) -{ - if (cppu::component_writeInfoHelper(pServiceManager, pRegistryKey, - aServiceImplementation)) - { - try - { - css::uno::Reference< css::registry::XRegistryKey >( - reinterpret_cast< css::registry::XRegistryKey * >( - pRegistryKey)-> - createKey( - rtl::OUString( - RTL_CONSTASCII_USTRINGPARAM( - "com.sun.star.comp.stoc.JavaVirtualMachine" - "/UNO/SINGLETONS/" - "com.sun.star.java.theJavaVirtualMachine"))))-> - setStringValue(serviceGetServiceName()); - return true; - } - catch (css::uno::Exception &) - { - OSL_ENSURE(false, "com.sun.star.uno.Exception caught"); - } - } - return false; -} - extern "C" void * SAL_CALL component_getFactory(sal_Char const * pImplName, void * pServiceManager, void * pRegistryKey) diff --git a/stoc/source/javavm/makefile.mk b/stoc/source/javavm/makefile.mk index 96908d10d1a1..bcd36e69681e 100644 --- a/stoc/source/javavm/makefile.mk +++ b/stoc/source/javavm/makefile.mk @@ -85,3 +85,10 @@ all: .INCLUDE : target.mk +ALLTAR : $(MISC)/javavm.component + +$(MISC)/javavm.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + javavm.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt javavm.component diff --git a/stoc/source/namingservice/makefile.mk b/stoc/source/namingservice/makefile.mk index 424180e114a1..cc98cdfc3571 100644 --- a/stoc/source/namingservice/makefile.mk +++ b/stoc/source/namingservice/makefile.mk @@ -64,3 +64,10 @@ DEF1NAME= $(SHL1TARGET) .INCLUDE : target.mk +ALLTAR : $(MISC)/namingservice.component + +$(MISC)/namingservice.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt namingservice.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt namingservice.component diff --git a/stoc/source/namingservice/namingservice.component b/stoc/source/namingservice/namingservice.component new file mode 100644 index 000000000000..8450cdee6d7e --- /dev/null +++ b/stoc/source/namingservice/namingservice.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.NamingService"> + <service name="com.sun.star.uno.NamingService"/> + </implementation> +</component> diff --git a/stoc/source/namingservice/namingservice.cxx b/stoc/source/namingservice/namingservice.cxx index 73f036bf7b6e..3fe9a0c8389e 100644 --- a/stoc/source/namingservice/namingservice.cxx +++ b/stoc/source/namingservice/namingservice.cxx @@ -238,12 +238,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/stoc/source/proxy_factory/makefile.mk b/stoc/source/proxy_factory/makefile.mk index b38dac146ae1..23146e678f5a 100644 --- a/stoc/source/proxy_factory/makefile.mk +++ b/stoc/source/proxy_factory/makefile.mk @@ -63,3 +63,11 @@ DEF1NAME=$(SHL1TARGET) # --- Targets ------------------------------------------------------ .INCLUDE : target.mk + +ALLTAR : $(MISC)/proxyfac.component + +$(MISC)/proxyfac.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + proxyfac.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt proxyfac.component diff --git a/stoc/source/proxy_factory/proxyfac.component b/stoc/source/proxy_factory/proxyfac.component new file mode 100644 index 000000000000..bfe2c9c4268a --- /dev/null +++ b/stoc/source/proxy_factory/proxyfac.component @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.reflection.ProxyFactory"> + <service name="com.sun.star.reflection.ProxyFactory"/> + </implementation> +</component> diff --git a/stoc/source/proxy_factory/proxyfac.cxx b/stoc/source/proxy_factory/proxyfac.cxx index 3dc80ff99f44..50612a0e231d 100644 --- a/stoc/source/proxy_factory/proxyfac.cxx +++ b/stoc/source/proxy_factory/proxyfac.cxx @@ -527,13 +527,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return ::cppu::component_writeInfoHelper( - pServiceManager, pRegistryKey, g_entries ); -} - void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/stoc/source/registry_tdprovider/tdprovider.cxx b/stoc/source/registry_tdprovider/tdprovider.cxx index 43802388a910..eb2629558fcc 100644 --- a/stoc/source/registry_tdprovider/tdprovider.cxx +++ b/stoc/source/registry_tdprovider/tdprovider.cxx @@ -173,6 +173,8 @@ public: virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); // XHierarchicalNameAccess + Any getByHierarchicalNameImpl( const OUString & rName ); + virtual Any SAL_CALL getByHierarchicalName( const OUString & rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::uno::RuntimeException); virtual sal_Bool SAL_CALL hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException); @@ -224,14 +226,7 @@ Any ProviderImpl::TypeDescriptionManagerWrapper::getByHierarchicalName( sal_Bool ProviderImpl::TypeDescriptionManagerWrapper::hasByHierarchicalName( OUString const & name ) throw (RuntimeException) { - try - { - return getByHierarchicalName( name ).hasValue(); - } - catch (container::NoSuchElementException &) - { - return false; - } + return m_xTDMgr->hasByHierarchicalName( name ) || m_xThisProvider->hasByHierarchicalName( name ); } //______________________________________________________________________________ @@ -345,8 +340,7 @@ Sequence< OUString > ProviderImpl::getSupportedServiceNames() // XHierarchicalNameAccess //__________________________________________________________________________________________________ -Any SAL_CALL ProviderImpl::getByHierarchicalName( const OUString & rName ) - throw(::com::sun::star::uno::RuntimeException, com::sun::star::container::NoSuchElementException) +Any ProviderImpl::getByHierarchicalNameImpl( const OUString & rName ) { Any aRet; @@ -433,7 +427,17 @@ Any SAL_CALL ProviderImpl::getByHierarchicalName( const OUString & rName ) // Don't stop iteration in this case. } + catch ( NoSuchElementException const & ) + { + } } + return aRet; +} + +Any SAL_CALL ProviderImpl::getByHierarchicalName( const OUString & rName ) + throw(::com::sun::star::uno::RuntimeException, com::sun::star::container::NoSuchElementException) +{ + Any aRet( getByHierarchicalNameImpl( rName ) ); if ( !aRet.hasValue() ) throw NoSuchElementException( @@ -446,14 +450,7 @@ Any SAL_CALL ProviderImpl::getByHierarchicalName( const OUString & rName ) sal_Bool ProviderImpl::hasByHierarchicalName( const OUString & rName ) throw(::com::sun::star::uno::RuntimeException) { - try - { - return getByHierarchicalName( rName ).hasValue(); - } - catch (NoSuchElementException &) - { - } - return sal_False; + return getByHierarchicalNameImpl( rName ).hasValue(); } // XTypeDescriptionEnumerationAccess diff --git a/stoc/source/simpleregistry/makefile.mk b/stoc/source/simpleregistry/makefile.mk index 510e7b466d83..bc0ddf7cc71a 100644 --- a/stoc/source/simpleregistry/makefile.mk +++ b/stoc/source/simpleregistry/makefile.mk @@ -39,7 +39,8 @@ UNOUCROUT=$(OUT)$/inc$/bootstrap # ------------------------------------------------------------------ SLOFILES= \ - $(SLO)$/simpleregistry.obj + $(SLO)/simpleregistry.obj \ + $(SLO)/textualservices.obj # --- Targets ------------------------------------------------------ diff --git a/stoc/source/simpleregistry/simpleregistry.cxx b/stoc/source/simpleregistry/simpleregistry.cxx index f54a362b66ec..4485f69e020c 100644..100755 --- a/stoc/source/simpleregistry/simpleregistry.cxx +++ b/stoc/source/simpleregistry/simpleregistry.cxx @@ -1,1309 +1,1322 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + #include "precompiled_stoc.hxx" -#include <osl/diagnose.h> -#include <osl/mutex.hxx> -#include <rtl/alloc.h> -#include <rtl/ustrbuf.hxx> -#include <cppuhelper/queryinterface.hxx> -#include <cppuhelper/weak.hxx> -#include <cppuhelper/factory.hxx> -#include <cppuhelper/implbase1.hxx> -#include <cppuhelper/implbase2.hxx> -#include <cppuhelper/implementationentry.hxx> -#include <registry/registry.hxx> - -#include <com/sun/star/registry/XSimpleRegistry.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XSingleServiceFactory.hpp> - -using namespace com::sun::star::uno; -using namespace com::sun::star::registry; -using namespace com::sun::star::lang; -using namespace cppu; -using namespace osl; - -using ::rtl::OUString; -using ::rtl::OUStringBuffer; -using ::rtl::OString; -using ::rtl::OStringToOUString; -using ::rtl::OUStringToOString; - -#define SERVICENAME "com.sun.star.registry.SimpleRegistry" -#define IMPLNAME "com.sun.star.comp.stoc.SimpleRegistry" +#include "sal/config.h" + +#include <cstdlib> +#include <memory> +#include <vector> + +#include "com/sun/star/lang/XServiceInfo.hpp" +#include "com/sun/star/registry/InvalidRegistryException.hpp" +#include "com/sun/star/registry/InvalidValueException.hpp" +#include "com/sun/star/registry/MergeConflictException.hpp" +#include "com/sun/star/registry/RegistryKeyType.hpp" +#include "com/sun/star/registry/XRegistryKey.hpp" +#include "com/sun/star/registry/XSimpleRegistry.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/XComponentContext.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "com/sun/star/uno/Sequence.hxx" +#include "cppuhelper/implbase1.hxx" +#include "cppuhelper/implbase2.hxx" +#include "cppuhelper/weak.hxx" +#include "osl/mutex.hxx" +#include "registry/registry.hxx" +#include "registry/regtype.h" +#include "rtl/ref.hxx" +#include "rtl/string.h" +#include "rtl/string.hxx" +#include "rtl/textcvt.h" +#include "rtl/textenc.h" +#include "rtl/unload.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" + +#include "bootstrapservices.hxx" + +#include "textualservices.hxx" extern rtl_StandardModuleCount g_moduleCount; -namespace stoc_bootstrap -{ -Sequence< OUString > simreg_getSupportedServiceNames() -{ - static Sequence < OUString > *pNames = 0; - if( ! pNames ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( !pNames ) - { - static Sequence< OUString > seqNames(1); - seqNames.getArray()[0] = OUString(RTL_CONSTASCII_USTRINGPARAM(SERVICENAME)); - pNames = &seqNames; - } - } - return *pNames; -} - -OUString simreg_getImplementationName() -{ - static OUString *pImplName = 0; - if( ! pImplName ) - { - MutexGuard guard( Mutex::getGlobalMutex() ); - if( ! pImplName ) - { - static OUString implName( RTL_CONSTASCII_USTRINGPARAM( IMPLNAME ) ); - pImplName = &implName; - } - } - return *pImplName; -} -} +namespace { -namespace stoc_simreg { +namespace css = com::sun::star; -//************************************************************************* -// class RegistryKeyImpl the implenetation of interface XRegistryKey -//************************************************************************* -class RegistryKeyImpl; - -//************************************************************************* -// SimpleRegistryImpl -//************************************************************************* -class SimpleRegistryImpl : public WeakImplHelper2< XSimpleRegistry, XServiceInfo > +class SimpleRegistry: + public cppu::WeakImplHelper2< + css::registry::XSimpleRegistry, css::lang::XServiceInfo > { public: - SimpleRegistryImpl( const Registry& rRegistry ); - - ~SimpleRegistryImpl(); - - // XServiceInfo - virtual OUString SAL_CALL getImplementationName( ) throw(RuntimeException); - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(RuntimeException); - virtual Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(RuntimeException); - - // XSimpleRegistry - virtual OUString SAL_CALL getURL() throw(RuntimeException); - virtual void SAL_CALL open( const OUString& rURL, sal_Bool bReadOnly, sal_Bool bCreate ) throw(InvalidRegistryException, RuntimeException); - virtual sal_Bool SAL_CALL isValid( ) throw(RuntimeException); - virtual void SAL_CALL close( ) throw(InvalidRegistryException, RuntimeException); - virtual void SAL_CALL destroy( ) throw(InvalidRegistryException, RuntimeException); - virtual Reference< XRegistryKey > SAL_CALL getRootKey( ) throw(InvalidRegistryException, RuntimeException); - virtual sal_Bool SAL_CALL isReadOnly( ) throw(InvalidRegistryException, RuntimeException); - virtual void SAL_CALL mergeKey( const OUString& aKeyName, const OUString& aUrl ) throw(InvalidRegistryException, MergeConflictException, RuntimeException); - - friend class RegistryKeyImpl; -protected: - Mutex m_mutex; - OUString m_url; - Registry m_registry; -}; + SimpleRegistry() { g_moduleCount.modCnt.acquire(&g_moduleCount.modCnt); } + ~SimpleRegistry() { g_moduleCount.modCnt.release(&g_moduleCount.modCnt); } -class RegistryKeyImpl : public WeakImplHelper1< XRegistryKey > -{ -public: - RegistryKeyImpl( const RegistryKey& rKey, SimpleRegistryImpl* pRegistry ); - - RegistryKeyImpl( const OUString& rKeyName, SimpleRegistryImpl* pRegistry ); - - ~RegistryKeyImpl(); - - // XRegistryKey - virtual OUString SAL_CALL getKeyName() throw(RuntimeException); - virtual sal_Bool SAL_CALL isReadOnly( ) throw(InvalidRegistryException, RuntimeException); - virtual sal_Bool SAL_CALL isValid( ) throw(RuntimeException); - virtual RegistryKeyType SAL_CALL getKeyType( const OUString& rKeyName ) throw(InvalidRegistryException, RuntimeException); - virtual RegistryValueType SAL_CALL getValueType( ) throw(InvalidRegistryException, RuntimeException); - virtual sal_Int32 SAL_CALL getLongValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException); - virtual void SAL_CALL setLongValue( sal_Int32 value ) throw(InvalidRegistryException, RuntimeException); - virtual Sequence< sal_Int32 > SAL_CALL getLongListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException); - virtual void SAL_CALL setLongListValue( const ::com::sun::star::uno::Sequence< sal_Int32 >& seqValue ) throw(InvalidRegistryException, RuntimeException); - virtual OUString SAL_CALL getAsciiValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException); - virtual void SAL_CALL setAsciiValue( const OUString& value ) throw(InvalidRegistryException, RuntimeException); - virtual Sequence< OUString > SAL_CALL getAsciiListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException); - virtual void SAL_CALL setAsciiListValue( const ::com::sun::star::uno::Sequence< OUString >& seqValue ) throw(InvalidRegistryException, RuntimeException); - virtual OUString SAL_CALL getStringValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException); - virtual void SAL_CALL setStringValue( const OUString& value ) throw(InvalidRegistryException, RuntimeException); - virtual Sequence< OUString > SAL_CALL getStringListValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException); - virtual void SAL_CALL setStringListValue( const ::com::sun::star::uno::Sequence< OUString >& seqValue ) throw(InvalidRegistryException, RuntimeException); - virtual Sequence< sal_Int8 > SAL_CALL getBinaryValue( ) throw(InvalidRegistryException, InvalidValueException, RuntimeException); - virtual void SAL_CALL setBinaryValue( const ::com::sun::star::uno::Sequence< sal_Int8 >& value ) throw(InvalidRegistryException, RuntimeException); - virtual Reference< XRegistryKey > SAL_CALL openKey( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException); - virtual Reference< XRegistryKey > SAL_CALL createKey( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException); - virtual void SAL_CALL closeKey( ) throw(InvalidRegistryException, RuntimeException); - virtual void SAL_CALL deleteKey( const OUString& rKeyName ) throw(InvalidRegistryException, RuntimeException); - virtual Sequence< Reference< XRegistryKey > > SAL_CALL openKeys( ) throw(InvalidRegistryException, RuntimeException); - virtual Sequence< OUString > SAL_CALL getKeyNames( ) throw(InvalidRegistryException, RuntimeException); - virtual sal_Bool SAL_CALL createLink( const OUString& aLinkName, const OUString& aLinkTarget ) throw(InvalidRegistryException, RuntimeException); - virtual void SAL_CALL deleteLink( const OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException); - virtual OUString SAL_CALL getLinkTarget( const OUString& rLinkName ) throw(InvalidRegistryException, RuntimeException); - virtual OUString SAL_CALL getResolvedName( const OUString& aKeyName ) throw(InvalidRegistryException, RuntimeException); - -protected: - OUString m_name; - RegistryKey m_key; - SimpleRegistryImpl* m_pRegistry; -}; + osl::Mutex mutex_; -//************************************************************************* -RegistryKeyImpl::RegistryKeyImpl( const RegistryKey& key, SimpleRegistryImpl* pRegistry ) - : m_key(key) - , m_pRegistry(pRegistry) -{ - m_pRegistry->acquire(); - m_name = m_key.getName(); -} +private: + virtual rtl::OUString SAL_CALL getURL() throw (css::uno::RuntimeException); -//************************************************************************* -RegistryKeyImpl::RegistryKeyImpl( const OUString& rKeyName, - SimpleRegistryImpl* pRegistry ) - : m_pRegistry(pRegistry) -{ - m_pRegistry->acquire(); + virtual void SAL_CALL open( + rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); - RegistryKey rootKey; - if (!pRegistry->m_registry.isValid() || - pRegistry->m_registry.openRootKey(rootKey)) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - if ( rootKey.openKey(rKeyName, m_key) ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - m_name = rKeyName; - } - } -} + virtual sal_Bool SAL_CALL isValid() throw (css::uno::RuntimeException); -//************************************************************************* -RegistryKeyImpl::~RegistryKeyImpl() -{ - m_pRegistry->release(); -} + virtual void SAL_CALL close() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); -//************************************************************************* -OUString SAL_CALL RegistryKeyImpl::getKeyName() throw(RuntimeException) -{ - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - return m_name; -} + virtual void SAL_CALL destroy() throw( + css::registry::InvalidRegistryException, css::uno::RuntimeException); -//************************************************************************* -sal_Bool SAL_CALL RegistryKeyImpl::isReadOnly( ) - throw(InvalidRegistryException, RuntimeException) -{ - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if (m_key.isValid()) - { - return(m_key.isReadOnly()); - } else - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } -} + virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL + getRootKey() throw( + css::registry::InvalidRegistryException, css::uno::RuntimeException); -//************************************************************************* -sal_Bool SAL_CALL RegistryKeyImpl::isValid( ) throw(RuntimeException) -{ - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - return m_key.isValid(); -} + virtual sal_Bool SAL_CALL isReadOnly() throw( + css::registry::InvalidRegistryException, css::uno::RuntimeException); -//************************************************************************* -RegistryKeyType SAL_CALL RegistryKeyImpl::getKeyType( const OUString& rKeyName ) - throw(InvalidRegistryException, RuntimeException) -{ - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( m_key.isValid() ) - { - RegKeyType keyType; - if ( !m_key.getKeyType(rKeyName, &keyType) ) - { - switch (keyType) - { - case RG_KEYTYPE: - return RegistryKeyType_KEY; - case RG_LINKTYPE: - return RegistryKeyType_LINK; - } - } else - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } - } else - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } + virtual void SAL_CALL mergeKey( + rtl::OUString const & aKeyName, rtl::OUString const & aUrl) + throw ( + css::registry::InvalidRegistryException, + css::registry::MergeConflictException, css::uno::RuntimeException); - return RegistryKeyType_KEY; -} + virtual rtl::OUString SAL_CALL getImplementationName() + throw (css::uno::RuntimeException) + { return stoc_bootstrap::simreg_getImplementationName(); } -//************************************************************************* -RegistryValueType SAL_CALL RegistryKeyImpl::getValueType( ) - throw(InvalidRegistryException, RuntimeException) -{ - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if (!m_key.isValid()) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegValueType type; - sal_uInt32 size; + virtual sal_Bool SAL_CALL supportsService(rtl::OUString const & ServiceName) + throw (css::uno::RuntimeException) + { return ServiceName == getSupportedServiceNames()[0]; } - if (m_key.getValueInfo(OUString(), &type, &size)) - { - return RegistryValueType_NOT_DEFINED; - } else - { - switch (type) - { - case RG_VALUETYPE_LONG: return RegistryValueType_LONG; - case RG_VALUETYPE_STRING: return RegistryValueType_ASCII; - case RG_VALUETYPE_UNICODE: return RegistryValueType_STRING; - case RG_VALUETYPE_BINARY: return RegistryValueType_BINARY; - case RG_VALUETYPE_LONGLIST: return RegistryValueType_LONGLIST; - case RG_VALUETYPE_STRINGLIST: return RegistryValueType_ASCIILIST; - case RG_VALUETYPE_UNICODELIST: return RegistryValueType_STRINGLIST; - default: return RegistryValueType_NOT_DEFINED; - } - } - } - - return RegistryValueType_NOT_DEFINED; -} + virtual css::uno::Sequence< rtl::OUString > SAL_CALL + getSupportedServiceNames() throw (css::uno::RuntimeException) + { return stoc_bootstrap::simreg_getSupportedServiceNames(); } -//************************************************************************* -sal_Int32 SAL_CALL RegistryKeyImpl::getLongValue( ) - throw(InvalidRegistryException, InvalidValueException, RuntimeException) -{ - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if (!m_key.isValid()) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegValueType type; - sal_uInt32 size; + Registry registry_; + std::auto_ptr< stoc::simpleregistry::TextualServices > textual_; +}; - if ( !m_key.getValueInfo(OUString(), &type, &size) ) - { - if (type == RG_VALUETYPE_LONG) - { - sal_Int32 value; - if ( !m_key.getValue(OUString(), (RegValue)&value) ) - { - return value; - } - } - } +class Key: public cppu::WeakImplHelper1< css::registry::XRegistryKey > { +public: + Key( + rtl::Reference< SimpleRegistry > const & registry, + RegistryKey const & key): + registry_(registry), key_(key) {} + +private: + virtual rtl::OUString SAL_CALL getKeyName() + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL isReadOnly() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL isValid() throw(css::uno::RuntimeException); + + virtual css::registry::RegistryKeyType SAL_CALL getKeyType( + rtl::OUString const & rKeyName) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual css::registry::RegistryValueType SAL_CALL getValueType() throw( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getLongValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setLongValue(sal_Int32 value) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue() throw( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setLongListValue( + com::sun::star::uno::Sequence< sal_Int32 > const & seqValue) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getAsciiValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setAsciiValue(rtl::OUString const & value) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue() + throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setAsciiListValue( + css::uno::Sequence< rtl::OUString > const & seqValue) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getStringValue() throw( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setStringValue(rtl::OUString const & value) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getStringListValue() + throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setStringListValue( + css::uno::Sequence< rtl::OUString > const & seqValue) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setBinaryValue( + css::uno::Sequence< sal_Int8 > const & value) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL openKey( + rtl::OUString const & aKeyName) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL + createKey(rtl::OUString const & aKeyName) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual void SAL_CALL closeKey() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual void SAL_CALL deleteKey(rtl::OUString const & rKeyName) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual + css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > + SAL_CALL openKeys() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getKeyNames() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL createLink( + rtl::OUString const & aLinkName, rtl::OUString const & aLinkTarget) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual void SAL_CALL deleteLink(rtl::OUString const & rLinkName) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getLinkTarget( + rtl::OUString const & rLinkName) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getResolvedName( + rtl::OUString const & aKeyName) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + rtl::Reference< SimpleRegistry > registry_; + RegistryKey key_; +}; - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } +rtl::OUString Key::getKeyName() throw (css::uno::RuntimeException) { + osl::MutexGuard guard(registry_->mutex_); + return key_.getName(); } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::setLongValue( sal_Int32 value ) - throw(InvalidRegistryException, RuntimeException) +sal_Bool Key::isReadOnly() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - if (m_key.setValue(OUString(), RG_VALUETYPE_LONG, &value, sizeof(sal_Int32))) - { - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } - } + osl::MutexGuard guard(registry_->mutex_); + return key_.isReadOnly(); } -//************************************************************************* -Sequence< sal_Int32 > SAL_CALL RegistryKeyImpl::getLongListValue( ) - throw(InvalidRegistryException, InvalidValueException, RuntimeException) -{ - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegValueType type; - sal_uInt32 size; - - if ( !m_key.getValueInfo(OUString(), &type, &size) ) - { - if (type == RG_VALUETYPE_LONGLIST) - { - RegistryValueList<sal_Int32> tmpValue; - if ( !m_key.getLongListValue(OUString(), tmpValue) ) - { - Sequence<sal_Int32> seqValue(size); - - for (sal_uInt32 i=0; i < size; i++) - { - seqValue.getArray()[i] = tmpValue.getElement(i); - } - - return seqValue; - } - } - } - - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } +sal_Bool Key::isValid() throw (css::uno::RuntimeException) { + osl::MutexGuard guard(registry_->mutex_); + return key_.isValid(); } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::setLongListValue( const Sequence< sal_Int32 >& seqValue ) - throw(InvalidRegistryException, RuntimeException) +css::registry::RegistryKeyType Key::getKeyType(rtl::OUString const & rKeyName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - sal_uInt32 length = seqValue.getLength(); - sal_Int32* tmpValue = new sal_Int32[length]; - - for (sal_uInt32 i=0; i < length; i++) - { - tmpValue[i] = seqValue.getConstArray()[i]; - } - - if ( m_key.setLongListValue(OUString(), tmpValue, length) ) - { - delete[] tmpValue; - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } - - delete[] tmpValue; + osl::MutexGuard guard(registry_->mutex_); + RegKeyType type; + RegError err = key_.getKeyType(rKeyName, &type); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getKeyType:" + " underlying RegistryKey::getKeyType() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + switch (type) { + default: + std::abort(); // this cannot happen + // pseudo-fall-through to avoid warnings on MSC + case RG_KEYTYPE: + return css::registry::RegistryKeyType_KEY; + case RG_LINKTYPE: + return css::registry::RegistryKeyType_LINK; } } -//************************************************************************* -OUString SAL_CALL RegistryKeyImpl::getAsciiValue( ) - throw(InvalidRegistryException, InvalidValueException, RuntimeException) +css::registry::RegistryValueType Key::getValueType() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if (!m_key.isValid()) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegValueType type; - sal_uInt32 size; - - if ( !m_key.getValueInfo(OUString(), &type, &size) ) - { - if ( type == RG_VALUETYPE_STRING ) - { - char* value = new char[size]; - if ( m_key.getValue(OUString(), (RegValue)value) ) - { - delete [] value; - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } else - { - OUString ret(OStringToOUString(value, RTL_TEXTENCODING_UTF8)); - delete [] value; - return ret; - } - } - } - - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); + osl::MutexGuard guard(registry_->mutex_); + RegValueType type; + sal_uInt32 size; + RegError err = key_.getValueInfo(rtl::OUString(), &type, &size); + switch (err) { + case REG_NO_ERROR: + break; + case REG_INVALID_VALUE: + type = RG_VALUETYPE_NOT_DEFINED; + break; + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getValueType:" + " underlying RegistryKey::getValueInfo() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + switch (type) { + default: + std::abort(); // this cannot happen + // pseudo-fall-through to avoid warnings on MSC + case RG_VALUETYPE_NOT_DEFINED: + return css::registry::RegistryValueType_NOT_DEFINED; + case RG_VALUETYPE_LONG: + return css::registry::RegistryValueType_LONG; + case RG_VALUETYPE_STRING: + return css::registry::RegistryValueType_ASCII; + case RG_VALUETYPE_UNICODE: + return css::registry::RegistryValueType_STRING; + case RG_VALUETYPE_BINARY: + return css::registry::RegistryValueType_BINARY; + case RG_VALUETYPE_LONGLIST: + return css::registry::RegistryValueType_LONGLIST; + case RG_VALUETYPE_STRINGLIST: + return css::registry::RegistryValueType_ASCIILIST; + case RG_VALUETYPE_UNICODELIST: + return css::registry::RegistryValueType_STRINGLIST; } } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::setAsciiValue( const OUString& value ) - throw(InvalidRegistryException, RuntimeException) +sal_Int32 Key::getLongValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - OString sValue = OUStringToOString(value, RTL_TEXTENCODING_UTF8); - sal_uInt32 size = sValue.getLength()+1; - if ( m_key.setValue(OUString(), RG_VALUETYPE_STRING, - (RegValue)(sValue.getStr()), size) ) - { - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } + osl::MutexGuard guard(registry_->mutex_); + sal_Int32 value; + RegError err = key_.getValue(rtl::OUString(), &value); + switch (err) { + case REG_NO_ERROR: + break; + case REG_INVALID_VALUE: + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getLongValue:" + " underlying RegistryKey::getValue() = REG_INVALID_VALUE")), + static_cast< OWeakObject * >(this)); + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getLongValue:" + " underlying RegistryKey::getValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } + return value; } -//************************************************************************* -Sequence< OUString > SAL_CALL RegistryKeyImpl::getAsciiListValue( ) - throw(InvalidRegistryException, InvalidValueException, RuntimeException) +void Key::setLongValue(sal_Int32 value) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegValueType type; - sal_uInt32 size; - - if ( !m_key.getValueInfo(OUString(), &type, &size) ) - { - if (type == RG_VALUETYPE_STRINGLIST) - { - RegistryValueList<char*> tmpValue; - if ( !m_key.getStringListValue(OUString(), tmpValue) ) - { - Sequence<OUString> seqValue(size); - - for (sal_uInt32 i=0; i < size; i++) - { - seqValue.getArray()[i] = - OStringToOUString(tmpValue.getElement(i), RTL_TEXTENCODING_UTF8); - } - - return seqValue; - } - } - } - - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); + osl::MutexGuard guard(registry_->mutex_); + RegError err = key_.setValue( + rtl::OUString(), RG_VALUETYPE_LONG, &value, sizeof (sal_Int32)); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key setLongValue:" + " underlying RegistryKey::setValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::setAsciiListValue( const Sequence< OUString >& seqValue ) - throw(InvalidRegistryException, RuntimeException) +css::uno::Sequence< sal_Int32 > Key::getLongListValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - sal_uInt32 length = seqValue.getLength(); - OString* pSValue = new OString[length]; - char** tmpValue = new char*[length]; - - for (sal_uInt32 i=0; i < length; i++) - { - pSValue[i] = OUStringToOString(seqValue.getConstArray()[i], RTL_TEXTENCODING_UTF8); - tmpValue[i] = (char*)pSValue[i].getStr(); - } - - if ( m_key.setStringListValue(OUString(), tmpValue, length) ) - { - delete[] pSValue; - delete[] tmpValue; - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } - - delete[] pSValue; - delete[] tmpValue; + osl::MutexGuard guard(registry_->mutex_); + RegistryValueList< sal_Int32 > list; + RegError err = key_.getLongListValue(rtl::OUString(), list); + switch (err) { + case REG_NO_ERROR: + break; + case REG_VALUE_NOT_EXISTS: + return css::uno::Sequence< sal_Int32 >(); + case REG_INVALID_VALUE: + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getLongListValue:" + " underlying RegistryKey::getLongListValue() =" + " REG_INVALID_VALUE")), + static_cast< OWeakObject * >(this)); + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getLongListValue:" + " underlying RegistryKey::getLongListValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + sal_uInt32 n = list.getLength(); + if (n > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getLongListValue:" + " underlying RegistryKey::getLongListValue() too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< sal_Int32 > value(static_cast< sal_Int32 >(n)); + for (sal_uInt32 i = 0; i < n; ++i) { + value[static_cast< sal_Int32 >(i)] = list.getElement(i); } + return value; } -//************************************************************************* -OUString SAL_CALL RegistryKeyImpl::getStringValue( ) - throw(InvalidRegistryException, InvalidValueException, RuntimeException) +void Key::setLongListValue(css::uno::Sequence< sal_Int32 > const & seqValue) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegValueType type; - sal_uInt32 size; - - if ( !m_key.getValueInfo(OUString(), &type, &size) ) - { - if (type == RG_VALUETYPE_UNICODE) - { - sal_Unicode* value = new sal_Unicode[size]; - if ( m_key.getValue(OUString(), (RegValue)value) ) - { - delete [] value; - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } else - { - OUString ret(value); - delete [] value; - return ret; - } - } - } - - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); + osl::MutexGuard guard(registry_->mutex_); + std::vector< sal_Int32 > list; + for (sal_Int32 i = 0; i < seqValue.getLength(); ++i) { + list.push_back(seqValue[i]); + } + RegError err = key_.setLongListValue( + rtl::OUString(), list.empty() ? 0 : &list[0], + static_cast< sal_uInt32 >(list.size())); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key setLongListValue:" + " underlying RegistryKey::setLongListValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::setStringValue( const OUString& value ) - throw(InvalidRegistryException, RuntimeException) +rtl::OUString Key::getAsciiValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - sal_uInt32 size = (value.getLength() + 1) * sizeof(sal_Unicode); - if ( m_key.setValue(OUString(), RG_VALUETYPE_UNICODE, - (RegValue)(value.getStr()), size) ) - { - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } + osl::MutexGuard guard(registry_->mutex_); + RegValueType type; + sal_uInt32 size; + RegError err = key_.getValueInfo(rtl::OUString(), &type, &size); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey::getValueInfo() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + if (type != RG_VALUETYPE_STRING) { + throw css::registry::InvalidValueException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey type = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(type))), + static_cast< OWeakObject * >(this)); + } + // size contains terminating null (error in underlying registry.cxx): + if (size == 0) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey size 0 cannot happen due to" + " design error")), + static_cast< OWeakObject * >(this)); + } + if (size > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey size too large")), + static_cast< OWeakObject * >(this)); + } + std::vector< char > list(size); + err = key_.getValue(rtl::OUString(), &list[0]); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey::getValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } + if (list[size - 1] != '\0') { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey value must be null-terminated due" + " to design error")), + static_cast< OWeakObject * >(this)); + } + rtl::OUString value; + if (!rtl_convertStringToUString( + &value.pData, &list[0], + static_cast< sal_Int32 >(size - 1), RTL_TEXTENCODING_UTF8, + (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))) + { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getAsciiValue:" + " underlying RegistryKey not UTF-8")), + static_cast< OWeakObject * >(this)); + } + return value; } -//************************************************************************* -Sequence< OUString > SAL_CALL RegistryKeyImpl::getStringListValue( ) - throw(InvalidRegistryException, InvalidValueException, RuntimeException) +void Key::setAsciiValue(rtl::OUString const & value) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegValueType type; - sal_uInt32 size; - - if ( !m_key.getValueInfo(OUString(), &type, &size) ) - { - if (type == RG_VALUETYPE_UNICODELIST) - { - RegistryValueList<sal_Unicode*> tmpValue; - if ( !m_key.getUnicodeListValue(OUString(), tmpValue) ) - { - Sequence<OUString> seqValue(size); - - for (sal_uInt32 i=0; i < size; i++) - { - seqValue.getArray()[i] = OUString(tmpValue.getElement(i)); - } - - return seqValue; - } - } - } - - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); + osl::MutexGuard guard(registry_->mutex_); + rtl::OString utf8; + if (!value.convertToString( + &utf8, RTL_TEXTENCODING_UTF8, + (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | + RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key setAsciiValue:" + " value not UTF-16")), + static_cast< OWeakObject * >(this)); + } + RegError err = key_.setValue( + rtl::OUString(), RG_VALUETYPE_STRING, + const_cast< char * >(utf8.getStr()), utf8.getLength() + 1); + // +1 for terminating null (error in underlying registry.cxx) + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key setAsciiValue:" + " underlying RegistryKey::setValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::setStringListValue( const Sequence< OUString >& seqValue ) - throw(InvalidRegistryException, RuntimeException) +css::uno::Sequence< rtl::OUString > Key::getAsciiListValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - sal_uInt32 length = seqValue.getLength(); - sal_Unicode** tmpValue = new sal_Unicode*[length]; - - for (sal_uInt32 i=0; i < length; i++) - { - tmpValue[i] = (sal_Unicode*)seqValue.getConstArray()[i].getStr(); - } - - if (m_key.setUnicodeListValue(OUString(), tmpValue, length)) + osl::MutexGuard guard(registry_->mutex_); + RegistryValueList< char * > list; + RegError err = key_.getStringListValue(rtl::OUString(), list); + switch (err) { + case REG_NO_ERROR: + break; + case REG_VALUE_NOT_EXISTS: + return css::uno::Sequence< rtl::OUString >(); + case REG_INVALID_VALUE: + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " getAsciiListValue: underlying" + " RegistryKey::getStringListValue() = REG_INVALID_VALUE")), + static_cast< OWeakObject * >(this)); + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " getAsciiListValue: underlying" + " RegistryKey::getStringListValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + sal_uInt32 n = list.getLength(); + if (n > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " getAsciiListValue: underlying" + " RegistryKey::getStringListValue() too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< rtl::OUString > value(static_cast< sal_Int32 >(n)); + for (sal_uInt32 i = 0; i < n; ++i) { + char * el = list.getElement(i); + sal_Int32 size = rtl_str_getLength(el); + if (!rtl_convertStringToUString( + &value[static_cast< sal_Int32 >(i)].pData, el, size, + RTL_TEXTENCODING_UTF8, + (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))) { - delete[] tmpValue; - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " getAsciiListValue: underlying RegistryKey not" + " UTF-8")), + static_cast< OWeakObject * >(this)); } - - delete[] tmpValue; } + return value; } -//************************************************************************* -Sequence< sal_Int8 > SAL_CALL RegistryKeyImpl::getBinaryValue( ) - throw(InvalidRegistryException, InvalidValueException, RuntimeException) +void Key::setAsciiListValue( + css::uno::Sequence< rtl::OUString > const & seqValue) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegValueType type; - sal_uInt32 size; - - if ( !m_key.getValueInfo(OUString(), &type, &size) ) + osl::MutexGuard guard(registry_->mutex_); + std::vector< rtl::OString > list; + for (sal_Int32 i = 0; i < seqValue.getLength(); ++i) { + rtl::OString utf8; + if (!seqValue[i].convertToString( + &utf8, RTL_TEXTENCODING_UTF8, + (RTL_UNICODETOTEXT_FLAGS_UNDEFINED_ERROR | + RTL_UNICODETOTEXT_FLAGS_INVALID_ERROR))) { - if (type == RG_VALUETYPE_BINARY) - { - sal_Int8* value = new sal_Int8[size]; - if (m_key.getValue(OUString(), (RegValue)value)) - { - delete [] value; - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } else - { - Sequence<sal_Int8> seqBytes(value, size); - delete [] value; - return seqBytes; - } - } + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " setAsciiListValue: value not UTF-16")), + static_cast< OWeakObject * >(this)); } - - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); + list.push_back(utf8); + } + std::vector< char * > list2; + for (std::vector< rtl::OString >::iterator i(list.begin()); i != list.end(); + ++i) + { + list2.push_back(const_cast< char * >(i->getStr())); + } + RegError err = key_.setStringListValue( + rtl::OUString(), list2.empty() ? 0 : &list2[0], + static_cast< sal_uInt32 >(list2.size())); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " setAsciiListValue: underlying" + " RegistryKey::setStringListValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::setBinaryValue( const Sequence< sal_Int8 >& value ) - throw(InvalidRegistryException, RuntimeException) +rtl::OUString Key::getStringValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - sal_uInt32 size = value.getLength(); - if ( m_key.setValue(OUString(), RG_VALUETYPE_BINARY, - (RegValue)(value.getConstArray()), size) ) - { - throw InvalidValueException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidValueException") ), - (OWeakObject *)this ); - } + osl::MutexGuard guard(registry_->mutex_); + RegValueType type; + sal_uInt32 size; + RegError err = key_.getValueInfo(rtl::OUString(), &type, &size); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey::getValueInfo() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + if (type != RG_VALUETYPE_UNICODE) { + throw css::registry::InvalidValueException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey type = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(type))), + static_cast< OWeakObject * >(this)); + } + // size contains terminating null and is *2 (error in underlying + // registry.cxx): + if (size == 0 || (size & 1) == 1) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey size 0 or odd cannot happen due to" + " design error")), + static_cast< OWeakObject * >(this)); } + if (size > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey size too large")), + static_cast< OWeakObject * >(this)); + } + std::vector< sal_Unicode > list(size); + err = key_.getValue(rtl::OUString(), &list[0]); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey::getValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + if (list[size/2 - 1] != 0) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getStringValue:" + " underlying RegistryKey value must be null-terminated due" + " to design error")), + static_cast< OWeakObject * >(this)); + } + return rtl::OUString(&list[0], static_cast< sal_Int32 >(size/2 - 1)); } -//************************************************************************* -Reference< XRegistryKey > SAL_CALL RegistryKeyImpl::openKey( const OUString& aKeyName ) - throw(InvalidRegistryException, RuntimeException) +void Key::setStringValue(rtl::OUString const & value) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - RegistryKey newKey; - - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegError _ret = m_key.openKey(aKeyName, newKey); - if ( _ret ) - { - if ( _ret == REG_INVALID_KEY ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } - - return Reference<XRegistryKey>(); - } else - { - return ((XRegistryKey*)new RegistryKeyImpl(newKey, m_pRegistry)); - } + osl::MutexGuard guard(registry_->mutex_); + RegError err = key_.setValue( + rtl::OUString(), RG_VALUETYPE_UNICODE, + const_cast< sal_Unicode * >(value.getStr()), + (value.getLength() + 1) * sizeof (sal_Unicode)); + // +1 for terminating null (error in underlying registry.cxx) + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key setStringValue:" + " underlying RegistryKey::setValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } } -//************************************************************************* -Reference< XRegistryKey > SAL_CALL RegistryKeyImpl::createKey( const OUString& aKeyName ) - throw(InvalidRegistryException, RuntimeException) +css::uno::Sequence< rtl::OUString > Key::getStringListValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) { - RegistryKey newKey; - - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegError _ret = m_key.createKey(aKeyName, newKey); - if ( _ret ) - { - if (_ret == REG_INVALID_KEY) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } - - return Reference<XRegistryKey>(); - } else - { - return ((XRegistryKey*)new RegistryKeyImpl(newKey, m_pRegistry)); - } + osl::MutexGuard guard(registry_->mutex_); + RegistryValueList< sal_Unicode * > list; + RegError err = key_.getUnicodeListValue(rtl::OUString(), list); + switch (err) { + case REG_NO_ERROR: + break; + case REG_VALUE_NOT_EXISTS: + return css::uno::Sequence< rtl::OUString >(); + case REG_INVALID_VALUE: + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " getStringListValue: underlying" + " RegistryKey::getUnicodeListValue() = REG_INVALID_VALUE")), + static_cast< OWeakObject * >(this)); + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " getStringListValue: underlying" + " RegistryKey::getUnicodeListValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + sal_uInt32 n = list.getLength(); + if (n > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " getStringListValue: underlying" + " RegistryKey::getUnicodeListValue() too large")), + static_cast< OWeakObject * >(this)); } + css::uno::Sequence< rtl::OUString > value(static_cast< sal_Int32 >(n)); + for (sal_uInt32 i = 0; i < n; ++i) { + value[static_cast< sal_Int32 >(i)] = list.getElement(i); + } + return value; } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::closeKey( ) - throw(InvalidRegistryException, RuntimeException) +void Key::setStringListValue( + css::uno::Sequence< rtl::OUString > const & seqValue) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( m_key.isValid() ) - { - if ( !m_key.closeKey() ) - return; + osl::MutexGuard guard(registry_->mutex_); + std::vector< sal_Unicode * > list; + for (sal_Int32 i = 0; i < seqValue.getLength(); ++i) { + list.push_back(const_cast< sal_Unicode * >(seqValue[i].getStr())); + } + RegError err = key_.setUnicodeListValue( + rtl::OUString(), list.empty() ? 0 : &list[0], + static_cast< sal_uInt32 >(list.size())); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key" + " setStringListValue: underlying" + " RegistryKey::setUnicodeListValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::deleteKey( const OUString& rKeyName ) - throw(InvalidRegistryException, RuntimeException) +css::uno::Sequence< sal_Int8 > Key::getBinaryValue() + throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( m_key.isValid() ) - { - if ( !m_key.deleteKey(rKeyName) ) - return; + osl::MutexGuard guard(registry_->mutex_); + RegValueType type; + sal_uInt32 size; + RegError err = key_.getValueInfo(rtl::OUString(), &type, &size); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getBinaryValue:" + " underlying RegistryKey::getValueInfo() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); + if (type != RG_VALUETYPE_BINARY) { + throw css::registry::InvalidValueException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getBinaryValue:" + " underlying RegistryKey type = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(type))), + static_cast< OWeakObject * >(this)); + } + if (size > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getBinaryValue:" + " underlying RegistryKey size too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< sal_Int8 > value(static_cast< sal_Int32 >(size)); + err = key_.getValue(rtl::OUString(), value.getArray()); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getBinaryValue:" + " underlying RegistryKey::getValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + return value; } -//************************************************************************* -Sequence< Reference< XRegistryKey > > SAL_CALL RegistryKeyImpl::openKeys( ) - throw(InvalidRegistryException, RuntimeException) +void Key::setBinaryValue(css::uno::Sequence< sal_Int8 > const & value) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegistryKeyArray subKeys; - RegError _ret = REG_NO_ERROR; - if ( (_ret = m_key.openSubKeys(OUString(), subKeys)) ) - { - if ( _ret == REG_INVALID_KEY ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } - - return Sequence< Reference<XRegistryKey> >(); - } else - { - sal_uInt32 length = subKeys.getLength(); - Sequence< Reference<XRegistryKey> > seqKeys(length); - - for (sal_uInt32 i=0; i < length; i++) - { - seqKeys.getArray()[i] = - (XRegistryKey*) new RegistryKeyImpl(subKeys.getElement(i), m_pRegistry); - } - return seqKeys; - } + osl::MutexGuard guard(registry_->mutex_); + RegError err = key_.setValue( + rtl::OUString(), RG_VALUETYPE_BINARY, + const_cast< sal_Int8 * >(value.getConstArray()), + static_cast< sal_uInt32 >(value.getLength())); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key setBinaryValue:" + " underlying RegistryKey::setValue() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } } -//************************************************************************* -Sequence< OUString > SAL_CALL RegistryKeyImpl::getKeyNames( ) - throw(InvalidRegistryException, RuntimeException) +css::uno::Reference< css::registry::XRegistryKey > Key::openKey( + rtl::OUString const & aKeyName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegistryKeyNames subKeys; - RegError _ret = REG_NO_ERROR; - if ( (_ret = m_key.getKeyNames(OUString(), subKeys)) ) - { - if ( _ret == REG_INVALID_KEY ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } - - return Sequence<OUString>(); - } else - { - sal_uInt32 length = subKeys.getLength(); - Sequence<OUString> seqKeys(length); - - for (sal_uInt32 i=0; i < length; i++) - { - seqKeys.getArray()[i] = subKeys.getElement(i); - } - return seqKeys; - } + osl::MutexGuard guard(registry_->mutex_); + RegistryKey key; + RegError err = key_.openKey(aKeyName, key); + switch (err) { + case REG_NO_ERROR: + return new Key(registry_, key); + case REG_KEY_NOT_EXISTS: + return css::uno::Reference< css::registry::XRegistryKey >(); + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key openKey:" + " underlying RegistryKey::openKey() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } } -//************************************************************************* -sal_Bool SAL_CALL RegistryKeyImpl::createLink( const OUString& aLinkName, const OUString& aLinkTarget ) - throw(InvalidRegistryException, RuntimeException) +css::uno::Reference< css::registry::XRegistryKey > Key::createKey( + rtl::OUString const & aKeyName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegError ret = m_key.createLink(aLinkName, aLinkTarget); - if ( ret ) - { - if ( ret == REG_DETECT_RECURSION || - ret == REG_INVALID_KEY ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - return sal_False; - } - } + osl::MutexGuard guard(registry_->mutex_); + RegistryKey key; + RegError err = key_.createKey(aKeyName, key); + switch (err) { + case REG_NO_ERROR: + return new Key(registry_, key); + case REG_INVALID_KEYNAME: + return css::uno::Reference< css::registry::XRegistryKey >(); + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key createKey:" + " underlying RegistryKey::createKey() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - return sal_True; } -//************************************************************************* -void SAL_CALL RegistryKeyImpl::deleteLink( const OUString& rLinkName ) - throw(InvalidRegistryException, RuntimeException) +void Key::closeKey() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - if ( m_key.deleteLink(rLinkName) ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } + osl::MutexGuard guard(registry_->mutex_); + RegError err = key_.closeKey(); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key closeKey:" + " underlying RegistryKey::closeKey() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } } -//************************************************************************* -OUString SAL_CALL RegistryKeyImpl::getLinkTarget( const OUString& rLinkName ) - throw(InvalidRegistryException, RuntimeException) +void Key::deleteKey(rtl::OUString const & rKeyName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - OUString linkTarget; - - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegError ret = m_key.getLinkTarget(rLinkName, linkTarget); - if ( ret ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } + osl::MutexGuard guard(registry_->mutex_); + RegError err = key_.deleteKey(rKeyName); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key deleteKey:" + " underlying RegistryKey::deleteKey() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - - return linkTarget; } -//************************************************************************* -OUString SAL_CALL RegistryKeyImpl::getResolvedName( const OUString& aKeyName ) - throw(InvalidRegistryException, RuntimeException) +css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > +Key::openKeys() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - OUString resolvedName; - - Guard< Mutex > aGuard( m_pRegistry->m_mutex ); - if ( !m_key.isValid() ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } else - { - RegError ret = m_key.getResolvedKeyName( - aKeyName, sal_True, resolvedName); - if ( ret ) - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } + osl::MutexGuard guard(registry_->mutex_); + RegistryKeyArray list; + RegError err = key_.openSubKeys(rtl::OUString(), list); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key openKeys:" + " underlying RegistryKey::openSubKeys() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - - return resolvedName; + sal_uInt32 n = list.getLength(); + if (n > SAL_MAX_INT32) { + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getKeyNames:" + " underlying RegistryKey::getKeyNames() too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > + keys(static_cast< sal_Int32 >(n)); + for (sal_uInt32 i = 0; i < n; ++i) { + keys[static_cast< sal_Int32 >(i)] = new Key( + registry_, list.getElement(i)); + } + return keys; } -//************************************************************************* -SimpleRegistryImpl::SimpleRegistryImpl( const Registry& rRegistry ) - : m_registry(rRegistry) +css::uno::Sequence< rtl::OUString > Key::getKeyNames() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - g_moduleCount.modCnt.acquire( &g_moduleCount.modCnt ); + osl::MutexGuard guard(registry_->mutex_); + RegistryKeyNames list; + RegError err = key_.getKeyNames(rtl::OUString(), list); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getKeyNames:" + " underlying RegistryKey::getKeyNames() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + sal_uInt32 n = list.getLength(); + if (n > SAL_MAX_INT32) { + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getKeyNames:" + " underlying RegistryKey::getKeyNames() too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< rtl::OUString > names(static_cast< sal_Int32 >(n)); + for (sal_uInt32 i = 0; i < n; ++i) { + names[static_cast< sal_Int32 >(i)] = list.getElement(i); + } + return names; } -//************************************************************************* -SimpleRegistryImpl::~SimpleRegistryImpl() +sal_Bool Key::createLink( + rtl::OUString const & aLinkName, rtl::OUString const & aLinkTarget) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - g_moduleCount.modCnt.release( &g_moduleCount.modCnt ); + osl::MutexGuard guard(registry_->mutex_); + RegError err = key_.createLink(aLinkName, aLinkTarget); + switch (err) { + case REG_NO_ERROR: + return true; + case REG_INVALID_KEY: + case REG_DETECT_RECURSION: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key createLink:" + " underlying RegistryKey::createLink() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + default: + return false; + } } -//************************************************************************* -OUString SAL_CALL SimpleRegistryImpl::getImplementationName( ) - throw(RuntimeException) +void Key::deleteLink(rtl::OUString const & rLinkName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - return stoc_bootstrap::simreg_getImplementationName(); + osl::MutexGuard guard(registry_->mutex_); + RegError err = key_.deleteLink(rLinkName); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key deleteLink:" + " underlying RegistryKey::deleteLink() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } } -//************************************************************************* -sal_Bool SAL_CALL SimpleRegistryImpl::supportsService( const OUString& ServiceName ) - throw(RuntimeException) +rtl::OUString Key::getLinkTarget(rtl::OUString const & rLinkName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_mutex ); - Sequence< OUString > aSNL = getSupportedServiceNames(); - const OUString * pArray = aSNL.getArray(); - for( sal_Int32 i = 0; i < aSNL.getLength(); i++ ) - if( pArray[i] == ServiceName ) - return sal_True; - return sal_False; + osl::MutexGuard guard(registry_->mutex_); + rtl::OUString target; + RegError err = key_.getLinkTarget(rLinkName, target); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getLinkTarget:" + " underlying RegistryKey::getLinkTarget() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + return target; } -//************************************************************************* -Sequence<OUString> SAL_CALL SimpleRegistryImpl::getSupportedServiceNames( ) - throw(RuntimeException) +rtl::OUString Key::getResolvedName(rtl::OUString const & aKeyName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - return stoc_bootstrap::simreg_getSupportedServiceNames(); + osl::MutexGuard guard(registry_->mutex_); + rtl::OUString resolved; + RegError err = key_.getResolvedKeyName(aKeyName, true, resolved); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry key getResolvedName:" + " underlying RegistryKey::getResolvedName() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); + } + return resolved; } -//************************************************************************* -OUString SAL_CALL SimpleRegistryImpl::getURL() throw(RuntimeException) -{ - Guard< Mutex > aGuard( m_mutex ); - return m_url; +rtl::OUString SimpleRegistry::getURL() throw (css::uno::RuntimeException) { + osl::MutexGuard guard(mutex_); + return textual_.get() == 0 ? registry_.getName() : textual_->getUri(); } -//************************************************************************* -void SAL_CALL SimpleRegistryImpl::open( const OUString& rURL, sal_Bool bReadOnly, sal_Bool bCreate ) - throw(InvalidRegistryException, RuntimeException) +void SimpleRegistry::open( + rtl::OUString const & rURL, sal_Bool bReadOnly, sal_Bool bCreate) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_mutex ); - if ( m_registry.isValid() ) - { - m_registry.close(); + osl::MutexGuard guard(mutex_); + if (textual_.get() != 0) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.open(")) + + rURL + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "): instance already open"))), + static_cast< OWeakObject * >(this)); } - - RegAccessMode accessMode = REG_READWRITE; - - if ( bReadOnly ) - accessMode = REG_READONLY; - - if ( !m_registry.open(rURL, accessMode) ) - { - m_url = rURL; - return; + RegError err = (rURL.getLength() == 0 && bCreate) + ? REG_REGISTRY_NOT_EXISTS + : registry_.open(rURL, bReadOnly ? REG_READONLY : REG_READWRITE); + if (err == REG_REGISTRY_NOT_EXISTS && bCreate) { + err = registry_.create(rURL); } - - if ( bCreate ) - { - if ( !m_registry.create(rURL) ) - { - m_url = rURL; - return; + switch (err) { + case REG_NO_ERROR: + break; + case REG_INVALID_REGISTRY: + if (bReadOnly && !bCreate) { + textual_.reset(new stoc::simpleregistry::TextualServices(rURL)); + break; } + // fall through + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.open(")) + + rURL + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "): underlying Registry::open/create() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - - m_url = OUString(); - - OUStringBuffer reason( 128 ); - reason.appendAscii( RTL_CONSTASCII_STRINGPARAM("Couldn't ") ); - if( bCreate ) - { - reason.appendAscii( RTL_CONSTASCII_STRINGPARAM("create") ); - } - else - { - reason.appendAscii( RTL_CONSTASCII_STRINGPARAM("open") ); - } - reason.appendAscii( RTL_CONSTASCII_STRINGPARAM(" registry ") ); - reason.append( rURL ); - if( bReadOnly ) - { - reason.appendAscii( RTL_CONSTASCII_STRINGPARAM(" for reading") ); - } - else - { - reason.appendAscii( RTL_CONSTASCII_STRINGPARAM(" for writing" ) ); - } - throw InvalidRegistryException( reason.makeStringAndClear() , Reference< XInterface >() ); } -//************************************************************************* -sal_Bool SAL_CALL SimpleRegistryImpl::isValid( ) throw(RuntimeException) -{ - Guard< Mutex > aGuard( m_mutex ); - return m_registry.isValid(); +sal_Bool SimpleRegistry::isValid() throw (css::uno::RuntimeException) { + osl::MutexGuard guard(mutex_); + return textual_.get() != 0 || registry_.isValid(); } -//************************************************************************* -void SAL_CALL SimpleRegistryImpl::close( ) - throw(InvalidRegistryException, RuntimeException) +void SimpleRegistry::close() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_mutex ); - if ( m_registry.isValid() ) - { - if ( !m_registry.close() ) - { - m_url = OUString(); - return; - } + osl::MutexGuard guard(mutex_); + if (textual_.get() != 0) { + textual_.reset(); + return; + } + RegError err = registry_.close(); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.close:" + " underlying Registry::close() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); } -//************************************************************************* -void SAL_CALL SimpleRegistryImpl::destroy( ) - throw(InvalidRegistryException, RuntimeException) +void SimpleRegistry::destroy() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_mutex ); - if ( m_registry.isValid() ) - { - if ( !m_registry.destroy(OUString()) ) - { - m_url = OUString(); - return; - } + osl::MutexGuard guard(mutex_); + if (textual_.get() != 0) { + textual_.reset(); + return; + } + RegError err = registry_.destroy(rtl::OUString()); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.destroy:" + " underlying Registry::destroy() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); } -//************************************************************************* -Reference< XRegistryKey > SAL_CALL SimpleRegistryImpl::getRootKey( ) - throw(InvalidRegistryException, RuntimeException) +css::uno::Reference< css::registry::XRegistryKey > SimpleRegistry::getRootKey() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_mutex ); - if ( m_registry.isValid() ) - return ((XRegistryKey*)new RegistryKeyImpl(OUString( RTL_CONSTASCII_USTRINGPARAM("/") ), this)); - else - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); + osl::MutexGuard guard(mutex_); + if (textual_.get() != 0) { + return textual_->getRootKey(); + } + RegistryKey root; + RegError err = registry_.openRootKey(root); + if (err != REG_NO_ERROR) { + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.getRootKey:" + " underlying Registry::getRootKey() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } + return new Key(this, root); } -//************************************************************************* -sal_Bool SAL_CALL SimpleRegistryImpl::isReadOnly( ) - throw(InvalidRegistryException, RuntimeException) +sal_Bool SimpleRegistry::isReadOnly() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_mutex ); - if ( m_registry.isValid() ) - return m_registry.isReadOnly(); - else - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } + osl::MutexGuard guard(mutex_); + return textual_.get() != 0 || registry_.isReadOnly(); } -//************************************************************************* -void SAL_CALL SimpleRegistryImpl::mergeKey( const OUString& aKeyName, const OUString& aUrl ) - throw(InvalidRegistryException, MergeConflictException, RuntimeException) +void SimpleRegistry::mergeKey( + rtl::OUString const & aKeyName, rtl::OUString const & aUrl) + throw ( + css::registry::InvalidRegistryException, + css::registry::MergeConflictException, css::uno::RuntimeException) { - Guard< Mutex > aGuard( m_mutex ); - if ( m_registry.isValid() ) - { - RegistryKey rootKey; - if ( !m_registry.openRootKey(rootKey) ) - { - RegError ret = m_registry.mergeKey(rootKey, aKeyName, aUrl, sal_False, sal_False); - if (ret) - { - if ( ret == REG_MERGE_CONFLICT ) - return; - if ( ret == REG_MERGE_ERROR ) - { - throw MergeConflictException( - OUString( RTL_CONSTASCII_USTRINGPARAM("MergeConflictException") ), - (OWeakObject *)this ); - } - else - { - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); - } - } - - return; - } + osl::MutexGuard guard(mutex_); + if (textual_.get() != 0) { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.mergeKey: not" + " supported for textual representation")), + static_cast< cppu::OWeakObject * >(this)); + } + RegistryKey root; + RegError err = registry_.openRootKey(root); + if (err == REG_NO_ERROR) { + err = registry_.mergeKey(root, aKeyName, aUrl, false, false); + } + switch (err) { + case REG_NO_ERROR: + case REG_MERGE_CONFLICT: + break; + case REG_MERGE_ERROR: + throw css::registry::MergeConflictException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.mergeKey:" + " underlying Registry::mergeKey() = REG_MERGE_ERROR")), + static_cast< cppu::OWeakObject * >(this)); + default: + throw css::registry::InvalidRegistryException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry.mergeKey:" + " underlying Registry::getRootKey/mergeKey() = ")) + + rtl::OUString::valueOf(static_cast< sal_Int32 >(err))), + static_cast< OWeakObject * >(this)); } - - throw InvalidRegistryException( - OUString( RTL_CONSTASCII_USTRINGPARAM("InvalidRegistryException") ), - (OWeakObject *)this ); -} } -namespace stoc_bootstrap -{ -//************************************************************************* -Reference<XInterface> SAL_CALL SimpleRegistry_CreateInstance( const Reference<XComponentContext>& ) -{ - Reference<XInterface> xRet; - - Registry reg; +} - XSimpleRegistry *pRegistry = (XSimpleRegistry*) new stoc_simreg::SimpleRegistryImpl(reg); +namespace stoc_bootstrap { - if (pRegistry) - { - xRet = Reference<XInterface>::query(pRegistry); - } +css::uno::Reference< css::uno::XInterface > SimpleRegistry_CreateInstance( + css::uno::Reference< css::uno::XComponentContext > const &) +{ + return static_cast< cppu::OWeakObject * >(new SimpleRegistry); +} - return xRet; +css::uno::Sequence< rtl::OUString > simreg_getSupportedServiceNames() { + css::uno::Sequence< rtl::OUString > names(1); + names[0] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.registry.SimpleRegistry")); + return names; } + +rtl::OUString simreg_getImplementationName() { + return rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("com.sun.star.comp.stoc.SimpleRegistry")); } +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/stoc/source/simpleregistry/textualservices.cxx b/stoc/source/simpleregistry/textualservices.cxx new file mode 100644 index 000000000000..5a50a5aa62c6 --- /dev/null +++ b/stoc/source/simpleregistry/textualservices.cxx @@ -0,0 +1,1228 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_stoc.hxx" +#include "sal/config.h" + +#include <cstddef> +#include <cstdlib> +#include <map> +#include <vector> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/container/NoSuchElementException.hpp" +#include "com/sun/star/registry/InvalidRegistryException.hpp" +#include "com/sun/star/registry/XRegistryKey.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/XInterface.hpp" +#include "cppuhelper/implbase1.hxx" +#include "osl/diagnose.h" +#include "rtl/malformeduriexception.hxx" +#include "rtl/ref.hxx" +#include "rtl/string.h" +#include "rtl/uri.hxx" +#include "rtl/ustrbuf.hxx" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "salhelper/simplereferenceobject.hxx" +#include "xmlreader/span.hxx" +#include "xmlreader/xmlreader.hxx" + +#include "textualservices.hxx" + +namespace stoc { namespace simpleregistry { + +namespace { + +namespace css = com::sun::star; + +struct Implementation { + rtl::OUString uri; + rtl::OUString loader; + std::vector< rtl::OUString > services; + std::vector< rtl::OUString > singletons; +}; + +typedef std::map< rtl::OUString, Implementation > Implementations; + +typedef std::map< rtl::OUString, std::vector< rtl::OUString > > + ImplementationMap; + +} + +class Data: public salhelper::SimpleReferenceObject, private boost::noncopyable +{ +public: + Implementations implementations; + ImplementationMap services; + ImplementationMap singletons; +}; + +namespace { + +class Parser: private boost::noncopyable { +public: + Parser(rtl::OUString const & uri, rtl::Reference< Data > const & data); + +private: + void handleComponent(); + + void handleImplementation(); + + void handleService(); + + void handleSingleton(); + + rtl::OUString getNameAttribute(); + + xmlreader::XmlReader reader_; + rtl::Reference< Data > data_; + rtl::OUString attrUri_; + rtl::OUString attrLoader_; + rtl::OUString attrImplementation_; +}; + +Parser::Parser(rtl::OUString const & uri, rtl::Reference< Data > const & data): + reader_(uri), data_(data) +{ + OSL_ASSERT(data.is()); + int ucNsId = reader_.registerNamespaceIri( + xmlreader::Span( + RTL_CONSTASCII_STRINGPARAM( + "http://openoffice.org/2010/uno-components"))); + enum State { + STATE_BEGIN, STATE_END, STATE_COMPONENTS, STATE_COMPONENT_INITIAL, + STATE_COMPONENT, STATE_IMPLEMENTATION, STATE_SERVICE, STATE_SINGLETON }; + for (State state = STATE_BEGIN;;) { + xmlreader::Span name; + int nsId; + xmlreader::XmlReader::Result res = reader_.nextItem( + xmlreader::XmlReader::TEXT_NONE, &name, &nsId); + switch (state) { + case STATE_BEGIN: + if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId && + name.equals(RTL_CONSTASCII_STRINGPARAM("components"))) + { + state = STATE_COMPONENTS; + break; + } + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": unexpected item in outer level"))), + css::uno::Reference< css::uno::XInterface >()); + case STATE_END: + if (res == xmlreader::XmlReader::RESULT_DONE) { + return; + } + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": unexpected item in outer level"))), + css::uno::Reference< css::uno::XInterface >()); + case STATE_COMPONENTS: + if (res == xmlreader::XmlReader::RESULT_END) { + state = STATE_END; + break; + } + if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId && + name.equals(RTL_CONSTASCII_STRINGPARAM("component"))) + { + handleComponent(); + state = STATE_COMPONENT_INITIAL; + break; + } + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": unexpected item in <components>"))), + css::uno::Reference< css::uno::XInterface >()); + case STATE_COMPONENT: + if (res == xmlreader::XmlReader::RESULT_END) { + state = STATE_COMPONENTS; + break; + } + // fall through + case STATE_COMPONENT_INITIAL: + if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId && + name.equals(RTL_CONSTASCII_STRINGPARAM("implementation"))) + { + handleImplementation(); + state = STATE_IMPLEMENTATION; + break; + } + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": unexpected item in <component>"))), + css::uno::Reference< css::uno::XInterface >()); + case STATE_IMPLEMENTATION: + if (res == xmlreader::XmlReader::RESULT_END) { + state = STATE_COMPONENT; + break; + } + if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId && + name.equals(RTL_CONSTASCII_STRINGPARAM("service"))) + { + handleService(); + state = STATE_SERVICE; + break; + } + if (res == xmlreader::XmlReader::RESULT_BEGIN && nsId == ucNsId && + name.equals(RTL_CONSTASCII_STRINGPARAM("singleton"))) + { + handleSingleton(); + state = STATE_SINGLETON; + break; + } + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": unexpected item in <implementation>"))), + css::uno::Reference< css::uno::XInterface >()); + case STATE_SERVICE: + if (res == xmlreader::XmlReader::RESULT_END) { + state = STATE_IMPLEMENTATION; + break; + } + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": unexpected item in <service>"))), + css::uno::Reference< css::uno::XInterface >()); + case STATE_SINGLETON: + if (res == xmlreader::XmlReader::RESULT_END) { + state = STATE_IMPLEMENTATION; + break; + } + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": unexpected item in <service>"))), + css::uno::Reference< css::uno::XInterface >()); + } + } +} + +void Parser::handleComponent() { + attrUri_ = rtl::OUString(); + attrLoader_ = rtl::OUString(); + xmlreader::Span name; + int nsId; + while (reader_.nextAttribute(&nsId, &name)) { + if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && + name.equals(RTL_CONSTASCII_STRINGPARAM("uri"))) + { + if (attrUri_.getLength() != 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": <component> has multiple \"uri\" attributes"))), + css::uno::Reference< css::uno::XInterface >()); + } + attrUri_ = reader_.getAttributeValue(false).convertFromUtf8(); + if (attrUri_.getLength() == 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": <component> has empty \"uri\" attribute"))), + css::uno::Reference< css::uno::XInterface >()); + } + } else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && + name.equals(RTL_CONSTASCII_STRINGPARAM("loader"))) + { + if (attrLoader_.getLength() != 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": <component> has multiple \"loader\"" + " attributes"))), + css::uno::Reference< css::uno::XInterface >()); + } + attrLoader_ = reader_.getAttributeValue(false).convertFromUtf8(); + if (attrLoader_.getLength() == 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": <component> has empty \"loader\" attribute"))), + css::uno::Reference< css::uno::XInterface >()); + } + } else { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": expected <component> attribute \"uri\" or" + " \"loader\""))), + css::uno::Reference< css::uno::XInterface >()); + } + } + if (attrUri_.getLength() == 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": <component> is missing \"uri\" attribute"))), + css::uno::Reference< css::uno::XInterface >()); + } + if (attrLoader_.getLength() == 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": <component> is missing \"loader\" attribute"))), + css::uno::Reference< css::uno::XInterface >()); + } + try { + attrUri_ = rtl::Uri::convertRelToAbs(reader_.getUrl(), attrUri_); + } catch (rtl::MalformedUriException & e) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM(": bad \"uri\" attribute: ")) + + e.getMessage()), + css::uno::Reference< css::uno::XInterface >()); + } +} + +void Parser::handleImplementation() { + attrImplementation_ = getNameAttribute(); + if (data_->implementations.find(attrImplementation_) != + data_->implementations.end()) + { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": duplicate <implementation name=\"")) + + attrImplementation_ + + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("\">"))), + css::uno::Reference< css::uno::XInterface >()); + } + data_->implementations[attrImplementation_].uri = attrUri_; + data_->implementations[attrImplementation_].loader = attrLoader_; +} + +void Parser::handleService() { + rtl::OUString name = getNameAttribute(); + data_->implementations[attrImplementation_].services.push_back(name); + data_->services[name].push_back(attrImplementation_); +} + +void Parser::handleSingleton() { + rtl::OUString name = getNameAttribute(); + data_->implementations[attrImplementation_].singletons.push_back(name); + data_->singletons[name].push_back(attrImplementation_); +} + +rtl::OUString Parser::getNameAttribute() { + rtl::OUString attrName; + xmlreader::Span name; + int nsId; + while (reader_.nextAttribute(&nsId, &name)) { + if (nsId == xmlreader::XmlReader::NAMESPACE_NONE && + name.equals(RTL_CONSTASCII_STRINGPARAM("name"))) + { + if (attrName.getLength() != 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": element has multiple \"name\" attributes"))), + css::uno::Reference< css::uno::XInterface >()); + } + attrName = reader_.getAttributeValue(false).convertFromUtf8(); + if (attrName.getLength() == 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": element has empty \"name\" attribute"))), + css::uno::Reference< css::uno::XInterface >()); + } + } else { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": expected element attribute \"name\""))), + css::uno::Reference< css::uno::XInterface >()); + } + } + if (attrName.getLength() == 0) { + throw css::registry::InvalidRegistryException( + (reader_.getUrl() + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + ": element is missing \"name\" attribute"))), + css::uno::Reference< css::uno::XInterface >()); + } + return attrName; +} + +rtl::OUString pathToString(std::vector< rtl::OUString > const & path) { + rtl::OUStringBuffer buf; + for (std::vector< rtl::OUString >::const_iterator i(path.begin()); + i != path.end(); ++i) + { + buf.append(sal_Unicode('/')); + buf.append(*i); + } + if (buf.getLength() == 0) { + buf.append(sal_Unicode('/')); + } + return buf.makeStringAndClear(); +} + +class Key: public cppu::WeakImplHelper1< css::registry::XRegistryKey > { +public: + Key( + rtl::Reference< Data > const & data, + std::vector< rtl::OUString > const & path): + data_(data), path_(path) { OSL_ASSERT(data.is()); + } + +private: + /* + / + IMPLEMENTATIONS + <implementation> + UNO + LOCATION utf-8 + ACTIVATOR utf-8 + SERVICES + <service> + ... + SINGLETONS + <singleton> utf-16 + ... + ... + SERVICES + <service> utf-8-list + ... + SINGLETONS + <singleton> utf-16 + REGISTERED_BY utf-8-list + ... + */ + enum State { + STATE_ROOT, STATE_IMPLEMENTATIONS, STATE_IMPLEMENTATION, STATE_UNO, + STATE_LOCATION, STATE_ACTIVATOR, STATE_IMPLEMENTATION_SERVICES, + STATE_IMPLEMENTATION_SERVICE, STATE_IMPLEMENTATION_SINGLETONS, + STATE_IMPLEMENTATION_SINGLETON, STATE_SERVICES, STATE_SERVICE, + STATE_SINGLETONS, STATE_SINGLETON, STATE_REGISTEREDBY }; + + virtual rtl::OUString SAL_CALL getKeyName() + throw (css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL isReadOnly() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL isValid() throw(css::uno::RuntimeException); + + virtual css::registry::RegistryKeyType SAL_CALL getKeyType( + rtl::OUString const & rKeyName) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual css::registry::RegistryValueType SAL_CALL getValueType() throw( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual sal_Int32 SAL_CALL getLongValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setLongValue(sal_Int32 value) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual css::uno::Sequence< sal_Int32 > SAL_CALL getLongListValue() throw( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setLongListValue( + com::sun::star::uno::Sequence< sal_Int32 > const & seqValue) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getAsciiValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setAsciiValue(rtl::OUString const & value) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getAsciiListValue() + throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setAsciiListValue( + css::uno::Sequence< rtl::OUString > const & seqValue) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getStringValue() throw( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setStringValue(rtl::OUString const & value) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getStringListValue() + throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setStringListValue( + css::uno::Sequence< rtl::OUString > const & seqValue) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual css::uno::Sequence< sal_Int8 > SAL_CALL getBinaryValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException); + + virtual void SAL_CALL setBinaryValue( + css::uno::Sequence< sal_Int8 > const & value) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL openKey( + rtl::OUString const & aKeyName) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual css::uno::Reference< css::registry::XRegistryKey > SAL_CALL + createKey(rtl::OUString const & aKeyName) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual void SAL_CALL closeKey() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual void SAL_CALL deleteKey(rtl::OUString const & rKeyName) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual + css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > + SAL_CALL openKeys() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual css::uno::Sequence< rtl::OUString > SAL_CALL getKeyNames() throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual sal_Bool SAL_CALL createLink( + rtl::OUString const & aLinkName, rtl::OUString const & aLinkTarget) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual void SAL_CALL deleteLink(rtl::OUString const & rLinkName) throw ( + css::registry::InvalidRegistryException, css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getLinkTarget( + rtl::OUString const & rLinkName) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + virtual rtl::OUString SAL_CALL getResolvedName( + rtl::OUString const & aKeyName) + throw ( + css::registry::InvalidRegistryException, + css::uno::RuntimeException); + + bool find( + rtl::OUString const & relative, std::vector< rtl::OUString > * path, + State * state, css::registry::RegistryValueType * type) const; + + css::uno::Sequence< rtl::OUString > getChildren(); + + rtl::Reference< Data > data_; + std::vector< rtl::OUString > path_; +}; + +rtl::OUString Key::getKeyName() throw (css::uno::RuntimeException) { + return pathToString(path_); +} + +sal_Bool Key::isReadOnly() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + return true; +} + +sal_Bool Key::isValid() throw(css::uno::RuntimeException) { + return true; +} + +css::registry::RegistryKeyType Key::getKeyType(rtl::OUString const & rKeyName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + if (!find(rtl::OUString(), 0, 0, 0)) { + throw css::registry::InvalidRegistryException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("unknown key ")) + + rKeyName), + static_cast< cppu::OWeakObject * >(this)); + } + return css::registry::RegistryKeyType_KEY; +} + +css::registry::RegistryValueType Key::getValueType() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + css::registry::RegistryValueType type = + css::registry::RegistryValueType_NOT_DEFINED; + OSL_VERIFY(find(rtl::OUString(), 0, 0, &type)); + return type; +} + +sal_Int32 Key::getLongValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) +{ + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getLongValue not supported")), + static_cast< OWeakObject * >(this)); +} + +void Key::setLongValue(sal_Int32) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " setLongValue not supported")), + static_cast< OWeakObject * >(this)); +} + +css::uno::Sequence< sal_Int32 > Key::getLongListValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) +{ + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getLongListValue not supported")), + static_cast< OWeakObject * >(this)); +} + +void Key::setLongListValue(css::uno::Sequence< sal_Int32 > const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " setLongListValue not supported")), + static_cast< OWeakObject * >(this)); +} + +rtl::OUString Key::getAsciiValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) +{ + State state = STATE_ROOT; + OSL_VERIFY(find(rtl::OUString(), 0, &state, 0)); + switch (state) { + case STATE_LOCATION: + return data_->implementations[path_[1]].uri; + case STATE_ACTIVATOR: + return data_->implementations[path_[1]].loader; + default: + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getAsciiValue: wrong type")), + static_cast< OWeakObject * >(this)); + } +} + +void Key::setAsciiValue(rtl::OUString const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " setAsciiValue not supported")), + static_cast< OWeakObject * >(this)); +} + +css::uno::Sequence< rtl::OUString > Key::getAsciiListValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) +{ + State state = STATE_ROOT; + OSL_VERIFY(find(rtl::OUString(), 0, &state, 0)); + std::vector< rtl::OUString > const * list; + switch (state) { + case STATE_SERVICE: + list = &data_->services[path_[1]]; + break; + case STATE_REGISTEREDBY: + list = &data_->singletons[path_[1]]; + break; + default: + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getAsciiListValue: wrong type")), + static_cast< OWeakObject * >(this)); + } + if (list->size() > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getAsciiListValue: too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< rtl::OUString > seq( + static_cast< sal_Int32 >(list->size())); + sal_Int32 i = 0; + for (std::vector< rtl::OUString >::const_iterator j(list->begin()); + j != list->end(); ++j) + { + seq[i++] = *j; + } + return seq; +} + +void Key::setAsciiListValue(css::uno::Sequence< rtl::OUString > const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " setAsciiListValue not supported")), + static_cast< OWeakObject * >(this)); +} + +rtl::OUString Key::getStringValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) +{ + State state = STATE_ROOT; + OSL_VERIFY(find(rtl::OUString(), 0, &state, 0)); + switch (state) { + case STATE_IMPLEMENTATION_SINGLETON: + case STATE_SINGLETON: + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getStringValue: does not associate singletons with" + " services")), + static_cast< OWeakObject * >(this)); + default: + break; + } + // default case extracted from switch to avoid erroneous compiler warnings + // on Solaris: + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getStringValue: wrong type")), + static_cast< OWeakObject * >(this)); +} + +void Key::setStringValue(rtl::OUString const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " setStringValue not supported")), + static_cast< OWeakObject * >(this)); +} + +css::uno::Sequence< rtl::OUString > Key::getStringListValue() throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) +{ + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getStringListValue not supported")), + static_cast< OWeakObject * >(this)); +} + +void Key::setStringListValue(css::uno::Sequence< rtl::OUString > const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " setStringListValue not supported")), + static_cast< OWeakObject * >(this)); +} + +css::uno::Sequence< sal_Int8 > Key::getBinaryValue() + throw ( + css::registry::InvalidRegistryException, + css::registry::InvalidValueException, css::uno::RuntimeException) +{ + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getBinarValue not supported")), + static_cast< OWeakObject * >(this)); +} + +void Key::setBinaryValue(css::uno::Sequence< sal_Int8 > const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " setBinaryValue not supported")), + static_cast< OWeakObject * >(this)); +} + +css::uno::Reference< css::registry::XRegistryKey > Key::openKey( + rtl::OUString const & aKeyName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + std::vector< rtl::OUString > path; + if (!find(aKeyName, &path, 0, 0)) { + return css::uno::Reference< css::registry::XRegistryKey >(); + } + return new Key(data_, path); +} + +css::uno::Reference< css::registry::XRegistryKey > Key::createKey( + rtl::OUString const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " createKey not supported")), + static_cast< OWeakObject * >(this)); +} + +void Key::closeKey() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{} + +void Key::deleteKey(rtl::OUString const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " deleteKey not supported")), + static_cast< OWeakObject * >(this)); +} + +css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > +Key::openKeys() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + css::uno::Sequence< rtl::OUString > names(getChildren()); + css::uno::Sequence< css::uno::Reference< css::registry::XRegistryKey > > + keys(names.getLength()); + for (sal_Int32 i = 0; i < keys.getLength(); ++i) { + keys[i] = openKey(names[i]); + OSL_ASSERT(keys[i].is()); + } + return keys; +} + +css::uno::Sequence< rtl::OUString > Key::getKeyNames() + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + css::uno::Sequence< rtl::OUString > names(getChildren()); + rtl::OUString prefix(pathToString(path_)); + prefix += rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/")); + for (sal_Int32 i = 0; i < names.getLength(); ++i) { + names[i] = prefix + names[i]; + } + return names; +} + +sal_Bool Key::createLink(rtl::OUString const &, rtl::OUString const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " createLink not supported")), + static_cast< OWeakObject * >(this)); +} + +void Key::deleteLink(rtl::OUString const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " deleteLink not supported")), + static_cast< OWeakObject * >(this)); +} + +rtl::OUString Key::getLinkTarget(rtl::OUString const &) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + throw css::registry::InvalidRegistryException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual services key" + " getLinkTarget not supported")), + static_cast< OWeakObject * >(this)); +} + +rtl::OUString Key::getResolvedName(rtl::OUString const & aKeyName) + throw (css::registry::InvalidRegistryException, css::uno::RuntimeException) +{ + std::vector< rtl::OUString > path; + find(aKeyName, &path, 0, 0); + return pathToString(path); +} + +bool Key::find( + rtl::OUString const & relative, std::vector< rtl::OUString > * path, + State * state, css::registry::RegistryValueType * type) const +{ + std::vector< rtl::OUString > p(path_); + sal_Int32 i = 0; + do { + rtl::OUString seg(relative.getToken(0, '/', i)); + if (seg.getLength() != 0) { + p.push_back(seg); + } + } while (i >= 0); + if (path != 0) { + *path = p; + } + std::size_t const MAX_TRANSITIONS = 4; + struct StateInfo { + css::registry::RegistryValueType type; + std::size_t count; + struct { char const * segment; State state; } + transitions[MAX_TRANSITIONS]; + }; + static StateInfo const info[] = { + // STATE_ROOT: + { css::registry::RegistryValueType_NOT_DEFINED, 3, + { { "IMPLEMENTATIONS", STATE_IMPLEMENTATIONS }, + { "SERVICES", STATE_SERVICES }, + { "SINGLETONS", STATE_SINGLETONS } } }, + // STATE_IMPLEMENTATIONS: + { css::registry::RegistryValueType_NOT_DEFINED, 1, + { { 0, STATE_IMPLEMENTATION } } }, + // STATE_IMPLEMENTATION: + { css::registry::RegistryValueType_NOT_DEFINED, 1, + { { "UNO", STATE_UNO } } }, + // STATE_UNO: + { css::registry::RegistryValueType_NOT_DEFINED, 4, + { { "LOCATION", STATE_LOCATION }, + { "ACTIVATOR", STATE_ACTIVATOR }, + { "SERVICES", STATE_IMPLEMENTATION_SERVICES }, + { "SINGLETONS", STATE_IMPLEMENTATION_SINGLETONS } } }, + // STATE_LOCATION: + { css::registry::RegistryValueType_ASCII, 0, {} }, + // STATE_ACTIVATOR: + { css::registry::RegistryValueType_ASCII, 0, {} }, + // STATE_IMPLEMENTATION_SERVICES: + { css::registry::RegistryValueType_NOT_DEFINED, 1, + { { 0, STATE_IMPLEMENTATION_SERVICE } } }, + // STATE_IMPLEMENTATION_SERVICE: + { css::registry::RegistryValueType_NOT_DEFINED, 0, {} }, + // STATE_IMPLEMENTATION_SINGLETONS: + { css::registry::RegistryValueType_NOT_DEFINED, 1, + { { 0, STATE_IMPLEMENTATION_SINGLETON } } }, + // STATE_IMPLEMENTATION_SINGLETON: + { css::registry::RegistryValueType_STRING, 0, {} }, + // STATE_SERVICES: + { css::registry::RegistryValueType_NOT_DEFINED, 1, + { { 0, STATE_SERVICE } } }, + // STATE_SERVICE: + { css::registry::RegistryValueType_ASCIILIST, 0, {} }, + // STATE_SINGLETONS: + { css::registry::RegistryValueType_NOT_DEFINED, 1, + { { 0, STATE_SINGLETON } } }, + // STATE_SINGLETON: + { css::registry::RegistryValueType_STRING, 1, + { { "REGISTERED_BY", STATE_REGISTEREDBY } } }, + // STATE_REGISTEREDBY: + { css::registry::RegistryValueType_ASCIILIST, 0, {} } }; + State s = STATE_ROOT; + for (std::vector< rtl::OUString >::iterator j(p.begin()); j != p.end(); ++j) + { + bool found = false; + for (std::size_t k = 0; k < info[s].count; ++k) { + if (info[s].transitions[k].segment == 0) { + switch (info[s].transitions[k].state) { + case STATE_IMPLEMENTATION: + found = data_->implementations.find(*j) != + data_->implementations.end(); + break; + case STATE_IMPLEMENTATION_SERVICE: + case STATE_IMPLEMENTATION_SINGLETON: + found = true; //TODO + break; + case STATE_SERVICE: + found = data_->services.find(*j) != data_->services.end(); + break; + case STATE_SINGLETON: + found = data_->singletons.find(*j) != + data_->singletons.end(); + break; + default: + std::abort(); // this cannot happen + } + } else { + found = j->equalsAscii(info[s].transitions[k].segment); + } + if (found) { + s = info[s].transitions[k].state; + break; + } + } + if (!found) { + return false; + } + } + if (state != 0) { + *state = s; + } + if (type != 0) { + *type = info[s].type; + } + return true; +} + +css::uno::Sequence< rtl::OUString > Key::getChildren() { + State state = STATE_ROOT; + OSL_VERIFY(find(rtl::OUString(), 0, &state, 0)); + switch (state) { + default: + std::abort(); // this cannot happen + // pseudo-fall-through to avoid warnings on MSC + case STATE_ROOT: + { + css::uno::Sequence< rtl::OUString > seq(3); + seq[0] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("IMPLEMENTATIONS")); + seq[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SERVICES")); + seq[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SINGLETONS")); + return seq; + } + case STATE_IMPLEMENTATIONS: + { + if (data_->implementations.size() > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual" + " services key openKeys: too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< rtl::OUString > seq( + static_cast< sal_Int32 >(data_->implementations.size())); + sal_Int32 i = 0; + for (Implementations::iterator j(data_->implementations.begin()); + j != data_->implementations.end(); ++j) + { + seq[i++] = j->first; + } + return seq; + } + case STATE_UNO: + { + css::uno::Sequence< rtl::OUString > seq(4); + seq[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCATION")); + seq[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ACTIVATOR")); + seq[2] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SERVICES")); + seq[3] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SINGLETONS")); + return seq; + } + case STATE_LOCATION: + case STATE_ACTIVATOR: + case STATE_IMPLEMENTATION_SERVICE: + case STATE_IMPLEMENTATION_SINGLETON: + case STATE_SERVICE: + case STATE_REGISTEREDBY: + return css::uno::Sequence< rtl::OUString >(); + case STATE_IMPLEMENTATION_SERVICES: + { + if (data_->implementations[path_[1]].services.size() > + SAL_MAX_INT32) + { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual" + " services key openKeys: too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< rtl::OUString > seq( + static_cast< sal_Int32 >( + data_->implementations[path_[1]].services.size())); + sal_Int32 i = 0; + for (std::vector< rtl::OUString >::iterator j( + data_->implementations[path_[1]].services.begin()); + j != data_->implementations[path_[1]].services.end(); ++j) + { + seq[i++] = *j; + } + return seq; + } + case STATE_IMPLEMENTATION_SINGLETONS: + { + if (data_->implementations[path_[1]].singletons.size() > + SAL_MAX_INT32) + { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual" + " services key openKeys: too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< rtl::OUString > seq( + static_cast< sal_Int32 >( + data_->implementations[path_[1]].singletons.size())); + sal_Int32 i = 0; + for (std::vector< rtl::OUString >::iterator j( + data_->implementations[path_[1]].singletons.begin()); + j != data_->implementations[path_[1]].singletons.end(); ++j) + { + seq[i++] = *j; + } + return seq; + } + case STATE_SERVICES: + { + if (data_->services.size() > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual" + " services key openKeys: too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< rtl::OUString > seq( + static_cast< sal_Int32 >(data_->services.size())); + sal_Int32 i = 0; + for (ImplementationMap::iterator j(data_->services.begin()); + j != data_->services.end(); ++j) + { + seq[i++] = j->first; + } + return seq; + } + case STATE_SINGLETONS: + { + if (data_->singletons.size() > SAL_MAX_INT32) { + throw css::registry::InvalidValueException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "com.sun.star.registry.SimpleRegistry textual" + " services key openKeys: too large")), + static_cast< OWeakObject * >(this)); + } + css::uno::Sequence< rtl::OUString > seq( + static_cast< sal_Int32 >(data_->singletons.size())); + sal_Int32 i = 0; + for (ImplementationMap::iterator j(data_->singletons.begin()); + j != data_->singletons.end(); ++j) + { + seq[i++] = j->first; + } + return seq; + } + case STATE_SINGLETON: + { + css::uno::Sequence< rtl::OUString > seq(1); + seq[0] = rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("REGISTERED_BY")); + return seq; + } + } +} + +} + +TextualServices::TextualServices(rtl::OUString const & uri): + uri_(uri), data_(new Data) +{ + try { + Parser(uri, data_); + } catch (css::container::NoSuchElementException &) { + throw css::registry::InvalidRegistryException( + (uri + + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM(": no such file"))), + css::uno::Reference< css::uno::XInterface >()); + } +} + +TextualServices::~TextualServices() {} + +css::uno::Reference< css::registry::XRegistryKey > TextualServices::getRootKey() +{ + return new Key(data_, std::vector< rtl::OUString >()); +} + +} } diff --git a/stoc/source/simpleregistry/textualservices.hxx b/stoc/source/simpleregistry/textualservices.hxx new file mode 100644 index 000000000000..0261e260444e --- /dev/null +++ b/stoc/source/simpleregistry/textualservices.hxx @@ -0,0 +1,67 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_STOC_SOURCE_SIMPLEREGISTRY_TEXTUALSERVICES_HXX +#define INCLUDED_STOC_SOURCE_SIMPLEREGISTRY_TEXTUALSERVICES_HXX + +#include "sal/config.h" + +#include <memory> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" + +namespace com { namespace sun { namespace star { namespace registry { + class XRegistryKey; +} } } } + +namespace stoc { namespace simpleregistry { + +class Data; + +class TextualServices: private boost::noncopyable { +public: + explicit TextualServices(rtl::OUString const & uri); + // throws com::sun::star::registry::InvalidRegistryException + + virtual ~TextualServices(); + + inline rtl::OUString getUri() { return uri_; } + + com::sun::star::uno::Reference< com::sun::star::registry::XRegistryKey > + getRootKey(); + +private: + rtl::OUString uri_; + rtl::Reference< Data > data_; +}; + +} } + +#endif diff --git a/stoc/source/stocservices/stocservices.cxx b/stoc/source/stocservices/stocservices.cxx index 6e69b8f8c1cd..348ad2651342 100644 --- a/stoc/source/stocservices/stocservices.cxx +++ b/stoc/source/stocservices/stocservices.cxx @@ -102,12 +102,6 @@ void SAL_CALL component_getImplementationEnvironment( *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; } //================================================================================================== -sal_Bool SAL_CALL component_writeInfo( - void * pServiceManager, void * pRegistryKey ) -{ - return component_writeInfoHelper( pServiceManager, pRegistryKey, g_entries ); -} -//================================================================================================== void * SAL_CALL component_getFactory( const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) { diff --git a/stoc/test/uriproc/makefile.mk b/stoc/test/uriproc/makefile.mk index cfdc33e7586b..05ffd5fdd210 100644 --- a/stoc/test/uriproc/makefile.mk +++ b/stoc/test/uriproc/makefile.mk @@ -35,6 +35,8 @@ TARGET := test_uriproc ENABLE_EXCEPTIONS := TRUE +my_components = stocservices + .INCLUDE: settings.mk CFLAGSCXX += $(CPPUNIT_CFLAGS) @@ -62,14 +64,20 @@ ALLTAR: test test .PHONY: $(SHL1TARGETN) $(MISC)/$(TARGET)/services.rdb $(CPPUNITTESTER) $(SHL1TARGETN) \ - -env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \ -env:UNO_TYPES=$(my_file)$(SOLARBINDIR)/udkapi.rdb \ - -env:OOO_TEST_PREFIX=$(my_file)$(PWD)/$(DLLDEST)/ + -env:UNO_SERVICES=$(my_file)$(PWD)/$(MISC)/$(TARGET)/services.rdb \ + -env:URE_INTERNAL_LIB_DIR=$(my_file)$(PWD)/$(DLLDEST) + +$(MISC)/$(TARGET)/services.rdb .ERRREMOVE: $(SOLARENV)/bin/packcomponents.xslt \ + $(MISC)/$(TARGET)/services.input \ + $(my_components:^"$(MISC)/":+".component") + $(XSLTPROC) --nonet --stringparam prefix $(PWD)/$(MISC)/ -o $@ \ + $(SOLARENV)/bin/packcomponents.xslt $(MISC)/$(TARGET)/services.input -$(MISC)/$(TARGET)/services.rdb: +$(MISC)/$(TARGET)/services.input: $(MKDIRHIER) $(@:d) - $(RM) $@ - $(REGCOMP) -register -r $@ -wop=vnd.sun.star.expand:\$${{OOO_TEST_PREFIX}} \ - -c $(DLLDEST)/stocservices.uno$(DLLPOST) + echo \ + '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \ + > $@ .END diff --git a/stoc/util/bootstrap.component b/stoc/util/bootstrap.component new file mode 100644 index 000000000000..ccc131b4a6db --- /dev/null +++ b/stoc/util/bootstrap.component @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.DLLComponentLoader"> + <service name="com.sun.star.loader.SharedLibrary"/> + </implementation> + <implementation name="com.sun.star.comp.stoc.ImplementationRegistration"> + <service name="com.sun.star.registry.ImplementationRegistration"/> + </implementation> + <implementation name="com.sun.star.comp.stoc.NestedRegistry"> + <service name="com.sun.star.registry.NestedRegistry"/> + </implementation> + <implementation name="com.sun.star.comp.stoc.ORegistryServiceManager"> + <service name="com.sun.star.lang.RegistryServiceManager"/> + </implementation> + <implementation name="com.sun.star.comp.stoc.OServiceManager"> + <service name="com.sun.star.lang.ServiceManager"/> + </implementation> + <implementation name="com.sun.star.comp.stoc.OServiceManagerWrapper"/> + <implementation name="com.sun.star.comp.stoc.RegistryTypeDescriptionProvider"> + <service name="com.sun.star.reflection.TypeDescriptionProvider"/> + </implementation> + <implementation name="com.sun.star.comp.stoc.SimpleRegistry"> + <service name="com.sun.star.registry.SimpleRegistry"/> + </implementation> + <implementation name="com.sun.star.comp.stoc.TypeDescriptionManager"> + <service name="com.sun.star.reflection.TypeDescriptionManager"/> + </implementation> + <implementation name="com.sun.star.security.comp.stoc.AccessController"> + <service name="com.sun.star.security.AccessController"/> + </implementation> + <implementation name="com.sun.star.security.comp.stoc.FilePolicy"> + <service name="com.sun.star.security.Policy"/> + </implementation> +</component> diff --git a/stoc/util/makefile.mk b/stoc/util/makefile.mk index 4243d45511fe..32f229cc3d14 100644 --- a/stoc/util/makefile.mk +++ b/stoc/util/makefile.mk @@ -57,7 +57,8 @@ SHL1STDLIBS= \ $(SALHELPERLIB) \ $(CPPUHELPERLIB) \ $(SALLIB) \ - $(REGLIB) + $(REGLIB) \ + $(XMLREADERLIB) SHL1DEPN= SHL1IMPLIB= i$(TARGET) @@ -94,3 +95,16 @@ DEF2NAME= $(SHL2TARGET) .INCLUDE : target.mk +ALLTAR : $(MISC)/bootstrap.component $(MISC)/stocservices.component + +$(MISC)/bootstrap.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \ + bootstrap.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL1TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt bootstrap.component + +$(MISC)/stocservices.component .ERRREMOVE : \ + $(SOLARENV)/bin/createcomponent.xslt stocservices.component + $(XSLTPROC) --nonet --stringparam uri \ + '$(COMPONENTPREFIX_URE_NATIVE)$(SHL2TARGETN:f)' -o $@ \ + $(SOLARENV)/bin/createcomponent.xslt stocservices.component diff --git a/stoc/util/stocservices.component b/stoc/util/stocservices.component new file mode 100644 index 000000000000..fb3528728347 --- /dev/null +++ b/stoc/util/stocservices.component @@ -0,0 +1,51 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!--********************************************************************** +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +**********************************************************************--> + +<component loader="com.sun.star.loader.SharedLibrary" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name="com.sun.star.comp.stoc.TypeConverter"> + <service name="com.sun.star.script.Converter"/> + </implementation> + <implementation name="com.sun.star.comp.uri.ExternalUriReferenceTranslator"> + <service name="com.sun.star.uri.ExternalUriReferenceTranslator"/> + </implementation> + <implementation name="com.sun.star.comp.uri.UriReferenceFactory"> + <service name="com.sun.star.uri.UriReferenceFactory"/> + </implementation> + <implementation + name="com.sun.star.comp.uri.UriSchemeParser_vndDOTsunDOTstarDOTexpand"> + <service name="com.sun.star.uri.UriSchemeParser_vndDOTsunDOTstarDOTexpand"/> + </implementation> + <implementation + name="com.sun.star.comp.uri.UriSchemeParser_vndDOTsunDOTstarDOTscript"> + <service name="com.sun.star.uri.UriSchemeParser_vndDOTsunDOTstarDOTscript"/> + </implementation> + <implementation name="com.sun.star.comp.uri.VndSunStarPkgUrlReferenceFactory"> + <service name="com.sun.star.uri.VndSunStarPkgUrlReferenceFactory"/> + </implementation> +</component> diff --git a/udkapi/com/sun/star/script/XDirectInvocation.idl b/udkapi/com/sun/star/script/XDirectInvocation.idl new file mode 100644 index 000000000000..8a37c47dd781 --- /dev/null +++ b/udkapi/com/sun/star/script/XDirectInvocation.idl @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef __com_sun_star_script_XDirectInvocation_idl__ +#define __com_sun_star_script_XDirectInvocation_idl__ + +#ifndef __com_sun_star_uno_XInterface_idl__ +#include <com/sun/star/uno/XInterface.idl> +#endif + +#ifndef __com_sun_star_lang_IllegalArgumentException_idl__ +#include <com/sun/star/lang/IllegalArgumentException.idl> +#endif + +#ifndef __com_sun_star_script_CannotConvertException_idl__ +#include <com/sun/star/script/CannotConvertException.idl> +#endif + +#ifndef __com_sun_star_reflection_InvocationTargetException_idl__ +#include <com/sun/star/reflection/InvocationTargetException.idl> +#endif + +#ifndef __com_sun_star_beans_UnknownPropertyException_idl__ +#include <com/sun/star/beans/UnknownPropertyException.idl> +#endif + + +//============================================================================= + + module com { module sun { module star { module script { + +//============================================================================= +/** provides access to an object's methods and properties. + */ +published interface XDirectInvocation: com::sun::star::uno::XInterface +{ + //------------------------------------------------------------------------- + /** provides access to methods and properties exposed by an object. + + @param aParams all parameters, out parameters are not supported + */ + any directInvoke( [in] string aName, + [in] sequence<any> aParams ) + raises( com::sun::star::lang::IllegalArgumentException, + com::sun::star::script::CannotConvertException, + com::sun::star::reflection::InvocationTargetException ); + + //------------------------------------------------------------------------- + /** returns <TRUE/> if the method or property with the specified name exists, else <FALSE/>. + */ + boolean hasMember( [in] string aName ); +}; + +//============================================================================= + +}; }; }; }; + +#endif + diff --git a/udkapi/com/sun/star/script/makefile.mk b/udkapi/com/sun/star/script/makefile.mk index e6f49a984bca..0a16872f1107 100644 --- a/udkapi/com/sun/star/script/makefile.mk +++ b/udkapi/com/sun/star/script/makefile.mk @@ -60,6 +60,7 @@ IDLFILES=\ XAllListener.idl\ XAllListenerAdapterService.idl\ XDebugging.idl\ + XDirectInvocation.idl\ XEngine.idl\ XEngineListener.idl\ XEventAttacher.idl\ diff --git a/udkapi/prj/makefile.mk b/udkapi/prj/makefile.mk deleted file mode 100644 index 0b1e9335ed44..000000000000 --- a/udkapi/prj/makefile.mk +++ /dev/null @@ -1,61 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=. -PRJNAME:=udkapi - -# --- Settings ----------------------------------------------------- - -OUT!:=$(PRJ)$/out - -# ------------------------------------------------------------------ - -INCLUDES= \ - com$/sun$/star$/container$/makefile.mk \ - com$/sun$/star$/io$/makefile.mk \ - com$/sun$/star$/reflection$/makefile.mk \ - com$/sun$/star$/beans$/makefile.mk \ - com$/sun$/star$/lang$/makefile.mk \ - com$/sun$/star$/uno$/makefile.mk \ - com$/sun$/star$/uno$/util$/logging$/makefile.mk \ - com$/sun$/star$/corba$/makefile.mk \ - com$/sun$/star$/corba$/iop$/makefile.mk \ - com$/sun$/star$/corba$/giop$/makefile.mk \ - com$/sun$/star$/corba$/iiop$/makefile.mk \ - com$/sun$/star$/script$/makefile.mk \ - com$/sun$/star$/test$/makefile.mk \ - com$/sun$/star$/registry$/makefile.mk \ - com$/sun$/star$/loader$/makefile.mk \ - com$/sun$/star$/bridge$/makefile.mk - -.INCLUDE: $(INCLUDES) - -out$/$(PRJNAME).rdb:: $(ALLIDLFILES) - unoidl @$(mktmp -I$(PRJ) -Burd -OHout $(ALLIDLFILES:+"\n")) - regmerge @$(mktmp $@ /UCR out$/{$(?:f:s/.idl/.urd/:+"\n")} ) - touch $@ - diff --git a/ure/prj/build.lst b/ure/prj/build.lst index 07fbfc484201..7618bf3299b7 100644 --- a/ure/prj/build.lst +++ b/ure/prj/build.lst @@ -1,2 +1,2 @@ -ur ure : cli_ure solenv NULL +ur ure : LIBXSLT:libxslt binaryurp cli_ure io javaunohelper remotebridges solenv stoc NULL ur ure\source nmake - all ur_source NULL diff --git a/ure/prj/d.lst b/ure/prj/d.lst index 23524c981608..22cfb161c19a 100644 --- a/ure/prj/d.lst +++ b/ure/prj/d.lst @@ -1,9 +1,11 @@ mkdir: %_DEST%\bin%_EXT%\ure -..\%__SRC%\bin\ure\README %_DEST%\bin%_EXT%\ure\README -..\%__SRC%\bin\ure\THIRDPARTYLICENSEREADME.html %_DEST%\bin%_EXT%\ure\THIRDPARTYLICENSEREADME.html -..\%__SRC%\bin\ure\jvmfwk3.ini %_DEST%\bin%_EXT%\ure\jvmfwk3.ini -..\%__SRC%\bin\ure\jvmfwk3rc %_DEST%\bin%_EXT%\ure\jvmfwk3rc -..\%__SRC%\bin\ure\startup.sh %_DEST%\bin%_EXT%\ure\startup.sh -..\%__SRC%\bin\ure\uno.ini %_DEST%\bin%_EXT%\ure\uno.ini -..\%__SRC%\bin\ure\unorc %_DEST%\bin%_EXT%\ure\unorc +mkdir: %_DEST%\xml%_EXT%\ure ..\%__SRC%\bin\uretest.zip %COMMON_DEST%\bin%_EXT%\uretest.zip +..\%__SRC%\misc\services.rdb %_DEST%\xml%_EXT%\ure\services.rdb +..\source\README %_DEST%\bin%_EXT%\ure\README +..\source\THIRDPARTYLICENSEREADME.html %_DEST%\bin%_EXT%\ure\THIRDPARTYLICENSEREADME.html +..\source\jvmfwk3.ini %_DEST%\bin%_EXT%\ure\jvmfwk3.ini +..\source\jvmfwk3rc %_DEST%\bin%_EXT%\ure\jvmfwk3rc +..\source\startup.sh %_DEST%\bin%_EXT%\ure\startup.sh +..\source\uno.ini %_DEST%\bin%_EXT%\ure\uno.ini +..\source\unorc %_DEST%\bin%_EXT%\ure\unorc diff --git a/ure/source/README b/ure/source/README index 6e5162d8f058..fdf1c7e85d9b 100644 --- a/ure/source/README +++ b/ure/source/README @@ -63,8 +63,8 @@ Linux x86, Solaris x86, and Solaris SPARC: /opt/openoffice.org/ure/bin/regcomp.bin [private] /opt/openoffice.org/ure/lib/unorc [private] /opt/openoffice.org/ure/lib/libreg.so.3 [private] -/opt/openoffice.org/ure/lib/librmcxt.so.3 [private] /opt/openoffice.org/ure/lib/libstore.so.3 [private] +/opt/openoffice.org/ure/lib/libxmlreader.so [private] /opt/openoffice.org/ure/lib/libjvmaccessgcc3.so.3 [private; Linux x86 only] /opt/openoffice.org/ure/lib/libjvmaccessC52.so.3 [private; Solaris only] /opt/openoffice.org/ure/lib/libjvmfwk.so.3 [private] @@ -74,7 +74,6 @@ Linux x86, Solaris x86, and Solaris SPARC: /opt/openoffice.org/ure/lib/libgcc3_uno.so [private; Linux x86 only] /opt/openoffice.org/ure/lib/libsunpro5_uno.so [private; Solaris only] /opt/openoffice.org/ure/lib/libjava_uno.so [private] -/opt/openoffice.org/ure/lib/liburp_uno.so [private] /opt/openoffice.org/ure/lib/libunsafe_uno_uno.so [private] /opt/openoffice.org/ure/lib/libaffine_uno_uno.so [private] /opt/openoffice.org/ure/lib/liblog_uno_uno.so [private] @@ -82,8 +81,8 @@ Linux x86, Solaris x86, and Solaris SPARC: /opt/openoffice.org/ure/lib/libjuh.so [private] /opt/openoffice.org/ure/lib/libjuhx.so [private] /opt/openoffice.org/ure/lib/acceptor.uno.so [private] +/opt/openoffice.org/ure/lib/binaryurp.uno.so [private] /opt/openoffice.org/ure/lib/bootstrap.uno.so [private] -/opt/openoffice.org/ure/lib/bridgefac.uno.so [private] /opt/openoffice.org/ure/lib/connector.uno.so [private] /opt/openoffice.org/ure/lib/introspection.uno.so [private] /opt/openoffice.org/ure/lib/invocadapt.uno.so [private] @@ -93,7 +92,6 @@ Linux x86, Solaris x86, and Solaris SPARC: /opt/openoffice.org/ure/lib/namingservice.uno.so [private] /opt/openoffice.org/ure/lib/proxyfac.uno.so [private] /opt/openoffice.org/ure/lib/reflection.uno.so [private] -/opt/openoffice.org/ure/lib/remotebridge.uno.so [private] /opt/openoffice.org/ure/lib/streams.uno.so [private] /opt/openoffice.org/ure/lib/textinstream.uno.so [private] /opt/openoffice.org/ure/lib/textoutstream.uno.so [private] @@ -126,8 +124,8 @@ Program Files\URE\misc\services.rdb Program Files\URE\bin\libxml2.dll [external] Program Files\URE\bin\uno.ini [private] Program Files\URE\bin\reg3.dll [private] -Program Files\URE\bin\rmcxt3.dll [private] Program Files\URE\bin\store3.dll [private] +Program Files\URE\bin\xmlreader.dll [private] Program Files\URE\bin\jvmaccess3MSC.dll [private] Program Files\URE\bin\jvmfwk3.dll [private] Program Files\URE\bin\sunjavaplugin.dll [private] @@ -136,7 +134,6 @@ Program Files\URE\bin\jvmfwk3.ini [private] Program Files\URE\bin\msci_uno.dll [private] Program Files\URE\bin\java_uno.dll [private] Program Files\URE\bin\cli_uno.dll [private] -Program Files\URE\bin\urp_uno.dll [private] Program Files\URE\bin\unsafe_uno_uno.dll [private] Program Files\URE\bin\affine_uno_uno.dll [private] Program Files\URE\bin\log_uno_uno.dll [private] @@ -145,8 +142,8 @@ Program Files\URE\bin\jpipx.dll [private] Program Files\URE\bin\juh.dll [private] Program Files\URE\bin\juhx.dll [private] Program Files\URE\bin\acceptor.uno.dll [private] +Program Files\URE\bin\binaryurp.uno.dll [private] Program Files\URE\bin\bootstrap.uno.dll [private] -Program Files\URE\bin\bridgefac.uno.dll [private] Program Files\URE\bin\connector.uno.dll [private] Program Files\URE\bin\introspection.uno.dll [private] Program Files\URE\bin\invocadapt.uno.dll [private] @@ -156,7 +153,6 @@ Program Files\URE\bin\javavm.uno.dll [private] Program Files\URE\bin\namingservice.uno.dll [private] Program Files\URE\bin\proxyfac.uno.dll [private] Program Files\URE\bin\reflection.uno.dll [private] -Program Files\URE\bin\remotebridge.uno.dll [private] Program Files\URE\bin\streams.uno.dll [private] Program Files\URE\bin\textinstream.uno.dll [private] Program Files\URE\bin\textoutstream.uno.dll [private] diff --git a/ure/source/makefile.mk b/ure/source/makefile.mk index a1728b2773b4..bdd43656b32c 100644 --- a/ure/source/makefile.mk +++ b/ure/source/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -25,52 +25,45 @@ # #************************************************************************* -PRJ := .. -PRJNAME := ure -TARGET := $(PRJNAME) - -.INCLUDE: settings.mk - -.IF "$(OS)" == "WNT" || "$(OS)" == "OS2" -MY_RC = .ini -.ELSE -MY_RC = rc -.ENDIF +PRJ = .. +PRJNAME = ure +TARGET = source ZIP1TARGET = uretest ZIP1FLAGS = -r ZIP1LIST = uretest -.INCLUDE: target.mk - -ALLTAR: \ - $(BIN)$/ure$/README \ - $(BIN)$/ure$/THIRDPARTYLICENSEREADME.html \ - $(BIN)$/ure$/jvmfwk3$(MY_RC) \ - $(BIN)$/ure$/uno$(MY_RC) +my_components = \ + acceptor \ + binaryurp \ + bootstrap \ + connector \ + introspection \ + invocadapt \ + invocation \ + javaloader \ + javavm \ + juh \ + namingservice \ + proxyfac \ + reflection \ + stocservices \ + streams \ + textinstream \ + textoutstream \ + uuresolver -$(BIN)$/ure$/README: README - -$(MKDIR) $(@:d) - $(COPY) $< $@ - -$(BIN)$/ure$/THIRDPARTYLICENSEREADME.html: THIRDPARTYLICENSEREADME.html - - $(MKDIR) $(@:d) - $(COPY) $< $@ - -$(BIN)$/ure$/jvmfwk3$(MY_RC): jvmfwk3$(MY_RC) - -$(MKDIR) $(@:d) - $(COPY) $< $@ - -$(BIN)$/ure$/uno$(MY_RC): uno$(MY_RC) - -$(MKDIR) $(@:d) - $(COPY) $< $@ - -.IF "$(OS)" != "WNT" +.INCLUDE: settings.mk +.INCLUDE: target.mk -ALLTAR: $(BIN)$/ure$/startup.sh +ALLTAR : $(MISC)/services.rdb -$(BIN)$/ure$/startup.sh: startup.sh - -$(MKDIR) $(@:d) - $(COPY) $< $@ +$(MISC)/services.rdb .ERRREMOVE : $(SOLARENV)/bin/packcomponents.xslt \ + $(MISC)/services.input $(my_components:^"$(SOLARXMLDIR)/":+".component") + $(XSLTPROC) --nonet --stringparam prefix $(SOLARXMLDIR)/ -o $@ \ + $(SOLARENV)/bin/packcomponents.xslt $(MISC)/services.input -.ENDIF +$(MISC)/services.input : + echo \ + '<list>$(my_components:^"<filename>":+".component</filename>")</list>' \ + > $@ diff --git a/bridges/source/remote/static/makefile.mk b/xmlreader/inc/makefile.mk index 9b3c2b795f8d..9f84434701ac 100644 --- a/bridges/source/remote/static/makefile.mk +++ b/xmlreader/inc/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -23,39 +23,18 @@ # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. # -#************************************************************************* - -PRJ=..$/..$/.. - -PRJNAME=bridges -TARGET=bridges_remote_static -ENABLE_EXCEPTIONS=TRUE -USE_DEFFILE=TRUE - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -# ------------------------------------------------------------------ - -SLOFILES= \ - $(SLO)$/proxy.obj \ - $(SLO)$/stub.obj \ - $(SLO)$/remote.obj \ - $(SLO)$/mapping.obj \ - $(SLO)$/helper.obj \ - $(SLO)$/remote_types.obj - -# Forte6 update 1 on Solaris Intel dies with internal compiler error -# on stub.cxx if optimization is on. Switch it off for now. -# To be reevaluated on compiler upgrade -.IF "$(OS)$(CPU)"=="SOLARISI" -NOOPTFILES=\ - $(SLO)$/stub.obj -.ENDIF +#***********************************************************************/ -# --- Targets ------------------------------------------------------ +PRJ = .. +PRJNAME = xmlreader +TARGET = inc -.INCLUDE : target.mk +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/xmlreader/inc/pch/precompiled_xmlreader.cxx b/xmlreader/inc/pch/precompiled_xmlreader.cxx new file mode 100644 index 000000000000..e5d584855eb8 --- /dev/null +++ b/xmlreader/inc/pch/precompiled_xmlreader.cxx @@ -0,0 +1,28 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_xmlreader.hxx" diff --git a/xmlreader/inc/pch/precompiled_xmlreader.hxx b/xmlreader/inc/pch/precompiled_xmlreader.hxx new file mode 100644 index 000000000000..7561fe89f7c4 --- /dev/null +++ b/xmlreader/inc/pch/precompiled_xmlreader.hxx @@ -0,0 +1,32 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#if defined PRECOMPILED_HEADERS + +#include "sal/config.h" + +#endif diff --git a/remotebridges/source/dynamicloader/makefile.mk b/xmlreader/inc/xmlreader/README index 9135d2fb26f3..cf238a695c61 100755..100644 --- a/remotebridges/source/dynamicloader/makefile.mk +++ b/xmlreader/inc/xmlreader/README @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -23,47 +23,12 @@ # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. # -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=remotebridges -TARGET = dynamicloader.uno -ENABLE_EXCEPTIONS=TRUE -COMP1TYPELIST = dynamicloader - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk -.IF "$(L10N_framework)"=="" -DLLPRE = - -# ------------------------------------------------------------------ - -# use for types from COMP1TYPELIST -NO_OFFUH=TRUE -CPPUMAKERFLAGS += -C - -SLOFILES= \ - $(SLO)$/dynamicloader.obj - -SHL1TARGET= $(TARGET) -SHL1VERSIONMAP = $(SOLARENV)$/src$/component.map - -SHL1STDLIBS=\ - $(CPPUHELPERLIB) \ - $(CPPULIB) \ - $(SALLIB) - -SHL1IMPLIB= i$(TARGET) -SHL1LIBS=$(SLB)$/$(TARGET).lib - -SHL1DEF=$(MISC)$/$(SHL1TARGET).def - -DEF1NAME= $(SHL1TARGET) - -.ENDIF # L10N_framework - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk +#***********************************************************************/ + +<http://qa.openoffice.org/issues/show_bug.cgi?id=115203>: "Issue 113189 +extracted xmlreader from configmgr, to make the former available within URE. +The xmlreader library is for now considered a private part of URE (cf. +ure/source/README), for simplicity uses OOO_DLLPUBLIC_XMLREADER-based symbol +visibility (and thus no symbol versioning), but is of course used from outside +URE in configmgr. This works as long as its ABI does not change. If it ever +changes, symbol versioning will have to be added (in some form or other)." diff --git a/xmlreader/inc/xmlreader/detail/xmlreaderdllapi.hxx b/xmlreader/inc/xmlreader/detail/xmlreaderdllapi.hxx new file mode 100644 index 000000000000..238661a2426f --- /dev/null +++ b/xmlreader/inc/xmlreader/detail/xmlreaderdllapi.hxx @@ -0,0 +1,41 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_XMLREADER_DETAIL_XMLREADERDLLAPI_HXX +#define INCLUDED_XMLREADER_DETAIL_XMLREADERDLLAPI_HXX + +#include "sal/config.h" + +#include "sal/types.h" + +#if defined OOO_DLLIMPLEMENTATION_XMLREADER +#define OOO_DLLPUBLIC_XMLREADER SAL_DLLPUBLIC_EXPORT +#else +#define OOO_DLLPUBLIC_XMLREADER SAL_DLLPUBLIC_IMPORT +#endif + +#endif diff --git a/xmlreader/inc/xmlreader/pad.hxx b/xmlreader/inc/xmlreader/pad.hxx new file mode 100644 index 000000000000..d01574147665 --- /dev/null +++ b/xmlreader/inc/xmlreader/pad.hxx @@ -0,0 +1,59 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_XMLREADER_PAD_HXX +#define INCLUDED_XMLREADER_PAD_HXX + +#include "sal/config.h" + +#include "rtl/strbuf.hxx" +#include "sal/types.h" +#include "xmlreader/detail/xmlreaderdllapi.hxx" +#include "xmlreader/span.hxx" + +namespace xmlreader { + +class OOO_DLLPUBLIC_XMLREADER Pad { +public: + void add(char const * begin, sal_Int32 length); + + void addEphemeral(char const * begin, sal_Int32 length); + + void clear(); + + Span get() const; + +private: + SAL_DLLPRIVATE void flushSpan(); + + Span span_; + rtl::OStringBuffer buffer_; +}; + +} + +#endif diff --git a/xmlreader/inc/xmlreader/span.hxx b/xmlreader/inc/xmlreader/span.hxx new file mode 100644 index 000000000000..4ec8b574f940 --- /dev/null +++ b/xmlreader/inc/xmlreader/span.hxx @@ -0,0 +1,69 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_XMLREADER_SPAN_HXX +#define INCLUDED_XMLREADER_SPAN_HXX + +#include "sal/config.h" + +#include "rtl/string.h" +#include "sal/types.h" +#include "xmlreader/detail/xmlreaderdllapi.hxx" + +namespace rtl { class OUString; } + +namespace xmlreader { + +struct OOO_DLLPUBLIC_XMLREADER Span { + char const * begin; + sal_Int32 length; + + inline Span(): begin(0), length(0) {} + // init length to avoid compiler warnings + + inline Span(char const * theBegin, sal_Int32 theLength): + begin(theBegin), length(theLength) {} + + inline void clear() throw() { begin = 0; } + + inline bool is() const { return begin != 0; } + + inline bool equals(Span const & text) const { + return rtl_str_compare_WithLength( + begin, length, text.begin, text.length) == 0; + } + + inline bool equals(char const * textBegin, sal_Int32 textLength) const { + return equals(Span(textBegin, textLength)); + } + + rtl::OUString convertFromUtf8() const; +}; + +} + +#endif diff --git a/xmlreader/inc/xmlreader/xmlreader.hxx b/xmlreader/inc/xmlreader/xmlreader.hxx new file mode 100644 index 000000000000..242af58c7306 --- /dev/null +++ b/xmlreader/inc/xmlreader/xmlreader.hxx @@ -0,0 +1,199 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#ifndef INCLUDED_XMLREADER_XMLREADER_HXX +#define INCLUDED_XMLREADER_XMLREADER_HXX + +#include "sal/config.h" + +#include <stack> +#include <vector> + +#include "boost/noncopyable.hpp" +#include "com/sun/star/container/NoSuchElementException.hpp" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "osl/file.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "xmlreader/detail/xmlreaderdllapi.hxx" +#include "xmlreader/pad.hxx" +#include "xmlreader/span.hxx" + +namespace xmlreader { + +class OOO_DLLPUBLIC_XMLREADER XmlReader: private boost::noncopyable { +public: + explicit XmlReader(rtl::OUString const & fileUrl) + SAL_THROW(( + com::sun::star::container::NoSuchElementException, + com::sun::star::uno::RuntimeException)); + + ~XmlReader(); + + enum { NAMESPACE_NONE = -2, NAMESPACE_UNKNOWN = -1, NAMESPACE_XML = 0 }; + + enum Text { TEXT_NONE, TEXT_RAW, TEXT_NORMALIZED }; + + enum Result { RESULT_BEGIN, RESULT_END, RESULT_TEXT, RESULT_DONE }; + + int registerNamespaceIri(Span const & iri); + + // RESULT_BEGIN: data = localName, ns = ns + // RESULT_END: data, ns unused + // RESULT_TEXT: data = text, ns unused + Result nextItem(Text reportText, Span * data, int * nsId); + + bool nextAttribute(int * nsId, Span * localName); + + // the span returned by getAttributeValue is only valid until the next call + // to nextItem or getAttributeValue + Span getAttributeValue(bool fullyNormalize); + + int getNamespaceId(Span const & prefix) const; + + rtl::OUString getUrl() const; + +private: + typedef std::vector< Span > NamespaceIris; + + // If NamespaceData (and similarly ElementData and AttributeData) is made + // SAL_DLLPRIVATE, at least gcc 4.2.3 erroneously warns about + // "'xmlreader::XmlReader' declared with greater visibility than the type of + // its field 'xmlreader::XmlReader::namespaces_'" (and similarly for + // elements_ and attributes_): + + struct NamespaceData { + Span prefix; + int nsId; + + NamespaceData() {} + + NamespaceData(Span const & thePrefix, int theNsId): + prefix(thePrefix), nsId(theNsId) {} + }; + + typedef std::vector< NamespaceData > NamespaceList; + + struct ElementData { + Span name; + NamespaceList::size_type inheritedNamespaces; + int defaultNamespaceId; + + ElementData( + Span const & theName, + NamespaceList::size_type theInheritedNamespaces, + int theDefaultNamespaceId): + name(theName), inheritedNamespaces(theInheritedNamespaces), + defaultNamespaceId(theDefaultNamespaceId) + {} + }; + + typedef std::stack< ElementData > ElementStack; + + struct AttributeData { + char const * nameBegin; + char const * nameEnd; + char const * nameColon; + char const * valueBegin; + char const * valueEnd; + + AttributeData( + char const * theNameBegin, char const * theNameEnd, + char const * theNameColon, char const * theValueBegin, + char const * theValueEnd): + nameBegin(theNameBegin), nameEnd(theNameEnd), + nameColon(theNameColon), valueBegin(theValueBegin), + valueEnd(theValueEnd) + {} + }; + + typedef std::vector< AttributeData > Attributes; + + enum State { + STATE_CONTENT, STATE_START_TAG, STATE_END_TAG, STATE_EMPTY_ELEMENT_TAG, + STATE_DONE }; + + SAL_DLLPRIVATE inline char read() { return pos_ == end_ ? '\0' : *pos_++; } + + SAL_DLLPRIVATE inline char peek() { return pos_ == end_ ? '\0' : *pos_; } + + SAL_DLLPRIVATE void normalizeLineEnds(Span const & text); + + SAL_DLLPRIVATE void skipSpace(); + + SAL_DLLPRIVATE bool skipComment(); + + SAL_DLLPRIVATE void skipProcessingInstruction(); + + SAL_DLLPRIVATE void skipDocumentTypeDeclaration(); + + SAL_DLLPRIVATE Span scanCdataSection(); + + SAL_DLLPRIVATE bool scanName(char const ** nameColon); + + SAL_DLLPRIVATE int scanNamespaceIri( + char const * begin, char const * end); + + SAL_DLLPRIVATE char const * handleReference( + char const * position, char const * end); + + SAL_DLLPRIVATE Span handleAttributeValue( + char const * begin, char const * end, bool fullyNormalize); + + SAL_DLLPRIVATE Result handleStartTag(int * nsId, Span * localName); + + SAL_DLLPRIVATE Result handleEndTag(); + + SAL_DLLPRIVATE void handleElementEnd(); + + SAL_DLLPRIVATE Result handleSkippedText(Span * data, int * nsId); + + SAL_DLLPRIVATE Result handleRawText(Span * text); + + SAL_DLLPRIVATE Result handleNormalizedText(Span * text); + + SAL_DLLPRIVATE int toNamespaceId(NamespaceIris::size_type pos); + + rtl::OUString fileUrl_; + oslFileHandle fileHandle_; + sal_uInt64 fileSize_; + void * fileAddress_; + NamespaceIris namespaceIris_; + NamespaceList namespaces_; + ElementStack elements_; + char const * pos_; + char const * end_; + State state_; + Attributes attributes_; + Attributes::iterator currentAttribute_; + bool firstAttribute_; + Pad pad_; +}; + +} + +#endif diff --git a/xmlreader/prj/build.lst b/xmlreader/prj/build.lst new file mode 100644 index 000000000000..5408a5255db7 --- /dev/null +++ b/xmlreader/prj/build.lst @@ -0,0 +1,3 @@ +xr xmlreader : BOOST:boost cppu offuh sal stlport NULL +xr xmlreader\inc nmake - all xr_inc NULL +xr xmlreader\source nmake - all xr_source xr_inc NULL diff --git a/xmlreader/prj/d.lst b/xmlreader/prj/d.lst new file mode 100755 index 000000000000..fcb99bd30266 --- /dev/null +++ b/xmlreader/prj/d.lst @@ -0,0 +1,10 @@ +mkdir: %_DEST%\inc%_EXT%\xmlreader +mkdir: %_DEST%\inc%_EXT%\xmlreader\detail +..\%__SRC%\bin\xmlreader.dll %_DEST%\bin%_EXT%\xmlreader.dll +..\%__SRC%\lib\ixmlreader.lib %_DEST%\lib%_EXT%\ixmlreader.lib +..\%__SRC%\lib\libxmlreader.dylib %_DEST%\lib%_EXT%\libxmlreader.dylib +..\%__SRC%\lib\libxmlreader.so %_DEST%\lib%_EXT%\libxmlreader.so +..\inc\xmlreader\detail\xmlreaderdllapi.hxx %_DEST%\inc%_EXT%\xmlreader\detail\xmlreaderdllapi.hxx +..\inc\xmlreader\pad.hxx %_DEST%\inc%_EXT%\xmlreader\pad.hxx +..\inc\xmlreader\span.hxx %_DEST%\inc%_EXT%\xmlreader\span.hxx +..\inc\xmlreader\xmlreader.hxx %_DEST%\inc%_EXT%\xmlreader\xmlreader.hxx diff --git a/cpputools/source/regcomplazy/makefile.mk b/xmlreader/source/makefile.mk index 0a4fe8477128..cb71e21a16b1 100755..100644 --- a/cpputools/source/regcomplazy/makefile.mk +++ b/xmlreader/source/makefile.mk @@ -1,7 +1,7 @@ #************************************************************************* # # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# +# # Copyright 2000, 2010 Oracle and/or its affiliates. # # OpenOffice.org - a multi-platform office productivity suite @@ -23,32 +23,31 @@ # <http://www.openoffice.org/license.html> # for a copy of the LGPLv3 License. # -#************************************************************************* -PRJ=..$/.. - -PRJNAME=cpputools -TARGET=regcomplazy -TARGETTYPE=CUI -LIBTARGET=NO - -ENABLE_EXCEPTIONS=TRUE - -# --- Settings ----------------------------------------------------- +#***********************************************************************/ -.INCLUDE : settings.mk +PRJ = .. +PRJNAME = xmlreader +TARGET = xmlreader -# --- Files -------------------------------------------------------- +ENABLE_EXCEPTIONS = TRUE +VISIBILITY_HIDDEN = TRUE -DEPOBJFILES= \ - $(OBJ)$/regcomplazy.obj +.INCLUDE: settings.mk -APP1TARGET=$(TARGET) -APP1OBJS=$(DEPOBJFILES) +CDEFS += -DOOO_DLLIMPLEMENTATION_XMLREADER -APP1STDLIBS= \ - $(SALLIB) \ - $(SALHELPERLIB) \ - $(REGLIB) +SLOFILES = \ + $(SLO)/pad.obj \ + $(SLO)/span.obj \ + $(SLO)/xmlreader.obj -.INCLUDE : target.mk +SHL1IMPLIB = i$(SHL1TARGET) +SHL1OBJS = $(SLOFILES) +SHL1RPATH = URELIB +SHL1STDLIBS = \ + $(SALLIB) +SHL1TARGET = xmlreader +SHL1USE_EXPORTS = name +DEF1NAME = $(SHL1TARGET) +.INCLUDE: target.mk diff --git a/xmlreader/source/pad.cxx b/xmlreader/source/pad.cxx new file mode 100644 index 000000000000..b1673c4a4431 --- /dev/null +++ b/xmlreader/source/pad.cxx @@ -0,0 +1,85 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_xmlreader.hxx" +#include "sal/config.h" + +#include "osl/diagnose.h" +#include "rtl/string.h" +#include "sal/types.h" +#include "xmlreader/pad.hxx" +#include "xmlreader/span.hxx" + +namespace xmlreader { + +void Pad::add(char const * begin, sal_Int32 length) { + OSL_ASSERT( + begin != 0 && length >= 0 && !(span_.is() && buffer_.getLength() != 0)); + if (length != 0) { + flushSpan(); + if (buffer_.getLength() == 0) { + span_ = Span(begin, length); + } else { + buffer_.append(begin, length); + } + } +} + +void Pad::addEphemeral(char const * begin, sal_Int32 length) { + OSL_ASSERT( + begin != 0 && length >= 0 && !(span_.is() && buffer_.getLength() != 0)); + if (length != 0) { + flushSpan(); + buffer_.append(begin, length); + } +} + +void Pad::clear() { + OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0)); + span_.clear(); + buffer_.setLength(0); +} + +Span Pad::get() const { + OSL_ASSERT(!(span_.is() && buffer_.getLength() != 0)); + if (span_.is()) { + return span_; + } else if (buffer_.getLength() == 0) { + return Span(RTL_CONSTASCII_STRINGPARAM("")); + } else { + return Span(buffer_.getStr(), buffer_.getLength()); + } +} + +void Pad::flushSpan() { + if (span_.is()) { + buffer_.append(span_.begin, span_.length); + span_.clear(); + } +} + +} diff --git a/xmlreader/source/span.cxx b/xmlreader/source/span.cxx new file mode 100644 index 000000000000..3b936553b431 --- /dev/null +++ b/xmlreader/source/span.cxx @@ -0,0 +1,66 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_xmlreader.hxx" +#include "sal/config.h" + +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "osl/diagnose.h" +#include "rtl/textcvt.h" +#include "rtl/textenc.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "xmlreader/span.hxx" + +namespace xmlreader { + +namespace { + +namespace css = com::sun::star; + +} + +rtl::OUString Span::convertFromUtf8() const { + OSL_ASSERT(is()); + rtl_uString * s = 0; + if (!rtl_convertStringToUString( + &s, begin, length, RTL_TEXTENCODING_UTF8, + (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR | + RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR))) + { + throw css::uno::RuntimeException( + rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("cannot convert from UTF-8")), + css::uno::Reference< css::uno::XInterface >()); + } + return rtl::OUString(s, SAL_NO_ACQUIRE); +} + +} diff --git a/xmlreader/source/xmlreader.cxx b/xmlreader/source/xmlreader.cxx new file mode 100644 index 000000000000..27350a8f0947 --- /dev/null +++ b/xmlreader/source/xmlreader.cxx @@ -0,0 +1,1054 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +#include "precompiled_xmlreader.hxx" +#include "sal/config.h" + +#include <climits> +#include <cstddef> + +#include "com/sun/star/container/NoSuchElementException.hpp" +#include "com/sun/star/uno/Reference.hxx" +#include "com/sun/star/uno/RuntimeException.hpp" +#include "com/sun/star/uno/XInterface.hpp" +#include "osl/diagnose.h" +#include "osl/file.h" +#include "rtl/string.h" +#include "rtl/ustring.h" +#include "rtl/ustring.hxx" +#include "sal/types.h" +#include "xmlreader/pad.hxx" +#include "xmlreader/span.hxx" +#include "xmlreader/xmlreader.hxx" + +namespace xmlreader { + +namespace { + +namespace css = com::sun::star; + +bool isSpace(char c) { + switch (c) { + case '\x09': + case '\x0A': + case '\x0D': + case ' ': + return true; + default: + return false; + } +} + +} + +XmlReader::XmlReader(rtl::OUString const & fileUrl) + SAL_THROW(( + css::container::NoSuchElementException, css::uno::RuntimeException)): + fileUrl_(fileUrl) +{ + switch (osl_openFile(fileUrl_.pData, &fileHandle_, osl_File_OpenFlag_Read)) + { + case osl_File_E_None: + break; + case osl_File_E_NOENT: + throw css::container::NoSuchElementException( + fileUrl_, css::uno::Reference< css::uno::XInterface >()); + default: + throw css::uno::RuntimeException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cannot open ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + oslFileError e = osl_getFileSize(fileHandle_, &fileSize_); + if (e == osl_File_E_None) { + e = osl_mapFile( + fileHandle_, &fileAddress_, fileSize_, 0, + osl_File_MapFlag_WillNeed); + } + if (e != osl_File_E_None) { + e = osl_closeFile(fileHandle_); + if (e != osl_File_E_None) { + OSL_TRACE("osl_closeFile failed with %ld", static_cast< long >(e)); + } + throw css::uno::RuntimeException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("cannot mmap ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + namespaceIris_.push_back( + Span( + RTL_CONSTASCII_STRINGPARAM( + "http://www.w3.org/XML/1998/namespace"))); + namespaces_.push_back( + NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xml")), NAMESPACE_XML)); + pos_ = static_cast< char * >(fileAddress_); + end_ = pos_ + fileSize_; + state_ = STATE_CONTENT; +} + +XmlReader::~XmlReader() { + oslFileError e = osl_unmapFile(fileAddress_, fileSize_); + if (e != osl_File_E_None) { + OSL_TRACE("osl_unmapFile failed with %ld", static_cast< long >(e)); + } + e = osl_closeFile(fileHandle_); + if (e != osl_File_E_None) { + OSL_TRACE("osl_closeFile failed with %ld", static_cast< long >(e)); + } +} + +int XmlReader::registerNamespaceIri(Span const & iri) { + int id = toNamespaceId(namespaceIris_.size()); + namespaceIris_.push_back(iri); + if (iri.equals( + Span( + RTL_CONSTASCII_STRINGPARAM( + "http://www.w3.org/2001/XMLSchema-instance")))) + { + // Old user layer .xcu files used the xsi namespace prefix without + // declaring a corresponding namespace binding, see issue 77174; reading + // those files during migration would fail without this hack that can be + // removed once migration is no longer relevant (see + // configmgr::Components::parseModificationLayer): + namespaces_.push_back( + NamespaceData(Span(RTL_CONSTASCII_STRINGPARAM("xsi")), id)); + } + return id; +} + +XmlReader::Result XmlReader::nextItem(Text reportText, Span * data, int * nsId) +{ + switch (state_) { + case STATE_CONTENT: + switch (reportText) { + case TEXT_NONE: + return handleSkippedText(data, nsId); + case TEXT_RAW: + return handleRawText(data); + case TEXT_NORMALIZED: + return handleNormalizedText(data); + } + case STATE_START_TAG: + return handleStartTag(nsId, data); + case STATE_END_TAG: + return handleEndTag(); + case STATE_EMPTY_ELEMENT_TAG: + handleElementEnd(); + return RESULT_END; + default: // STATE_DONE + return RESULT_DONE; + } +} + +bool XmlReader::nextAttribute(int * nsId, Span * localName) { + OSL_ASSERT(nsId != 0 && localName != 0); + if (firstAttribute_) { + currentAttribute_ = attributes_.begin(); + firstAttribute_ = false; + } else { + ++currentAttribute_; + } + if (currentAttribute_ == attributes_.end()) { + return false; + } + if (currentAttribute_->nameColon == 0) { + *nsId = NAMESPACE_NONE; + *localName = Span( + currentAttribute_->nameBegin, + currentAttribute_->nameEnd - currentAttribute_->nameBegin); + } else { + *nsId = getNamespaceId( + Span( + currentAttribute_->nameBegin, + currentAttribute_->nameColon - currentAttribute_->nameBegin)); + *localName = Span( + currentAttribute_->nameColon + 1, + currentAttribute_->nameEnd - (currentAttribute_->nameColon + 1)); + } + return true; +} + +Span XmlReader::getAttributeValue(bool fullyNormalize) { + return handleAttributeValue( + currentAttribute_->valueBegin, currentAttribute_->valueEnd, + fullyNormalize); +} + +int XmlReader::getNamespaceId(Span const & prefix) const { + for (NamespaceList::const_reverse_iterator i(namespaces_.rbegin()); + i != namespaces_.rend(); ++i) + { + if (prefix.equals(i->prefix)) { + return i->nsId; + } + } + return NAMESPACE_UNKNOWN; +} + +rtl::OUString XmlReader::getUrl() const { + return fileUrl_; +} + +void XmlReader::normalizeLineEnds(Span const & text) { + char const * p = text.begin; + sal_Int32 n = text.length; + for (;;) { + sal_Int32 i = rtl_str_indexOfChar_WithLength(p, n, '\x0D'); + if (i < 0) { + break; + } + pad_.add(p, i); + p += i + 1; + n -= i + 1; + if (n == 0 || *p != '\x0A') { + pad_.add(RTL_CONSTASCII_STRINGPARAM("\x0A")); + } + } + pad_.add(p, n); +} + +void XmlReader::skipSpace() { + while (isSpace(peek())) { + ++pos_; + } +} + +bool XmlReader::skipComment() { + if (rtl_str_shortenedCompare_WithLength( + pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("--"), + RTL_CONSTASCII_LENGTH("--")) != + 0) + { + return false; + } + pos_ += RTL_CONSTASCII_LENGTH("--"); + sal_Int32 i = rtl_str_indexOfStr_WithLength( + pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("--")); + if (i < 0) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "premature end (within comment) of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + pos_ += i + RTL_CONSTASCII_LENGTH("--"); + if (read() != '>') { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "illegal \"--\" within comment in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + return true; +} + +void XmlReader::skipProcessingInstruction() { + sal_Int32 i = rtl_str_indexOfStr_WithLength( + pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("?>")); + if (i < 0) { + throw css::uno::RuntimeException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad '<?' in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + pos_ += i + RTL_CONSTASCII_LENGTH("?>"); +} + +void XmlReader::skipDocumentTypeDeclaration() { + // Neither is it checked that the doctypedecl is at the correct position in + // the document, nor that it is well-formed: + for (;;) { + char c = read(); + switch (c) { + case '\0': // i.e., EOF + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "premature end (within DTD) of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + case '"': + case '\'': + { + sal_Int32 i = rtl_str_indexOfChar_WithLength( + pos_, end_ - pos_, c); + if (i < 0) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "premature end (within DTD) of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + pos_ += i + 1; + } + break; + case '>': + return; + case '[': + for (;;) { + c = read(); + switch (c) { + case '\0': // i.e., EOF + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "premature end (within DTD) of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + case '"': + case '\'': + { + sal_Int32 i = rtl_str_indexOfChar_WithLength( + pos_, end_ - pos_, c); + if (i < 0) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "premature end (within DTD) of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + pos_ += i + 1; + } + break; + case '<': + switch (read()) { + case '\0': // i.e., EOF + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "premature end (within DTD) of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + case '!': + skipComment(); + break; + case '?': + skipProcessingInstruction(); + break; + default: + break; + } + break; + case ']': + skipSpace(); + if (read() != '>') { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "missing \">\" of DTD in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + return; + default: + break; + } + } + default: + break; + } + } +} + +Span XmlReader::scanCdataSection() { + if (rtl_str_shortenedCompare_WithLength( + pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("[CDATA["), + RTL_CONSTASCII_LENGTH("[CDATA[")) != + 0) + { + return Span(); + } + pos_ += RTL_CONSTASCII_LENGTH("[CDATA["); + char const * begin = pos_; + sal_Int32 i = rtl_str_indexOfStr_WithLength( + pos_, end_ - pos_, RTL_CONSTASCII_STRINGPARAM("]]>")); + if (i < 0) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "premature end (within CDATA section) of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + pos_ += i + RTL_CONSTASCII_LENGTH("]]>"); + return Span(begin, i); +} + +bool XmlReader::scanName(char const ** nameColon) { + OSL_ASSERT(nameColon != 0 && *nameColon == 0); + for (char const * begin = pos_;; ++pos_) { + switch (peek()) { + case '\0': // i.e., EOF + case '\x09': + case '\x0A': + case '\x0D': + case ' ': + case '/': + case '=': + case '>': + return pos_ != begin; + case ':': + *nameColon = pos_; + break; + default: + break; + } + } +} + +int XmlReader::scanNamespaceIri(char const * begin, char const * end) { + OSL_ASSERT(begin != 0 && begin <= end); + Span iri(handleAttributeValue(begin, end, false)); + for (NamespaceIris::size_type i = 0; i < namespaceIris_.size(); ++i) { + if (namespaceIris_[i].equals(iri)) { + return toNamespaceId(i); + } + } + return XmlReader::NAMESPACE_UNKNOWN; +} + +char const * XmlReader::handleReference(char const * position, char const * end) +{ + OSL_ASSERT(position != 0 && *position == '&' && position < end); + ++position; + if (*position == '#') { + ++position; + sal_Int32 val = 0; + char const * p; + if (*position == 'x') { + ++position; + p = position; + for (;; ++position) { + char c = *position; + if (c >= '0' && c <= '9') { + val = 16 * val + (c - '0'); + } else if (c >= 'A' && c <= 'F') { + val = 16 * val + (c - 'A') + 10; + } else if (c >= 'a' && c <= 'f') { + val = 16 * val + (c - 'a') + 10; + } else { + break; + } + if (val > 0x10FFFF) { // avoid overflow + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "'&#x...' too large in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + } + } else { + p = position; + for (;; ++position) { + char c = *position; + if (c >= '0' && c <= '9') { + val = 10 * val + (c - '0'); + } else { + break; + } + if (val > 0x10FFFF) { // avoid overflow + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "'&#...' too large in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + } + } + if (position == p || *position++ != ';') { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("'&#...' missing ';' in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + OSL_ASSERT(val >= 0 && val <= 0x10FFFF); + if ((val < 0x20 && val != 0x9 && val != 0xA && val != 0xD) || + (val >= 0xD800 && val <= 0xDFFF) || val == 0xFFFE || val == 0xFFFF) + { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "character reference denoting invalid character in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + char buf[4]; + sal_Int32 len; + if (val < 0x80) { + buf[0] = static_cast< char >(val); + len = 1; + } else if (val < 0x800) { + buf[0] = static_cast< char >((val >> 6) | 0xC0); + buf[1] = static_cast< char >((val & 0x3F) | 0x80); + len = 2; + } else if (val < 0x10000) { + buf[0] = static_cast< char >((val >> 12) | 0xE0); + buf[1] = static_cast< char >(((val >> 6) & 0x3F) | 0x80); + buf[2] = static_cast< char >((val & 0x3F) | 0x80); + len = 3; + } else { + buf[0] = static_cast< char >((val >> 18) | 0xF0); + buf[1] = static_cast< char >(((val >> 12) & 0x3F) | 0x80); + buf[2] = static_cast< char >(((val >> 6) & 0x3F) | 0x80); + buf[3] = static_cast< char >((val & 0x3F) | 0x80); + len = 4; + } + pad_.addEphemeral(buf, len); + return position; + } else { + struct EntityRef { + char const * inBegin; + sal_Int32 inLength; + char const * outBegin; + sal_Int32 outLength; + }; + static EntityRef const refs[] = { + { RTL_CONSTASCII_STRINGPARAM("amp;"), + RTL_CONSTASCII_STRINGPARAM("&") }, + { RTL_CONSTASCII_STRINGPARAM("lt;"), + RTL_CONSTASCII_STRINGPARAM("<") }, + { RTL_CONSTASCII_STRINGPARAM("gt;"), + RTL_CONSTASCII_STRINGPARAM(">") }, + { RTL_CONSTASCII_STRINGPARAM("apos;"), + RTL_CONSTASCII_STRINGPARAM("'") }, + { RTL_CONSTASCII_STRINGPARAM("quot;"), + RTL_CONSTASCII_STRINGPARAM("\"") } }; + for (std::size_t i = 0; i < sizeof refs / sizeof refs[0]; ++i) { + if (rtl_str_shortenedCompare_WithLength( + position, end - position, refs[i].inBegin, refs[i].inLength, + refs[i].inLength) == + 0) + { + position += refs[i].inLength; + pad_.add(refs[i].outBegin, refs[i].outLength); + return position; + } + } + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("unknown entity reference in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } +} + +Span XmlReader::handleAttributeValue( + char const * begin, char const * end, bool fullyNormalize) +{ + pad_.clear(); + if (fullyNormalize) { + while (begin != end && isSpace(*begin)) { + ++begin; + } + while (end != begin && isSpace(end[-1])) { + --end; + } + char const * p = begin; + enum Space { SPACE_NONE, SPACE_SPAN, SPACE_BREAK }; + // a single true space character can go into the current span, + // everything else breaks the span + Space space = SPACE_NONE; + while (p != end) { + switch (*p) { + case '\x09': + case '\x0A': + case '\x0D': + switch (space) { + case SPACE_NONE: + pad_.add(begin, p - begin); + pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + space = SPACE_BREAK; + break; + case SPACE_SPAN: + pad_.add(begin, p - begin); + space = SPACE_BREAK; + break; + case SPACE_BREAK: + break; + } + begin = ++p; + break; + case ' ': + switch (space) { + case SPACE_NONE: + ++p; + space = SPACE_SPAN; + break; + case SPACE_SPAN: + pad_.add(begin, p - begin); + begin = ++p; + space = SPACE_BREAK; + break; + case SPACE_BREAK: + begin = ++p; + break; + } + break; + case '&': + pad_.add(begin, p - begin); + p = handleReference(p, end); + begin = p; + space = SPACE_NONE; + break; + default: + ++p; + space = SPACE_NONE; + break; + } + } + pad_.add(begin, p - begin); + } else { + char const * p = begin; + while (p != end) { + switch (*p) { + case '\x09': + case '\x0A': + pad_.add(begin, p - begin); + begin = ++p; + pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + break; + case '\x0D': + pad_.add(begin, p - begin); + ++p; + if (peek() == '\x0A') { + ++p; + } + begin = p; + pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + break; + case '&': + pad_.add(begin, p - begin); + p = handleReference(p, end); + begin = p; + break; + default: + ++p; + break; + } + } + pad_.add(begin, p - begin); + } + return pad_.get(); +} + +XmlReader::Result XmlReader::handleStartTag(int * nsId, Span * localName) { + OSL_ASSERT(nsId != 0 && localName); + char const * nameBegin = pos_; + char const * nameColon = 0; + if (!scanName(&nameColon)) { + throw css::uno::RuntimeException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("bad tag name in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + char const * nameEnd = pos_; + NamespaceList::size_type inheritedNamespaces = namespaces_.size(); + bool hasDefaultNs = false; + int defaultNsId = NAMESPACE_NONE; + attributes_.clear(); + for (;;) { + char const * p = pos_; + skipSpace(); + if (peek() == '/' || peek() == '>') { + break; + } + if (pos_ == p) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "missing whitespace before attribute in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + char const * attrNameBegin = pos_; + char const * attrNameColon = 0; + if (!scanName(&attrNameColon)) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("bad attribute name in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + char const * attrNameEnd = pos_; + skipSpace(); + if (read() != '=') { + throw css::uno::RuntimeException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '=' in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + skipSpace(); + char del = read(); + if (del != '\'' && del != '"') { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("bad attribute value in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + char const * valueBegin = pos_; + sal_Int32 i = rtl_str_indexOfChar_WithLength(pos_, end_ - pos_, del); + if (i < 0) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM( + "unterminated attribute value in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + char const * valueEnd = pos_ + i; + pos_ += i + 1; + if (attrNameColon == 0 && + Span(attrNameBegin, attrNameEnd - attrNameBegin).equals( + RTL_CONSTASCII_STRINGPARAM("xmlns"))) + { + hasDefaultNs = true; + defaultNsId = scanNamespaceIri(valueBegin, valueEnd); + } else if (attrNameColon != 0 && + Span(attrNameBegin, attrNameColon - attrNameBegin).equals( + RTL_CONSTASCII_STRINGPARAM("xmlns"))) + { + namespaces_.push_back( + NamespaceData( + Span(attrNameColon + 1, attrNameEnd - (attrNameColon + 1)), + scanNamespaceIri(valueBegin, valueEnd))); + } else { + attributes_.push_back( + AttributeData( + attrNameBegin, attrNameEnd, attrNameColon, valueBegin, + valueEnd)); + } + } + if (!hasDefaultNs && !elements_.empty()) { + defaultNsId = elements_.top().defaultNamespaceId; + } + firstAttribute_ = true; + if (peek() == '/') { + state_ = STATE_EMPTY_ELEMENT_TAG; + ++pos_; + } else { + state_ = STATE_CONTENT; + } + if (peek() != '>') { + throw css::uno::RuntimeException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '>' in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + ++pos_; + elements_.push( + ElementData( + Span(nameBegin, nameEnd - nameBegin), inheritedNamespaces, + defaultNsId)); + if (nameColon == 0) { + *nsId = defaultNsId; + *localName = Span(nameBegin, nameEnd - nameBegin); + } else { + *nsId = getNamespaceId(Span(nameBegin, nameColon - nameBegin)); + *localName = Span(nameColon + 1, nameEnd - (nameColon + 1)); + } + return RESULT_BEGIN; +} + +XmlReader::Result XmlReader::handleEndTag() { + if (elements_.empty()) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("spurious end tag in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + char const * nameBegin = pos_; + char const * nameColon = 0; + if (!scanName(&nameColon) || + !elements_.top().name.equals(nameBegin, pos_ - nameBegin)) + { + throw css::uno::RuntimeException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("tag mismatch in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + handleElementEnd(); + skipSpace(); + if (peek() != '>') { + throw css::uno::RuntimeException( + (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("missing '>' in ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + ++pos_; + return RESULT_END; +} + +void XmlReader::handleElementEnd() { + OSL_ASSERT(!elements_.empty()); + namespaces_.resize(elements_.top().inheritedNamespaces); + elements_.pop(); + state_ = elements_.empty() ? STATE_DONE : STATE_CONTENT; +} + +XmlReader::Result XmlReader::handleSkippedText(Span * data, int * nsId) { + for (;;) { + sal_Int32 i = rtl_str_indexOfChar_WithLength(pos_, end_ - pos_, '<'); + if (i < 0) { + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("premature end of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + } + pos_ += i + 1; + switch (peek()) { + case '!': + ++pos_; + if (!skipComment() && !scanCdataSection().is()) { + skipDocumentTypeDeclaration(); + } + break; + case '/': + ++pos_; + return handleEndTag(); + case '?': + ++pos_; + skipProcessingInstruction(); + break; + default: + return handleStartTag(nsId, data); + } + } +} + +XmlReader::Result XmlReader::handleRawText(Span * text) { + pad_.clear(); + for (char const * begin = pos_;;) { + switch (peek()) { + case '\0': // i.e., EOF + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("premature end of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + case '\x0D': + pad_.add(begin, pos_ - begin); + ++pos_; + if (peek() != '\x0A') { + pad_.add(RTL_CONSTASCII_STRINGPARAM("\x0A")); + } + begin = pos_; + break; + case '&': + pad_.add(begin, pos_ - begin); + pos_ = handleReference(pos_, end_); + begin = pos_; + break; + case '<': + pad_.add(begin, pos_ - begin); + ++pos_; + switch (peek()) { + case '!': + ++pos_; + if (!skipComment()) { + Span cdata(scanCdataSection()); + if (cdata.is()) { + normalizeLineEnds(cdata); + } else { + skipDocumentTypeDeclaration(); + } + } + begin = pos_; + break; + case '/': + *text = pad_.get(); + ++pos_; + state_ = STATE_END_TAG; + return RESULT_TEXT; + case '?': + ++pos_; + skipProcessingInstruction(); + begin = pos_; + break; + default: + *text = pad_.get(); + state_ = STATE_START_TAG; + return RESULT_TEXT; + } + break; + default: + ++pos_; + break; + } + } +} + +XmlReader::Result XmlReader::handleNormalizedText(Span * text) { + pad_.clear(); + char const * flowBegin = pos_; + char const * flowEnd = pos_; + enum Space { SPACE_START, SPACE_NONE, SPACE_SPAN, SPACE_BREAK }; + // a single true space character can go into the current flow, + // everything else breaks the flow + Space space = SPACE_START; + for (;;) { + switch (peek()) { + case '\0': // i.e., EOF + throw css::uno::RuntimeException( + (rtl::OUString( + RTL_CONSTASCII_USTRINGPARAM("premature end of ")) + + fileUrl_), + css::uno::Reference< css::uno::XInterface >()); + case '\x09': + case '\x0A': + case '\x0D': + switch (space) { + case SPACE_START: + case SPACE_BREAK: + break; + case SPACE_NONE: + case SPACE_SPAN: + space = SPACE_BREAK; + break; + } + ++pos_; + break; + case ' ': + switch (space) { + case SPACE_START: + case SPACE_BREAK: + break; + case SPACE_NONE: + space = SPACE_SPAN; + break; + case SPACE_SPAN: + space = SPACE_BREAK; + break; + } + ++pos_; + break; + case '&': + switch (space) { + case SPACE_START: + break; + case SPACE_NONE: + case SPACE_SPAN: + pad_.add(flowBegin, pos_ - flowBegin); + break; + case SPACE_BREAK: + pad_.add(flowBegin, flowEnd - flowBegin); + pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + break; + } + pos_ = handleReference(pos_, end_); + flowBegin = pos_; + flowEnd = pos_; + space = SPACE_NONE; + break; + case '<': + ++pos_; + switch (peek()) { + case '!': + ++pos_; + if (skipComment()) { + space = SPACE_BREAK; + } else { + Span cdata(scanCdataSection()); + if (cdata.is()) { + // CDATA is not normalized (similar to character + // references; it keeps the code simple), but it might + // arguably be better to normalize it: + switch (space) { + case SPACE_START: + break; + case SPACE_NONE: + case SPACE_SPAN: + pad_.add(flowBegin, pos_ - flowBegin); + break; + case SPACE_BREAK: + pad_.add(flowBegin, flowEnd - flowBegin); + pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + break; + } + normalizeLineEnds(cdata); + flowBegin = pos_; + flowEnd = pos_; + space = SPACE_NONE; + } else { + skipDocumentTypeDeclaration(); + } + } + break; + case '/': + ++pos_; + pad_.add(flowBegin, flowEnd - flowBegin); + *text = pad_.get(); + state_ = STATE_END_TAG; + return RESULT_TEXT; + case '?': + ++pos_; + skipProcessingInstruction(); + space = SPACE_BREAK; + break; + default: + pad_.add(flowBegin, flowEnd - flowBegin); + *text = pad_.get(); + state_ = STATE_START_TAG; + return RESULT_TEXT; + } + break; + default: + switch (space) { + case SPACE_START: + flowBegin = pos_; + break; + case SPACE_NONE: + case SPACE_SPAN: + break; + case SPACE_BREAK: + pad_.add(flowBegin, flowEnd - flowBegin); + pad_.add(RTL_CONSTASCII_STRINGPARAM(" ")); + flowBegin = pos_; + break; + } + flowEnd = ++pos_; + space = SPACE_NONE; + break; + } + } +} + +int XmlReader::toNamespaceId(NamespaceIris::size_type pos) { + OSL_ASSERT(pos <= INT_MAX); + return static_cast< int >(pos); +} + +} |