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 
27 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
28 #include <cppuhelper/factory.hxx>
30 #include <rtl/ref.hxx>
31 
33 
34 using namespace com::sun::star;
35 using namespace tdoc_ucp;
36 
37 
38 // DocumentContentFactory Implementation.
39 
40 
41 DocumentContentFactory::DocumentContentFactory(
42  const uno::Reference< uno::XComponentContext >& rxContext )
43 : m_xContext( rxContext )
44 {
45 }
46 
47 
48 // virtual
50 {
51 }
52 
53 
54 // XServiceInfo methods.
55 
56 
57 // virtual
59 {
60  return "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory";
61 }
62 
63 // virtual
64 sal_Bool SAL_CALL
65 DocumentContentFactory::supportsService( const OUString& ServiceName )
66 {
67  return cppu::supportsService(this, ServiceName);
68 }
69 
70 // virtual
71 uno::Sequence< OUString > SAL_CALL
73 {
74  return { "com.sun.star.frame.TransientDocumentsDocumentContentFactory" };
75 }
76 
77 
78 // XTransientDocumentsDocumentContentFactory methods.
79 
80 
81 // virtual
82 uno::Reference< ucb::XContent > SAL_CALL
84  const uno::Reference< frame::XModel >& Model )
85 {
86  uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
87  try
88  {
89  xDocFac.set( m_xContext->getServiceManager()->createInstanceWithContext("com.sun.star.ucb.TransientDocumentsContentProvider", m_xContext),
90  uno::UNO_QUERY );
91  }
92  catch ( uno::Exception const & )
93  {
94  // handled below.
95  }
96 
97  if ( xDocFac.is() )
98  return xDocFac->createDocumentContent( Model );
99 
100  throw uno::RuntimeException(
101  "Unable to obtain document content factory!",
102  static_cast< cppu::OWeakObject * >( this ) );
103 }
104 
105 
106 // Service factory implementation.
107 
108 extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
110  css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const&)
111 {
113  g_Instance->acquire();
114  return static_cast<cppu::OWeakObject*>(g_Instance.get());
115 }
116 
117 
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Reference< css::ucb::XContent > SAL_CALL createDocumentContent(const css::uno::Reference< css::frame::XModel > &Model) override
virtual OUString SAL_CALL getImplementationName() override
css::uno::Reference< css::uno::XComponentContext > m_xContext
static rtl::Reference< UcbCommandEnvironment > g_Instance
Definition: cmdenv.cxx:37
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Reference< XComponentContext > m_xContext
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * ucb_tdoc_DocumentContentFactory_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)