incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1172098 - in /incubator/ooo/trunk/main: desktop/source/deployment/inc/ desktop/source/deployment/misc/ officecfg/registry/data/org/openoffice/Office/ officecfg/registry/schema/org/openoffice/Office/ postprocess/packregistry/
Date Sat, 17 Sep 2011 22:36:00 GMT
Author: mst
Date: Sat Sep 17 22:36:00 2011
New Revision: 1172098

URL: http://svn.apache.org/viewvc?rev=1172098&view=rev
Log:
jsc341: i117327: add extra extension dependency check

# HG changeset patch
# User Juergen Schmidt <jsc@openoffice.org>
# Date 1300456036 -3600
# Node ID 8c988d73324cb052c0fb2dfbed9e68f290b2aa4e
# Parent  7dbaa615ad894cfd4f9611e82783250bd0a3016d

Added:
    incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/ExtensionDependencies.xcu
    incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/ExtensionDependencies.xcs
Modified:
    incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_descriptioninfoset.hxx
    incubator/ooo/trunk/main/desktop/source/deployment/misc/dp_descriptioninfoset.cxx
    incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/makefile.mk
    incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/makefile.mk
    incubator/ooo/trunk/main/postprocess/packregistry/makefile.mk

Modified: incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_descriptioninfoset.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_descriptioninfoset.hxx?rev=1172098&r1=1172097&r2=1172098&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_descriptioninfoset.hxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/inc/dp_descriptioninfoset.hxx Sat Sep
17 22:36:00 2011
@@ -276,6 +276,20 @@ private:
     SAL_DLLPRIVATE ::rtl::OUString 
         getNodeValueFromExpression(::rtl::OUString const & expression) const;
 
+    /** Check the extensions blacklist if additional extension meta data (e.g. dependencies)
+        are defined for this extension and have to be taken into account.
+    */
+    SAL_DLLPRIVATE void
+        checkBlacklist() const;
+    
+    /** Helper method to compare the versions with the current version 
+     */
+    SAL_DLLPRIVATE bool
+        checkBlacklistVersion(::rtl::OUString currentversion,
+                              ::com::sun::star::uno::Sequence< ::rtl::OUString > const
& versions) const;
+    
+    ::com::sun::star::uno::Reference<
+        ::com::sun::star::uno::XComponentContext > m_context;
     ::com::sun::star::uno::Reference<
         ::com::sun::star::xml::dom::XNode > m_element;
     ::com::sun::star::uno::Reference<

Modified: incubator/ooo/trunk/main/desktop/source/deployment/misc/dp_descriptioninfoset.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/misc/dp_descriptioninfoset.cxx?rev=1172098&r1=1172097&r2=1172098&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/misc/dp_descriptioninfoset.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/misc/dp_descriptioninfoset.cxx Sat
Sep 17 22:36:00 2011
@@ -34,10 +34,15 @@
 #include "sal/config.h"
 
 #include "comphelper/sequence.hxx"
+#include "comphelper/seqstream.hxx"
 #include "comphelper/makesequence.hxx"
 #include "comphelper/processfactory.hxx"
 #include "boost/optional.hpp"
+#include "com/sun/star/container/XNameAccess.hpp"
 #include "com/sun/star/beans/Optional.hpp"
+#include "com/sun/star/beans/PropertyValue.hpp"
+#include "com/sun/star/beans/XPropertySet.hpp"
+#include "com/sun/star/io/SequenceInputStream.hpp"
 #include "com/sun/star/lang/XMultiComponentFactory.hpp"
 #include "com/sun/star/lang/Locale.hpp"
 #include "com/sun/star/uno/Reference.hxx"
@@ -365,6 +370,7 @@ DescriptionInfoset getDescriptionInfoset
 DescriptionInfoset::DescriptionInfoset(
     css::uno::Reference< css::uno::XComponentContext > const & context,
     css::uno::Reference< css::xml::dom::XNode > const & element):
+    m_context(context),
     m_element(element)
 {
     css::uno::Reference< css::lang::XMultiComponentFactory > manager(
@@ -407,6 +413,105 @@ DescriptionInfoset::~DescriptionInfoset(
     return n.is() ? getNodeValue(n) : ::rtl::OUString();
 }
 
+void DescriptionInfoset::checkBlacklist() const
+{
+    if (m_element.is()) {
+        boost::optional< OUString > id(getIdentifier());
+        if (!id)
+            return; // nothing to check
+        OUString currentversion(getVersion());
+        if (currentversion.getLength() == 0)
+            return;  // nothing to check
+
+        css::uno::Reference< css::lang::XMultiComponentFactory > manager(
+            m_context->getServiceManager(), css::uno::UNO_QUERY_THROW);
+        css::uno::Reference< css::lang::XMultiServiceFactory> provider(
+            manager->createInstanceWithContext(
+                ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationProvider")),
m_context),
+                css::uno::UNO_QUERY_THROW);
+
+        css::uno::Sequence< css::uno::Any > args = css::uno::Sequence< css::uno::Any
>(1);
+        css::beans::PropertyValue prop;
+        prop.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("nodepath"));
+        prop.Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("/org.openoffice.Office.ExtensionDependencies/Extensions"));
+        args[0] <<= prop;
+
+        css::uno::Reference< css::container::XNameAccess > blacklist(
+            provider->createInstanceWithArguments(
+                ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.configuration.ConfigurationAccess")),
args),
+                css::uno::UNO_QUERY_THROW);
+
+        // check first if a blacklist entry is available
+        if (blacklist.is() && blacklist->hasByName(*id)) {
+            css::uno::Reference< css::beans::XPropertySet > extProps(
+                blacklist->getByName(*id), css::uno::UNO_QUERY_THROW);
+
+            css::uno::Any anyValue = extProps->getPropertyValue(
+                ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Versions")));
+            
+            css::uno::Sequence< ::rtl::OUString > blversions;
+            anyValue >>= blversions;
+
+            // check if the current version requires further dependency checks from the blacklist
+            if (checkBlacklistVersion(currentversion, blversions)) {
+                anyValue = extProps->getPropertyValue(
+                    ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Dependencies")));
+                ::rtl::OUString udeps;
+                anyValue >>= udeps;
+
+                if (udeps.getLength() == 0)
+                    return; // nothing todo
+                
+                ::rtl::OString xmlDependencies = ::rtl::OUStringToOString(udeps, RTL_TEXTENCODING_UNICODE);
+                
+                css::uno::Reference< css::xml::dom::XDocumentBuilder> docbuilder(
+                    manager->createInstanceWithContext(
+                        ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.dom.DocumentBuilder")),
m_context),
+                    css::uno::UNO_QUERY_THROW);
+
+                css::uno::Sequence< sal_Int8 > byteSeq((const sal_Int8*)xmlDependencies.getStr(),
xmlDependencies.getLength());
+
+                css::uno::Reference< css::io::XInputStream> inputstream( css::io::SequenceInputStream::createStreamFromSequence(m_context,
byteSeq), 
+                                                                         css::uno::UNO_QUERY_THROW);
+                
+                css::uno::Reference< css::xml::dom::XDocument > xDocument(docbuilder->parse(inputstream));
+                css::uno::Reference< css::xml::dom::XElement > xElement(xDocument->getDocumentElement());
+                css::uno::Reference< css::xml::dom::XNodeList > xDeps(xElement->getChildNodes());
+                sal_Int32 nLen = xDeps->getLength();
+
+                // get dependency node of current description info to merge the new dependencies
from the blacklist
+                css::uno::Reference< css::xml::dom::XNode > xCurrentDeps(
+                    m_xpath->selectSingleNode(m_element, ::rtl::OUString(
+                                                  RTL_CONSTASCII_USTRINGPARAM("desc:dependencies"))));
+
+                css::uno::Reference< css::xml::dom::XDocument > xCurrentDescInfo(xCurrentDeps->getOwnerDocument());
+                
+                for (sal_Int32 i=0; i<nLen; i++) {
+                    css::uno::Reference< css::xml::dom::XNode > xNode(xDeps->item(i));
+                    css::uno::Reference< css::xml::dom::XElement > xDep(xNode, css::uno::UNO_QUERY);
+                    if (xDep.is()) {
+                        // found valid blacklist dependency, import the node first and append
it to the existing dependency node
+                        css::uno::Reference< css::xml::dom::XNode > importedNode =
xCurrentDescInfo->importNode(xNode, true);
+                        xCurrentDeps->appendChild(importedNode);
+                    }
+                }
+            }
+        }
+    }
+}
+
+bool DescriptionInfoset::checkBlacklistVersion(
+    ::rtl::OUString currentversion,
+    ::com::sun::star::uno::Sequence< ::rtl::OUString > const & versions) const
+{
+    sal_Int32 nLen = versions.getLength();
+    for (sal_Int32 i=0; i<nLen; i++) {
+        if (currentversion.equals(versions[i]))
+            return true;
+    }
+
+    return false;
+}
 
 ::rtl::OUString DescriptionInfoset::getVersion() const 
 {
@@ -445,7 +550,7 @@ css::uno::Sequence< ::rtl::OUString > De
         aToken = aToken.trim();
         if (aToken.getLength())
             vec.push_back(aToken);
-     
+        
     }
     while (nIndex >= 0);
 
@@ -456,6 +561,9 @@ css::uno::Reference< css::xml::dom::XNod
 DescriptionInfoset::getDependencies() const {
     if (m_element.is()) {
         try {
+            // check the extension blacklist first and expand the dependencies if applicable
+            checkBlacklist();
+            
             return m_xpath->selectNodeList(m_element, ::rtl::OUString(
                         RTL_CONSTASCII_USTRINGPARAM("desc:dependencies/*")));
         } catch (css::xml::xpath::XPathException &) {

Added: incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/ExtensionDependencies.xcu
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/ExtensionDependencies.xcu?rev=1172098&view=auto
==============================================================================
--- incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/ExtensionDependencies.xcu
(added)
+++ incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/ExtensionDependencies.xcu
Sat Sep 17 22:36:00 2011
@@ -0,0 +1,16 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<oor:component-data xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"
+    oor:name="ExtensionDependencies" oor:package="org.openoffice.Office">
+    <node oor:name="Extensions">
+        <node oor:name="org.openoffice.bi.OracleBIConnector" oor:op="replace">
+            <prop oor:name="Versions">
+                <value>
+                    <it>1.0</it>
+                </value>
+            </prop>
+            <prop oor:name="Dependencies">
+                <value>&lt;dependencies xmlns=&quot;http://openoffice.org/extensions/description/2006&quot;&gt;&lt;OpenOffice.org-maximal-version
d:name=&quot;OpenOffice.org 3.3&quot; value="3.3"/&gt;&lt;/dependencies&gt;</value>
+            </prop>
+        </node>
+    </node>
+</oor:component-data>
\ No newline at end of file

Modified: incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/makefile.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/makefile.mk?rev=1172098&r1=1172097&r2=1172098&view=diff
==============================================================================
--- incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/makefile.mk (original)
+++ incubator/ooo/trunk/main/officecfg/registry/data/org/openoffice/Office/makefile.mk Sat
Sep 17 22:36:00 2011
@@ -43,8 +43,9 @@ XCUFILES= \
     Compatibility.xcu \
     DataAccess.xcu \
     Embedding.xcu \
+    ExtensionDependencies.xcu \
     ExtensionManager.xcu \
-	Impress.xcu	\
+    Impress.xcu	\
     Jobs.xcu \
     Labels.xcu \
     Linguistic.xcu \

Added: incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/ExtensionDependencies.xcs
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/ExtensionDependencies.xcs?rev=1172098&view=auto
==============================================================================
--- incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/ExtensionDependencies.xcs
(added)
+++ incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/ExtensionDependencies.xcs
Sat Sep 17 22:36:00 2011
@@ -0,0 +1,27 @@
+<!DOCTYPE oor:component-schema SYSTEM "../../../../component-schema.dtd">
+<oor:component-schema oor:name="ExtensionDependencies" oor:package="org.openoffice.Office"
xml:lang="en-US" xmlns:oor="http://openoffice.org/2001/registry" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+    <info>
+	<author>JSC</author>
+        <desc>Contains a list of extensions with additonal dependencies to overrule
missing dependencies in extensions
+              or to control specific extensions in general.</desc>
+    </info>
+    <templates>
+        <group oor:name="Extension">
+            <info><desc>Describes the additonal meta data for an extension whereas
the node name have to be the extension identifier.</desc></info>
+            <prop oor:name="Versions" oor:type="oor:string-list" oor:localized="false">
+                <info><desc>Specifies a list of extension versions for which
the extra dependecies should be active.</desc></info>
+            </prop>
+            <prop oor:name="Platforms" oor:type="oor:string-list" oor:localized="false">
+                <info><desc>Specifies a list of platforms for which the extra
dependencies mechanism is active.</desc></info>
+            </prop>
+            <prop oor:name="Dependencies" oor:type="xs:string" oor:localized="false">
+                <info><desc>Specifies a list of additonal dependencies.</desc></info>
+            </prop>
+	</group>
+    </templates>
+    <component>
+        <set oor:name="Extensions" oor:node-type="Extension">
+            <info><desc>Specifies the list of extensions with extra dependecies.</desc></info>
+        </set>
+    </component>
+</oor:component-schema>

Modified: incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/makefile.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/makefile.mk?rev=1172098&r1=1172097&r2=1172098&view=diff
==============================================================================
--- incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/makefile.mk (original)
+++ incubator/ooo/trunk/main/officecfg/registry/schema/org/openoffice/Office/makefile.mk Sat
Sep 17 22:36:00 2011
@@ -49,6 +49,7 @@ XCSFILES= \
     Draw.xcs \
     Events.xcs \
     Embedding.xcs \
+    ExtensionDependencies.xcs \
     ExtensionManager.xcs \
     Impress.xcs \
     Java.xcs \

Modified: incubator/ooo/trunk/main/postprocess/packregistry/makefile.mk
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/postprocess/packregistry/makefile.mk?rev=1172098&r1=1172097&r2=1172098&view=diff
==============================================================================
--- incubator/ooo/trunk/main/postprocess/packregistry/makefile.mk (original)
+++ incubator/ooo/trunk/main/postprocess/packregistry/makefile.mk Sat Sep 17 22:36:00 2011
@@ -153,6 +153,7 @@ MY_FILES_main = \
     $(MY_XCS)/Office/Embedding.xcs \
     $(MY_XCS)/Office/Events.xcs \
     $(MY_XCS)/Office/ExtendedColorScheme.xcs \
+    $(MY_XCS)/Office/ExtensionDependencies.xcs \
     $(MY_XCS)/Office/ExtensionManager.xcs \
     $(MY_XCS)/Office/FormWizard.xcs \
     $(MY_XCS)/Office/Histories.xcs \
@@ -227,6 +228,7 @@ MY_FILES_main = \
     $(MY_XCU)/Office/Common.xcu \
     $(MY_XCU)/Office/DataAccess.xcu \
     $(MY_XCU)/Office/Embedding.xcu \
+    $(MY_XCU)/Office/ExtensionDependencies.xcu \
     $(MY_XCU)/Office/ExtensionManager.xcu \
     $(MY_XCU)/Office/FormWizard.xcu \
     $(MY_XCU)/Office/Histories.xcu \



Mime
View raw message