1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 /**************************************************************************
23 **************************************************************************
25 *************************************************************************/
27 #include "cppuhelper/factory.hxx"
28 #include <cppuhelper/supportsservice.hxx>
30 #include "tdoc_documentcontentfactory.hxx"
32 using namespace com::sun::star
;
33 using namespace tdoc_ucp
;
38 // DocumentContentFactory Implementation.
43 DocumentContentFactory::DocumentContentFactory(
44 const uno::Reference
< lang::XMultiServiceFactory
>& xSMgr
)
51 DocumentContentFactory::~DocumentContentFactory()
57 // XServiceInfo methods.
62 OUString SAL_CALL
DocumentContentFactory::getImplementationName()
63 throw ( uno::RuntimeException
, std::exception
)
65 return getImplementationName_Static();
70 DocumentContentFactory::supportsService( const OUString
& ServiceName
)
71 throw ( uno::RuntimeException
, std::exception
)
73 return cppu::supportsService(this, ServiceName
);
77 uno::Sequence
< OUString
> SAL_CALL
78 DocumentContentFactory::getSupportedServiceNames()
79 throw ( uno::RuntimeException
, std::exception
)
81 return getSupportedServiceNames_Static();
86 OUString
DocumentContentFactory::getImplementationName_Static()
89 "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory" );
94 uno::Sequence
< OUString
>
95 DocumentContentFactory::getSupportedServiceNames_Static()
97 uno::Sequence
< OUString
> aSNS( 1 );
99 = "com.sun.star.frame.TransientDocumentsDocumentContentFactory";
105 // XTransientDocumentsDocumentContentFactory methods.
110 uno::Reference
< ucb::XContent
> SAL_CALL
111 DocumentContentFactory::createDocumentContent(
112 const uno::Reference
< frame::XModel
>& Model
)
113 throw ( lang::IllegalArgumentException
, uno::RuntimeException
, std::exception
)
115 uno::Reference
< frame::XTransientDocumentsDocumentContentFactory
> xDocFac
;
119 = uno::Reference
< frame::XTransientDocumentsDocumentContentFactory
>(
120 m_xSMgr
->createInstance(
122 "com.sun.star.ucb.TransientDocumentsContentProvider" )
126 catch ( uno::Exception
const & )
132 return xDocFac
->createDocumentContent( Model
);
134 throw uno::RuntimeException(
136 "Unable to obtain document content factory!" ),
137 static_cast< cppu::OWeakObject
* >( this ) );
142 // Service factory implementation.
146 static uno::Reference
< uno::XInterface
> SAL_CALL
147 DocumentContentFactory_CreateInstance(
148 const uno::Reference
< lang::XMultiServiceFactory
> & rSMgr
)
149 throw( uno::Exception
)
151 lang::XServiceInfo
* pX
= static_cast< lang::XServiceInfo
* >(
152 new DocumentContentFactory( rSMgr
) );
153 return uno::Reference
< uno::XInterface
>::query( pX
);
158 uno::Reference
< lang::XSingleServiceFactory
>
159 DocumentContentFactory::createServiceFactory(
160 const uno::Reference
< lang::XMultiServiceFactory
>& rxServiceMgr
)
162 return uno::Reference
< lang::XSingleServiceFactory
>(
163 cppu::createOneInstanceFactory(
165 DocumentContentFactory::getImplementationName_Static(),
166 DocumentContentFactory_CreateInstance
,
167 DocumentContentFactory::getSupportedServiceNames_Static() ) );
170 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */