summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--basic/source/inc/namecont.hxx14
-rw-r--r--basic/source/uno/namecont.cxx16
-rw-r--r--desktop/source/deployment/registry/component/dp_compbackenddb.cxx93
-rw-r--r--desktop/source/deployment/registry/component/dp_compbackenddb.hxx3
-rw-r--r--desktop/source/deployment/registry/dp_backenddb.cxx308
-rw-r--r--desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx89
-rw-r--r--desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx18
-rw-r--r--desktop/source/deployment/registry/help/dp_helpbackenddb.cxx76
-rw-r--r--desktop/source/deployment/registry/help/dp_helpbackenddb.hxx7
-rw-r--r--desktop/source/deployment/registry/inc/dp_backenddb.hxx35
-rw-r--r--desktop/source/deployment/registry/package/dp_extbackenddb.cxx65
-rw-r--r--desktop/source/deployment/registry/package/dp_extbackenddb.hxx3
-rw-r--r--desktop/source/deployment/registry/script/dp_script.cxx254
-rw-r--r--desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx88
-rw-r--r--desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx76
-rw-r--r--desktop/source/deployment/registry/script/makefile.mk3
-rw-r--r--scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java20
-rwxr-xr-xscripting/java/com/sun/star/script/framework/provider/ScriptProvider.java18
-rw-r--r--scripting/source/provider/ActiveMSPList.cxx7
-rw-r--r--scripting/source/provider/ActiveMSPList.hxx1
-rw-r--r--xmlhelp/source/cxxhelp/provider/databases.cxx3
-rw-r--r--xmlhelp/source/treeview/tvread.cxx47
-rw-r--r--xmlhelp/source/treeview/tvread.hxx9
23 files changed, 796 insertions, 457 deletions
diff --git a/basic/source/inc/namecont.hxx b/basic/source/inc/namecont.hxx
index 2d24759d9b83..7cd2de701634 100644
--- a/basic/source/inc/namecont.hxx
+++ b/basic/source/inc/namecont.hxx
@@ -35,6 +35,7 @@
#include <com/sun/star/script/XStorageBasedLibraryContainer.hpp>
#include <com/sun/star/script/XLibraryContainerPassword.hpp>
#include <com/sun/star/script/XLibraryContainerExport.hpp>
+#include <com/sun/star/script/XLibraryContainer3.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
@@ -57,7 +58,7 @@
#include <com/sun/star/deployment/XPackage.hpp>
#include <cppuhelper/implbase2.hxx>
-#include <cppuhelper/compbase6.hxx>
+#include <cppuhelper/compbase7.hxx>
#include <cppuhelper/interfacecontainer.hxx>
class BasicManager;
@@ -65,11 +66,12 @@ class BasicManager;
namespace basic
{
-typedef ::cppu::WeakComponentImplHelper6<
+typedef ::cppu::WeakComponentImplHelper7<
::com::sun::star::lang::XInitialization,
::com::sun::star::script::XStorageBasedLibraryContainer,
::com::sun::star::script::XLibraryContainerPassword,
::com::sun::star::script::XLibraryContainerExport,
+ ::com::sun::star::script::XLibraryContainer3,
::com::sun::star::container::XContainer,
::com::sun::star::lang::XServiceInfo > LibraryContainerHelper;
@@ -405,6 +407,12 @@ public:
virtual ::rtl::OUString SAL_CALL getContainerLocationName() throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL storeLibraries( ) throw (::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
+ //Methods XLibraryContainer3
+ virtual ::rtl::OUString SAL_CALL getOriginalLibraryLinkURL( const ::rtl::OUString& Name )
+ throw (::com::sun::star::lang::IllegalArgumentException,
+ ::com::sun::star::container::NoSuchElementException,
+ ::com::sun::star::uno::RuntimeException);
+
// Methods XLibraryContainer2 (base of XPersistentLibraryContainer)
virtual sal_Bool SAL_CALL isLibraryLink( const ::rtl::OUString& Name )
throw (::com::sun::star::container::NoSuchElementException,
@@ -541,6 +549,8 @@ private:
::rtl::OUString maLibInfoFileURL;
::rtl::OUString maStorageURL;
::rtl::OUString maUnexpandedStorageURL;
+ ::rtl::OUString maOrignialStorageURL;
+
sal_Bool mbLink;
sal_Bool mbReadOnly;
sal_Bool mbReadOnlyLink;
diff --git a/basic/source/uno/namecont.cxx b/basic/source/uno/namecont.cxx
index 7a6a771f85cc..e357b0e85f91 100644
--- a/basic/source/uno/namecont.cxx
+++ b/basic/source/uno/namecont.cxx
@@ -2169,6 +2169,7 @@ Reference< XNameAccess > SAL_CALL SfxLibraryContainer::createLibraryLink
SfxLibrary* pNewLib = implCreateLibraryLink( Name, aLibInfoFileURL, aLibDirURL, ReadOnly );
pNewLib->maLibElementFileExtension = maLibElementFileExtension;
pNewLib->maUnexpandedStorageURL = aUnexpandedStorageURL;
+ pNewLib->maOrignialStorageURL = StorageURL;
OUString aInitFileName;
uno::Reference< embed::XStorage > xDummyStor;
@@ -2788,6 +2789,19 @@ OUString SfxLibraryContainer::expand_url( const OUString& url )
}
}
+//XLibraryContainer3
+OUString SAL_CALL SfxLibraryContainer::getOriginalLibraryLinkURL( const OUString& Name )
+ throw (IllegalArgumentException, NoSuchElementException, RuntimeException)
+{
+ LibraryContainerMethodGuard aGuard( *this );
+ SfxLibrary* pImplLib = getImplLib( Name );
+ sal_Bool bLink = pImplLib->mbLink;
+ if( !bLink )
+ throw IllegalArgumentException();
+ OUString aRetStr = pImplLib->maOrignialStorageURL;
+ return aRetStr;
+}
+
// Methods XServiceInfo
::sal_Bool SAL_CALL SfxLibraryContainer::supportsService( const ::rtl::OUString& _rServiceName )
throw (RuntimeException)
@@ -3381,7 +3395,7 @@ Reference< deployment::XPackage > ScriptExtensionIterator::implGetNextSharedScri
if( m_iSharedPackage == m_aSharedPackagesSeq.getLength() )
{
- m_eState = END_REACHED;
+ m_eState = BUNDLED_EXTENSIONS;
}
else
{
diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx
index 568ecca08138..898e7c931f6d 100644
--- a/desktop/source/deployment/registry/component/dp_compbackenddb.cxx
+++ b/desktop/source/deployment/registry/component/dp_compbackenddb.cxx
@@ -46,6 +46,7 @@ using ::rtl::OUString;
#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/component-registry/2010"
#define NS_PREFIX "comp"
#define ROOT_ELEMENT_NAME "component-backend-db"
+#define KEY_ELEMENT_NAME "component"
namespace dp_registry {
namespace backend {
@@ -73,54 +74,31 @@ OUString ComponentBackendDb::getRootElementName()
return OUSTR(ROOT_ELEMENT_NAME);
}
+OUString ComponentBackendDb::getKeyElementName()
+{
+ return OUSTR(KEY_ELEMENT_NAME);
+}
+
void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
{
try{
- const OUString sNameSpace = getDbNSName();
- const OUString sPrefix = getNSPrefix();
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
-
-#if OSL_DEBUG_LEVEL > 0
- //There must not be yet an entry with the same url
- OUString sExpression(
- sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]"));
- Reference<css::xml::dom::XNode> _extensionNode =
- getXPathAPI()->selectSingleNode(root, sExpression);
- OSL_ASSERT(! _extensionNode.is());
-#endif
- Reference<css::xml::dom::XElement> componentElement(
- doc->createElementNS(sNameSpace, sPrefix + OUSTR(":component")));
-
- componentElement->setAttribute(OUSTR("url"), url);
-
- Reference<css::xml::dom::XNode> componentNode(
- componentElement, UNO_QUERY_THROW);
-
- root->appendChild(componentNode);
-
- Reference<css::xml::dom::XNode> javaTypeLibNode(
- doc->createElementNS(sNameSpace, sPrefix + OUSTR(":java-type-library")), UNO_QUERY_THROW);
-
- componentNode->appendChild(javaTypeLibNode);
-
- Reference<css::xml::dom::XNode> javaTypeLibValueNode(
- doc->createTextNode(OUString::valueOf((sal_Bool) data.javaTypeLibrary)),
- UNO_QUERY_THROW);
- javaTypeLibNode->appendChild(javaTypeLibValueNode);
+ Reference<css::xml::dom::XNode> componentNode = writeKeyElement(url);
+ writeSimpleElement(OUSTR("java-type-library"),
+ OUString::valueOf((sal_Bool) data.javaTypeLibrary),
+ componentNode);
writeSimpleList(
data.implementationNames,
- sPrefix + OUSTR(":implementation-names"),
- sPrefix + OUSTR(":name"),
+ OUSTR("implementation-names"),
+ OUSTR("name"),
componentNode);
writeVectorOfPair(
data.singletons,
- sPrefix + OUSTR(":singletons"),
- sPrefix + OUSTR(":item"),
- sPrefix + OUSTR(":key"),
- sPrefix + OUSTR(":value"),
+ OUSTR("singletons"),
+ OUSTR("item"),
+ OUSTR("key"),
+ OUSTR("value"),
componentNode);
save();
@@ -134,50 +112,31 @@ void ComponentBackendDb::addEntry(::rtl::OUString const & url, Data const & data
}
}
-void ComponentBackendDb::removeEntry(::rtl::OUString const & url)
-{
- OUString sExpression(
- OUSTR(NS_PREFIX) + OUSTR(":component[@url = \"") + url + OUSTR("\"]"));
- removeElement(sExpression);
-}
-
ComponentBackendDb::Data ComponentBackendDb::getEntry(::rtl::OUString const & url)
{
try
{
- const OUString sPrefix = getNSPrefix();
ComponentBackendDb::Data retData;
- const OUString sExpression(
- sPrefix + OUSTR(":component[@url = \"") + url + OUSTR("\"]"));
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
-
- Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
- //find the extension element that is to be removed
- Reference<css::xml::dom::XNode> aNode =
- xpathApi->selectSingleNode(root, sExpression);
+ Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
if (aNode.is())
{
- const OUString sExprJavaTypeLib(sPrefix + OUSTR(":java-type-library/text()"));
-
- Reference<css::xml::dom::XNode> idValueNode =
- xpathApi->selectSingleNode(aNode, sExprJavaTypeLib);
- retData.javaTypeLibrary =
- idValueNode->getNodeValue().equals(OUSTR("true")) ? true : false;
+ bool bJava = readSimpleElement(OUSTR("java-type-library"), aNode)
+ .equals(OUSTR("true")) ? true : false;
+ retData.javaTypeLibrary = bJava;
retData.implementationNames =
readList(
aNode,
- sPrefix + OUSTR(":implementation-names"),
- sPrefix + OUSTR(":name"));
+ OUSTR("implementation-names"),
+ OUSTR("name"));
retData.singletons =
readVectorOfPair(
aNode,
- sPrefix + OUSTR(":singletons"),
- sPrefix + OUSTR(":item"),
- sPrefix + OUSTR(":key"),
- sPrefix + OUSTR(":value"));
+ OUSTR("singletons"),
+ OUSTR("item"),
+ OUSTR("key"),
+ OUSTR("value"));
}
return retData;
}
diff --git a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx
index 90ff41f2a4b8..b9a5ed737b7c 100644
--- a/desktop/source/deployment/registry/component/dp_compbackenddb.hxx
+++ b/desktop/source/deployment/registry/component/dp_compbackenddb.hxx
@@ -85,6 +85,7 @@ protected:
virtual ::rtl::OUString getDbNSName();
virtual ::rtl::OUString getNSPrefix();
virtual ::rtl::OUString getRootElementName();
+ virtual ::rtl::OUString getKeyElementName();
public:
struct Data
@@ -104,7 +105,7 @@ public:
::rtl::OUString const & url);
void addEntry(::rtl::OUString const & url, Data const & data);
- void removeEntry(::rtl::OUString const & url);
+
Data getEntry(::rtl::OUString const & url);
diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx
index fe8b39b94d44..660c5ad80bf1 100644
--- a/desktop/source/deployment/registry/dp_backenddb.cxx
+++ b/desktop/source/deployment/registry/dp_backenddb.cxx
@@ -63,13 +63,13 @@ BackendDb::BackendDb(
void BackendDb::save()
{
- Reference<css::io::XActiveDataSource> xDataSource(m_doc,css::uno::UNO_QUERY_THROW);
+ const Reference<css::io::XActiveDataSource> xDataSource(m_doc,css::uno::UNO_QUERY_THROW);
::rtl::ByteSequence bytes;
xDataSource->setOutputStream(::xmlscript::createOutputStream(&bytes));
- Reference<css::io::XActiveDataControl> xDataControl(m_doc,css::uno::UNO_QUERY_THROW);
+ const Reference<css::io::XActiveDataControl> xDataControl(m_doc,css::uno::UNO_QUERY_THROW);
xDataControl->start();
- Reference<css::io::XInputStream> xData(
+ const Reference<css::io::XInputStream> xData(
::xmlscript::createInputStream(bytes));
::ucbhelper::Content ucbDb(m_urlDb, 0);
ucbDb.writeStream(xData, true /*replace existing*/);
@@ -79,7 +79,7 @@ css::uno::Reference<css::xml::dom::XDocument> BackendDb::getDocument()
{
if (!m_doc.is())
{
- Reference<css::xml::dom::XDocumentBuilder> xDocBuilder(
+ const Reference<css::xml::dom::XDocumentBuilder> xDocBuilder(
m_xContext->getServiceManager()->createInstanceWithContext(
OUSTR("com.sun.star.xml.dom.DocumentBuilder"),
m_xContext ), css::uno::UNO_QUERY);
@@ -97,11 +97,10 @@ css::uno::Reference<css::xml::dom::XDocument> BackendDb::getDocument()
{
//Create a new document and insert some basic stuff
m_doc = xDocBuilder->newDocument();
- Reference<css::xml::dom::XElement> rootNode =
+ const Reference<css::xml::dom::XElement> rootNode =
m_doc->createElementNS(getDbNSName(), getNSPrefix() +
OUSTR(":") + getRootElementName());
-// rootNode->setAttribute(
-// OUSTR("xmlns"), getDbNSName());
+
m_doc->appendChild(Reference<css::xml::dom::XNode>(
rootNode, UNO_QUERY_THROW));
save();
@@ -144,11 +143,11 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression)
{
try
{
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
- Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
//find the extension element that is to be removed
- Reference<css::xml::dom::XNode> aNode =
+ const Reference<css::xml::dom::XNode> aNode =
xpathApi->selectSingleNode(root, sXPathExpression);
if (aNode.is())
@@ -159,7 +158,7 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression)
#if OSL_DEBUG_LEVEL > 0
//There must not be any other entry with the same url
- Reference<css::xml::dom::XNode> nextNode =
+ const Reference<css::xml::dom::XNode> nextNode =
xpathApi->selectSingleNode(root, sXPathExpression);
OSL_ASSERT(! nextNode.is());
#endif
@@ -171,7 +170,50 @@ void BackendDb::removeElement(::rtl::OUString const & sXPathExpression)
OUSTR("Extension Manager: failed to write data entry in backend db: ") +
m_urlDb, 0, exc);
}
+}
+void BackendDb::removeEntry(::rtl::OUString const & url)
+{
+ const OUString sKeyElement = getKeyElementName();
+ const OUString sPrefix = getNSPrefix();
+ ::rtl::OUStringBuffer sExpression(500);
+ sExpression.append(sPrefix);
+ sExpression.appendAscii(":");
+ sExpression.append(sKeyElement);
+ sExpression.append(OUSTR("[@url = \""));
+ sExpression.append(url);
+ sExpression.appendAscii("\"]");
+
+ removeElement(sExpression.makeStringAndClear());
+}
+
+Reference<css::xml::dom::XNode> BackendDb::getKeyElement(
+ ::rtl::OUString const & url)
+{
+ try
+ {
+ const OUString sPrefix = getNSPrefix();
+ const OUString sKeyElement = getKeyElementName();
+ ::rtl::OUStringBuffer sExpression(500);
+ sExpression.append(sPrefix);
+ sExpression.appendAscii(":");
+ sExpression.append(sKeyElement);
+ sExpression.append(OUSTR("[@url = \""));
+ sExpression.append(url);
+ sExpression.appendAscii("\"]");
+
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ return xpathApi->selectSingleNode(root, sExpression.makeStringAndClear());
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read key element in backend db: ") +
+ m_urlDb, 0, exc);
+ }
}
//Only writes the data if there is at least one entry
@@ -188,11 +230,12 @@ void BackendDb::writeVectorOfPair(
return;
const OUString sNameSpace = getDbNSName();
OSL_ASSERT(sNameSpace.getLength());
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+ const OUString sPrefix(getNSPrefix() + OUSTR(":"));
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const Reference<css::xml::dom::XNode> root = doc->getFirstChild();
- Reference<css::xml::dom::XElement> vectorNode(
- doc->createElementNS(sNameSpace, sVectorTagName));
+ const Reference<css::xml::dom::XElement> vectorNode(
+ doc->createElementNS(sNameSpace, sPrefix + sVectorTagName));
xParent->appendChild(
Reference<css::xml::dom::XNode>(
@@ -200,35 +243,35 @@ void BackendDb::writeVectorOfPair(
typedef ::std::vector< ::std::pair< OUString, OUString > >::const_iterator CIT;
for (CIT i = vecPairs.begin(); i != vecPairs.end(); i++)
{
- Reference<css::xml::dom::XElement> pairNode(
- doc->createElementNS(sNameSpace, sPairTagName));
+ const Reference<css::xml::dom::XElement> pairNode(
+ doc->createElementNS(sNameSpace, sPrefix + sPairTagName));
vectorNode->appendChild(
Reference<css::xml::dom::XNode>(
pairNode, css::uno::UNO_QUERY_THROW));
- Reference<css::xml::dom::XElement> firstNode(
- doc->createElementNS(sNameSpace, sFirstTagName));
+ const Reference<css::xml::dom::XElement> firstNode(
+ doc->createElementNS(sNameSpace, sPrefix + sFirstTagName));
pairNode->appendChild(
Reference<css::xml::dom::XNode>(
firstNode, css::uno::UNO_QUERY_THROW));
- Reference<css::xml::dom::XText> firstTextNode(
+ const Reference<css::xml::dom::XText> firstTextNode(
doc->createTextNode( i->first));
firstNode->appendChild(
Reference<css::xml::dom::XNode>(
firstTextNode, css::uno::UNO_QUERY_THROW));
- Reference<css::xml::dom::XElement> secondNode(
- doc->createElementNS(sNameSpace, sSecondTagName));
+ const Reference<css::xml::dom::XElement> secondNode(
+ doc->createElementNS(sNameSpace, sPrefix + sSecondTagName));
pairNode->appendChild(
Reference<css::xml::dom::XNode>(
secondNode, css::uno::UNO_QUERY_THROW));
- Reference<css::xml::dom::XText> secondTextNode(
+ const Reference<css::xml::dom::XText> secondTextNode(
doc->createTextNode( i->second));
secondNode->appendChild(
@@ -256,23 +299,24 @@ BackendDb::readVectorOfPair(
try
{
OSL_ASSERT(parent.is());
- Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
- OUString sExprPairs(
- sListTagName + OUSTR("/") + sPairTagName);
- Reference<css::xml::dom::XNodeList> listPairs =
+ const OUString sPrefix(getNSPrefix() + OUSTR(":"));
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const OUString sExprPairs(
+ sPrefix + sListTagName + OUSTR("/") + sPrefix + sPairTagName);
+ const Reference<css::xml::dom::XNodeList> listPairs =
xpathApi->selectNodeList(parent, sExprPairs);
::std::vector< ::std::pair< OUString, OUString > > retVector;
sal_Int32 length = listPairs->getLength();
for (sal_Int32 i = 0; i < length; i++)
{
- Reference<css::xml::dom::XNode> aPair = listPairs->item(i);
- OUString sExprFirst(sFirstTagName + OUSTR("/text()"));
- Reference<css::xml::dom::XNode> first =
+ const Reference<css::xml::dom::XNode> aPair = listPairs->item(i);
+ const OUString sExprFirst(sPrefix + sFirstTagName + OUSTR("/text()"));
+ const Reference<css::xml::dom::XNode> first =
xpathApi->selectSingleNode(aPair, sExprFirst);
- OUString sExprSecond(sSecondTagName + OUSTR("/text()"));
- Reference<css::xml::dom::XNode> second =
+ const OUString sExprSecond(sPrefix + sSecondTagName + OUSTR("/text()"));
+ const Reference<css::xml::dom::XNode> second =
xpathApi->selectSingleNode(aPair, sExprSecond);
OSL_ASSERT(first.is() && second.is());
@@ -302,10 +346,11 @@ void BackendDb::writeSimpleList(
if (list.size() == 0)
return;
const OUString sNameSpace = getDbNSName();
- Reference<css::xml::dom::XDocument> doc = getDocument();
+ const OUString sPrefix(getNSPrefix() + OUSTR(":"));
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XElement> listNode(
- doc->createElementNS(sNameSpace, sListTagName));
+ const Reference<css::xml::dom::XElement> listNode(
+ doc->createElementNS(sNameSpace, sPrefix + sListTagName));
xParent->appendChild(
Reference<css::xml::dom::XNode>(
@@ -314,12 +359,12 @@ void BackendDb::writeSimpleList(
typedef ::std::list<OUString>::const_iterator ITC_ITEMS;
for (ITC_ITEMS i = list.begin(); i != list.end(); i++)
{
- Reference<css::xml::dom::XNode> memberNode(
- doc->createElementNS(sNameSpace, sMemberTagName), css::uno::UNO_QUERY_THROW);
+ const Reference<css::xml::dom::XNode> memberNode(
+ doc->createElementNS(sNameSpace, sPrefix + sMemberTagName), css::uno::UNO_QUERY_THROW);
listNode->appendChild(memberNode);
- Reference<css::xml::dom::XNode> textNode(
+ const Reference<css::xml::dom::XNode> textNode(
doc->createTextNode( *i), css::uno::UNO_QUERY_THROW);
memberNode->appendChild(textNode);
@@ -332,9 +377,105 @@ void BackendDb::writeSimpleList(
OUSTR("Extension Manager: failed to write data entry in backend db: ") +
m_urlDb, 0, exc);
}
+}
+
+//Writes only the element if is has a value.
+//The prefix is automatically added to the element name
+void BackendDb::writeSimpleElement(
+ OUString const & sElementName, OUString const & value,
+ Reference<css::xml::dom::XNode> const & xParent)
+{
+ try
+ {
+ if (value.getLength() == 0)
+ return;
+ const OUString sPrefix = getNSPrefix();
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const OUString sNameSpace = getDbNSName();
+ const Reference<css::xml::dom::XNode> dataNode(
+ doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName),
+ UNO_QUERY_THROW);
+ xParent->appendChild(dataNode);
+
+ const Reference<css::xml::dom::XNode> dataValue(
+ doc->createTextNode(value), UNO_QUERY_THROW);
+ dataNode->appendChild(dataValue);
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry(writeSimpleElement) in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+
+}
+
+/** The key elements have an url attribute and are always children of the root
+ element.
+*/
+Reference<css::xml::dom::XNode> BackendDb::writeKeyElement(
+ ::rtl::OUString const & url)
+{
+ try
+ {
+ const OUString sNameSpace = getDbNSName();
+ const OUString sPrefix = getNSPrefix();
+ const OUString sElementName = getKeyElementName();
+ const Reference<css::xml::dom::XDocument> doc = getDocument();
+ const Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+#if OSL_DEBUG_LEVEL > 0
+ //There must not be yet an entry with the same url
+ const OUString sExpression(
+ sPrefix + OUSTR(":") + sElementName + OUSTR("[@url = \"") + url + OUSTR("\"]"));
+ const Reference<css::xml::dom::XNode> _extensionNode =
+ getXPathAPI()->selectSingleNode(root, sExpression);
+ OSL_ASSERT(! _extensionNode.is());
+#endif
+ const Reference<css::xml::dom::XElement> keyElement(
+ doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sElementName));
+
+ keyElement->setAttribute(OUSTR("url"), url);
+
+ const Reference<css::xml::dom::XNode> keyNode(
+ keyElement, UNO_QUERY_THROW);
+ root->appendChild(keyNode);
+ return keyNode;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write key element in backend db: ") +
+ m_urlDb, 0, exc);
+ }
}
+OUString BackendDb::readSimpleElement(
+ OUString const & sElementName, Reference<css::xml::dom::XNode> const & xParent)
+{
+ try
+ {
+ const OUString sPrefix = getNSPrefix();
+ const OUString sExpr(sPrefix + OUSTR(":") + sElementName + OUSTR("/text()"));
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const Reference<css::xml::dom::XNode> val =
+ xpathApi->selectSingleNode(xParent, sExpr);
+ if (val.is())
+ return val->getNodeValue();
+ return OUString();
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data (readSimpleElement) in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
::std::list< OUString> BackendDb::readList(
Reference<css::xml::dom::XNode> const & parent,
OUString const & sListTagName,
@@ -343,17 +484,18 @@ void BackendDb::writeSimpleList(
try
{
OSL_ASSERT(parent.is());
- Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
- OUString sExprList(
- sListTagName + OUSTR("/") + sMemberTagName + OUSTR("/text()"));
- Reference<css::xml::dom::XNodeList> list =
+ const OUString sPrefix(getNSPrefix() + OUSTR(":"));
+ const Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ const OUString sExprList(
+ sPrefix + sListTagName + OUSTR("/") + sPrefix + sMemberTagName + OUSTR("/text()"));
+ const Reference<css::xml::dom::XNodeList> list =
xpathApi->selectNodeList(parent, sExprList);
::std::list<OUString > retList;
sal_Int32 length = list->getLength();
for (sal_Int32 i = 0; i < length; i++)
{
- Reference<css::xml::dom::XNode> member = list->item(i);
+ const Reference<css::xml::dom::XNode> member = list->item(i);
retList.push_back(member->getNodeValue());
}
return retList;
@@ -369,6 +511,84 @@ void BackendDb::writeSimpleList(
+//================================================================================
+RegisteredDb::RegisteredDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):BackendDb(xContext, url)
+{
+
+}
+
+void RegisteredDb::addEntry(::rtl::OUString const & url)
+{
+ try{
+
+ const OUString sNameSpace = getDbNSName();
+ const OUString sPrefix = getNSPrefix();
+ const OUString sEntry = getKeyElementName();
+
+ Reference<css::xml::dom::XDocument> doc = getDocument();
+ Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+#if OSL_DEBUG_LEVEL > 0
+ //There must not be yet an entry with the same url
+ OUString sExpression(
+ sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]"));
+ Reference<css::xml::dom::XNode> _extensionNode =
+ getXPathAPI()->selectSingleNode(root, sExpression);
+ OSL_ASSERT(! _extensionNode.is());
+#endif
+ Reference<css::xml::dom::XElement> helpElement(
+ doc->createElementNS(sNameSpace, sPrefix + OUSTR(":") + sEntry));
+
+ helpElement->setAttribute(OUSTR("url"), url);
+
+ Reference<css::xml::dom::XNode> helpNode(
+ helpElement, UNO_QUERY_THROW);
+ root->appendChild(helpNode);
+
+ save();
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to write data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+bool RegisteredDb::getEntry(::rtl::OUString const & url)
+{
+ try
+ {
+ const OUString sPrefix = getNSPrefix();
+ const OUString sEntry = getKeyElementName();
+ const OUString sExpression(
+ sPrefix + OUSTR(":") + sEntry + OUSTR("[@url = \"") + url + OUSTR("\"]"));
+ Reference<css::xml::dom::XDocument> doc = getDocument();
+ Reference<css::xml::dom::XNode> root = doc->getFirstChild();
+
+ Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ //find the extension element that is to be removed
+ Reference<css::xml::dom::XNode> aNode =
+ xpathApi->selectSingleNode(root, sExpression);
+ if (!aNode.is())
+ {
+ return false;
+ }
+ return true;
+ }
+ catch(css::uno::Exception &)
+ {
+ Any exc( ::cppu::getCaughtException() );
+ throw css::deployment::DeploymentException(
+ OUSTR("Extension Manager: failed to read data entry in backend db: ") +
+ m_urlDb, 0, exc);
+ }
+}
+
+
} // namespace backend
} // namespace dp_registry
diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx
index 893a58ee8c64..976a6281a2bd 100644
--- a/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx
+++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.cxx
@@ -32,13 +32,8 @@
#include "precompiled_desktop.hxx"
#include "rtl/string.h"
-#include "rtl/bootstrap.hxx"
-#include "cppuhelper/exc_hlp.hxx"
#include "com/sun/star/uno/XComponentContext.hpp"
-#include "com/sun/star/xml/dom/XDocumentBuilder.hpp"
-#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
#include "dp_misc.h"
-
#include "dp_executablebackenddb.hxx"
@@ -49,6 +44,7 @@ using ::rtl::OUString;
#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/executable-registry/2010"
#define NS_PREFIX "exe"
#define ROOT_ELEMENT_NAME "executable-backend-db"
+#define ENTRY_NAME "executable"
namespace dp_registry {
namespace backend {
@@ -56,7 +52,7 @@ namespace executable {
ExecutableBackendDb::ExecutableBackendDb(
Reference<XComponentContext> const & xContext,
- ::rtl::OUString const & url):BackendDb(xContext, url)
+ ::rtl::OUString const & url):RegisteredDb(xContext, url)
{
}
@@ -76,86 +72,9 @@ OUString ExecutableBackendDb::getRootElementName()
return OUSTR(ROOT_ELEMENT_NAME);
}
-void ExecutableBackendDb::addEntry(::rtl::OUString const & url)
+OUString ExecutableBackendDb::getKeyElementName()
{
- try{
-
- const OUString sNameSpace = getDbNSName();
- const OUString sPrefix = getNSPrefix();
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
-
-#if OSL_DEBUG_LEVEL > 0
- //There must not be yet an entry with the same url
- OUString sExpression(
- sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]"));
- Reference<css::xml::dom::XNode> _extensionNode =
- getXPathAPI()->selectSingleNode(root, sExpression);
- OSL_ASSERT(! _extensionNode.is());
-#endif
- Reference<css::xml::dom::XElement> helpElement(
- doc->createElementNS(sNameSpace, sPrefix + OUSTR(":executable")));
-
- helpElement->setAttribute(OUSTR("url"), url);
-
- Reference<css::xml::dom::XNode> helpNode(
- helpElement, UNO_QUERY_THROW);
- root->appendChild(helpNode);
-
-// Reference<css::xml::dom::XNode> dataNode(
-// doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")),
-// UNO_QUERY_THROW);
-// helpNode->appendChild(dataNode);
-
-// Reference<css::xml::dom::XNode> dataValue(
-// doc->createTextNode(data.dataUrl), UNO_QUERY_THROW);
-// dataNode->appendChild(dataValue);
-
- save();
- }
- catch(css::uno::Exception &)
- {
- Any exc( ::cppu::getCaughtException() );
- throw css::deployment::DeploymentException(
- OUSTR("Extension Manager: failed to write data entry in backend db: ") +
- m_urlDb, 0, exc);
- }
-}
-
-void ExecutableBackendDb::removeEntry(::rtl::OUString const & url)
-{
- OUString sExpression(
- OUSTR(NS_PREFIX) + OUSTR(":executable[@url = \"") + url + OUSTR("\"]"));
- removeElement(sExpression);
-}
-
-bool ExecutableBackendDb::getEntry(::rtl::OUString const & url)
-{
- try
- {
- const OUString sPrefix = getNSPrefix();
- const OUString sExpression(
- sPrefix + OUSTR(":executable[@url = \"") + url + OUSTR("\"]"));
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
-
- Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
- //find the extension element that is to be removed
- Reference<css::xml::dom::XNode> aNode =
- xpathApi->selectSingleNode(root, sExpression);
- if (!aNode.is())
- {
- return false;
- }
- return true;
- }
- catch(css::uno::Exception &)
- {
- Any exc( ::cppu::getCaughtException() );
- throw css::deployment::DeploymentException(
- OUSTR("Extension Manager: failed to read data entry in backend db: ") +
- m_urlDb, 0, exc);
- }
+ return OUSTR(ENTRY_NAME);
}
diff --git a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx
index 2634d1d9d376..4f17eeda24a6 100644
--- a/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx
+++ b/desktop/source/deployment/registry/executable/dp_executablebackenddb.hxx
@@ -32,10 +32,6 @@
#define INCLUDED_DP_EXECUTABLEBACKENDDB_HXX
#include "rtl/ustring.hxx"
-#include "rtl/string.hxx"
-#include <vector>
-#include <list>
-#include "boost/optional.hpp"
#include "dp_backenddb.hxx"
namespace css = ::com::sun::star;
@@ -44,13 +40,6 @@ namespace com { namespace sun { namespace star {
namespace uno {
class XComponentContext;
}
- namespace xml { namespace dom {
- class XDocument;
- class XNode;
- }}
- namespace xml { namespace xpath {
- class XXPathAPI;
- }}
}}}
namespace dp_registry {
@@ -63,7 +52,7 @@ namespace executable {
<?xml version="1.0"?>
*/
-class ExecutableBackendDb: public dp_registry::backend::BackendDb
+class ExecutableBackendDb: public dp_registry::backend::RegisteredDb
{
protected:
virtual ::rtl::OUString getDbNSName();
@@ -72,14 +61,13 @@ protected:
virtual ::rtl::OUString getRootElementName();
+ virtual ::rtl::OUString getKeyElementName();
+
public:
ExecutableBackendDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
::rtl::OUString const & url);
- void addEntry(::rtl::OUString const & url);
- void removeEntry(::rtl::OUString const & url);
- bool getEntry(::rtl::OUString const & url);
};
diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx
index cad6ddecf751..4a8fa71e0618 100644
--- a/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx
+++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.cxx
@@ -49,6 +49,7 @@ using ::rtl::OUString;
#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/help-registry/2010"
#define NS_PREFIX "help"
#define ROOT_ELEMENT_NAME "help-backend-db"
+#define KEY_ELEMENT_NAME "help"
namespace dp_registry {
namespace backend {
@@ -76,43 +77,25 @@ OUString HelpBackendDb::getRootElementName()
return OUSTR(ROOT_ELEMENT_NAME);
}
-void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
+OUString HelpBackendDb::getKeyElementName()
{
- try{
-
- const OUString sNameSpace = getDbNSName();
- const OUString sPrefix = getNSPrefix();
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
-
-#if OSL_DEBUG_LEVEL > 0
- //There must not be yet an entry with the same url
- OUString sExpression(
- sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]"));
- Reference<css::xml::dom::XNode> _extensionNode =
- getXPathAPI()->selectSingleNode(root, sExpression);
- OSL_ASSERT(! _extensionNode.is());
-#endif
- Reference<css::xml::dom::XElement> helpElement(
- doc->createElementNS(sNameSpace, sPrefix + OUSTR(":help")));
-
- helpElement->setAttribute(OUSTR("url"), url);
-
- Reference<css::xml::dom::XNode> helpNode(
- helpElement, UNO_QUERY_THROW);
- root->appendChild(helpNode);
+ return OUSTR(KEY_ELEMENT_NAME);
+}
- Reference<css::xml::dom::XNode> dataNode(
- doc->createElementNS(sNameSpace, sPrefix + OUSTR(":data-url")),
- UNO_QUERY_THROW);
- helpNode->appendChild(dataNode);
- Reference<css::xml::dom::XNode> dataValue(
- doc->createTextNode(data.dataUrl), UNO_QUERY_THROW);
- dataNode->appendChild(dataValue);
+void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
+{
+ try{
+ Reference<css::xml::dom::XNode> helpNode
+ = writeKeyElement(url);
+ writeSimpleElement(OUSTR("data-url"), data.dataUrl, helpNode);
save();
}
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
catch(css::uno::Exception &)
{
Any exc( ::cppu::getCaughtException() );
@@ -122,36 +105,17 @@ void HelpBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
}
}
-void HelpBackendDb::removeEntry(::rtl::OUString const & url)
-{
- OUString sExpression(
- OUSTR(NS_PREFIX) + OUSTR(":help[@url = \"") + url + OUSTR("\"]"));
- removeElement(sExpression);
-}
::boost::optional<HelpBackendDb::Data>
HelpBackendDb::getEntry(::rtl::OUString const & url)
{
try
{
- const OUString sPrefix = getNSPrefix();
HelpBackendDb::Data retData;
- const OUString sExpression(
- sPrefix + OUSTR(":help[@url = \"") + url + OUSTR("\"]"));
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
-
- Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
- //find the extension element that is to be removed
- Reference<css::xml::dom::XNode> aNode =
- xpathApi->selectSingleNode(root, sExpression);
+ Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
if (aNode.is())
{
- const OUString sExprDataUrl(sPrefix + OUSTR(":data-url/text()"));
-
- Reference<css::xml::dom::XNode> dataUrlVal =
- xpathApi->selectSingleNode(aNode, sExprDataUrl);
- retData.dataUrl = dataUrlVal->getNodeValue();
+ retData.dataUrl = readSimpleElement(OUSTR("data-url"), aNode);
}
else
{
@@ -159,6 +123,10 @@ HelpBackendDb::getEntry(::rtl::OUString const & url)
}
return ::boost::optional<Data>(retData);
}
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
catch(css::uno::Exception &)
{
Any exc( ::cppu::getCaughtException() );
@@ -190,6 +158,10 @@ HelpBackendDb::getEntry(::rtl::OUString const & url)
}
return listRet;
}
+ catch (css::deployment::DeploymentException& )
+ {
+ throw;
+ }
catch(css::uno::Exception &)
{
Any exc( ::cppu::getCaughtException() );
diff --git a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx
index bf812ad96511..baecf0da48e6 100644
--- a/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx
+++ b/desktop/source/deployment/registry/help/dp_helpbackenddb.hxx
@@ -59,9 +59,6 @@ namespace help {
/* The XML file stores the extensions which are currently registered.
They will be removed when they are revoked.
- The format looks like this:
-
-<?xml version="1.0"?>
*/
class HelpBackendDb: public dp_registry::backend::BackendDb
{
@@ -72,6 +69,8 @@ protected:
virtual ::rtl::OUString getRootElementName();
+ virtual ::rtl::OUString getKeyElementName();
+
public:
struct Data
{
@@ -87,7 +86,7 @@ public:
::rtl::OUString const & url);
void addEntry(::rtl::OUString const & url, Data const & data);
- void removeEntry(::rtl::OUString const & url);
+
::boost::optional<Data> getEntry(::rtl::OUString const & url);
::std::list< ::rtl::OUString> getAllDataUrls();
diff --git a/desktop/source/deployment/registry/inc/dp_backenddb.hxx b/desktop/source/deployment/registry/inc/dp_backenddb.hxx
index ca28f28ac390..b8ba5facd492 100644
--- a/desktop/source/deployment/registry/inc/dp_backenddb.hxx
+++ b/desktop/source/deployment/registry/inc/dp_backenddb.hxx
@@ -30,6 +30,7 @@
#include "rtl/ustring.hxx"
#include <list>
+#include <vector>
namespace css = ::com::sun::star;
@@ -75,6 +76,9 @@ protected:
void save();
void removeElement(::rtl::OUString const & sXPathExpression);
+ css::uno::Reference<css::xml::dom::XNode> getKeyElement(
+ ::rtl::OUString const & url);
+
void writeSimpleList(
::std::list< ::rtl::OUString> const & list,
::rtl::OUString const & sListTagName,
@@ -89,6 +93,17 @@ protected:
::rtl::OUString const & sSecondTagName,
css::uno::Reference<css::xml::dom::XNode> const & xParent);
+ void writeSimpleElement(
+ ::rtl::OUString const & sElementName, ::rtl::OUString const & value,
+ css::uno::Reference<css::xml::dom::XNode> const & xParent);
+
+ css::uno::Reference<css::xml::dom::XNode> writeKeyElement(
+ ::rtl::OUString const & url);
+
+ ::rtl::OUString readSimpleElement(
+ ::rtl::OUString const & sElementName,
+ css::uno::Reference<css::xml::dom::XNode> const & xParent);
+
::std::vector< ::std::pair< ::rtl::OUString, ::rtl::OUString > >
readVectorOfPair(
css::uno::Reference<css::xml::dom::XNode> const & parent,
@@ -117,6 +132,10 @@ protected:
/* returns the name of the root element without any namespace prefix.
*/
virtual ::rtl::OUString getRootElementName()=0;
+ /* returns the name of xml element for each entry
+ */
+ virtual ::rtl::OUString getKeyElementName()=0;
+
public:
@@ -124,8 +143,24 @@ public:
::rtl::OUString const & url);
virtual ~BackendDb() {};
+ void removeEntry(::rtl::OUString const & url);
};
+class RegisteredDb: public BackendDb
+{
+
+public:
+ RegisteredDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+ virtual ~RegisteredDb() {};
+
+
+ virtual void addEntry(::rtl::OUString const & url);
+ virtual bool getEntry(::rtl::OUString const & url);
+
+};
+
+
}
}
#endif
diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx
index 99aa2178b421..2e92a907f8fb 100644
--- a/desktop/source/deployment/registry/package/dp_extbackenddb.cxx
+++ b/desktop/source/deployment/registry/package/dp_extbackenddb.cxx
@@ -46,6 +46,7 @@ using ::rtl::OUString;
#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/extension-registry/2010"
#define NS_PREFIX "ext"
#define ROOT_ELEMENT_NAME "extension-backend-db"
+#define KEY_ELEMENT_NAME "extension"
namespace dp_registry {
namespace backend {
@@ -73,40 +74,21 @@ OUString ExtensionBackendDb::getRootElementName()
return OUSTR(ROOT_ELEMENT_NAME);
}
+OUString ExtensionBackendDb::getKeyElementName()
+{
+ return OUSTR(KEY_ELEMENT_NAME);
+}
+
void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data)
{
try{
-
- const OUString sNameSpace = getDbNSName();
- const OUString sPrefix = getNSPrefix();
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
-
-#if OSL_DEBUG_LEVEL > 0
- //There must not be yet an entry with the same url
- OUString sExpression(
- sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]"));
- Reference<css::xml::dom::XNode> _extensionNode =
- getXPathAPI()->selectSingleNode(root, sExpression);
- OSL_ASSERT(! _extensionNode.is());
-#endif
- // <extension url="file:///...">
- Reference<css::xml::dom::XElement> extensionNode(
- doc->createElementNS(sNameSpace,
- sPrefix + OUSTR(":extension")));
-
- extensionNode->setAttribute(OUSTR("url"), url);
-
- Reference<css::xml::dom::XNode> extensionNodeNode(
- extensionNode, css::uno::UNO_QUERY_THROW);
- root->appendChild(extensionNodeNode);
-
+ Reference<css::xml::dom::XNode> extensionNodeNode = writeKeyElement(url);
writeVectorOfPair(
data.items,
- sPrefix + OUSTR(":extension-items"),
- sPrefix + OUSTR(":item"),
- sPrefix + OUSTR(":url"),
- sPrefix + OUSTR(":media-type"),
+ OUSTR("extension-items"),
+ OUSTR("item"),
+ OUSTR("url"),
+ OUSTR("media-type"),
extensionNodeNode);
save();
}
@@ -119,37 +101,22 @@ void ExtensionBackendDb::addEntry(::rtl::OUString const & url, Data const & data
}
}
-void ExtensionBackendDb::removeEntry(::rtl::OUString const & url)
-{
- OUString sExpression(
- OUSTR(NS_PREFIX) + OUSTR(":extension[@url = \"") + url + OUSTR("\"]"));
- removeElement(sExpression);
-}
-
ExtensionBackendDb::Data ExtensionBackendDb::getEntry(::rtl::OUString const & url)
{
try
{
- const OUString sPrefix = getNSPrefix();
ExtensionBackendDb::Data retData;
- const OUString sExpression(
- sPrefix + OUSTR(":extension[@url = \"") + url + OUSTR("\"]"));
- Reference<css::xml::dom::XDocument> doc = getDocument();
- Reference<css::xml::dom::XNode> root = doc->getFirstChild();
-
- Reference<css::xml::xpath::XXPathAPI> xpathApi = getXPathAPI();
+ Reference<css::xml::dom::XNode> aNode = getKeyElement(url);
- Reference<css::xml::dom::XNode> aNode =
- xpathApi->selectSingleNode(root, sExpression);
if (aNode.is())
{
retData.items =
readVectorOfPair(
aNode,
- sPrefix + OUSTR(":extension-items"),
- sPrefix + OUSTR(":item"),
- sPrefix + OUSTR(":url"),
- sPrefix + OUSTR(":media-type"));
+ OUSTR("extension-items"),
+ OUSTR("item"),
+ OUSTR("url"),
+ OUSTR("media-type"));
}
return retData;
}
diff --git a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx
index e46c67b166de..d09fd0891a32 100644
--- a/desktop/source/deployment/registry/package/dp_extbackenddb.hxx
+++ b/desktop/source/deployment/registry/package/dp_extbackenddb.hxx
@@ -62,6 +62,7 @@ protected:
virtual ::rtl::OUString getDbNSName();
virtual ::rtl::OUString getNSPrefix();
virtual ::rtl::OUString getRootElementName();
+ virtual ::rtl::OUString getKeyElementName();
public:
struct Data
@@ -81,7 +82,7 @@ public:
::rtl::OUString const & url);
void addEntry(::rtl::OUString const & url, Data const & data);
- void removeEntry(::rtl::OUString const & url);
+
Data getEntry(::rtl::OUString const & url);
};
diff --git a/desktop/source/deployment/registry/script/dp_script.cxx b/desktop/source/deployment/registry/script/dp_script.cxx
index e808cd0f5e73..f0c4c9b42c6e 100644
--- a/desktop/source/deployment/registry/script/dp_script.cxx
+++ b/desktop/source/deployment/registry/script/dp_script.cxx
@@ -39,12 +39,12 @@
#include "comphelper/servicedecl.hxx"
#include "svl/inettype.hxx"
#include "com/sun/star/util/XUpdatable.hpp"
-#include "com/sun/star/script/XLibraryContainer.hpp"
+#include "com/sun/star/script/XLibraryContainer3.hpp"
#include <com/sun/star/ucb/XSimpleFileAccess.hpp>
#include <com/sun/star/util/XMacroExpander.hpp>
#include <com/sun/star/uri/XUriReferenceFactory.hpp>
-#include <com/sun/star/uri/XVndSunStarExpandUrl.hpp>
#include <memory>
+#include "dp_scriptbackenddb.hxx"
using namespace ::dp_misc;
using namespace ::com::sun::star;
@@ -100,15 +100,19 @@ class BackendImpl : public t_helper
sal_Bool bRemoved, OUString const & identifier,
Reference<XCommandEnvironment> const & xCmdEnv );
- rtl::OUString getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage );
- rtl::OUString expandURL( const rtl::OUString& aURL );
- Reference< ucb::XSimpleFileAccess > getFileAccess( void );
- Reference< ucb::XSimpleFileAccess > m_xSFA;
+ void addDataToDb(OUString const & url);
+ void deleteDataFromDb(OUString const & url);
+ bool isRegisteredInDb(OUString const & url);
+
+
+
+// Reference< ucb::XSimpleFileAccess > getFileAccess( void );
+// Reference< ucb::XSimpleFileAccess > m_xSFA;
const Reference<deployment::XPackageTypeInfo> m_xBasicLibTypeInfo;
const Reference<deployment::XPackageTypeInfo> m_xDialogLibTypeInfo;
Sequence< Reference<deployment::XPackageTypeInfo> > m_typeInfos;
-
+ std::auto_ptr<ScriptBackendDb> m_backendDb;
public:
BackendImpl( Sequence<Any> const & args,
Reference<XComponentContext> const & xComponentContext );
@@ -172,6 +176,33 @@ BackendImpl::BackendImpl(
m_typeInfos[ 1 ] = m_xDialogLibTypeInfo;
OSL_ASSERT( ! transientMode() );
+
+ if (!transientMode())
+ {
+ OUString dbFile = makeURL(getCachePath(), OUSTR("backenddb.xml"));
+ m_backendDb.reset(
+ new ScriptBackendDb(getComponentContext(), dbFile));
+ }
+
+}
+void BackendImpl::addDataToDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->addEntry(url);
+}
+
+bool BackendImpl::isRegisteredInDb(OUString const & url)
+{
+ bool registered = false;
+ if (m_backendDb.get())
+ registered = m_backendDb->getEntry(url);
+ return registered;
+}
+
+void BackendImpl::deleteDataFromDb(OUString const & url)
+{
+ if (m_backendDb.get())
+ m_backendDb->removeEntry(url);
}
// XUpdatable
@@ -261,90 +292,6 @@ Reference<deployment::XPackage> BackendImpl::bindPackage_(
static_cast<sal_Int16>(-1) );
}
-rtl::OUString BackendImpl::getRegisteredFlagFileURL( Reference< deployment::XPackage > xPackage )
-{
- rtl::OUString aRetURL;
- if( !xPackage.is() )
- return aRetURL;
- rtl::OUString aHelpURL = xPackage->getURL();
- aRetURL = expandURL( aHelpURL );
- aRetURL += rtl::OUString::createFromAscii( "/RegisteredFlag" );
- return aRetURL;
-}
-
-rtl::OUString BackendImpl::expandURL( const rtl::OUString& aURL )
-{
- static Reference< util::XMacroExpander > xMacroExpander;
- static Reference< uri::XUriReferenceFactory > xFac;
-
- if( !xMacroExpander.is() || !xFac.is() )
- {
- Reference<XComponentContext> const & xContext = getComponentContext();
- if( xContext.is() )
- {
- xFac = Reference< uri::XUriReferenceFactory >(
- xContext->getServiceManager()->createInstanceWithContext( rtl::OUString::createFromAscii(
- "com.sun.star.uri.UriReferenceFactory"), xContext ) , UNO_QUERY );
- }
- if( !xFac.is() )
- {
- throw RuntimeException(
- ::rtl::OUString::createFromAscii(
- "dp_registry::backend::help::BackendImpl::expandURL(), "
- "could not instatiate UriReferenceFactory." ),
- Reference< XInterface >() );
- }
-
- xMacroExpander = Reference< util::XMacroExpander >(
- xContext->getValueByName(
- ::rtl::OUString::createFromAscii( "/singletons/com.sun.star.util.theMacroExpander" ) ),
- UNO_QUERY_THROW );
- }
-
- rtl::OUString aRetURL = aURL;
- if( xMacroExpander.is() )
- {
- Reference< uri::XUriReference > uriRef;
- for (;;)
- {
- uriRef = Reference< uri::XUriReference >( xFac->parse( aRetURL ), UNO_QUERY );
- if ( uriRef.is() )
- {
- Reference < uri::XVndSunStarExpandUrl > sxUri( uriRef, UNO_QUERY );
- if( !sxUri.is() )
- break;
-
- aRetURL = sxUri->expand( xMacroExpander );
- }
- }
- }
- return aRetURL;
-}
-
-Reference< ucb::XSimpleFileAccess > BackendImpl::getFileAccess( void )
-{
- if( !m_xSFA.is() )
- {
- Reference<XComponentContext> const & xContext = getComponentContext();
- if( xContext.is() )
- {
- m_xSFA = Reference< ucb::XSimpleFileAccess >(
- xContext->getServiceManager()->createInstanceWithContext(
- rtl::OUString::createFromAscii( "com.sun.star.ucb.SimpleFileAccess" ),
- xContext ), UNO_QUERY );
- }
- if( !m_xSFA.is() )
- {
- throw RuntimeException(
- ::rtl::OUString::createFromAscii(
- "dp_registry::backend::help::BackendImpl::getFileAccess(), "
- "could not instatiate SimpleFileAccess." ),
- Reference< XInterface >() );
- }
- }
- return m_xSFA;
-}
-
//##############################################################################
// Package
@@ -373,14 +320,11 @@ BackendImpl::PackageImpl::isRegistered_(
BackendImpl * that = getMyBackend();
Reference< deployment::XPackage > xThisPackage( this );
- rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage );
-
- Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess();
- bool bReg = xSFA->exists( aRegisteredFlagFile );
+ bool registered = getMyBackend()->isRegisteredInDb(getURL());
return beans::Optional< beans::Ambiguous<sal_Bool> >(
true /* IsPresent */,
- beans::Ambiguous<sal_Bool>( bReg, false /* IsAmbiguous */ ) );
+ beans::Ambiguous<sal_Bool>( registered, false /* IsAmbiguous */ ) );
}
//______________________________________________________________________________
@@ -396,15 +340,13 @@ void BackendImpl::PackageImpl::processPackage_(
BackendImpl * that = getMyBackend();
Reference< deployment::XPackage > xThisPackage( this );
- rtl::OUString aRegisteredFlagFile = that->getRegisteredFlagFileURL( xThisPackage );
- Reference< ucb::XSimpleFileAccess > xSFA = that->getFileAccess();
Reference<XComponentContext> const & xComponentContext = that->getComponentContext();
bool bScript = (m_scriptURL.getLength() > 0);
- Reference<css::script::XLibraryContainer> xScriptLibs;
+ Reference<css::script::XLibraryContainer3> xScriptLibs;
bool bDialog = (m_dialogURL.getLength() > 0);
- Reference<css::script::XLibraryContainer> xDialogLibs;
+ Reference<css::script::XLibraryContainer3> xDialogLibs;
bool bRunning = office_is_running();
if( bRunning )
@@ -425,52 +367,116 @@ void BackendImpl::PackageImpl::processPackage_(
xComponentContext ), UNO_QUERY_THROW );
}
}
-
+ bool bRegistered = getMyBackend()->isRegisteredInDb(getURL());
if( !doRegisterPackage )
{
- if( xSFA->exists( aRegisteredFlagFile ) )
+ //We cannot just call removeLibrary(name) because this could remove a
+ //script which was added by an extension in a different repository. For
+ //example, extension foo is contained in the bundled repository and then
+ //the user adds it it to the user repository. The extension manager will
+ //then register the new script and revoke the script from the bundled
+ //extension. removeLibrary(name) would now remove the script from the
+ //user repository. That is, the script of the newly added user extension does
+ //not work anymore. Therefore we must check if the currently active
+ //script comes in fact from the currently processed extension.
+
+ if (bRegistered)
{
- xSFA->kill( aRegisteredFlagFile );
-
- if( bScript && xScriptLibs.is() && xScriptLibs->hasByName( m_name ) )
- xScriptLibs->removeLibrary( m_name );
+ if (!isRemoved())
+ {
+ if (bScript && xScriptLibs.is() && xScriptLibs->hasByName(m_name))
+ {
+ const OUString sScriptUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name);
+ if (sScriptUrl.equals(m_scriptURL))
+ xScriptLibs->removeLibrary(m_name);
+ }
- if( bDialog && xDialogLibs.is() && xDialogLibs->hasByName( m_dialogName ) )
- xDialogLibs->removeLibrary( m_dialogName );
+ if (bDialog && xDialogLibs.is() && xDialogLibs->hasByName(m_dialogName))
+ {
+ const OUString sDialogUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName);
+ if (sDialogUrl.equals(m_dialogURL))
+ xDialogLibs->removeLibrary(m_dialogName);
+ }
+ }
+ getMyBackend()->deleteDataFromDb(getURL());
+ return;
}
- return;
}
-
- if( xSFA->exists( aRegisteredFlagFile ) )
+ if (bRegistered)
return; // Already registered
// Update LibraryContainer
bool bScriptSuccess = false;
const bool bReadOnly = false;
- if( bScript && xScriptLibs.is() && !xScriptLibs->hasByName( m_name ) )
+
+ //If there is a bundled extension, and the user installes the same extension
+ //then the script from the bundled extension must be removed. If this does not work
+ //then live deployment does not work for scripts.
+ if (bScript && xScriptLibs.is())
{
- xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly );
- bScriptSuccess = xScriptLibs->hasByName( m_name );
+ bool bCanAdd = true;
+ if (xScriptLibs->hasByName(m_name))
+ {
+ const OUString sOriginalUrl = xScriptLibs->getOriginalLibraryLinkURL(m_name);
+ //We assume here that library names in extensions are unique, which may not be the case
+ //ToDo: If the script exist in another extension, then both extensions must have the
+ //same id
+ if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"))
+ || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"))
+ || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")))
+ {
+ xScriptLibs->removeLibrary(m_name);
+ bCanAdd = true;
+ }
+ else
+ {
+ bCanAdd = false;
+ }
+ }
+
+ if (bCanAdd)
+ {
+ xScriptLibs->createLibraryLink( m_name, m_scriptURL, bReadOnly );
+ bScriptSuccess = xScriptLibs->hasByName( m_name );
+ }
}
bool bDialogSuccess = false;
- if( bDialog && xDialogLibs.is() && !xDialogLibs->hasByName( m_dialogName ) )
+ if (bDialog && xDialogLibs.is())
{
- xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly );
- bDialogSuccess = xDialogLibs->hasByName( m_dialogName );
- }
+ bool bCanAdd = true;
+ if (xDialogLibs->hasByName(m_dialogName))
+ {
+ const OUString sOriginalUrl = xDialogLibs->getOriginalLibraryLinkURL(m_dialogName);
+ //We assume here that library names in extensions are unique, which may not be the case
+ //ToDo: If the script exist in another extension, then both extensions must have the
+ //same id
+ if (sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_USER_PACKAGES_CACHE"))
+ || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$UNO_SHARED_PACKAGES_CACHE"))
+ || sOriginalUrl.match(OUSTR("vnd.sun.star.expand:$BUNDLED_EXTENSIONS")))
+ {
+ xDialogLibs->removeLibrary(m_dialogName);
+ bCanAdd = true;
+ }
+ else
+ {
+ bCanAdd = false;
+ }
+ }
+ if (bCanAdd)
+ {
+ xDialogLibs->createLibraryLink( m_dialogName, m_dialogURL, bReadOnly );
+ bDialogSuccess = xDialogLibs->hasByName(m_dialogName);
+ }
+ }
bool bSuccess = bScript || bDialog; // Something must have happened
if( bRunning )
if( (bScript && !bScriptSuccess) || (bDialog && !bDialogSuccess) )
bSuccess = false;
- if( bSuccess && !xSFA->exists( aRegisteredFlagFile ) )
- {
- Reference< io::XOutputStream > xOutputStream = xSFA->openFileWrite( aRegisteredFlagFile );
- if( xOutputStream.is() )
- xOutputStream->closeOutput();
- }
+ if (bSuccess)
+ getMyBackend()->addDataToDb(getURL());
}
} // anon namespace
diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx
new file mode 100644
index 000000000000..ce0d3029084d
--- /dev/null
+++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dp_package.cxx,v $
+ * $Revision: 1.34.16.2 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+// MARKER(update_precomp.py): autogen include statement, do not remove
+#include "precompiled_desktop.hxx"
+
+#include "rtl/string.h"
+#include "cppuhelper/exc_hlp.hxx"
+#include "com/sun/star/uno/XComponentContext.hpp"
+#include "com/sun/star/xml/dom/XDocument.hpp"
+#include "com/sun/star/xml/xpath/XXPathAPI.hpp"
+#include "dp_misc.h"
+#include "dp_scriptbackenddb.hxx"
+
+
+namespace css = ::com::sun::star;
+using namespace ::com::sun::star::uno;
+using ::rtl::OUString;
+
+#define EXTENSION_REG_NS "http://openoffice.org/extensionmanager/script-registry/2010"
+#define NS_PREFIX "script"
+#define ROOT_ELEMENT_NAME "script-backend-db"
+#define KEY_ELEMENT_NAME "script"
+
+namespace dp_registry {
+namespace backend {
+namespace script {
+
+ScriptBackendDb::ScriptBackendDb(
+ Reference<XComponentContext> const & xContext,
+ ::rtl::OUString const & url):RegisteredDb(xContext, url)
+{
+
+}
+
+OUString ScriptBackendDb::getDbNSName()
+{
+ return OUSTR(EXTENSION_REG_NS);
+}
+
+OUString ScriptBackendDb::getNSPrefix()
+{
+ return OUSTR(NS_PREFIX);
+}
+
+OUString ScriptBackendDb::getRootElementName()
+{
+ return OUSTR(ROOT_ELEMENT_NAME);
+}
+
+OUString ScriptBackendDb::getKeyElementName()
+{
+ return OUSTR(KEY_ELEMENT_NAME);
+}
+
+
+
+} // namespace executable
+} // namespace backend
+} // namespace dp_registry
+
diff --git a/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx
new file mode 100644
index 000000000000..9d227f8b64b8
--- /dev/null
+++ b/desktop/source/deployment/registry/script/dp_scriptbackenddb.hxx
@@ -0,0 +1,76 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2008 by Sun Microsystems, Inc.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: dp_backend.h,v $
+ * $Revision: 1.18 $
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+#if ! defined INCLUDED_DP_SCRIPTBACKENDDB_HXX
+#define INCLUDED_DP_SCRIPTBACKENDDB_HXX
+
+#include "rtl/ustring.hxx"
+#include "dp_backenddb.hxx"
+#include "boost/optional.hpp"
+namespace css = ::com::sun::star;
+
+namespace com { namespace sun { namespace star {
+ namespace uno {
+ class XComponentContext;
+ }
+}}}
+
+namespace dp_registry {
+namespace backend {
+namespace script {
+
+/* The XML file stores the extensions which are currently registered.
+ They will be removed when they are revoked.
+ */
+class ScriptBackendDb: public dp_registry::backend::RegisteredDb
+{
+protected:
+ virtual ::rtl::OUString getDbNSName();
+
+ virtual ::rtl::OUString getNSPrefix();
+
+ virtual ::rtl::OUString getRootElementName();
+
+ virtual ::rtl::OUString getKeyElementName();
+
+
+public:
+
+ ScriptBackendDb( css::uno::Reference<css::uno::XComponentContext> const & xContext,
+ ::rtl::OUString const & url);
+};
+
+
+
+}
+}
+}
+#endif
+
diff --git a/desktop/source/deployment/registry/script/makefile.mk b/desktop/source/deployment/registry/script/makefile.mk
index ae159914a548..708def358021 100644
--- a/desktop/source/deployment/registry/script/makefile.mk
+++ b/desktop/source/deployment/registry/script/makefile.mk
@@ -41,7 +41,8 @@ INCPRE += ..$/..$/inc
SLOFILES = \
$(SLO)$/dp_script.obj \
- $(SLO)$/dp_lib_container.obj
+ $(SLO)$/dp_lib_container.obj \
+ $(SLO)$/dp_scriptbackenddb.obj
.INCLUDE : ..$/..$/target.pmk
.INCLUDE : target.mk
diff --git a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java
index 4c6a4f1eda2b..edf6a2d806b7 100644
--- a/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java
+++ b/scripting/java/com/sun/star/script/framework/container/UnoPkgContainer.java
@@ -50,10 +50,15 @@ public class UnoPkgContainer extends ParcelContainer
{
private Map registeredPackages = new HashMap();
+ protected String extensionDb;
+ protected String extensionRepository;
- public UnoPkgContainer( XComponentContext xCtx, String locationURL, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
+ public UnoPkgContainer( XComponentContext xCtx, String locationURL,
+ String _extensionDb, String _extensionRepository, String language ) throws com.sun.star.lang.IllegalArgumentException, com.sun.star.lang.WrappedTargetException
{
super( xCtx, locationURL, language, false );
+ extensionDb = _extensionDb;
+ extensionRepository = _extensionRepository;
init();
}
@@ -218,8 +223,8 @@ public class UnoPkgContainer extends ParcelContainer
DeployedUnoPackagesDB dp = null;
try
{
- String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") );
- String packagesUrl = PathUtils.make_url( path, "Scripts/unopkg-desc.xml" );
+// String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") );
+ String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" );
LogUtils.DEBUG("getUnoPackagesDB() looking for existing db in " + packagesUrl );
if ( m_xSFA.exists( packagesUrl ) )
{
@@ -277,8 +282,8 @@ public class UnoPkgContainer extends ParcelContainer
OutputStream os = null;
try
{
- String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") );
- String packagesUrl = PathUtils.make_url( path, "Scripts/unopkg-desc.xml" );
+// String path = containerUrl.substring( 0, containerUrl.lastIndexOf("/") );
+ String packagesUrl = PathUtils.make_url( extensionDb, "/Scripts/" + extensionRepository + "-extension-desc.xml" );
xos = m_xSFA.openFileWrite( packagesUrl );
XTruncate xTrc = (XTruncate) UnoRuntime.queryInterface( XTruncate.class, xos );
if ( xTrc != null )
@@ -375,7 +380,10 @@ public class UnoPkgContainer extends ParcelContainer
String parentUrl = uri;
if ( uri.indexOf( "%2Funo_packages%2F" ) > -1 ||
- uri.indexOf( "/uno_packages/" ) > -1 )
+ uri.indexOf( "/uno_packages/" ) > -1 ||
+ uri.indexOf("$UNO_USER_PACKAGES_CACHE/") > -1 ||
+ uri.indexOf("$UNO_SHARED_PACKAGES_CACHE/") > -1 ||
+ uri.indexOf("$BUNDLED_EXTENSIONS/") > -1 )
{
//its in a bundle need to determine the uno-package file its in
LogUtils.DEBUG("processUnoPackage - is part of a uno bundle");
diff --git a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
index c43756072ba3..e83410f3f35c 100755
--- a/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
+++ b/scripting/java/com/sun/star/script/framework/provider/ScriptProvider.java
@@ -213,26 +213,40 @@ public abstract class ScriptProvider
}
else
{
+ String extensionDb = null;
+ String extensionRepository = null;
+ if ( originalContextURL.startsWith( "bundled" ) )
+ {
+ contextUrl = "vnd.sun.star.expand:$BUNDLED_EXTENSIONS";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionRepository = "bundled";
+ }
+
if ( originalContextURL.startsWith( "share" ) )
{
contextUrl = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::BaseInstallation}/share";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionRepository = "shared";
}
else if ( originalContextURL.startsWith( "user" ) )
{
contextUrl = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionDb = "vnd.sun.star.expand:${$BRAND_BASE_DIR/program/" + PathUtils.BOOTSTRAP_NAME + "::UserInstallation}/user";
+ extensionRepository = "user";
}
if ( originalContextURL.endsWith( "uno_packages") )
{
isPkgProvider = true;
}
- if ( originalContextURL.endsWith( "uno_packages") && !originalContextURL.equals( contextUrl ) )
+ if ( originalContextURL.endsWith( "uno_packages") && !originalContextURL.equals( contextUrl )
+ && !extensionRepository.equals("bundled"))
{
contextUrl = PathUtils.make_url( contextUrl, "uno_packages" );
}
if ( isPkgProvider )
{
- m_container = new UnoPkgContainer( m_xContext, contextUrl, language );
+ m_container = new UnoPkgContainer( m_xContext, contextUrl, extensionDb, extensionRepository, language );
}
else
{
diff --git a/scripting/source/provider/ActiveMSPList.cxx b/scripting/source/provider/ActiveMSPList.cxx
index f8400ed77950..3c6206d8d051 100644
--- a/scripting/source/provider/ActiveMSPList.cxx
+++ b/scripting/source/provider/ActiveMSPList.cxx
@@ -59,6 +59,7 @@ ActiveMSPList::ActiveMSPList( const Reference< XComponentContext > & xContext )
{
userDirString = ::rtl::OUString::createFromAscii("user");
shareDirString = ::rtl::OUString::createFromAscii("share");
+ bundledDirString = ::rtl::OUString::createFromAscii("bundled");
}
ActiveMSPList::~ActiveMSPList()
@@ -307,6 +308,12 @@ ActiveMSPList::createNonDocMSPs()
Reference< provider::XScriptProvider > shareMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY );
// should check if provider reference is valid
m_hMsps[ shareDirString ] = shareMsp;
+
+ args[ 0 ] <<= bundledDirString;
+ Reference< provider::XScriptProvider > bundledMsp( m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( serviceName, args, m_xContext ), UNO_QUERY );
+ // should check if provider reference is valid
+ m_hMsps[ bundledDirString ] = bundledMsp;
+
created = true;
}
diff --git a/scripting/source/provider/ActiveMSPList.hxx b/scripting/source/provider/ActiveMSPList.hxx
index 5adf2fc5a961..b127f3c41b16 100644
--- a/scripting/source/provider/ActiveMSPList.hxx
+++ b/scripting/source/provider/ActiveMSPList.hxx
@@ -107,6 +107,7 @@ private:
osl::Mutex m_mutex;
::rtl::OUString userDirString;
::rtl::OUString shareDirString;
+ ::rtl::OUString bundledDirString;
css::uno::Reference< css::uno::XComponentContext > m_xContext;
};
} // func_provider
diff --git a/xmlhelp/source/cxxhelp/provider/databases.cxx b/xmlhelp/source/cxxhelp/provider/databases.cxx
index 5c164e08c100..f1113c1e114f 100644
--- a/xmlhelp/source/cxxhelp/provider/databases.cxx
+++ b/xmlhelp/source/cxxhelp/provider/databases.cxx
@@ -1511,6 +1511,7 @@ void ExtensionIteratorBase::init()
m_bUserPackagesLoaded = false;
m_bSharedPackagesLoaded = false;
+ m_bBundledPackagesLoaded = false;
m_iUserPackage = 0;
m_iSharedPackage = 0;
m_iBundledPackage = 0;
@@ -1624,7 +1625,7 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa
if( m_iSharedPackage == m_aSharedPackagesSeq.getLength() )
{
- m_eState = END_REACHED;
+ m_eState = BUNDLED_EXTENSIONS;
}
else
{
diff --git a/xmlhelp/source/treeview/tvread.cxx b/xmlhelp/source/treeview/tvread.cxx
index 478562fca7b7..73c413394763 100644
--- a/xmlhelp/source/treeview/tvread.cxx
+++ b/xmlhelp/source/treeview/tvread.cxx
@@ -986,8 +986,10 @@ void ExtensionIteratorBase::init()
m_bUserPackagesLoaded = false;
m_bSharedPackagesLoaded = false;
+ m_bBundledPackagesLoaded = false;
m_iUserPackage = 0;
m_iSharedPackage = 0;
+ m_iBundledPackage = 0;
}
Reference< deployment::XPackage > ExtensionIteratorBase::implGetHelpPackageFromPackage
@@ -1089,7 +1091,7 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa
if( m_iSharedPackage == m_aSharedPackagesSeq.getLength() )
{
- m_eState = END_REACHED;
+ m_eState = BUNDLED_EXTENSIONS;
}
else
{
@@ -1102,6 +1104,36 @@ Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextSharedHelpPa
return xHelpPackage;
}
+Reference< deployment::XPackage > ExtensionIteratorBase::implGetNextBundledHelpPackage
+ ( Reference< deployment::XPackage >& o_xParentPackageBundle )
+{
+ Reference< deployment::XPackage > xHelpPackage;
+
+ if( !m_bBundledPackagesLoaded )
+ {
+ Reference< XPackageManager > xBundledManager =
+ thePackageManagerFactory::get( m_xContext )->getPackageManager( rtl::OUString::createFromAscii("bundled") );
+ m_aBundledPackagesSeq = xBundledManager->getDeployedPackages
+ ( Reference< task::XAbortChannel >(), Reference< ucb::XCommandEnvironment >() );
+
+ m_bBundledPackagesLoaded = true;
+ }
+
+ if( m_iBundledPackage == m_aBundledPackagesSeq.getLength() )
+ {
+ m_eState = END_REACHED;
+ }
+ else
+ {
+ const Reference< deployment::XPackage >* pBundledPackages = m_aBundledPackagesSeq.getConstArray();
+ Reference< deployment::XPackage > xPackage = pBundledPackages[ m_iBundledPackage++ ];
+ VOS_ENSURE( xPackage.is(), "ExtensionIteratorBase::implGetNextBundledHelpPackage(): Invalid package" );
+ xHelpPackage = implGetHelpPackageFromPackage( xPackage, o_xParentPackageBundle );
+ }
+
+ return xHelpPackage;
+}
+
inline bool isLetter( sal_Unicode c )
{
bool bLetter = ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z'));
@@ -1173,7 +1205,18 @@ rtl::OUString TreeFileIterator::nextTreeFile( sal_Int32& rnFileSize )
aRetFile = implGetTreeFileFromPackage( rnFileSize, xHelpPackage );
break;
}
- case END_REACHED:
+ case BUNDLED_EXTENSIONS:
+ {
+ Reference< deployment::XPackage > xParentPackageBundle;
+ Reference< deployment::XPackage > xHelpPackage = implGetNextBundledHelpPackage( xParentPackageBundle );
+ if( !xHelpPackage.is() )
+ break;
+
+ aRetFile = implGetTreeFileFromPackage( rnFileSize, xHelpPackage );
+ break;
+ }
+
+ case END_REACHED:
VOS_ENSURE( false, "DataBaseIterator::nextTreeFile(): Invalid case END_REACHED" );
break;
}
diff --git a/xmlhelp/source/treeview/tvread.hxx b/xmlhelp/source/treeview/tvread.hxx
index 907568815568..7cc3887448be 100644
--- a/xmlhelp/source/treeview/tvread.hxx
+++ b/xmlhelp/source/treeview/tvread.hxx
@@ -328,6 +328,7 @@ namespace treeview {
{
USER_EXTENSIONS,
SHARED_EXTENSIONS,
+ BUNDLED_EXTENSIONS,
END_REACHED
};
@@ -347,6 +348,9 @@ namespace treeview {
( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextSharedHelpPackage
( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
+ com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > implGetNextBundledHelpPackage
+ ( com::sun::star::uno::Reference< com::sun::star::deployment::XPackage >& o_xParentPackageBundle );
+
void implGetLanguageVectorFromPackage( ::std::vector< ::rtl::OUString > &rv,
com::sun::star::uno::Reference< com::sun::star::deployment::XPackage > xPackage );
@@ -365,8 +369,13 @@ namespace treeview {
< com::sun::star::deployment::XPackage > > m_aSharedPackagesSeq;
bool m_bSharedPackagesLoaded;
+ com::sun::star::uno::Sequence< com::sun::star::uno::Reference
+ < com::sun::star::deployment::XPackage > > m_aBundledPackagesSeq;
+ bool m_bBundledPackagesLoaded;
+
int m_iUserPackage;
int m_iSharedPackage;
+ int m_iBundledPackage;
}; // end class ExtensionIteratorBase