LibreOffice Module ucb (master) 1
tdoc_documentcontentfactory.cxx
Go to the documentation of this file.
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
28#include <cppuhelper/weak.hxx>
29#include <utility>
30
32
33using namespace com::sun::star;
34using namespace tdoc_ucp;
35
36
37// DocumentContentFactory Implementation.
38
39
40DocumentContentFactory::DocumentContentFactory(
41 uno::Reference< uno::XComponentContext > xContext )
42: m_xContext(std::move( xContext ))
43{
44}
45
46
47// virtual
49{
50}
51
52
53// XServiceInfo methods.
54
55
56// virtual
58{
59 return "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory";
60}
61
62// virtual
63sal_Bool SAL_CALL
64DocumentContentFactory::supportsService( const OUString& ServiceName )
65{
67}
68
69// virtual
70uno::Sequence< OUString > SAL_CALL
72{
73 return { "com.sun.star.frame.TransientDocumentsDocumentContentFactory" };
74}
75
76
77// XTransientDocumentsDocumentContentFactory methods.
78
79
80// virtual
81uno::Reference< ucb::XContent > SAL_CALL
83 const uno::Reference< frame::XModel >& Model )
84{
85 uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
86 try
87 {
88 xDocFac.set( m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.ucb.TransientDocumentsContentProvider", 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 "Unable to obtain document content factory!",
101 getXWeak() );
102}
103
104
105// Service factory implementation.
106
107extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
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: */
Reference< XComponentContext > m_xContext
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createDocumentContent(const css::uno::Reference< css::frame::XModel > &Model) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_tdoc_DocumentContentFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
unsigned char sal_Bool