diff options
author | Noel Grandin <noel@peralex.com> | 2012-08-23 18:23:43 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2012-09-03 15:55:04 +0200 |
commit | 9b07288138228af56e58f50dc6ba50865b52fdfb (patch) | |
tree | 2bde7ca61824f7266c70a404be6049fba26d8c98 /desktop | |
parent | Explicit rtl::OUString ctors no longer needed (diff) | |
download | core-9b07288138228af56e58f50dc6ba50865b52fdfb.tar.gz core-9b07288138228af56e58f50dc6ba50865b52fdfb.zip |
fdo#46808, Adapt xml::dom::DocumentBuilder UNO service to new style
Change-Id: I577fbc7f990be9ec1f7b7eea53218b7daaccb2a1
Diffstat (limited to 'desktop')
3 files changed, 70 insertions, 84 deletions
diff --git a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx index 1a5a43a518a2..c63744bba0cb 100644 --- a/desktop/source/deployment/misc/dp_descriptioninfoset.cxx +++ b/desktop/source/deployment/misc/dp_descriptioninfoset.cxx @@ -47,7 +47,7 @@ #include "com/sun/star/xml/dom/DOMException.hpp" #include "com/sun/star/xml/dom/XNode.hpp" #include "com/sun/star/xml/dom/XNodeList.hpp" -#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/dom/DocumentBuilder.hpp" #include "com/sun/star/xml/xpath/XXPathAPI.hpp" #include "com/sun/star/ucb/InteractiveIOException.hpp" #include "cppuhelper/implbase1.hxx" @@ -224,11 +224,7 @@ ExtensionDescription::ExtensionDescription( //get root node of description.xml Reference<css::xml::dom::XDocumentBuilder> xDocBuilder( - xContext->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.xml.dom.DocumentBuilder"), - xContext ), css::uno::UNO_QUERY); - if (!xDocBuilder.is()) - throw css::uno::Exception(OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0); + css::xml::dom::DocumentBuilder::create(xContext) ); if (xDocBuilder->isNamespaceAware() == sal_False) { diff --git a/desktop/source/deployment/registry/dp_backenddb.cxx b/desktop/source/deployment/registry/dp_backenddb.cxx index 1d0686014c8c..4616c2a82aee 100644 --- a/desktop/source/deployment/registry/dp_backenddb.cxx +++ b/desktop/source/deployment/registry/dp_backenddb.cxx @@ -33,7 +33,7 @@ #include "cppuhelper/exc_hlp.hxx" #include "osl/file.hxx" #include "com/sun/star/uno/XComponentContext.hpp" -#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/dom/DocumentBuilder.hpp" #include "com/sun/star/xml/xpath/XXPathAPI.hpp" #include "com/sun/star/io/XActiveDataSource.hpp" #include "com/sun/star/io/XActiveDataControl.hpp" @@ -79,12 +79,7 @@ css::uno::Reference<css::xml::dom::XDocument> BackendDb::getDocument() if (!m_doc.is()) { const Reference<css::xml::dom::XDocumentBuilder> xDocBuilder( - m_xContext->getServiceManager()->createInstanceWithContext( - OUSTR("com.sun.star.xml.dom.DocumentBuilder"), - m_xContext ), css::uno::UNO_QUERY); - if (!xDocBuilder.is()) - throw css::uno::RuntimeException( - OUSTR(" Could not create service com.sun.star.xml.dom.DocumentBuilder"), 0); + css::xml::dom::DocumentBuilder::create(m_xContext) ); ::osl::DirectoryItem item; ::osl::File::RC err = ::osl::DirectoryItem::get(m_urlDb, item); diff --git a/desktop/source/migration/services/oo3extensionmigration.cxx b/desktop/source/migration/services/oo3extensionmigration.cxx index 726f6a5c85cc..e32392b4ee78 100644 --- a/desktop/source/migration/services/oo3extensionmigration.cxx +++ b/desktop/source/migration/services/oo3extensionmigration.cxx @@ -46,6 +46,7 @@ #include <com/sun/star/ucb/NameClash.hpp> #include <com/sun/star/ucb/XCommandEnvironment.hpp> #include <com/sun/star/xml/xpath/XXPathAPI.hpp> +#include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <com/sun/star/beans/NamedValue.hpp> #include <com/sun/star/deployment/ExtensionManager.hpp> @@ -211,10 +212,7 @@ bool OO3ExtensionMigration::scanDescriptionXml( const ::rtl::OUString& sDescript { if ( !m_xDocBuilder.is() ) { - m_xDocBuilder = uno::Reference< xml::dom::XDocumentBuilder >( - m_ctx->getServiceManager()->createInstanceWithContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.dom.DocumentBuilder")), - m_ctx ), uno::UNO_QUERY ); + m_xDocBuilder = uno::Reference< xml::dom::XDocumentBuilder >( xml::dom::DocumentBuilder::create(m_ctx) ); } if ( !m_xSimpleFileAccess.is() ) @@ -223,94 +221,91 @@ bool OO3ExtensionMigration::scanDescriptionXml( const ::rtl::OUString& sDescript } ::rtl::OUString aExtIdentifier; - if ( m_xDocBuilder.is() && m_xSimpleFileAccess.is() ) + try { - try - { - uno::Reference< io::XInputStream > xIn = - m_xSimpleFileAccess->openFileRead( sDescriptionXmlURL ); + uno::Reference< io::XInputStream > xIn = + m_xSimpleFileAccess->openFileRead( sDescriptionXmlURL ); - if ( xIn.is() ) + if ( xIn.is() ) + { + uno::Reference< xml::dom::XDocument > xDoc = m_xDocBuilder->parse( xIn ); + if ( xDoc.is() ) { - uno::Reference< xml::dom::XDocument > xDoc = m_xDocBuilder->parse( xIn ); - if ( xDoc.is() ) + uno::Reference< xml::dom::XElement > xRoot = xDoc->getDocumentElement(); + if ( xRoot.is() && xRoot->getTagName() == "description" ) { - uno::Reference< xml::dom::XElement > xRoot = xDoc->getDocumentElement(); - if ( xRoot.is() && xRoot->getTagName() == "description" ) + uno::Reference< xml::xpath::XXPathAPI > xPath( + m_ctx->getServiceManager()->createInstanceWithContext( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.xpath.XPathAPI")), + m_ctx), + uno::UNO_QUERY); + + xPath->registerNS( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("desc")), + xRoot->getNamespaceURI()); + xPath->registerNS( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("xlink")), + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http://www.w3.org/1999/xlink"))); + + try + { + uno::Reference< xml::dom::XNode > xRootNode( xRoot, uno::UNO_QUERY ); + uno::Reference< xml::dom::XNode > xNode( + xPath->selectSingleNode( + xRootNode, + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("desc:identifier/@value")) )); + if ( xNode.is() ) + aExtIdentifier = xNode->getNodeValue(); + } + catch ( const xml::xpath::XPathException& ) + { + } + catch ( const xml::dom::DOMException& ) { - uno::Reference< xml::xpath::XXPathAPI > xPath( - m_ctx->getServiceManager()->createInstanceWithContext( - ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.xml.xpath.XPathAPI")), - m_ctx), - uno::UNO_QUERY); - - xPath->registerNS( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("desc")), - xRoot->getNamespaceURI()); - xPath->registerNS( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("xlink")), - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("http://www.w3.org/1999/xlink"))); - - try - { - uno::Reference< xml::dom::XNode > xRootNode( xRoot, uno::UNO_QUERY ); - uno::Reference< xml::dom::XNode > xNode( - xPath->selectSingleNode( - xRootNode, - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("desc:identifier/@value")) )); - if ( xNode.is() ) - aExtIdentifier = xNode->getNodeValue(); - } - catch ( const xml::xpath::XPathException& ) - { - } - catch ( const xml::dom::DOMException& ) - { - } } } } - - if ( !aExtIdentifier.isEmpty() ) - { - // scan extension identifier and try to match with our black list entries - for ( sal_uInt32 i = 0; i < m_aBlackList.size(); i++ ) - { - utl::SearchParam param(m_aBlackList[i], utl::SearchParam::SRCH_REGEXP); - utl::TextSearch ts(param, LANGUAGE_DONTKNOW); - - xub_StrLen start = 0; - xub_StrLen end = static_cast<sal_uInt16>(aExtIdentifier.getLength()); - if (ts.SearchFrwrd(aExtIdentifier, &start, &end)) - return false; - } - } - } - catch ( const ucb::CommandAbortedException& ) - { - } - catch ( const uno::RuntimeException& ) - { } - if ( aExtIdentifier.isEmpty() ) + if ( !aExtIdentifier.isEmpty() ) { - // Fallback: - // Try to use the folder name to match our black list - // as some extensions don't provide an identifier in the - // description.xml! + // scan extension identifier and try to match with our black list entries for ( sal_uInt32 i = 0; i < m_aBlackList.size(); i++ ) { utl::SearchParam param(m_aBlackList[i], utl::SearchParam::SRCH_REGEXP); utl::TextSearch ts(param, LANGUAGE_DONTKNOW); xub_StrLen start = 0; - xub_StrLen end = static_cast<sal_uInt16>(sDescriptionXmlURL.getLength()); - if (ts.SearchFrwrd(sDescriptionXmlURL, &start, &end)) + xub_StrLen end = static_cast<sal_uInt16>(aExtIdentifier.getLength()); + if (ts.SearchFrwrd(aExtIdentifier, &start, &end)) return false; } } } + catch ( const ucb::CommandAbortedException& ) + { + } + catch ( const uno::RuntimeException& ) + { + } + + if ( aExtIdentifier.isEmpty() ) + { + // Fallback: + // Try to use the folder name to match our black list + // as some extensions don't provide an identifier in the + // description.xml! + for ( sal_uInt32 i = 0; i < m_aBlackList.size(); i++ ) + { + utl::SearchParam param(m_aBlackList[i], utl::SearchParam::SRCH_REGEXP); + utl::TextSearch ts(param, LANGUAGE_DONTKNOW); + + xub_StrLen start = 0; + xub_StrLen end = static_cast<sal_uInt16>(sDescriptionXmlURL.getLength()); + if (ts.SearchFrwrd(sDescriptionXmlURL, &start, &end)) + return false; + } + } return true; } |