diff options
author | Ivo Hinkelmann <ihi@openoffice.org> | 2011-03-07 16:31:11 +0100 |
---|---|---|
committer | Ivo Hinkelmann <ihi@openoffice.org> | 2011-03-07 16:31:11 +0100 |
commit | 33e2b11638c87ffed5d91405ba76cb00cd91e1be (patch) | |
tree | e30a081dee51efa24b250ddb608973ab7543b37e /odk/examples/cpp/DocumentLoader/DocumentLoader.cxx | |
parent | 1ae1f64e641d67a553eac4bcc91566efbe6a5d48 (diff) | |
parent | 7de486ee0f338fd2a0a2defd8edd22f5516b5408 (diff) |
CWS-TOOLING: integrate CWS jsc340
Notes
Notes:
split repo tag: sdk_ooo/DEV300_m102
split repo tag: sdk_ooo/DEV300_m103
split repo tag: sdk_ooo/DEV300_m104
split repo tag: sdk_ooo/DEV300_m105
split repo tag: sdk_ooo/DEV300_m106
Diffstat (limited to 'odk/examples/cpp/DocumentLoader/DocumentLoader.cxx')
-rw-r--r-- | odk/examples/cpp/DocumentLoader/DocumentLoader.cxx | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx b/odk/examples/cpp/DocumentLoader/DocumentLoader.cxx index a2ea5b4f9107..02eabbc5c3c5 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,35 +72,21 @@ 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 @@ -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( |