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 <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <cppuhelper/factory.hxx>
29 #include <cppuhelper/supportsservice.hxx>
30 #include <cppuhelper/weak.hxx>
32 #include "tdoc_documentcontentfactory.hxx"
34 using namespace com::sun::star
;
35 using namespace tdoc_ucp
;
38 // DocumentContentFactory Implementation.
41 DocumentContentFactory::DocumentContentFactory(
42 const uno::Reference
< uno::XComponentContext
>& rxContext
)
43 : m_xContext( rxContext
)
49 DocumentContentFactory::~DocumentContentFactory()
54 // XServiceInfo methods.
58 OUString SAL_CALL
DocumentContentFactory::getImplementationName()
60 return "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory";
65 DocumentContentFactory::supportsService( const OUString
& ServiceName
)
67 return cppu::supportsService(this, ServiceName
);
71 uno::Sequence
< OUString
> SAL_CALL
72 DocumentContentFactory::getSupportedServiceNames()
74 return { "com.sun.star.frame.TransientDocumentsDocumentContentFactory" };
78 // XTransientDocumentsDocumentContentFactory methods.
82 uno::Reference
< ucb::XContent
> SAL_CALL
83 DocumentContentFactory::createDocumentContent(
84 const uno::Reference
< frame::XModel
>& Model
)
86 uno::Reference
< frame::XTransientDocumentsDocumentContentFactory
> xDocFac
;
89 xDocFac
.set( m_xContext
->getServiceManager()->createInstanceWithContext("com.sun.star.ucb.TransientDocumentsContentProvider", m_xContext
),
92 catch ( uno::Exception
const & )
98 return xDocFac
->createDocumentContent( Model
);
100 throw uno::RuntimeException(
101 "Unable to obtain document content factory!",
102 static_cast< cppu::OWeakObject
* >( this ) );
106 // Service factory implementation.
108 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
109 ucb_tdoc_DocumentContentFactory_get_implementation(
110 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
112 return cppu::acquire(new DocumentContentFactory(context
));
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */