Kaydet (Commit) 68a5b264 authored tarafından Noel Grandin's avatar Noel Grandin

fdo#46808, Use service constructor for document::DocumentProperties

Change-Id: I4be6985d5f1c7729f74b8a5ddc41024a407e770c
üst b70c3ec8
...@@ -648,10 +648,8 @@ SfxDocumentMetaData::getURLProperties( ...@@ -648,10 +648,8 @@ SfxDocumentMetaData::getURLProperties(
"com.sun.star.beans.PropertyBag"), m_xContext), "com.sun.star.beans.PropertyBag"), m_xContext),
css::uno::UNO_QUERY_THROW); css::uno::UNO_QUERY_THROW);
try { try {
OUString dburl = OUString dburl("DocumentBaseURL");
OUString("DocumentBaseURL"); OUString hdn("HierarchicalDocumentName");
OUString hdn =
OUString("HierarchicalDocumentName");
for (sal_Int32 i = 0; i < i_rMedium.getLength(); ++i) { for (sal_Int32 i = 0; i < i_rMedium.getLength(); ++i) {
if (i_rMedium[i].Name.equals(dburl)) { if (i_rMedium[i].Name.equals(dburl)) {
xPropArg->addProperty( xPropArg->addProperty(
...@@ -682,8 +680,7 @@ getNodeText(css::uno::Reference<css::xml::dom::XNode> i_xNode) ...@@ -682,8 +680,7 @@ getNodeText(css::uno::Reference<css::xml::dom::XNode> i_xNode)
throw (css::uno::RuntimeException) throw (css::uno::RuntimeException)
{ {
if (!i_xNode.is()) throw css::uno::RuntimeException( if (!i_xNode.is()) throw css::uno::RuntimeException(
OUString( OUString("SfxDocumentMetaData::getNodeText: argument is null"), i_xNode);
"SfxDocumentMetaData::getNodeText: argument is null"), i_xNode);
for (css::uno::Reference<css::xml::dom::XNode> c = i_xNode->getFirstChild(); for (css::uno::Reference<css::xml::dom::XNode> c = i_xNode->getFirstChild();
c.is(); c.is();
c = c->getNextSibling()) { c = c->getNextSibling()) {
...@@ -762,8 +759,7 @@ SfxDocumentMetaData::setMetaText(const char* i_name, ...@@ -762,8 +759,7 @@ SfxDocumentMetaData::setMetaText(const char* i_name,
} catch (const css::xml::dom::DOMException & e) { } catch (const css::xml::dom::DOMException & e) {
css::uno::Any a(e); css::uno::Any a(e);
throw css::lang::WrappedTargetRuntimeException( throw css::lang::WrappedTargetRuntimeException(
OUString( OUString("SfxDocumentMetaData::setMetaText: DOM exception"),
"SfxDocumentMetaData::setMetaText: DOM exception"),
css::uno::Reference<css::uno::XInterface>(*this), a); css::uno::Reference<css::uno::XInterface>(*this), a);
} }
} }
...@@ -899,8 +895,7 @@ SfxDocumentMetaData::setMetaList(const char* i_name, ...@@ -899,8 +895,7 @@ SfxDocumentMetaData::setMetaList(const char* i_name,
} catch (const css::xml::dom::DOMException & e) { } catch (const css::xml::dom::DOMException & e) {
css::uno::Any a(e); css::uno::Any a(e);
throw css::lang::WrappedTargetRuntimeException( throw css::lang::WrappedTargetRuntimeException(
OUString( OUString("SfxDocumentMetaData::setMetaList: DOM exception"),
"SfxDocumentMetaData::setMetaList: DOM exception"),
css::uno::Reference<css::uno::XInterface>(*this), a); css::uno::Reference<css::uno::XInterface>(*this), a);
} }
} }
...@@ -1040,8 +1035,7 @@ SfxDocumentMetaData::updateElement(const char *i_name, ...@@ -1040,8 +1035,7 @@ SfxDocumentMetaData::updateElement(const char *i_name,
} catch (const css::xml::dom::DOMException & e) { } catch (const css::xml::dom::DOMException & e) {
css::uno::Any a(e); css::uno::Any a(e);
throw css::lang::WrappedTargetRuntimeException( throw css::lang::WrappedTargetRuntimeException(
OUString( OUString("SfxDocumentMetaData::updateElement: DOM exception"),
"SfxDocumentMetaData::updateElement: DOM exception"),
css::uno::Reference<css::uno::XInterface>(*this), a); css::uno::Reference<css::uno::XInterface>(*this), a);
} }
} }
...@@ -1141,8 +1135,7 @@ void SAL_CALL SfxDocumentMetaData::init( ...@@ -1141,8 +1135,7 @@ void SAL_CALL SfxDocumentMetaData::init(
css::uno::Reference<css::xml::dom::XDocument> i_xDoc) css::uno::Reference<css::xml::dom::XDocument> i_xDoc)
{ {
if (!i_xDoc.is()) throw css::uno::RuntimeException( if (!i_xDoc.is()) throw css::uno::RuntimeException(
OUString( OUString("SfxDocumentMetaData::init: no DOM tree given"), *this);
"SfxDocumentMetaData::init: no DOM tree given"), *this);
css::uno::Reference<css::xml::xpath::XXPathAPI> xPath = css::xml::xpath::XPathAPI::create(m_xContext); css::uno::Reference<css::xml::xpath::XXPathAPI> xPath = css::xml::xpath::XPathAPI::create(m_xContext);
...@@ -1220,8 +1213,7 @@ void SAL_CALL SfxDocumentMetaData::init( ...@@ -1220,8 +1213,7 @@ void SAL_CALL SfxDocumentMetaData::init(
} catch (const css::xml::dom::DOMException & e) { } catch (const css::xml::dom::DOMException & e) {
css::uno::Any a(e); css::uno::Any a(e);
throw css::lang::WrappedTargetRuntimeException( throw css::lang::WrappedTargetRuntimeException(
OUString( OUString("SfxDocumentMetaData::init: DOM exception"),
"SfxDocumentMetaData::init: DOM exception"),
css::uno::Reference<css::uno::XInterface>(*this), a); css::uno::Reference<css::uno::XInterface>(*this), a);
} }
} }
...@@ -1703,9 +1695,8 @@ SfxDocumentMetaData::setAutoloadSecs(::sal_Int32 the_value) ...@@ -1703,9 +1695,8 @@ SfxDocumentMetaData::setAutoloadSecs(::sal_Int32 the_value)
throw (css::uno::RuntimeException, css::lang::IllegalArgumentException) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException)
{ {
if (the_value < 0) throw css::lang::IllegalArgumentException( if (the_value < 0) throw css::lang::IllegalArgumentException(
OUString( OUString("SfxDocumentMetaData::setAutoloadSecs: argument is negative"),
"SfxDocumentMetaData::setAutoloadSecs: argument is negative"), *this, 0);
*this, 0);
::osl::ClearableMutexGuard g(m_aMutex); ::osl::ClearableMutexGuard g(m_aMutex);
checkInit(); checkInit();
if (m_AutoloadSecs != the_value) { if (m_AutoloadSecs != the_value) {
...@@ -1817,9 +1808,8 @@ SfxDocumentMetaData::setEditingCycles(::sal_Int16 the_value) ...@@ -1817,9 +1808,8 @@ SfxDocumentMetaData::setEditingCycles(::sal_Int16 the_value)
throw (css::uno::RuntimeException, css::lang::IllegalArgumentException) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException)
{ {
if (the_value < 0) throw css::lang::IllegalArgumentException( if (the_value < 0) throw css::lang::IllegalArgumentException(
OUString( OUString("SfxDocumentMetaData::setEditingCycles: argument is negative"),
"SfxDocumentMetaData::setEditingCycles: argument is negative"), *this, 0);
*this, 0);
OUStringBuffer buf; OUStringBuffer buf;
::sax::Converter::convertNumber(buf, the_value); ::sax::Converter::convertNumber(buf, the_value);
setMetaTextAndNotify("meta:editing-cycles", buf.makeStringAndClear()); setMetaTextAndNotify("meta:editing-cycles", buf.makeStringAndClear());
...@@ -1837,9 +1827,8 @@ SfxDocumentMetaData::setEditingDuration(::sal_Int32 the_value) ...@@ -1837,9 +1827,8 @@ SfxDocumentMetaData::setEditingDuration(::sal_Int32 the_value)
throw (css::uno::RuntimeException, css::lang::IllegalArgumentException) throw (css::uno::RuntimeException, css::lang::IllegalArgumentException)
{ {
if (the_value < 0) throw css::lang::IllegalArgumentException( if (the_value < 0) throw css::lang::IllegalArgumentException(
OUString( OUString("SfxDocumentMetaData::setEditingDuration: argument is negative"),
"SfxDocumentMetaData::setEditingDuration: argument is negative"), *this, 0);
*this, 0);
setMetaTextAndNotify("meta:editing-duration", durationToText(the_value)); setMetaTextAndNotify("meta:editing-duration", durationToText(the_value));
} }
...@@ -1891,8 +1880,7 @@ SfxDocumentMetaData::loadFromStorage( ...@@ -1891,8 +1880,7 @@ SfxDocumentMetaData::loadFromStorage(
css::lang::WrappedTargetException, css::io::IOException) css::lang::WrappedTargetException, css::io::IOException)
{ {
if (!xStorage.is()) throw css::lang::IllegalArgumentException( if (!xStorage.is()) throw css::lang::IllegalArgumentException(
OUString("SfxDocumentMetaData::loadFromStorage:" OUString("SfxDocumentMetaData::loadFromStorage: argument is null"), *this, 0);
" argument is null"), *this, 0);
::osl::MutexGuard g(m_aMutex); ::osl::MutexGuard g(m_aMutex);
// open meta data file // open meta data file
...@@ -2060,8 +2048,7 @@ SfxDocumentMetaData::loadFromMedium(const OUString & URL, ...@@ -2060,8 +2048,7 @@ SfxDocumentMetaData::loadFromMedium(const OUString & URL,
throw; throw;
} catch (const css::uno::Exception & e) { } catch (const css::uno::Exception & e) {
throw css::lang::WrappedTargetException( throw css::lang::WrappedTargetException(
OUString( OUString("SfxDocumentMetaData::loadFromMedium: exception"),
"SfxDocumentMetaData::loadFromMedium: exception"),
css::uno::Reference<css::uno::XInterface>(*this), css::uno::Reference<css::uno::XInterface>(*this),
css::uno::makeAny(e)); css::uno::makeAny(e));
} }
...@@ -2185,8 +2172,7 @@ SfxDocumentMetaData::createClone() ...@@ -2185,8 +2172,7 @@ SfxDocumentMetaData::createClone()
} catch (const css::uno::Exception & e) { } catch (const css::uno::Exception & e) {
css::uno::Any a(e); css::uno::Any a(e);
throw css::lang::WrappedTargetRuntimeException( throw css::lang::WrappedTargetRuntimeException(
OUString( OUString("SfxDocumentMetaData::createClone: exception"),
"SfxDocumentMetaData::createClone: exception"),
css::uno::Reference<css::uno::XInterface>(*this), a); css::uno::Reference<css::uno::XInterface>(*this), a);
} }
return css::uno::Reference<css::util::XCloneable> (pNew); return css::uno::Reference<css::util::XCloneable> (pNew);
...@@ -2314,8 +2300,7 @@ void SfxDocumentMetaData::createUserDefined() ...@@ -2314,8 +2300,7 @@ void SfxDocumentMetaData::createUserDefined()
m_xContext->getServiceManager()); m_xContext->getServiceManager());
m_xUserDefined.set( m_xUserDefined.set(
xMsf->createInstanceWithContext( xMsf->createInstanceWithContext(
OUString( OUString("com.sun.star.beans.PropertyBag"), m_xContext),
"com.sun.star.beans.PropertyBag"), m_xContext),
css::uno::UNO_QUERY_THROW); css::uno::UNO_QUERY_THROW);
const css::uno::Reference<css::lang::XInitialization> xInit( const css::uno::Reference<css::lang::XInitialization> xInit(
m_xUserDefined, css::uno::UNO_QUERY); m_xUserDefined, css::uno::UNO_QUERY);
...@@ -2347,16 +2332,16 @@ void SfxDocumentMetaData::createUserDefined() ...@@ -2347,16 +2332,16 @@ void SfxDocumentMetaData::createUserDefined()
namespace comp_CompatWriterDocProps { namespace comp_CompatWriterDocProps {
OUString SAL_CALL _getImplementationName() { OUString SAL_CALL _getImplementationName() {
return OUString( return OUString("CompatWriterDocPropsImpl");
"CompatWriterDocPropsImpl"); }
}
css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames() css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames()
{ {
css::uno::Sequence< rtl::OUString > aServiceNames(1); css::uno::Sequence< rtl::OUString > aServiceNames(1);
aServiceNames[ 0 ] = rtl::OUString( "com.sun.star.writer.DocumentProperties" ); aServiceNames[ 0 ] = rtl::OUString( "com.sun.star.writer.DocumentProperties" );
return aServiceNames; return aServiceNames;
} }
css::uno::Reference< css::uno::XInterface > SAL_CALL _create( css::uno::Reference< css::uno::XInterface > SAL_CALL _create(
const css::uno::Reference< css::uno::XComponentContext > & context) const css::uno::Reference< css::uno::XComponentContext > & context)
SAL_THROW((css::uno::Exception)) SAL_THROW((css::uno::Exception))
...@@ -2366,18 +2351,17 @@ namespace comp_CompatWriterDocProps { ...@@ -2366,18 +2351,17 @@ namespace comp_CompatWriterDocProps {
} }
} }
namespace comp_SfxDocumentMetaData { namespace comp_SfxDocumentMetaData {
OUString SAL_CALL _getImplementationName() { OUString SAL_CALL _getImplementationName() {
return OUString( return OUString("SfxDocumentMetaData");
"SfxDocumentMetaData");
} }
css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames() css::uno::Sequence< OUString > SAL_CALL _getSupportedServiceNames()
{ {
css::uno::Sequence< OUString > s(1); css::uno::Sequence< OUString > s(1);
s[0] = OUString( s[0] = OUString("com.sun.star.document.DocumentProperties");
"com.sun.star.document.DocumentProperties");
return s; return s;
} }
......
...@@ -40,6 +40,7 @@ ...@@ -40,6 +40,7 @@
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/beans/XPropertySetInfo.hpp>
#include <com/sun/star/document/XTypeDetection.hpp> #include <com/sun/star/document/XTypeDetection.hpp>
#include <com/sun/star/document/DocumentProperties.hpp>
#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp> #include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
#include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/Desktop.hpp>
#include <com/sun/star/frame/XComponentLoader.hpp> #include <com/sun/star/frame/XComponentLoader.hpp>
...@@ -105,8 +106,6 @@ using ::std::advance; ...@@ -105,8 +106,6 @@ using ::std::advance;
#define TARGET_DIR_URL "TargetDirURL" #define TARGET_DIR_URL "TargetDirURL"
#define COMMAND_TRANSFER "transfer" #define COMMAND_TRANSFER "transfer"
#define SERVICENAME_DOCINFO "com.sun.star.document.DocumentProperties"
//======================================================================== //========================================================================
class RegionData_Impl; class RegionData_Impl;
...@@ -1668,11 +1667,9 @@ sal_Bool SfxDocTemplate_Impl::Construct( ) ...@@ -1668,11 +1667,9 @@ sal_Bool SfxDocTemplate_Impl::Construct( )
if ( mbConstructed ) if ( mbConstructed )
return sal_True; return sal_True;
uno::Reference< XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
uno::Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext(); uno::Reference< XComponentContext > xContext = ::comphelper::getProcessComponentContext();
OUString aService( SERVICENAME_DOCINFO ); uno::Reference< XPersist > xInfo( document::DocumentProperties::create(xContext), UNO_QUERY );
uno::Reference< XPersist > xInfo( xFactory->createInstance( aService ), UNO_QUERY );
mxInfo = xInfo; mxInfo = xInfo;
mxTemplates = frame::DocumentTemplates::create(xContext); mxTemplates = frame::DocumentTemplates::create(xContext);
...@@ -1695,7 +1692,7 @@ sal_Bool SfxDocTemplate_Impl::Construct( ) ...@@ -1695,7 +1692,7 @@ sal_Bool SfxDocTemplate_Impl::Construct( )
if ( aLongNames.Count() ) if ( aLongNames.Count() )
maStandardGroup = aLongNames.GetString( 0 ); maStandardGroup = aLongNames.GetString( 0 );
Content aTemplRoot( aRootContent, aCmdEnv, comphelper::getProcessComponentContext() ); Content aTemplRoot( aRootContent, aCmdEnv, xContext );
CreateFromHierarchy( aTemplRoot ); CreateFromHierarchy( aTemplRoot );
return sal_True; return sal_True;
......
...@@ -178,7 +178,7 @@ class SfxDocTplService_Impl ...@@ -178,7 +178,7 @@ class SfxDocTplService_Impl
{ {
uno::Reference< XMultiServiceFactory > mxFactory; uno::Reference< XMultiServiceFactory > mxFactory;
uno::Reference< XCommandEnvironment > maCmdEnv; uno::Reference< XCommandEnvironment > maCmdEnv;
uno::Reference<XDocumentProperties> m_xDocProps; uno::Reference< XDocumentProperties> m_xDocProps;
uno::Reference< XTypeDetection > mxType; uno::Reference< XTypeDetection > mxType;
::osl::Mutex maMutex; ::osl::Mutex maMutex;
...@@ -1809,12 +1809,10 @@ sal_Bool SfxDocTplService_Impl::storeTemplate( const OUString& rGroupName, ...@@ -1809,12 +1809,10 @@ sal_Bool SfxDocTplService_Impl::storeTemplate( const OUString& rGroupName,
try try
{ {
uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory(); uno::Reference< lang::XMultiServiceFactory > xFactory = ::comphelper::getProcessServiceFactory();
if ( !xFactory.is() ) uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
throw uno::RuntimeException();
// get document service name // get document service name
uno::Reference< frame::XModuleManager2 > xModuleManager( uno::Reference< frame::XModuleManager2 > xModuleManager( frame::ModuleManager::create(xContext) );
frame::ModuleManager::create(comphelper::getComponentContext(xFactory)) );
sDocServiceName = xModuleManager->identify( uno::Reference< uno::XInterface >( rStorable, uno::UNO_QUERY ) ); sDocServiceName = xModuleManager->identify( uno::Reference< uno::XInterface >( rStorable, uno::UNO_QUERY ) );
if ( sDocServiceName.isEmpty() ) if ( sDocServiceName.isEmpty() )
throw uno::RuntimeException(); throw uno::RuntimeException();
...@@ -1823,7 +1821,7 @@ sal_Bool SfxDocTplService_Impl::storeTemplate( const OUString& rGroupName, ...@@ -1823,7 +1821,7 @@ sal_Bool SfxDocTplService_Impl::storeTemplate( const OUString& rGroupName,
::rtl::OUString aFilterName; ::rtl::OUString aFilterName;
uno::Reference< lang::XMultiServiceFactory > xConfigProvider = uno::Reference< lang::XMultiServiceFactory > xConfigProvider =
configuration::theDefaultProvider::get( comphelper::getComponentContext(xFactory) ); configuration::theDefaultProvider::get( xContext );
uno::Sequence< uno::Any > aArgs( 1 ); uno::Sequence< uno::Any > aArgs( 1 );
beans::PropertyValue aPathProp; beans::PropertyValue aPathProp;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment