Kaydet (Commit) 91dc9f3b authored tarafından Henry Castro's avatar Henry Castro

lok: load component library

Change-Id: I7fd048e9d3ccd1679bf4a3593be3efd61b5e3c3f
üst 2dd5ba7e
...@@ -58,6 +58,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\ ...@@ -58,6 +58,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
ucbhelper \ ucbhelper \
utl \ utl \
vcl \ vcl \
xmlreader \
$(gb_UWINAPI) \ $(gb_UWINAPI) \
)) ))
......
...@@ -57,6 +57,7 @@ ...@@ -57,6 +57,7 @@
#include <unotools/mediadescriptor.hxx> #include <unotools/mediadescriptor.hxx>
#include <osl/module.hxx> #include <osl/module.hxx>
#include <comphelper/sequence.hxx> #include <comphelper/sequence.hxx>
#include <xmlreader/xmlreader.hxx>
#include <app.hxx> #include <app.hxx>
...@@ -966,31 +967,125 @@ static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit: ...@@ -966,31 +967,125 @@ static void lo_status_indicator_callback(void *data, comphelper::LibreOfficeKit:
} }
} }
static void loadSharedLibrary(const OUString & aUriRdb)
{
int nsId;
int nUcNsId;
OUString sAttrUri;
OUString sAttrLoader;
xmlreader::Span aName;
xmlreader::XmlReader::Result aItem = xmlreader::XmlReader::RESULT_BEGIN;
xmlreader::XmlReader aRdbReader(aUriRdb);
nUcNsId = aRdbReader.registerNamespaceIri(xmlreader::Span(RTL_CONSTASCII_STRINGPARAM("http://openoffice.org/2010/uno-components")));
while( aItem != xmlreader::XmlReader::RESULT_DONE )
{
aItem = aRdbReader.nextItem(xmlreader::XmlReader::TEXT_NONE, &aName, &nsId );
if (nsId == nUcNsId &&
aName.equals(RTL_CONSTASCII_STRINGPARAM("component")))
{
sAttrLoader = OUString();
sAttrUri = OUString();
while (aRdbReader.nextAttribute(&nsId, &aName))
{
if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
aName.equals(RTL_CONSTASCII_STRINGPARAM("loader")))
sAttrLoader = aRdbReader.getAttributeValue(false).convertFromUtf8();
else if (nsId == xmlreader::XmlReader::NAMESPACE_NONE &&
aName.equals(RTL_CONSTASCII_STRINGPARAM("uri")))
sAttrUri = aRdbReader.getAttributeValue(false).convertFromUtf8();
}
try
{
sAttrUri = cppu::bootstrap_expandUri(sAttrUri);
}
catch(css::lang::IllegalArgumentException)
{
fprintf(stderr, "Cannot expand URI '%s'\n",
OUStringToOString(sAttrUri, RTL_TEXTENCODING_UTF8).getStr());
}
if (sAttrLoader == "com.sun.star.loader.SharedLibrary")
{
oslModule aModule = osl_loadModule( sAttrUri.pData, SAL_LOADMODULE_NOW | SAL_LOADMODULE_GLOBAL );
SAL_INFO("lok", "loaded component library " << sAttrUri << ( aModule ? " ok" : " no"));
// leak aModule
// osl_unloadModule(aModule);
aModule = 0;
}
}
}
}
/// pre-load all C++ component factories and leak references to them. /// pre-load all C++ component factories and leak references to them.
static void forceLoadAllNativeComponents() static void forceLoadAllNativeComponents(const OUString & aAppURL)
{ {
// FIXME: we need to inject RTLD_NOW into here, either by a sal_Int32 nIndex = 0;
// putenv("LD_BIND_NOW=1") in parent process or ... (?).
try { rtl::Bootstrap bs(aAppURL + "/" + SAL_CONFIGFILE("uno"));
uno::Reference<container::XContentEnumerationAccess> xEnumAcc( if (bs.getHandle() == 0)
xContext->getServiceManager(), css::uno::UNO_QUERY_THROW); {
uno::Reference<container::XHierarchicalNameAccess> xTypeMgr( fprintf(stderr, "Cannot open uno ini '%s'\n",
xContext->getValueByName( OUStringToOString(aAppURL + "/" + SAL_CONFIGFILE("uno"), RTL_TEXTENCODING_UTF8).getStr());
"/singletons/com.sun.star.reflection.theTypeDescriptionManager"), return;
css::uno::UNO_QUERY_THROW); }
uno::Sequence<OUString> aServiceNames(
xContext->getServiceManager()->getAvailableServiceNames()); OUString aRdbFiles;
if (!bs.getFrom("UNO_SERVICES", aRdbFiles))
for (sal_Int32 i = 0; i != aServiceNames.getLength(); ++i) {
fprintf(stderr, "Cannot obtain UNO_SERVICES from uno ini\n");
return;
}
while (nIndex != -1)
{
OUString aUriRdb(aRdbFiles.getToken(0, ' ', nIndex));
if (aUriRdb.isEmpty())
continue;
if (aUriRdb[0] == '?')
aUriRdb = aUriRdb.copy(1);
if (aUriRdb.startsWith("<") && aUriRdb.endsWith(">*"))
{
aUriRdb = aUriRdb.copy(1, aUriRdb.getLength() - 3);
osl::Directory aDir(aUriRdb);
if ( aDir.open() == osl::FileBase::E_None )
{
while(true)
{
osl::DirectoryItem aDirItem;
if ( aDir.getNextItem(aDirItem, SAL_MAX_UINT32) != osl::FileBase::E_None)
break;
osl::FileStatus stat(osl_FileStatus_Mask_Type |
osl_FileStatus_Mask_FileName |
osl_FileStatus_Mask_FileURL);
if (aDirItem.getFileStatus(stat) == osl::FileBase::E_None)
loadSharedLibrary(stat.getFileURL());
}
}
else
{
fprintf(stderr, "Cannot open directory '%s'\n",
OUStringToOString(aUriRdb, RTL_TEXTENCODING_UTF8).getStr());
}
}
else
{ {
css::uno::Reference<css::container::XEnumeration> xServiceImpls( loadSharedLibrary(aUriRdb);
xEnumAcc->createContentEnumeration(aServiceNames[i]),
css::uno::UNO_SET_THROW);
SAL_INFO("lok", "service " << aServiceNames[i]);
// FIXME: need to actually load and link each native DSO.
} }
} catch (const uno::Exception &) {
} }
} }
...@@ -1072,7 +1167,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char ...@@ -1072,7 +1167,7 @@ static int lo_initialize(LibreOfficeKit* pThis, const char* pAppPath, const char
if (eStage == PRE_INIT) if (eStage == PRE_INIT)
{ {
forceLoadAllNativeComponents(); forceLoadAllNativeComponents(aAppURL);
forceLoadFilterXML(); forceLoadFilterXML();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment