summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuergen Schmidt <jsc@openoffice.org>2011-02-28 14:10:02 +0100
committerJuergen Schmidt <jsc@openoffice.org>2011-02-28 14:10:02 +0100
commita8f4bb16d11f4fb3833c188d694ef7ad14f9f874 (patch)
treef8959c8e6c9f691636e51560f8d8a8581c7a2ebf
parent8a3de9d1aa80f80c514554b8b3c8cf19995ee850 (diff)
jsc340: i114609: adapt examples to work with the URE and use the passive registration
-rw-r--r--odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile34
-rw-r--r--odk/examples/cpp/DocumentLoader/DocumentLoader.cxx47
-rw-r--r--odk/examples/cpp/DocumentLoader/Makefile37
-rw-r--r--odk/examples/cpp/counter/Makefile37
-rw-r--r--odk/examples/cpp/counter/counter.cxx54
-rw-r--r--odk/examples/cpp/counter/countermain.cxx68
-rw-r--r--odk/examples/cpp/remoteclient/Makefile59
-rw-r--r--odk/examples/cpp/remoteclient/remoteclient.cxx52
8 files changed, 172 insertions, 216 deletions
diff --git a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile
index 05880e3a..fb235c76 100644
--- a/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile
+++ b/odk/examples/DevelopersGuide/ProfUNO/CppBinding/Makefile
@@ -49,17 +49,11 @@ SAMPLE_OBJ_OUT=$(OUT_OBJ)/$(SAMPLE_NAME)
APP1_NAME=office_connect
APP1_BINARY=$(OUT_BIN)/$(APP1_NAME)$(EXE_EXT)
-APP1_RDB=$(OUT_BIN)/office_connect.rdb
-APP1_ENV_FLAG = $(SAMPLE_GEN_OUT)/cpp_$(SAMPLE_NAME)_prepare_env.flag
APP2_NAME=string_samples
APP2_BINARY=$(OUT_BIN)/$(APP2_NAME)$(EXE_EXT)
-ifeq "$(OS)" "WIN"
-INI_EXTENSION=.ini
-else
-INI_EXTENSION=rc
-endif
+ENV_OFFICE_TYPES=-env:URE_MORE_TYPES=file://$(OFFICE_TYPES)
CXXFILES = \
office_connect.cxx \
@@ -72,14 +66,6 @@ ALL : \
include $(SETTINGS)/stdtarget.mk
-$(OUT_BIN)/%$(INI_EXTENSION) : %$(INI_EXTENSION)
- -$(MKDIR) $(subst /,$(PS),$(@D))
- $(COPY) $< $(subst /,$(PS),$@)
-
-$(OUT_BIN)/%.rdb :
- -$(MKDIR) $(subst /,$(PS),$(@D))
- $(REGMERGE) $@ / $(URE_TYPES) $(OFFICE_TYPES)
-
$(SAMPLE_OBJ_OUT)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(SAMPLE_INC_OUT) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
@@ -98,23 +84,10 @@ ifeq "$(OS)" "MACOSX"
endif
endif
-$(OUT_BIN)/office_connect$(EXE_EXT) : $(APP1_ENV_FLAG) $(OUT_BIN)/office_connect$(INI_EXTENSION) $(SAMPLE_OBJ_OUT)/office_connect.$(OBJ_EXT)
+$(OUT_BIN)/office_connect$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/office_connect.$(OBJ_EXT)
$(OUT_BIN)/string_samples$(EXE_EXT) : $(SAMPLE_OBJ_OUT)/string_samples.$(OBJ_EXT)
-$(APP1_ENV_FLAG) : $(APP1_RDB)
- -$(MKDIR) $(subst /,$(PS),$(@D))
- -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
- @echo --------------------------------------------------------------------------------
- @echo Register necessary runtime components in $(APP1_RDB)
- @echo --------------------------------------------------------------------------------
- $(REGCOMP) -register -r $(APP1_RDB) -c connector.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(APP1_RDB) -c remotebridge.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(APP1_RDB) -c bridgefac.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(APP1_RDB) -c uuresolver.uno.$(SHAREDLIB_EXT)
- @echo bla > $@
-
-
ProUNOCppBindingExample : $(APP1_BINARY) $(APP2_BINARY)
@echo --------------------------------------------------------------------------------
@echo Note: For the "$(QM)$(APP1_NAME)$(QM)" example you need a running office listening
@@ -131,6 +104,9 @@ ProUNOCppBindingExample : $(APP1_BINARY) $(APP2_BINARY)
%.run: $(OUT_BIN)/%$(EXE_EXT)
cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+$(API1_NAME).run: $(API1_BINARY)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_OFFICE_TYPES)
+
.PHONY: clean
clean :
-$(DELRECURSIVE) $(subst /,$(PS),$(SAMPLE_INC_OUT))
diff --git a/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx b/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx
index 211f2024..0ef6c115 100644
--- a/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx
+++ b/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx
@@ -48,6 +48,7 @@
#include <osl/file.hxx>
#include <osl/process.h>
+#include <rtl/process.h>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/bridge/XUnoUrlResolver.hpp>
@@ -71,36 +72,22 @@ using namespace com::sun::star::registry;
SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
{
OUString sConnectionString(RTL_CONSTASCII_USTRINGPARAM("uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager"));
- if (argc < 2)
+
+ sal_Int32 nCount = (sal_Int32)rtl_getAppCommandArgCount();
+
+ if (nCount < 1)
{
- printf("using: DocumentLoader <file_url> [<uno_connection_url>]\n\n"
- "example: DocumentLoader \"file:///e:/temp/test.odt\" \"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager\"\n");
+ printf("using: DocumentLoader -env:URE_MORE_TYPES=<office_types_rdb_url> <file_url> [<uno_connection_url>]\n\n"
+ "example: DocumentLoader -env:URE_MORE_TYPES=\"file:///.../basis-link/program/offapi.rdb\" \"file:///e:/temp/test.odt\" \"uno:socket,host=localhost,port=2083;urp;StarOffice.ServiceManager\"\n");
exit(1);
}
- if (argc == 3)
+ if (nCount == 2)
{
- sConnectionString = OUString::createFromAscii(argv[2]);
+ rtl_getAppCommandArg(1, &sConnectionString.pData);
}
-
- // Creates a simple registry service instance.
- Reference< XSimpleRegistry > xSimpleRegistry(
- ::cppu::createSimpleRegistry() );
-
- // Connects the registry to a persistent data source represented by an URL.
- xSimpleRegistry->open( OUString( RTL_CONSTASCII_USTRINGPARAM(
- "DocumentLoader.rdb") ), sal_True, sal_False );
-
- /* Bootstraps an initial component context with service manager upon a given
- registry. This includes insertion of initial services:
- - (registry) service manager, shared lib loader,
- - simple registry, nested registry,
- - implementation registration
- - registry typedescription provider, typedescription manager (also
- installs it into cppu core)
- */
- Reference< XComponentContext > xComponentContext(
- ::cppu::bootstrap_InitialComponentContext( xSimpleRegistry ) );
-
+
+ Reference< XComponentContext > xComponentContext(::cppu::defaultBootstrap_InitialComponentContext());
+
/* Gets the service manager instance to be used (or null). This method has
been added for convenience, because the service manager is a often used
object.
@@ -131,7 +118,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr());
exit(1);
}
-
+
// gets the server component context as property of the office component factory
Reference< XPropertySet > xPropSet( xInterface, UNO_QUERY );
xPropSet->getPropertyValue( OUString::createFromAscii("DefaultContext") ) >>= xComponentContext;
@@ -139,7 +126,7 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
// gets the service manager from the office
Reference< XMultiComponentFactory > xMultiComponentFactoryServer(
xComponentContext->getServiceManager() );
-
+
/* Creates an instance of a component which supports the services specified
by the factory. Important: using the office component context.
*/
@@ -151,9 +138,11 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv)
/* Loads a component specified by an URL into the specified new or existing
frame.
*/
- OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
+ OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl, sArgDocUrl;
+ rtl_getAppCommandArg(0, &sArgDocUrl.pData);
+
osl_getProcessWorkingDir(&sWorkingDir.pData);
- osl::FileBase::getFileURLFromSystemPath( OUString::createFromAscii(argv[1]), sDocPathUrl);
+ osl::FileBase::getFileURLFromSystemPath( sArgDocUrl, sDocPathUrl);
osl::FileBase::getAbsoluteFileURL( sWorkingDir, sDocPathUrl, sAbsoluteDocUrl);
Reference< XComponent > xComponent = xComponentLoader->loadComponentFromURL(
diff --git a/odk/examples/cpp/DocumentLoader/Makefile b/odk/examples/cpp/DocumentLoader/Makefile
index 91e6f49c..3e7b904d 100644
--- a/odk/examples/cpp/DocumentLoader/Makefile
+++ b/odk/examples/cpp/DocumentLoader/Makefile
@@ -43,19 +43,17 @@ include $(SETTINGS)/dk.mk
# Define non-platform/compiler specific settings
COMPONENT_NAME=DocumentLoader
-COMPONENT_RDB_NAME = $(COMPONENT_NAME).rdb
-COMPONENT_RDB = $(OUT_BIN)/$(COMPONENT_RDB_NAME)
OUT_COMP_INC = $(OUT_INC)/$(COMPONENT_NAME)
OUT_COMP_GEN = $(OUT_MISC)/$(COMPONENT_NAME)
OUT_COMP_OBJ=$(OUT_OBJ)/$(COMPONENT_NAME)
-COMPOENNT_ENV_FLAG = $(OUT_MISC)/cpp_$(COMPONENT_NAME)_prepare_env.flag
-
CXXFILES = DocumentLoader.cxx
OBJFILES = $(patsubst %.cxx,$(OUT_SLO_COMP)/%.$(OBJ_EXT),$(CXXFILES))
+ENV_OFFICE_TYPES=-env:URE_MORE_TYPES=file://$(OFFICE_TYPES)
+
# Targets
.PHONY: ALL
ALL : \
@@ -63,12 +61,6 @@ ALL : \
include $(SETTINGS)/stdtarget.mk
-# This example type library will be extended by the URE and office types
-$(OUT_BIN)/%.rdb :
- -$(MKDIR) $(subst /,$(PS),$(@D))
- -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
- $(REGMERGE) $@ / $(URE_TYPES) $(OFFICE_TYPES)
-
$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(SDKTYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(CC) $(CC_FLAGS) $(CC_INCLUDES) -I$(OUT_COMP_INC) $(CC_DEFINES) $(CC_OUTPUT_SWITCH)$(subst /,$(PS),$@) $<
@@ -87,41 +79,30 @@ ifeq "$(OS)" "MACOSX"
endif
endif
-$(COMPOENNT_ENV_FLAG) : $(COMPONENT_RDB)
- -$(MKDIR) $(subst /,$(PS),$(@D))
- -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
- @echo --------------------------------------------------------------------------------
- @echo Register necessary runtime components in the DocumentLoader.rdb
- @echo --------------------------------------------------------------------------------
- $(REGCOMP) -register -r $(COMPONENT_RDB) -c connector.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(COMPONENT_RDB) -c remotebridge.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(COMPONENT_RDB) -c bridgefac.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(COMPONENT_RDB) -c uuresolver.uno.$(SHAREDLIB_EXT)
- @echo bla > $@
-
-CppDocumentLoaderExample : $(OUT_BIN)/DocumentLoader$(EXE_EXT) $(COMPOENNT_ENV_FLAG)
+CppDocumentLoaderExample : $(OUT_BIN)/DocumentLoader$(EXE_EXT)
@echo --------------------------------------------------------------------------------
@echo The example loads the "$(QM)test.odt$(QM)" document in the DocumentLoader example directory.
- @echo I you want to load your own document, please use: DocumentLoader "$(QM)filename$(QM)" [connection_url]
+ @echo If you want to load your own document, please use:
+ @echo $(SQM) $(SQM)DocumentLoader -env:URE_MORE_TYPES="$(QM)<fileurl_office_types_rdb>$(QM)" "$(QM)filename$(QM)" [connection_url]
@echo -
@echo Use the following command to execute the example!
@echo -
@echo $(MAKE) DocumentLoader.run
@echo -
@echo NOTE: This example does not use the new UNO bootstrap mechanism, it uses still a socket
- @echo $(SQM) $(SQM)connection. Before you can run this example you have to start your office in listening mode.
+ @echo $(SQM) $(SQM)connection. The example use the defaultBootstrap_InitialComponentContext method and provides
+ @echo $(SQM) $(SQM)the additional office types via the UNO environment variable -env:URE_MORE_TYPES=...
+ @echo $(SQM) $(SQM)Before you can run this example you have to start your office in listening mode.
@echo -
@echo $(SQM) $(SQM)soffice "$(QM)-accept=socket,host=localhost,port=2083;urp;StarOffice.ServiceManager$(QM)"
@echo --------------------------------------------------------------------------------
%.run: $(OUT_BIN)/DocumentLoader$(EXE_EXT)
- cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(subst \\,/,$(subst /,$(PS),"$(OO_SDK_HOME)/examples/cpp/DocumentLoader/test.odt"))
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_OFFICE_TYPES) $(subst \\,/,$(subst /,$(PS),"$(OO_SDK_HOME)/examples/cpp/DocumentLoader/test.odt"))
.PHONY: clean
clean :
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_OBJ))
- -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPOENNT_ENV_FLAG)))
- -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMPONENT_RDB)))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/DocumentLoader*))
diff --git a/odk/examples/cpp/counter/Makefile b/odk/examples/cpp/counter/Makefile
index 5e7f620a..84062dc2 100644
--- a/odk/examples/cpp/counter/Makefile
+++ b/odk/examples/cpp/counter/Makefile
@@ -43,7 +43,7 @@ include $(SETTINGS)/dk.mk
# Define non-platform/compiler specific settings
COMP_NAME=counter
-COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
COMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
COMP_RDB_NAME = $(COMP_NAME).uno.rdb
COMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
@@ -52,6 +52,10 @@ OUT_COMP_INC = $(OUT_INC)/$(COMP_NAME)
OUT_COMP_GEN = $(OUT_MISC)/$(COMP_NAME)
OUT_COMP_OBJ = $(OUT_OBJ)/$(COMP_NAME)
OUT_COMP_SLO = $(OUT_SLO)/$(COMP_NAME)
+COMP_SERVICES=$(OUT_BIN)/counterservices.rdb
+
+ENV_EXAMPLE_TYPES=-env:URE_MORE_TYPES=file://$(COMP_RDB)
+ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=file://$(COMP_SERVICES)
COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
@@ -84,12 +88,12 @@ $(OUT_BIN)/%.rdb : $(GENURDFILES)
-$(MKDIR) $(subst /,$(PS),$(@D))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
$(REGMERGE) $@ /UCR $(GENURDFILES)
- $(REGMERGE) $@ / $(URE_TYPES)
+# $(REGMERGE) $@ / $(URE_TYPES)
$(COMP_TYPEFLAG) : $(COMP_RDB) $(SDKTYPEFLAG)
-$(MKDIR) $(subst /,$(PS),$(@D))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
- $(CPPUMAKER) -Gc -BUCR -O$(OUT_COMP_INC) $(TYPESLIST) $(COMP_RDB)
+ $(CPPUMAKER) -Gc -BUCR -O$(OUT_COMP_INC) $(TYPESLIST) $(COMP_RDB) -X $(URE_TYPES)
echo flagged > $@
$(OUT_COMP_OBJ)/%.$(OBJ_EXT) : %.cxx $(COMP_TYPEFLAG)
@@ -110,7 +114,7 @@ ifeq "$(OS)" "MACOSX"
endif
ifeq "$(OS)" "WIN"
-$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
-$(MKDIR) $(subst /,$(PS),$(@D))
-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
@@ -118,7 +122,8 @@ $(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
$(LINK_MANIFEST)
else
-$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
+#$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
@@ -138,16 +143,33 @@ else
$(CPPUHELPERLIB) $(CPPULIB) $(SALHELPERLIB) $(SALLIB) $(STLPORTLIB) $(STDC++LIB)
endif
+$(COMP_SERVICES) :
+ -$(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)com.sun.star.comp.example.cpp.Counter$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)foo.Counter$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@
+ @echo $(OSEP)/components$(CSEP) >> $@
+
-CppCounterExample : $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL)
+CppCounterExample : $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL) $(COMP_SERVICES)
@echo --------------------------------------------------------------------------------
@echo Please use the following command to execute the example!
@echo -
@echo $(MAKE) countermain.run
+ @echo -
+ @echo NOTE: The example makes use of the URE and use the defaultBootstrap_InitialComponentContext method.
+ @echo $(SQM) $(SQM)The additional example IDL types are provided via the UNO environment variable -env:URE_MORE_TYPES=...
+ @echo $(SQM) $(SQM)and the example component is made available via -env:URE_MORE_SERVICES=...
+ @echo $(SQM) $(SQM)Please check the generated $(QM)$(COMP_SERVICES)$(QM) 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 --------------------------------------------------------------------------------
%.run: $(OUT_BIN)/countermain$(EXE_EXT) $(COMP_IMPL)
- cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@)
+ cd $(subst /,$(PS),$(OUT_BIN)) && $(basename $@) $(ENV_EXAMPLE_TYPES) $(ENV_COMP_SERVICES)
.PHONY: clean
clean :
@@ -159,3 +181,4 @@ clean :
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_RDB)))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/countermain*))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
diff --git a/odk/examples/cpp/counter/counter.cxx b/odk/examples/cpp/counter/counter.cxx
index db903cfa..f13ee41f 100644
--- a/odk/examples/cpp/counter/counter.cxx
+++ b/odk/examples/cpp/counter/counter.cxx
@@ -167,7 +167,7 @@ Reference< XInterface > SAL_CALL MyCounterImpl_create(
/**
* Gives the environment this component belongs to.
*/
-extern "C" void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)
+extern "C" SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv)
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
@@ -179,33 +179,33 @@ extern "C" void SAL_CALL component_getImplementationEnvironment(const sal_Char *
* @param pServiceManager the service manager
* @param pRegistryKey the registry key
*/
-extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void * pRegistryKey)
-{
- sal_Bool result = sal_False;
-
- if (pRegistryKey)
- {
- try
- {
- Reference< XRegistryKey > xNewKey(
- reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
- OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
+// extern "C" SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void * pRegistryKey)
+// {
+// sal_Bool result = sal_False;
+
+// if (pRegistryKey)
+// {
+// try
+// {
+// Reference< XRegistryKey > xNewKey(
+// reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+// OUString( RTL_CONSTASCII_USTRINGPARAM("/" IMPLNAME "/UNO/SERVICES") ) ) );
- const Sequence< OUString > & rSNL =
- MyCounterImpl::getSupportedServiceNames_Static();
- const OUString * pArray = rSNL.getConstArray();
- for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
- xNewKey->createKey( pArray[nPos] );
+// const Sequence< OUString > & rSNL =
+// MyCounterImpl::getSupportedServiceNames_Static();
+// const OUString * pArray = rSNL.getConstArray();
+// for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
+// xNewKey->createKey( pArray[nPos] );
- return sal_True;
- }
- catch (InvalidRegistryException &)
- {
- // we should not ignore exceptions
- }
- }
- return result;
-}
+// return sal_True;
+// }
+// catch (InvalidRegistryException &)
+// {
+// // we should not ignore exceptions
+// }
+// }
+// return result;
+// }
/**
* This function is called to get service factories for an implementation.
@@ -215,7 +215,7 @@ extern "C" sal_Bool SAL_CALL component_writeInfo(void * pServiceManager, void *
* @param pRegistryKey the registry key for this component, need for persistent data
* @return a component factory
*/
-extern "C" void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey)
+extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey)
{
void * pRet = 0;
diff --git a/odk/examples/cpp/counter/countermain.cxx b/odk/examples/cpp/counter/countermain.cxx
index 08a68b19..fce1715f 100644
--- a/odk/examples/cpp/counter/countermain.cxx
+++ b/odk/examples/cpp/counter/countermain.cxx
@@ -68,55 +68,37 @@ using namespace ::rtl;
//=======================================================================
SAL_IMPLEMENT_MAIN()
{
- Reference< XSimpleRegistry > xReg = createSimpleRegistry();
- OSL_ENSURE( xReg.is(), "### cannot get service instance of \"com.sun.star.regiystry.SimpleRegistry\"!" );
-
- xReg->open(OUString::createFromAscii("counter.uno.rdb"), sal_False, sal_False);
- OSL_ENSURE( xReg->isValid(), "### cannot open test registry \"counter.uno.rdb\"!" );
-
- Reference< XComponentContext > xContext = bootstrap_InitialComponentContext(xReg);
- OSL_ENSURE( xContext.is(), "### cannot creage intial component context!" );
-
- Reference< XMultiComponentFactory > xMgr = xContext->getServiceManager();
- OSL_ENSURE( xMgr.is(), "### cannot get initial service manager!" );
-
- // register my counter component
- Reference< XImplementationRegistration > xImplReg(
- xMgr->createInstanceWithContext(OUString::createFromAscii("com.sun.star.registry.ImplementationRegistration"), xContext), UNO_QUERY);
- OSL_ENSURE( xImplReg.is(), "### cannot get service instance of \"com.sun.star.registry.ImplementationRegistration\"!" );
-
- if (xImplReg.is())
- {
- xImplReg->registerImplementation(
- OUString::createFromAscii("com.sun.star.loader.SharedLibrary"), // loader for component
-#ifdef UNX
-#ifdef MACOSX
- OUString::createFromAscii("counter.uno.dylib"), // component location
-#else
- OUString::createFromAscii("counter.uno.so"), // component location
-#endif
-#else
- OUString::createFromAscii("counter.uno.dll"), // component location
-#endif
- Reference< XSimpleRegistry >() // registry omitted,
- // defaulting to service manager registry used
- );
-
- // get a counter instance
- Reference< XInterface > xx ;
- xx = xMgr->createInstanceWithContext(OUString::createFromAscii("foo.Counter"), xContext);
+ try {
+
+ Reference< XComponentContext > xContext(::cppu::defaultBootstrap_InitialComponentContext());
+ OSL_ENSURE( xContext.is(), "### bootstrap failed!\n" );
+
+ Reference< XMultiComponentFactory > xMgr = xContext->getServiceManager();
+ OSL_ENSURE( xMgr.is(), "### cannot get initial service manager!" );
+
+ Reference< XInterface > xx = xMgr->createInstanceWithContext(
+ OUString::createFromAscii("foo.Counter"), xContext);
+
+ OSL_ENSURE( xx.is(), "### cannot get service instance of \"foo.Counter\"!" );
+
Reference< XCountable > xCount( xx, UNO_QUERY );
- OSL_ENSURE( xCount.is(), "### cannot get service instance of \"foo.Counter\"!" );
+ OSL_ENSURE( xCount.is(), "### cannot query XCountable interface of service instance \"foo.Counter\"!" );
if (xCount.is())
{
- xCount->setCount( 42 );
- fprintf( stdout , "%d," , xCount->getCount() );
- fprintf( stdout , "%d," , xCount->increment() );
- fprintf( stdout , "%d\n" , xCount->decrement() );
+ xCount->setCount( 42 );
+ fprintf( stdout , "%d," , (int)xCount->getCount() );
+ fprintf( stdout , "%d," , (int)xCount->increment() );
+ fprintf( stdout , "%d\n" , (int)xCount->decrement() );
}
+
+ Reference< XComponent >::query( xContext )->dispose();
+
+ } catch( Exception& e) {
+ printf("Error: caught exception:\n %s\n",
+ OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr());
+ exit(1);
}
- Reference< XComponent >::query( xContext )->dispose();
return 0;
}
diff --git a/odk/examples/cpp/remoteclient/Makefile b/odk/examples/cpp/remoteclient/Makefile
index 40d51deb..50e3545a 100644
--- a/odk/examples/cpp/remoteclient/Makefile
+++ b/odk/examples/cpp/remoteclient/Makefile
@@ -43,17 +43,19 @@ include $(SETTINGS)/dk.mk
# Define non-platform/compiler specific settings
COMP_NAME=remoteclientsample
-COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
+COMP_IMPL_NAME=$(COMP_NAME).uno.$(SHAREDLIB_EXT)
COMP_IMPL=$(SHAREDLIB_OUT)/$(COMP_IMPL_NAME)
COMP_RDB_NAME = $(COMP_NAME).uno.rdb
COMP_RDB = $(OUT_BIN)/$(COMP_RDB_NAME)
COMP_MAPFILE = $(OUT_COMP_GEN)/$(COMP_NAME).uno.map
+COMP_SERVICES=$(SHAREDLIB_OUT)/remoteclientsample.rdb
+
+ENV_COMP_SERVICES=-env:URE_MORE_SERVICES=file://$(COMP_SERVICES)
OUT_COMP_INC=$(OUT_INC)/$(COMP_NAME)
OUT_COMP_GEN=$(OUT_MISC)/$(COMP_NAME)
OUT_COMP_SLO=$(OUT_SLO)/$(COMP_NAME)
-COMP_ENV_FLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_prepare_env.flag
COMP_TYPEFLAG = $(OUT_MISC)/cpp_$(COMP_NAME)_types.flag
CXXFILES = remoteclient.cxx
@@ -85,7 +87,7 @@ ifeq "$(OS)" "MACOSX"
endif
ifeq "$(OS)" "WIN"
-$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
-$(MKDIR) $(subst /,$(PS),$(@D))
-$(MKDIR) $(subst /,$(PS),$(OUT_COMP_GEN))
$(LINK) $(COMP_LINK_FLAGS) /OUT:$@ \
@@ -93,7 +95,7 @@ $(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) msvcrt.lib kernel32.lib
$(LINK_MANIFEST)
else
-$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES) $(COMP_MAPFILE)
+$(SHAREDLIB_OUT)/%.$(SHAREDLIB_EXT) : $(SLOFILES)
-$(MKDIR) $(subst /,$(PS),$(@D))
$(LINK) $(COMP_LINK_FLAGS) $(LINK_LIBS) -o $@ $(SLOFILES) \
$(CPPUHELPERLIB) $(CPPULIB) $(SALLIB) $(STLPORTLIB) $(STC++LIB) $(CPPUHELPERDYLIB) $(CPPUDYLIB) $(SALDYLIB)
@@ -102,40 +104,41 @@ ifeq "$(OS)" "MACOSX"
endif
endif
-$(COMP_ENV_FLAG) : $(COMP_RDB) $(OUT_BIN)/remoteserver.rdb
+$(COMP_SERVICES) :
-$(MKDIR) $(subst /,$(PS),$(@D))
- -$(DEL) $(subst \\,\,$(subst /,$(PS),$@))
- @echo --------------------------------------------------------------------------------
- @echo Register necessary runtime components in remoteserver/remoteclientsample rdb
- @echo --------------------------------------------------------------------------------
- $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c connector.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c remotebridge.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c bridgefac.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c uuresolver.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(OUT_BIN)/remoteserver.rdb -c streams.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(COMP_RDB) -c connector.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(COMP_RDB) -c remotebridge.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(COMP_RDB) -c bridgefac.uno.$(SHAREDLIB_EXT)
- $(REGCOMP) -register -r $(COMP_RDB) -c uuresolver.uno.$(SHAREDLIB_EXT)
- @echo bla > $@
-
-CppClientExample : $(COMP_IMPL) $(COMP_ENV_FLAG)
+ @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)com.sun.star.comp.product.example.RemoteClientSample$(QM)"$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)service name="$(QM)com.sun.star.bridge.example.RemoteClientSample$(QM)"/$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/implementation$(CSEP) >> $@
+ @echo $(SQM) $(SQM)$(OSEP)/component$(CSEP) >> $@
+ @echo $(OSEP)/components$(CSEP) >> $@
+
+
+#CppClientExample : $(COMP_IMPL) $(COMP_ENV_FLAG)
+CppClientExample : $(COMP_IMPL) $(COMP_SERVICES)
@echo --------------------------------------------------------------------------------
@echo The remoteclient C++ component can be used by using the uno binary. Use the
@echo the follwong command to start the example. The run target starts a remote
@echo server and connect with the client to this server.
@echo -
@echo $(MAKE) remoteclient.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) 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 --------------------------------------------------------------------------------
-%.run: $(COMP_IMPL) $(COMP_ENV_FLAG)
+%.run: $(COMP_IMPL)
@echo Start the remote server process ...
@echo -
ifeq "$(OS)" "WIN"
- start uno -rw $(OUT_BIN)/remoteserver.rdb --singleaccept -s com.sun.star.io.Pipe \
+ start uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
-u "uno:socket,host=localhost,port=2083;urp;MyPipe"
else
- uno -rw $(OUT_BIN)/remoteserver.rdb --singleaccept -s com.sun.star.io.Pipe \
+ uno $(ENV_COMP_SERVICES) --singleaccept -s com.sun.star.io.Pipe \
-u "uno:socket,host=localhost,port=2083;urp;MyPipe" &
@echo waiting on the server process ...
sleep 5
@@ -145,8 +148,8 @@ endif
@echo -
@echo Start remote client process ...
@echo -
- uno -l $(COMP_IMPL) -c com.sun.star.comp.product.example.RemoteClientSample \
- -rw $(COMP_RDB) -- "uno:socket,host=localhost,port=2083;urp;MyPipe"
+ uno $(ENV_COMP_SERVICES) -s com.sun.star.bridge.example.RemoteClientSample \
+ -- "uno:socket,host=localhost,port=2083;urp;MyPipe"
@echo -
.PHONY: clean
@@ -154,7 +157,7 @@ clean :
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_INC))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_GEN))
-$(DELRECURSIVE) $(subst /,$(PS),$(OUT_COMP_SLO))
- -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_ENV_FLAG)))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_TYPEFLAG)))
+ -$(DEL) $(subst \\,\,$(subst /,$(PS),$(COMP_SERVICES)))
-$(DEL) $(subst \\,\,$(subst /,$(PS),$(SHAREDLIB_OUT)/$(COMP_NAME).*))
- -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/remoteserver.rdb))
+# -$(DEL) $(subst \\,\,$(subst /,$(PS),$(OUT_BIN)/remoteserver.rdb))
diff --git a/odk/examples/cpp/remoteclient/remoteclient.cxx b/odk/examples/cpp/remoteclient/remoteclient.cxx
index be2dd90c..867c1092 100644
--- a/odk/examples/cpp/remoteclient/remoteclient.cxx
+++ b/odk/examples/cpp/remoteclient/remoteclient.cxx
@@ -227,39 +227,41 @@ using namespace remotebridges_officeclient;
extern "C"
{
//==================================================================================================
-void SAL_CALL component_getImplementationEnvironment(
+SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment(
const sal_Char ** ppEnvTypeName, uno_Environment ** ppEnv )
{
*ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME;
}
+
//==================================================================================================
-sal_Bool SAL_CALL component_writeInfo(
- void * pServiceManager, void * pRegistryKey )
-{
- if (pRegistryKey)
- {
- try
- {
- Reference< XRegistryKey > xNewKey(
- reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
- OUString::createFromAscii( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
+// SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo(
+// void * pServiceManager, void * pRegistryKey )
+// {
+// if (pRegistryKey)
+// {
+// try
+// {
+// Reference< XRegistryKey > xNewKey(
+// reinterpret_cast< XRegistryKey * >( pRegistryKey )->createKey(
+// OUString::createFromAscii( "/" IMPLEMENTATION_NAME "/UNO/SERVICES" ) ) );
- const Sequence< OUString > & rSNL = getSupportedServiceNames();
- const OUString * pArray = rSNL.getConstArray();
- for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
- xNewKey->createKey( pArray[nPos] );
+// const Sequence< OUString > & rSNL = getSupportedServiceNames();
+// 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;
-}
+// return sal_True;
+// }
+// catch (InvalidRegistryException &)
+// {
+// OSL_ENSURE( sal_False, "### InvalidRegistryException!" );
+// }
+// }
+// return sal_False;
+// }
+
//==================================================================================================
-void * SAL_CALL component_getFactory(
+SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey )
{
void * pRet = 0;