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 | |
parent | eb0e7f62587d957c8d7a86d1c8170e5cd7a7e029 (diff) |
fdo#46808, Adapt xml::dom::DocumentBuilder UNO service to new style
Change-Id: I577fbc7f990be9ec1f7b7eea53218b7daaccb2a1
-rw-r--r-- | desktop/source/deployment/misc/dp_descriptioninfoset.cxx | 8 | ||||
-rw-r--r-- | desktop/source/deployment/registry/dp_backenddb.cxx | 9 | ||||
-rw-r--r-- | desktop/source/migration/services/oo3extensionmigration.cxx | 137 | ||||
-rw-r--r-- | extensions/source/update/feed/updatefeed.cxx | 5 | ||||
-rw-r--r-- | filter/source/svg/svgreader.cxx | 6 | ||||
-rw-r--r-- | forms/source/xforms/submission.cxx | 6 | ||||
-rw-r--r-- | forms/source/xforms/submission/replace.cxx | 6 | ||||
-rw-r--r-- | forms/source/xforms/xmlhelper.cxx | 10 | ||||
-rw-r--r-- | offapi/UnoApi_offapi.mk | 4 | ||||
-rw-r--r-- | offapi/com/sun/star/xml/dom/DocumentBuilder.idl | 10 | ||||
-rw-r--r-- | oox/source/core/xmlfilterbase.cxx | 9 | ||||
-rw-r--r-- | sfx2/source/doc/SfxDocumentMetaData.cxx | 17 | ||||
-rw-r--r-- | unoxml/source/dom/saxbuilder.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/core/DomBuilderContext.cxx | 15 |
14 files changed, 110 insertions, 138 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; } diff --git a/extensions/source/update/feed/updatefeed.cxx b/extensions/source/update/feed/updatefeed.cxx index ae69e7c177c8..74a29e2004fd 100644 --- a/extensions/source/update/feed/updatefeed.cxx +++ b/extensions/source/update/feed/updatefeed.cxx @@ -52,7 +52,7 @@ #include <com/sun/star/ucb/OpenMode.hpp> #include <com/sun/star/sdbc/XRow.hpp> #include <com/sun/star/task/PasswordContainerInteractionHandler.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 <rtl/ref.hxx> @@ -416,8 +416,7 @@ UpdateInformationProvider::createInstance(const uno::Reference<uno::XComponentCo uno::Reference< ucb::XContentProvider > xContentProvider(xContentIdFactory, uno::UNO_QUERY_THROW); uno::Reference< xml::dom::XDocumentBuilder > xDocumentBuilder( - xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.xml.dom.DocumentBuilder" ), xContext ), - uno::UNO_QUERY_THROW); + xml::dom::DocumentBuilder::create(xContext)); uno::Reference< xml::xpath::XXPathAPI > xXPath( xServiceManager->createInstanceWithContext( UNISTRING( "com.sun.star.xml.xpath.XPathAPI" ), xContext ), diff --git a/filter/source/svg/svgreader.cxx b/filter/source/svg/svgreader.cxx index d8aee5525230..21d55ef2b81d 100644 --- a/filter/source/svg/svgreader.cxx +++ b/filter/source/svg/svgreader.cxx @@ -46,9 +46,10 @@ #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <com/sun/star/io/XSeekable.hpp> #include <com/sun/star/xml/sax/XParser.hpp> -#include <com/sun/star/xml/dom/XDocumentBuilder.hpp> +#include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <com/sun/star/xml/dom/NodeType.hpp> +#include <comphelper/componentcontext.hxx> #include <comphelper/processfactory.hxx> #include <basegfx/polygon/b2dpolygoncutandtouch.hxx> #include <basegfx/polygon/b2dpolypolygoncutter.hxx> @@ -1903,8 +1904,7 @@ SVGReader::SVGReader(const uno::Reference<lang::XMultiServiceFactory>& xServ sal_Bool SVGReader::parseAndConvert() { - uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder( - m_xServiceFactory->createInstance( "com.sun.star.xml.dom.DocumentBuilder" ), uno::UNO_QUERY_THROW ); + uno::Reference<xml::dom::XDocumentBuilder> xDomBuilder(xml::dom::DocumentBuilder::create(comphelper::ComponentContext(m_xServiceFactory).getUNOContext())); uno::Reference<xml::dom::XDocument> xDom( xDomBuilder->parse(m_xInputStream), diff --git a/forms/source/xforms/submission.cxx b/forms/source/xforms/submission.cxx index f834171c8b8f..82a239869cea 100644 --- a/forms/source/xforms/submission.cxx +++ b/forms/source/xforms/submission.cxx @@ -49,7 +49,7 @@ #include <com/sun/star/xml/xpath/XPathObjectType.hpp> #include <com/sun/star/xml/dom/XNodeList.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> -#include <com/sun/star/xml/dom/XDocumentBuilder.hpp> +#include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <com/sun/star/xml/dom/XDocumentFragment.hpp> #include <com/sun/star/xml/dom/NodeType.hpp> #include <com/sun/star/task/XInteractionHandler.hpp> @@ -58,6 +58,7 @@ #include <com/sun/star/xforms/InvalidDataOnSubmitException.hpp> #include <com/sun/star/frame/XFrame.hpp> #include <cppuhelper/typeprovider.hxx> +#include <comphelper/componentcontext.hxx> #include <comphelper/propertysetinfo.hxx> #include <comphelper/interaction.hxx> #include <comphelper/processfactory.hxx> @@ -662,8 +663,7 @@ Reference< XDocument > Submission::getInstanceDocument(const Reference< XXPathOb Reference< XDocumentFragment > Submission::createSubmissionDocument(const Reference< XXPathObject >& aObj, sal_Bool bRemoveWSNodes) { using namespace com::sun::star::xml::xpath; - Reference< XDocumentBuilder > aDocBuilder(m_aFactory->createInstance( - OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.dom.DocumentBuilder"))), UNO_QUERY); + Reference< XDocumentBuilder > aDocBuilder(DocumentBuilder::create(comphelper::ComponentContext(m_aFactory).getUNOContext())); Reference< XDocument > aDocument = aDocBuilder->newDocument(); Reference< XDocumentFragment > aFragment = aDocument->createDocumentFragment(); diff --git a/forms/source/xforms/submission/replace.cxx b/forms/source/xforms/submission/replace.cxx index 456bce53a939..9d487cc3c9e9 100644 --- a/forms/source/xforms/submission/replace.cxx +++ b/forms/source/xforms/submission/replace.cxx @@ -37,7 +37,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> -#include <com/sun/star/xml/dom/XDocumentBuilder.hpp> +#include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/beans/PropertyValue.hpp> @@ -58,6 +58,7 @@ CSubmission::SubmissionResult CSubmission::replace(const ::rtl::OUString& aRepla try { Reference< XMultiServiceFactory > xFactory = comphelper::getProcessServiceFactory(); + Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); if (aReplace.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("all")) || aReplace.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("document"))) { Reference< XComponentLoader > xLoader; @@ -85,8 +86,7 @@ CSubmission::SubmissionResult CSubmission::replace(const ::rtl::OUString& aRepla } else if (aReplace.equalsIgnoreAsciiCaseAsciiL(RTL_CONSTASCII_STRINGPARAM("instance"))) { if (aDocument.is()) { // parse the result stream into a new document - Reference< XDocumentBuilder > xBuilder(xFactory->createInstance( - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.xml.dom.DocumentBuilder") ) ), UNO_QUERY_THROW); + Reference< XDocumentBuilder > xBuilder(DocumentBuilder::create(xContext)); Reference< XDocument > aNewDocument = xBuilder->parse(m_aResultStream); if (aNewDocument.is()) { diff --git a/forms/source/xforms/xmlhelper.cxx b/forms/source/xforms/xmlhelper.cxx index c3359a307882..025bebf59cc8 100644 --- a/forms/source/xforms/xmlhelper.cxx +++ b/forms/source/xforms/xmlhelper.cxx @@ -23,12 +23,14 @@ #include "unohelper.hxx" #include <rtl/ustring.hxx> #include <com/sun/star/uno/Reference.hxx> -#include <com/sun/star/xml/dom/XDocumentBuilder.hpp> +#include <com/sun/star/xml/dom/DocumentBuilder.hpp> +#include <comphelper/processfactory.hxx> using rtl::OUString; using com::sun::star::uno::Reference; using com::sun::star::uno::UNO_QUERY_THROW; using com::sun::star::container::XNameContainer; +using com::sun::star::xml::dom::DocumentBuilder; using com::sun::star::xml::dom::XDocumentBuilder; @@ -128,11 +130,7 @@ bool isValidPrefixName( const OUString& sName, Reference<XDocumentBuilder> getDocumentBuilder() { - Reference<XDocumentBuilder> xBuilder( - xforms::createInstance( - OUSTRING("com.sun.star.xml.dom.DocumentBuilder") ), - UNO_QUERY_THROW ); - OSL_ENSURE( xBuilder.is(), "no document builder?" ); + Reference<XDocumentBuilder> xBuilder(DocumentBuilder::create(::comphelper::getProcessComponentContext())); return xBuilder; } diff --git a/offapi/UnoApi_offapi.mk b/offapi/UnoApi_offapi.mk index 3e76a42ad0c3..42c32488037d 100644 --- a/offapi/UnoApi_offapi.mk +++ b/offapi/UnoApi_offapi.mk @@ -290,6 +290,9 @@ $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/util,\ UriAbbreviation \ URLTransformer \ )) +$(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/dom,\ + DocumentBuilder \ +)) $(eval $(call gb_UnoApi_add_idlfiles_nohdl,offapi,offapi/com/sun/star/xml/sax,\ FastShapeContextHandler \ FastTokenHandler \ @@ -1528,7 +1531,6 @@ $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/xml/cry )) $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/xml/dom,\ SAXDocumentBuilder \ - DocumentBuilder \ )) $(eval $(call gb_UnoApi_add_idlfiles_noheader,offapi,offapi/com/sun/star/xml/input,\ SaxDocumentHandler \ diff --git a/offapi/com/sun/star/xml/dom/DocumentBuilder.idl b/offapi/com/sun/star/xml/dom/DocumentBuilder.idl index 41e37c45b63c..6b4bd7a1bbef 100644 --- a/offapi/com/sun/star/xml/dom/DocumentBuilder.idl +++ b/offapi/com/sun/star/xml/dom/DocumentBuilder.idl @@ -1,14 +1,16 @@ /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ + #ifndef __com_sun_star_xml_dom_documentbuilder_idl #define __com_sun_star_xml_dom_documentbuilder_idl + #include <com/sun/star/xml/dom/XDocumentBuilder.idl> + module com { module sun { module star { module xml { module dom { - service DocumentBuilder - { - interface XDocumentBuilder; - }; +service DocumentBuilder : XDocumentBuilder; + };};};};}; + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/oox/source/core/xmlfilterbase.cxx b/oox/source/core/xmlfilterbase.cxx index 2af9cb0c32d1..06773dc4be9e 100644 --- a/oox/source/core/xmlfilterbase.cxx +++ b/oox/source/core/xmlfilterbase.cxx @@ -43,7 +43,7 @@ #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XOOXMLDocumentPropertiesImporter.hpp> #include <com/sun/star/xml/dom/XDocument.hpp> -#include <com/sun/star/xml/dom/XDocumentBuilder.hpp> +#include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <comphelper/processfactory.hxx> #include <comphelper/mediadescriptor.hxx> @@ -52,6 +52,7 @@ using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::document::XOOXMLDocumentPropertiesImporter; using ::com::sun::star::document::XDocumentPropertiesSupplier; +using ::com::sun::star::xml::dom::DocumentBuilder; using ::com::sun::star::xml::dom::XDocument; using ::com::sun::star::xml::dom::XDocumentBuilder; using ::com::sun::star::xml::sax::XFastSAXSerializable; @@ -357,11 +358,7 @@ Reference<XDocument> XmlFilterBase::importFragment( const ::rtl::OUString& aFrag // create the dom parser Reference< XComponentContext > xContext = lcl_getComponentContext(getServiceFactory()); - Reference<XDocumentBuilder> xDomBuilder( - xContext->getServiceManager()->createInstanceWithContext( - ::rtl::OUString("com.sun.star.xml.dom.DocumentBuilder" ), - xContext), - UNO_QUERY_THROW ); + Reference<XDocumentBuilder> xDomBuilder( DocumentBuilder::create(xContext) ); // create DOM from fragment xRet = xDomBuilder->parse(xInStrm); diff --git a/sfx2/source/doc/SfxDocumentMetaData.cxx b/sfx2/source/doc/SfxDocumentMetaData.cxx index 5a3d543a59f3..8c717ed7c45d 100644 --- a/sfx2/source/doc/SfxDocumentMetaData.cxx +++ b/sfx2/source/doc/SfxDocumentMetaData.cxx @@ -47,7 +47,7 @@ #include "com/sun/star/xml/sax/XParser.hpp" #include "com/sun/star/xml/dom/XDocument.hpp" #include "com/sun/star/xml/dom/XElement.hpp" -#include "com/sun/star/xml/dom/XDocumentBuilder.hpp" +#include "com/sun/star/xml/dom/DocumentBuilder.hpp" #include "com/sun/star/xml/dom/XSAXDocumentBuilder.hpp" #include "com/sun/star/xml/dom/NodeType.hpp" #include "com/sun/star/xml/xpath/XXPathAPI.hpp" @@ -1116,18 +1116,9 @@ void SAL_CALL SfxDocumentMetaData::updateUserDefinedAndAttributes() css::uno::Reference<css::xml::dom::XDocument> SAL_CALL SfxDocumentMetaData::createDOM() const // throw (css::uno::RuntimeException) { - css::uno::Reference<css::lang::XMultiComponentFactory> xMsf ( - m_xContext->getServiceManager()); - css::uno::Reference<css::xml::dom::XDocumentBuilder> xBuilder( - xMsf->createInstanceWithContext(::rtl::OUString( - "com.sun.star.xml.dom.DocumentBuilder"), m_xContext), - css::uno::UNO_QUERY_THROW ); - if (!xBuilder.is()) throw css::uno::RuntimeException( - ::rtl::OUString("SfxDocumentMetaData::createDOM: " - "cannot create DocumentBuilder service"), - *const_cast<SfxDocumentMetaData*>(this)); - css::uno::Reference<css::xml::dom::XDocument> xDoc = - xBuilder->newDocument(); + css::uno::Reference<css::lang::XMultiComponentFactory> xMsf ( m_xContext->getServiceManager()); + css::uno::Reference<css::xml::dom::XDocumentBuilder> xBuilder( css::xml::dom::DocumentBuilder::create(m_xContext) ); + css::uno::Reference<css::xml::dom::XDocument> xDoc = xBuilder->newDocument(); if (!xDoc.is()) throw css::uno::RuntimeException( ::rtl::OUString("SfxDocumentMetaData::createDOM: " "cannot create new document"), diff --git a/unoxml/source/dom/saxbuilder.cxx b/unoxml/source/dom/saxbuilder.cxx index 5693be539009..a9ae0e01b5f0 100644 --- a/unoxml/source/dom/saxbuilder.cxx +++ b/unoxml/source/dom/saxbuilder.cxx @@ -22,7 +22,8 @@ #include "saxbuilder.hxx" -#include <com/sun/star/xml/dom/XDocumentBuilder.hpp> +#include <com/sun/star/xml/dom/DocumentBuilder.hpp> +#include <comphelper/componentcontext.hxx> namespace DOM @@ -166,8 +167,7 @@ namespace DOM if (!m_aState == SAXDocumentBuilderState_READY) throw SAXException(); - Reference< XDocumentBuilder > aBuilder(m_aServiceManager->createInstance( - "com.sun.star.xml.dom.DocumentBuilder"), UNO_QUERY_THROW); + Reference< XDocumentBuilder > aBuilder(DocumentBuilder::create(comphelper::ComponentContext(m_aServiceManager).getUNOContext())); Reference< XDocument > aDocument = aBuilder->newDocument(); m_aNodeStack.push(Reference< XNode >(aDocument, UNO_QUERY)); m_aDocument = aDocument; diff --git a/xmloff/source/core/DomBuilderContext.cxx b/xmloff/source/core/DomBuilderContext.cxx index 51b60cf02ba7..a8ce3bea1ea5 100644 --- a/xmloff/source/core/DomBuilderContext.cxx +++ b/xmloff/source/core/DomBuilderContext.cxx @@ -37,7 +37,7 @@ #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/xml/dom/XAttr.hpp> -#include <com/sun/star/xml/dom/XDocumentBuilder.hpp> +#include <com/sun/star/xml/dom/DocumentBuilder.hpp> #include <com/sun/star/xml/dom/XNode.hpp> #include <com/sun/star/xml/dom/XElement.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp> @@ -50,10 +50,12 @@ using com::sun::star::lang::XMultiServiceFactory; +using com::sun::star::uno::XComponentContext; using com::sun::star::uno::Reference; using com::sun::star::uno::Sequence; using com::sun::star::uno::UNO_QUERY; using com::sun::star::uno::UNO_QUERY_THROW; +using com::sun::star::xml::dom::DocumentBuilder; using com::sun::star::xml::dom::XAttr; using com::sun::star::xml::dom::XDocument; using com::sun::star::xml::dom::XDocumentBuilder; @@ -191,17 +193,12 @@ void DomBuilderContext::Characters( const OUString& rCharacters ) // helper function implementations // -const sal_Char sDocumentBuilder[] = "com.sun.star.xml.dom.DocumentBuilder"; - Reference<XNode> lcl_createDomInstance() { - Reference<XMultiServiceFactory> xFactory = comphelper::getProcessServiceFactory(); - DBG_ASSERT( xFactory.is(), "can't get service factory" ); + Reference<XComponentContext> xContext = comphelper::getProcessComponentContext(); + DBG_ASSERT( xContext.is(), "can't get service factory" ); - Reference<XDocumentBuilder> xBuilder( - xFactory->createInstance( - OUString( RTL_CONSTASCII_USTRINGPARAM( sDocumentBuilder ) ) ), - UNO_QUERY_THROW ); + Reference<XDocumentBuilder> xBuilder( DocumentBuilder::create(xContext) ); return Reference<XNode>( xBuilder->newDocument(), UNO_QUERY_THROW ); } |