You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by ar...@apache.org on 2013/02/24 13:59:40 UTC

svn commit: r1449471 - in /openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable: ./ ServerUnoExe/ ServerUnoExe/src/ StandaloneUnoExe/ StandaloneUnoExe/src/

Author: arielch
Date: Sun Feb 24 12:59:39 2013
New Revision: 1449471

URL: http://svn.apache.org/r1449471
Log:
Add UNO Executable examples

Added:
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/Makefile   (with props)
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.cxx
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.hxx
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/components.cxx
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/Makefile   (with props)
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/components.cxx
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.cxx
    openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.hxx

Added: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/Makefile
URL: http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/Makefile?rev=1449471&view=auto
==============================================================================
--- openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/Makefile (added)
+++ openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/Makefile Sun Feb 24 12:59:39 2013
@@ -0,0 +1,182 @@
+#**************************************************************
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#
+#**************************************************************
+
+PRJ=../../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.mk
+
+
+IMPLEMENTATION_NAME=com.sun.star.comp.product.example.ClientUnoExeSample
+SERVICE_NAME=com.sun.star.bridge.example.ClientUnoExeSample
+CONNECTION_URL=uno:socket,host=localhost,port=2083;urp;TextInputStream
+EXPORTED_COMPONENT=com.sun.star.io.TextInputStream
+
+# Define non-platform/compiler specific settings
+COMP_NAME=ClientUnoExe
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+COMP_RDB_NAME = $(COMP_NAME).uno.rdb
+
+#this should be in odk/settings/std.mk
+OUT_DEPLOY=$(OUT)/deploy
+
+OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
+OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
+OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
+OUT_COMP_LIB=$(SHAREDLIB_OUT)/$(COMP_NAME)
+OUT_COMP_BIN=$(OUT_BIN)/$(COMP_NAME)
+OUT_COMP_DEPLOY=$(OUT_DEPLOY)/$(COMP_NAME)
+
+COMP_IMPL=$(OUT_COMP_LIB)/$(COMP_IMPL_NAME)
+COMP_RDB = $(OUT_COMP_BIN)/$(COMP_RDB_NAME)
+COMP_SERVICES=$(OUT_COMP_LIB)/$(COMP_NAME).rdb
+
+ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
+
+CXXFILES = \
+	client.cxx \
+	components.cxx
+
+SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+	$(COMP_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+ifneq "$(DEBUG)" ""
+	CC_DEFINES+=-DOSL_DEBUG_LEVEL=3
+endif
+CC_DEFINES+=\
+	-DIMPLEMENTATION_NAME=\"$(IMPLEMENTATION_NAME)\" \
+	-DSERVICE_NAME=\"$(SERVICE_NAME)\"
+
+
+$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+	@echo
+	-$(MKDIR) $(subst /,$(PS),$(@D))
+	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+	@echo
+
+ifeq "$(OS)" "WIN"
+$(OUT_COMP_LIB)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+	@echo
+	-$(MKDIR) $(subst /,$(PS),$(@D))
+	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
+	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
+	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
+	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
+	$(LINK_MANIFEST)
+	@echo
+else
+$(OUT_COMP_LIB)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+	@echo
+	-$(MKDIR) $(subst /,$(PS),$(@D))
+	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
+ifeq "$(OS)" "MACOSX"
+	$(INSTALL_NAME_URELIBS)  $@
+endif
+	@echo
+endif
+
+$(COMP_SERVICES) :
+	@echo
+	-$(MKDIR) $(subst /,$(PS),$(@D))
+	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
+	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
+	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)$(IMPLEMENTATION_NAME)$(QM)"$(CSEP) >> $@
+	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)$(SERVICE_NAME)$(QM)"/$(CSEP) >> $@
+	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
+	@echo $(OSEP)/components$(CSEP) >> $@
+	@echo
+
+$(COMP_NAME) : $(COMP_IMPL) $(COMP_SERVICES)
+	@echo
+	@echo --------------------------------------------------------------------------------
+	@echo
+	@echo The $(COMP_NAME) C++ component can be used with the UNO Executable.
+	@echo See "http://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/The_UNO_Executable"
+	@echo
+	@echo The Server.run target starts a remote SERVER.
+	@echo Open another terminal and run the Client.run target to connect to that server.
+	@echo
+	@echo NOTE: The example uses the $(QM)uno$(QM) tool to prepare a working UNO environment.
+	@echo $(SQM)      $(SQM)The example component is made available via -env:URE_MORE_SERVICES=...
+	@echo $(SQM)      $(SQM)Please check the generated $(QM)$(COMP_SERVICES)$(QM)
+	@echo $(SQM)      $(SQM)to see how you can specify your own components in such an environment
+	@echo $(SQM)      $(SQM)and how to use the passive UNO registration.
+	@echo
+	@echo --------------------------------------------------------------------------------
+	@echo
+
+
+Server.run: $(COMP_IMPL)
+	@echo
+	@echo Start the remote SERVER process ...
+	@echo -
+ifeq "$(OS)" "WIN"
+	@echo
+	start uno \
+		$(ENV_COMP_SERVICES) \
+		--singleaccept \
+		-s $(EXPORTED_COMPONENT) \
+		-u "$(CONNECTION_URL)"
+	@echo
+else
+	@echo
+	uno \
+		$(ENV_COMP_SERVICES) \
+		--singleaccept \
+		-s $(EXPORTED_COMPONENT) \
+		-u "$(CONNECTION_URL)" &
+	@echo
+	@echo waiting on the server process ...
+	@echo
+	sleep 5
+	@echo
+endif
+	@echo
+	@echo -
+	@echo Start CLIENT process ...
+	@echo -
+	uno \
+		$(ENV_COMP_SERVICES) \
+		-s $(SERVICE_NAME) \
+		-- "$(CONNECTION_URL)"
+	@echo -
+	@echo
+
+.PHONY: clean
+clean :
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_LIB))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_BIN))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_DEPLOY))
+

Propchange: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/Makefile
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.cxx
URL: http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.cxx?rev=1449471&view=auto
==============================================================================
--- openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.cxx (added)
+++ openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.cxx Sun Feb 24 12:59:39 2013
@@ -0,0 +1,380 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "client.hxx"
+
+#include <algorithm>
+#include <cstdlib>
+#include <functional>
+#include <iostream>
+#include <vector>
+
+#include <rtl/instance.hxx>
+#include <rtl/ref.hxx>
+#include <cppuhelper/basemutex.hxx>
+
+#include <com/sun/star/bridge/XBridgeFactory.hpp>
+#include <com/sun/star/connection/XConnector.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
+#include <com/sun/star/lang/XEventListener.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+
+
+#ifndef IMPLEMENTATION_NAME
+#error  You must define IMPLEMENTATION_NAME
+#endif
+
+#ifndef SERVICE_NAME
+#error  You must define SERVICE_NAME
+#endif
+
+#define C2U( constAsciiStr ) \
+    ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) ) )
+
+#define U2C( ouString ) \
+    ( rtl::OUStringToOString( ouString, RTL_TEXTENCODING_UTF8 ).getStr() )
+
+
+using namespace standalone_uno_exe;
+
+namespace
+{
+    struct StaticImplementationName :
+        public rtl::StaticWithInit <
+            const rtl::OUString,
+            StaticImplementationName >
+    {
+        const rtl::OUString &operator()() const
+        {
+            static rtl::OUString aName(
+                RTL_CONSTASCII_USTRINGPARAM(
+                    IMPLEMENTATION_NAME ) );
+
+            return aName;
+        }
+    };
+
+    struct StaticSupportedServices :
+        public rtl::StaticWithInit <
+            const css::uno::Sequence< rtl::OUString >,
+            StaticSupportedServices >
+    {
+        const css::uno::Sequence< rtl::OUString > &
+        operator()() const
+        {
+            static css::uno::Sequence< rtl::OUString > aSeq( 1 );
+            aSeq[0] = rtl::OUString(
+                          RTL_CONSTASCII_USTRINGPARAM(
+                              SERVICE_NAME ) );
+            return aSeq;
+        }
+    };
+
+    struct PrintOUStringSeq
+            : public std::unary_function< const rtl::OUString &, void >
+    {
+            PrintOUStringSeq()
+                : m_nCount( 0 )
+            {}
+
+            void operator()( const rtl::OUString &rStr ) const
+            {
+                std::cout << '[' << m_nCount << "] " << U2C( rStr ) << '\n';
+                ++m_nCount;
+            }
+        private:
+            mutable int m_nCount;
+    };
+
+    struct UnoConnUrl
+    {
+        rtl::OUString Connection;
+        rtl::OUString Object;
+    };
+
+    static bool lcl_ParseUnoUrl( const rtl::OUString &sUrl, UnoConnUrl &url )
+    {
+        // must start with "uno:"
+        if ( sUrl.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "uno:" ) != 0 ) )
+            return false;
+
+        sal_Int32 nIndex = sizeof( "uno:" ) - 1;
+
+        url.Connection = sUrl.getToken( 0, sal_Unicode( ';' ), nIndex );
+        // there should be an initial object
+        if ( nIndex == -1 )
+            return false;
+
+        // protocol must be "urp"
+        rtl::OUString sProtocol = sUrl.getToken( 0, sal_Unicode( ';' ), nIndex );
+        if ( nIndex == -1 || !sProtocol.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "urp" ) ) )
+            return false;
+
+        url.Object = sUrl.getToken( 0, sal_Unicode( ';' ), nIndex );
+
+        return url.Object.getLength() > 0 /* && nIndex == -1 */;
+    }
+
+    typedef ::cppu::WeakImplHelper1< css::lang::XEventListener > RemoteConnection_Base;
+
+    class RemoteConnection
+        : protected ::cppu::BaseMutex, public RemoteConnection_Base
+    {
+        private:
+            css::uno::Reference< css::uno::XComponentContext > m_xLocalContext;
+            css::uno::Reference< css::lang::XComponent > m_xBridge;
+            css::uno::Reference< css::uno::XInterface > m_xRemoteObject;
+            UnoConnUrl m_aUnoURL;
+        public:
+            RemoteConnection(
+                const css::uno::Reference< css::uno::XComponentContext > &xLocalContext,
+                const UnoConnUrl &url )
+                : RemoteConnection_Base()
+                , m_xLocalContext( xLocalContext )
+                , m_xBridge()
+                , m_xRemoteObject()
+                , m_aUnoURL( url )
+            {
+                OSL_TRACE( "RemoteConnection::RemoteConnection" );
+            }
+
+            ~RemoteConnection()
+            {
+                OSL_TRACE( "RemoteConnection::~RemoteConnection" );
+            }
+
+            void close()
+            {
+                OSL_TRACE( "RemoteConnection::close" );
+                osl::MutexGuard aGuard( m_aMutex );
+                if ( m_xBridge.is() )
+                {
+                    m_xBridge->removeEventListener( this );
+                    m_xBridge.clear();
+                    m_xRemoteObject.clear();
+                }
+            }
+
+            void SAL_CALL disposing( const css::lang::EventObject &aEvent )
+            throw ( css::uno::RuntimeException )
+            {
+                OSL_TRACE( "RemoteConnection::disposing" );
+
+                osl::MutexGuard aGuard( m_aMutex );
+                OSL_ENSURE( aEvent.Source == m_xBridge, "Different source object!" );
+
+                m_xBridge.clear();
+                m_xRemoteObject.clear();
+            }
+
+            css::uno::Reference< css::uno::XInterface > getRemoteObject()
+            {
+                OSL_TRACE( "RemoteConnection::getRemoteObject" );
+
+                osl::ResettableMutexGuard aGuard( m_aMutex );
+                css::uno::Reference< css::uno::XInterface > xRemoteObject = m_xRemoteObject;
+                css::uno::Reference< css::bridge::XBridge > xBridge( m_xBridge, css::uno::UNO_QUERY );
+                css::uno::Reference< css::uno::XComponentContext > xContext = m_xLocalContext;
+                aGuard.clear();
+
+                if ( xRemoteObject.is() || !xContext.is() )
+                    return xRemoteObject;
+
+                if ( !xBridge.is() )
+                {
+                    try
+                    {
+                        css::uno::Reference< css::connection::XConnector > xConnector(
+                            xContext->getServiceManager()->createInstanceWithContext(
+                                rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+                                                   "com.sun.star.connection.Connector" ) ),
+                                xContext ), css::uno::UNO_QUERY );
+
+                        css::uno::Reference< css::connection::XConnection > xConnection(
+                            xConnector->connect( m_aUnoURL.Connection ) );
+
+                        css::uno::Reference< css::bridge::XBridgeFactory > xBridgeFactory(
+                            xContext->getServiceManager()->createInstanceWithContext(
+                                rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
+                                                   "com.sun.star.bridge.BridgeFactory" ) ),
+                                xContext ), css::uno::UNO_QUERY );
+
+                        // create a nameless bridge with no instance provider
+                        // using the middle part of the UNO URL
+                        xBridge.set(
+                            xBridgeFactory->createBridge(
+                                rtl::OUString(),
+                                C2U( "urp" ),
+                                xConnection,
+                                css::uno::Reference< css::bridge::XInstanceProvider>() ) );
+
+                        css::uno::Reference< css::lang::XComponent > xBridgeComp(
+                            xBridge, css::uno::UNO_QUERY_THROW );
+                        xBridgeComp->addEventListener( this );
+
+                        aGuard.reset();
+                        m_xBridge = xBridgeComp;
+                        aGuard.clear();
+                    }
+                    catch ( const css::uno::Exception &e )
+                    {
+                        OSL_TRACE( "getRemoteObject() caugth an exception: %s", U2C( e.Message ) );
+                    }
+                }
+
+                if ( xBridge.is() )
+                {
+                    try
+                    {
+                        xRemoteObject.set(
+                            xBridge->getInstance(
+                                m_aUnoURL.Object ),
+                            css::uno::UNO_QUERY_THROW );
+                    }
+                    catch ( const css::uno::Exception &e )
+                    {
+                        OSL_TRACE( "getRemoteObject() caugth an exception: %s", U2C( e.Message ) );
+                    }
+
+                    aGuard.reset();
+                    m_xRemoteObject = xRemoteObject;
+                    aGuard.clear();
+                }
+
+                return xRemoteObject;
+            }
+    };
+}
+
+ClientUnoExe::ClientUnoExe(
+    const css::uno::Reference< css::uno::XComponentContext > &rxContext )
+    : ClientUnoExe_Base()
+    , m_xContext( rxContext )
+{
+    OSL_TRACE( "ClientUnoExe::ClientUnoExe" );
+
+    // m_xContext is the URE-local component context
+    // In order to use the office components,
+    // we should bootstrap an office instance
+    css::uno::Reference< css::lang::XMultiComponentFactory > xMCF(
+        m_xContext->getServiceManager() );
+    css::uno::Sequence< rtl::OUString > sServices = xMCF->getAvailableServiceNames();
+
+    const rtl::OUString *pBegin = sServices.getConstArray();
+    std::vector< rtl::OUString > vServices(
+        pBegin, pBegin + sServices.getLength() );
+
+    std::cout << "\n\nAvailable services:\n";
+    std::for_each(
+        vServices.begin(), vServices.end(), PrintOUStringSeq() );
+}
+
+ClientUnoExe::~ClientUnoExe()
+{
+    OSL_TRACE( "ClientUnoExe::~ClientUnoExe" );
+}
+
+/**
+ * UNO exe invokation:
+ *
+ * uno [...] -- [arguments passed to the component's XMain::run()]
+ */
+sal_Int32 SAL_CALL
+ClientUnoExe::run(
+    const css::uno::Sequence< rtl::OUString > &aArguments )
+throw ( css::uno::RuntimeException )
+{
+    OSL_TRACE( "ClientUnoExe::run" );
+
+    // In this example, the first argument should contain a UNO connection URL
+    // to connect to the remote server running in the UNO executable launched
+    // in server mode.
+    UnoConnUrl aUrl;
+    rtl::OUString sUrl;
+
+    if ( aArguments.getLength() != 1 ||
+            !( sUrl = aArguments[0] ).getLength() ||
+            !lcl_ParseUnoUrl( sUrl, aUrl ) )
+    {
+        std::cerr << "You must specify the UNO connection URL\n";
+        return EXIT_FAILURE;
+    }
+
+    // Hold a reference to the connection so that it lives during this method
+    rtl::Reference< RemoteConnection > aConnection( new RemoteConnection( m_xContext, aUrl ) );
+
+    // get the object exported by the remote server
+    css::uno::Reference< css::lang::XServiceInfo > xServiceInfo(
+        aConnection->getRemoteObject(), css::uno::UNO_QUERY );
+
+    if ( xServiceInfo.is() )
+    {
+        std::cout << "Remote object: " << U2C( xServiceInfo->getImplementationName() ) << '\n';
+
+        std::cout << "Supported services:\n";
+        css::uno::Sequence< rtl::OUString > aSupportedService(
+            xServiceInfo->getSupportedServiceNames() );
+
+        const rtl::OUString *pBegin = aSupportedService.getConstArray();
+        std::vector< rtl::OUString > vServices(
+            pBegin, pBegin + aSupportedService.getLength() );
+        std::for_each(
+            vServices.begin(), vServices.end(), PrintOUStringSeq() );
+    }
+
+    std::cout << "Press ENTER to exit XMain::run()...";
+    std::cin.get();
+
+    aConnection->close();
+    aConnection.clear();
+
+    return EXIT_SUCCESS;
+
+}
+
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL
+ClientUnoExe::CreateInstance(
+    const css::uno::Reference< css::uno::XComponentContext > &rxContext )
+{
+    OSL_TRACE( "ClientUnoExe::CreateInstance" );
+
+    return css::uno::Reference< css::uno::XInterface >(
+               static_cast< OWeakObject * >(
+                   new ClientUnoExe( rxContext ) ) );
+}
+
+rtl::OUString SAL_CALL
+ClientUnoExe::GetImplementationName_static()
+{
+    OSL_TRACE( "ClientUnoExe::GetImplementationName_static" );
+
+    return StaticImplementationName::get();
+}
+
+css::uno::Sequence< rtl::OUString > SAL_CALL
+ClientUnoExe::GetSupportedServiceNames_static()
+{
+    OSL_TRACE( "ClientUnoExe::GetSupportedServiceNames_static" );
+
+    return StaticSupportedServices::get();
+}
+

Added: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.hxx
URL: http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.hxx?rev=1449471&view=auto
==============================================================================
--- openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.hxx (added)
+++ openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/client.hxx Sun Feb 24 12:59:39 2013
@@ -0,0 +1,51 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef __UNO_EXE_CLIENT__
+#define __UNO_EXE_CLIENT__
+
+#include <com/sun/star/lang/XMain.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace css = ::com::sun::star;
+
+namespace standalone_uno_exe
+{
+    typedef ::cppu::WeakImplHelper1< css::lang::XMain > ClientUnoExe_Base;
+
+    class ClientUnoExe : public ClientUnoExe_Base
+    {
+        private:
+            css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+        public:
+            ClientUnoExe( const css::uno::Reference< css::uno::XComponentContext > &rxContext );
+            ~ClientUnoExe();
+
+            virtual sal_Int32 SAL_CALL run( const css::uno::Sequence< rtl::OUString > &aArguments ) throw( css::uno::RuntimeException );
+
+            static css::uno::Reference< css::uno::XInterface > SAL_CALL CreateInstance( const css::uno::Reference< css::uno::XComponentContext > &rxContext );
+            static css::uno::Sequence< rtl::OUString > SAL_CALL GetSupportedServiceNames_static();
+            static rtl::OUString SAL_CALL GetImplementationName_static();
+    };
+}
+
+#endif

Added: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/components.cxx
URL: http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/components.cxx?rev=1449471&view=auto
==============================================================================
--- openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/components.cxx (added)
+++ openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/ServerUnoExe/src/components.cxx Sun Feb 24 12:59:39 2013
@@ -0,0 +1,66 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "client.hxx"
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
+
+
+namespace standalone_uno_exe
+{
+    static struct cppu::ImplementationEntry st_impl_entries[] =
+    {
+        {
+            ClientUnoExe::CreateInstance,
+            ClientUnoExe::GetImplementationName_static,
+            ClientUnoExe::GetSupportedServiceNames_static,
+            cppu::createSingleComponentFactory,
+            0,
+            0
+        },
+        { 0, 0, 0, 0, 0, 0 }
+    };
+}
+
+extern "C"
+{
+    SAL_DLLPUBLIC_EXPORT void SAL_CALL
+    component_getImplementationEnvironment(
+        const sal_Char **ppEnvTypeName,
+        uno_Environment **/*ppEnv*/ )
+    {
+        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+    }
+
+    SAL_DLLPUBLIC_EXPORT void *SAL_CALL
+    component_getFactory(
+        const sal_Char *pImplName,
+        void *pServiceManager,
+        void *pRegistryKey )
+    {
+        return ::cppu::component_getFactoryHelper(
+                   pImplName,
+                   pServiceManager,
+                   pRegistryKey ,
+                   standalone_uno_exe::st_impl_entries );
+    }
+}
+

Added: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/Makefile
URL: http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/Makefile?rev=1449471&view=auto
==============================================================================
--- openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/Makefile (added)
+++ openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/Makefile Sun Feb 24 12:59:39 2013
@@ -0,0 +1,161 @@
+#**************************************************************
+#
+#  Licensed to the Apache Software Foundation (ASF) under one
+#  or more contributor license agreements.  See the NOTICE file
+#  distributed with this work for additional information
+#  regarding copyright ownership.  The ASF licenses this file
+#  to you under the Apache License, Version 2.0 (the
+#  "License"); you may not use this file except in compliance
+#  with the License.  You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+#  Unless required by applicable law or agreed to in writing,
+#  software distributed under the License is distributed on an
+#  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#  KIND, either express or implied.  See the License for the
+#  specific language governing permissions and limitations
+#  under the License.
+#
+#**************************************************************
+
+PRJ=../../../../../..
+SETTINGS=$(PRJ)/settings
+
+include $(SETTINGS)/settings.mk
+include $(SETTINGS)/std.mk
+include $(SETTINGS)/dk.mk
+
+
+IMPLEMENTATION_NAME=com.sun.star.comp.product.example.StandaloneUnoExeSample
+SERVICE_NAME=com.sun.star.bridge.example.StandaloneUnoExeSample
+CONNECTION_URL=uno:socket,host=localhost,port=2083;urp;MyPipe
+
+
+# Define non-platform/compiler specific settings
+COMP_NAME=StandaloneUnoExe
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+COMP_RDB_NAME = $(COMP_NAME).uno.rdb
+
+#this should be in odk/settings/std.mk
+OUT_DEPLOY=$(OUT)/deploy
+
+OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
+OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
+OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
+OUT_COMP_LIB=$(SHAREDLIB_OUT)/$(COMP_NAME)
+OUT_COMP_BIN=$(OUT_BIN)/$(COMP_NAME)
+OUT_COMP_DEPLOY=$(OUT_DEPLOY)/$(COMP_NAME)
+
+COMP_IMPL=$(OUT_COMP_LIB)/$(COMP_IMPL_NAME)
+COMP_RDB = $(OUT_COMP_BIN)/$(COMP_RDB_NAME)
+COMP_SERVICES=$(OUT_COMP_LIB)/$(COMP_NAME).rdb
+
+ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=$(URLPREFIX)$(COMP_SERVICES)
+
+CXXFILES = \
+	standalone.cxx \
+	components.cxx
+
+SLOFILES = $(patsubst %.cxx,$(OUT_COMP_SLO)/%.$(OBJ_EXT),$(CXXFILES))
+
+# Targets
+.PHONY: ALL
+ALL : \
+	$(COMP_NAME)
+
+include $(SETTINGS)/stdtarget.mk
+
+ifneq "$(DEBUG)" ""
+	CC_DEFINES+=-DOSL_DEBUG_LEVEL=3
+endif
+CC_DEFINES+=\
+	-DIMPLEMENTATION_NAME=\"$(IMPLEMENTATION_NAME)\" \
+	-DSERVICE_NAME=\"$(SERVICE_NAME)\"
+
+
+$(OUT_COMP_SLO)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
+	@echo
+	-$(MKDIR) $(subst /,$(PS),$(@D))
+	$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
+	@echo
+
+ifeq "$(OS)" "WIN"
+$(OUT_COMP_LIB)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+	@echo
+	-$(MKDIR) $(subst /,$(PS),$(@D))
+	-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
+	$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
+	/MAP:$(OUT_COMP_GEN)/$(subst $(SHAREDLIB_EXT),map,$(@F)) $(SLOFILES) \
+	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
+	$(LINK_MANIFEST)
+	@echo
+else
+$(OUT_COMP_LIB)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+	@echo
+	-$(MKDIR) $(subst /,$(PS),$(@D))
+	$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
+	$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
+ifeq "$(OS)" "MACOSX"
+	$(INSTALL_NAME_URELIBS)  $@
+endif
+	@echo
+endif
+
+$(COMP_SERVICES) :
+	@echo
+	-$(MKDIR) $(subst /,$(PS),$(@D))
+	@echo $(OSEP)?xml version="$(QM)1.0$(QM)" encoding="$(QM)UTF-8$(QM)"?$(CSEP) > $@
+	@echo $(OSEP)components xmlns="$(QM)http://openoffice.org/2010/uno-components$(QM)"$(CSEP) >> $@
+	@echo $(SQM)  $(SQM)$(OSEP)component loader="$(QM)com.sun.star.loader.SharedLibrary$(QM)" uri="$(QM)$(COMP_IMPL_NAME)$(QM)"$(CSEP) >> $@
+	@echo $(SQM)    $(SQM)$(OSEP)implementation name="$(QM)$(IMPLEMENTATION_NAME)$(QM)"$(CSEP) >> $@
+	@echo $(SQM)      $(SQM)$(OSEP)service name="$(QM)$(SERVICE_NAME)$(QM)"/$(CSEP) >> $@
+	@echo $(SQM)    $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+	@echo $(SQM)  $(SQM)$(OSEP)/component$(CSEP) >> $@
+	@echo $(OSEP)/components$(CSEP) >> $@
+	@echo
+
+$(COMP_NAME) : $(COMP_IMPL) $(COMP_SERVICES)
+	@echo
+	@echo --------------------------------------------------------------------------------
+	@echo
+	@echo The $(COMP_NAME) C++ component can be used with the UNO Executable.
+	@echo See "http://wiki.openoffice.org/wiki/Documentation/DevGuide/WritingUNO/The_UNO_Executable"
+	@echo
+	@echo The run target launches the uno executable so that it instantiates
+	@echo the UNO component and invokes its "css::lang::XMain::run(arguments)" method.
+	@echo The arguments to "run()" are passed to the uno executable after "--"
+	@echo
+	@echo $(SQM)      $(SQM)"uno[.exe] [...] -- [arguments to XMain::run()]"
+	@echo
+	@echo Use the the follwong command to start the example.
+	@echo
+	@echo $(SQM)      $(SQM)$(MAKE) $(COMP_NAME).run
+	@echo
+	@echo NOTE: The example uses the $(QM)uno$(QM) tool to prepare a working UNO environment.
+	@echo $(SQM)      $(SQM)The example component is made available via -env:URE_MORE_SERVICES=...
+	@echo $(SQM)      $(SQM)Please check the generated $(QM)$(COMP_SERVICES)$(QM)
+	@echo $(SQM)      $(SQM)to see how you can specify your own components in such an environment
+	@echo $(SQM)      $(SQM)and how to use the passive UNO registration.
+	@echo
+	@echo --------------------------------------------------------------------------------
+	@echo
+
+$(COMP_NAME).run: $(COMP_IMPL)
+	@echo
+	uno \
+		$(ENV_COMP_SERVICES) \
+		-s $(SERVICE_NAME) \
+		-- --param1 --param2="test" --param3
+	@echo -
+	@echo
+
+.PHONY: clean
+clean :
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_LIB))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_BIN))
+	-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_DEPLOY))
+

Propchange: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/Makefile
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/components.cxx
URL: http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/components.cxx?rev=1449471&view=auto
==============================================================================
--- openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/components.cxx (added)
+++ openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/components.cxx Sun Feb 24 12:59:39 2013
@@ -0,0 +1,66 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "standalone.hxx"
+#include <cppuhelper/factory.hxx>
+#include <cppuhelper/implementationentry.hxx>
+
+
+namespace standalone_uno_exe
+{
+    static struct cppu::ImplementationEntry st_impl_entries[] =
+    {
+        {
+            StandaloneUnoExe::CreateInstance,
+            StandaloneUnoExe::GetImplementationName_static,
+            StandaloneUnoExe::GetSupportedServiceNames_static,
+            cppu::createSingleComponentFactory,
+            0,
+            0
+        },
+        { 0, 0, 0, 0, 0, 0 }
+    };
+}
+
+extern "C"
+{
+    SAL_DLLPUBLIC_EXPORT void SAL_CALL
+    component_getImplementationEnvironment(
+        const sal_Char **ppEnvTypeName,
+        uno_Environment **/*ppEnv*/ )
+    {
+        *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
+    }
+
+    SAL_DLLPUBLIC_EXPORT void *SAL_CALL
+    component_getFactory(
+        const sal_Char *pImplName,
+        void *pServiceManager,
+        void *pRegistryKey )
+    {
+        return ::cppu::component_getFactoryHelper(
+                   pImplName,
+                   pServiceManager,
+                   pRegistryKey ,
+                   standalone_uno_exe::st_impl_entries );
+    }
+}
+

Added: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.cxx
URL: http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.cxx?rev=1449471&view=auto
==============================================================================
--- openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.cxx (added)
+++ openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.cxx Sun Feb 24 12:59:39 2013
@@ -0,0 +1,177 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#include "standalone.hxx"
+
+#include <algorithm>
+#include <cstdlib>
+#include <functional>
+#include <iostream>
+#include <vector>
+
+#include <rtl/instance.hxx>
+
+#ifndef IMPLEMENTATION_NAME
+#error  You must define IMPLEMENTATION_NAME
+#endif
+
+#ifndef SERVICE_NAME
+#error  You must define SERVICE_NAME
+#endif
+
+#define C2U( constAsciiStr ) \
+    ( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( constAsciiStr ) ) )
+
+#define U2C( ouString ) \
+    ( rtl::OUStringToOString( ouString, RTL_TEXTENCODING_UTF8 ).getStr() )
+
+
+using namespace standalone_uno_exe;
+
+namespace
+{
+    struct StaticImplementationName :
+        public rtl::StaticWithInit <
+            const rtl::OUString,
+            StaticImplementationName >
+    {
+        const rtl::OUString &operator()() const
+        {
+            static rtl::OUString aName(
+                RTL_CONSTASCII_USTRINGPARAM(
+                    IMPLEMENTATION_NAME ) );
+
+            return aName;
+        }
+    };
+
+    struct StaticSupportedServices :
+        public rtl::StaticWithInit <
+            const css::uno::Sequence< rtl::OUString >,
+            StaticSupportedServices >
+    {
+        const css::uno::Sequence< rtl::OUString > &
+        operator()() const
+        {
+            static css::uno::Sequence< rtl::OUString > aSeq( 1 );
+            aSeq[0] = rtl::OUString(
+                          RTL_CONSTASCII_USTRINGPARAM(
+                              SERVICE_NAME ) );
+            return aSeq;
+        }
+    };
+
+    struct PrintOUStringSeq
+            : public std::unary_function< const rtl::OUString &, void >
+    {
+            PrintOUStringSeq()
+                : m_nCount( 0 )
+            {}
+
+            void operator()( const rtl::OUString &rStr ) const
+            {
+                std::cout << '[' << m_nCount << "] " << U2C( rStr ) << '\n';
+                ++m_nCount;
+            }
+        private:
+            mutable int m_nCount;
+    };
+}
+
+StandaloneUnoExe::StandaloneUnoExe(
+    const css::uno::Reference< css::uno::XComponentContext > &rxContext )
+    : StandaloneUnoExe_Base()
+    , m_xContext( rxContext )
+{
+    OSL_TRACE( "StandaloneUnoExe::StandaloneUnoExe" );
+
+    // m_xContext is the URE-local component context
+    // In order to use the office components,
+    // we should bootstrap an office instance
+    css::uno::Reference< css::lang::XMultiComponentFactory > xMCF(
+        m_xContext->getServiceManager() );
+    css::uno::Sequence< rtl::OUString > sServices = xMCF->getAvailableServiceNames();
+
+    const rtl::OUString *pBegin = sServices.getConstArray();
+    std::vector< rtl::OUString > vServices(
+        pBegin, pBegin + sServices.getLength() );
+
+    std::cout << "\n\nAvailable services:\n";
+    std::for_each(
+        vServices.begin(), vServices.end(), PrintOUStringSeq() );
+}
+
+StandaloneUnoExe::~StandaloneUnoExe()
+{
+    OSL_TRACE( "StandaloneUnoExe::~StandaloneUnoExe" );
+}
+
+/**
+ * UNO exe invokation:
+ *
+ * uno [...] -- [arguments passed to the component's XMain::run()]
+ */
+sal_Int32 SAL_CALL
+StandaloneUnoExe::run(
+    const css::uno::Sequence< rtl::OUString > &aArguments )
+throw ( css::uno::RuntimeException )
+{
+    OSL_TRACE( "StandaloneUnoExe::run" );
+
+    // Dummy: print the command line args
+    for (const rtl::OUString *pBegin = aArguments.getConstArray(),
+        *pEnd = pBegin + aArguments.getLength();
+        pBegin != pEnd; pBegin++ )
+    {
+        std::cout << '\t' << U2C(*pBegin) << '\n';
+    }
+
+    return EXIT_SUCCESS;
+}
+
+
+css::uno::Reference< css::uno::XInterface > SAL_CALL
+StandaloneUnoExe::CreateInstance(
+    const css::uno::Reference< css::uno::XComponentContext > &rxContext )
+{
+    OSL_TRACE( "StandaloneUnoExe::CreateInstance" );
+
+    return css::uno::Reference< css::uno::XInterface >(
+               static_cast< OWeakObject * >(
+                   new StandaloneUnoExe( rxContext ) ) );
+}
+
+rtl::OUString SAL_CALL
+StandaloneUnoExe::GetImplementationName_static()
+{
+    OSL_TRACE( "StandaloneUnoExe::GetImplementationName_static" );
+
+    return StaticImplementationName::get();
+}
+
+css::uno::Sequence< rtl::OUString > SAL_CALL
+StandaloneUnoExe::GetSupportedServiceNames_static()
+{
+    OSL_TRACE( "StandaloneUnoExe::GetSupportedServiceNames_static" );
+
+    return StaticSupportedServices::get();
+}
+

Added: openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.hxx
URL: http://svn.apache.org/viewvc/openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.hxx?rev=1449471&view=auto
==============================================================================
--- openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.hxx (added)
+++ openoffice/devtools/sdk-examples/trunk/cpp/cppbindings/UnoExecutable/StandaloneUnoExe/src/standalone.hxx Sun Feb 24 12:59:39 2013
@@ -0,0 +1,51 @@
+/**************************************************************
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+ *************************************************************/
+
+#ifndef __UNO_EXE_STANDALONE__
+#define __UNO_EXE_STANDALONE__
+
+#include <com/sun/star/lang/XMain.hpp>
+#include <cppuhelper/implbase1.hxx>
+
+namespace css = ::com::sun::star;
+
+namespace standalone_uno_exe
+{
+    typedef ::cppu::WeakImplHelper1< css::lang::XMain > StandaloneUnoExe_Base;
+
+    class StandaloneUnoExe : public StandaloneUnoExe_Base
+    {
+        private:
+            css::uno::Reference< css::uno::XComponentContext > m_xContext;
+
+        public:
+            StandaloneUnoExe( const css::uno::Reference< css::uno::XComponentContext > &rxContext );
+            ~StandaloneUnoExe();
+
+            virtual sal_Int32 SAL_CALL run( const css::uno::Sequence< rtl::OUString > &aArguments ) throw( css::uno::RuntimeException );
+
+            static css::uno::Reference< css::uno::XInterface > SAL_CALL CreateInstance( const css::uno::Reference< css::uno::XComponentContext > &rxContext );
+            static css::uno::Sequence< rtl::OUString > SAL_CALL GetSupportedServiceNames_static();
+            static rtl::OUString SAL_CALL GetImplementationName_static();
+    };
+}
+
+#endif