25 #include <rtl/bootstrap.hxx>
26 #include <rtl/random.h>
27 #include <rtl/ustrbuf.hxx>
28 #include <rtl/uri.hxx>
29 #include <osl/file.hxx>
30 #include <osl/security.hxx>
31 #include <osl/thread.hxx>
33 #include <osl/process.h>
38 #include <com/sun/star/bridge/UnoUrlResolver.hpp>
39 #include <com/sun/star/bridge/XUnoUrlResolver.hpp>
43 namespace com :: sun :: star ::
uno {
class XComponentContext; }
45 using namespace ::
osl;
59 :m_aMessage( rMessage )
92 "no soffice installation found!");
99 bool bOk = rtl_convertStringToUString(
100 &p2.pData, p1, std::strlen(p1), osl_getThreadTextEncoding(),
101 (RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_ERROR |
102 RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_ERROR |
103 RTL_TEXTTOUNICODE_FLAGS_INVALID_ERROR));
108 "bad characters in soffice installation path!");
112 if (osl::FileBase::getFileURLFromSystemPath(p2, path) !=
113 osl::FileBase::E_None)
116 "cannot convert soffice installation path to URL!");
118 if (!path.isEmpty() && !path.endsWith(
"/")) {
123 if (!Bootstrap::get(
"URE_BOOTSTRAP", uri)) {
137 if ( !xLocalContext.is() )
142 if ( hPool ==
nullptr )
146 != rtl_Random_E_None )
148 rtl_random_destroyPool( hPool );
149 OUStringBuffer buf(
"uno");
150 for (
unsigned char byte : bytes)
151 buf.append( static_cast< sal_Int32 >(
byte ) );
152 OUString sPipeName( buf.makeStringAndClear() );
156 OUString(
"--nologo"),
157 OUString(
"--nodefault"),
158 OUString(
"--norestore"),
159 OUString(
"--nolockcheck"),
160 OUString(
"--accept=pipe,name=" + sPipeName +
";urp;")
162 rtl_uString * ar_args [] = {
172 oslProcess hProcess =
nullptr;
173 oslProcessError rc = osl_executeProcess(
175 osl_Process_DETACHED,
182 case osl_Process_E_None:
183 osl_freeProcessHandle( hProcess );
185 case osl_Process_E_NotFound:
187 case osl_Process_E_TimedOut:
189 case osl_Process_E_NoPermission:
191 case osl_Process_E_Unknown:
193 case osl_Process_E_InvalidError:
199 Reference< bridge::XUnoUrlResolver > xUrlResolver(
200 bridge::UnoUrlResolver::create( xLocalContext ) );
203 OUString sConnectString(
"uno:pipe,name=" + sPipeName +
";urp;StarOffice.ComponentContext" );
212 xUrlResolver->resolve( sConnectString ), UNO_QUERY_THROW );
215 catch ( connection::NoConnectException & )
218 ::osl::Thread::wait( std::chrono::milliseconds(500) );
225 "unexpected UNO exception caught: " + e.Message );
228 return xRemoteContext;
233 return uri.startsWith(
"vnd.sun.star.expand:", &rest)
236 rest, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8))
const ::rtl::OUString & getMessage() const
Gets the message.
std::unique_ptr< ContentProperties > pData
std::vector< sal_uInt8 > bytes
::rtl::OUString m_aMessage
OUString bootstrap_expandUri(OUString const &uri)
An exception indicating a bootstrap error.
BootstrapException()
Constructs a BootstrapException.
BootstrapException & operator=(const BootstrapException &e)
Assigns a BootstrapException.
virtual ~BootstrapException()
Destructs a BootstrapException.
#define SAL_N_ELEMENTS(arr)
#define SAL_CONFIGFILE(name)
CPPUHELPER_DLLPUBLIC css::uno::Reference< css::uno::XComponentContext > SAL_CALL defaultBootstrap_InitialComponentContext()
Bootstraps an initial component context with service manager upon information from bootstrap variable...
Reference< XComponentContext > SAL_CALL bootstrap()
Bootstraps the component context from a UNO installation.
char * cppuhelper_detail_findSofficePath()
OUString expandMacros(OUString const &text)
Helper function to expand macros based on the unorc/uno.ini.
exports com.sun.star. uri