Debian Codegraph @

ucb/source/ucp/tdoc/tdoc_documentcontentfactory.cxx

raw
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20
21 /**************************************************************************
22 TODO
23 **************************************************************************
24
25 *************************************************************************/
26
27 #include <cppuhelper/supportsservice.hxx>
28 #include <cppuhelper/weak.hxx>
29 #include <utility>
30
31 #include "tdoc_documentcontentfactory.hxx"
32
33 using namespace com::sun::star;
34 using namespace tdoc_ucp;
35
36
37 // DocumentContentFactory Implementation.
38
39
40 DocumentContentFactory::DocumentContentFactory(
41 uno::Reference< uno::XComponentContext > xContext )
42 : m_xContext(std::move( xContext ))
43 {
44 }
45
46
47 // virtual
48 DocumentContentFactory::~DocumentContentFactory()
49 {
50 }
51
52
53 // XServiceInfo methods.
54
55
56 // virtual
57 OUString SAL_CALL DocumentContentFactory::getImplementationName()
58 {
59 return u"com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory"_ustr;
60 }
61
62 // virtual
63 sal_Bool SAL_CALL
64 DocumentContentFactory::supportsService( const OUString& ServiceName )
65 {
66 return cppu::supportsService(this, ServiceName);
67 }
68
69 // virtual
70 uno::Sequence< OUString > SAL_CALL
71 DocumentContentFactory::getSupportedServiceNames()
72 {
73 return { u"com.sun.star.frame.TransientDocumentsDocumentContentFactory"_ustr };
74 }
75
76
77 // XTransientDocumentsDocumentContentFactory methods.
78
79
80 // virtual
81 uno::Reference< ucb::XContent > SAL_CALL
82 DocumentContentFactory::createDocumentContent(
83 const uno::Reference< frame::XModel >& Model )
84 {
85 uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
86 try
87 {
88 xDocFac.set( m_xContext->getServiceManager()->createInstanceWithContext(u"com.sun.star.ucb.TransientDocumentsContentProvider"_ustr, m_xContext),
89 uno::UNO_QUERY );
90 }
91 catch ( uno::Exception const & )
92 {
93 // handled below.
94 }
95
96 if ( xDocFac.is() )
97 return xDocFac->createDocumentContent( Model );
98
99 throw uno::RuntimeException(
100 u"Unable to obtain document content factory!"_ustr,
101 getXWeak() );
102 }
103
104
105 // Service factory implementation.
106
107 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
108 ucb_tdoc_DocumentContentFactory_get_implementation(
109 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
110 {
111 return cppu::acquire(new DocumentContentFactory(context));
112 }
113
114
115 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */