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 <cppuhelper/factory.hxx>
29 
31 
32 using namespace com::sun::star;
33 using namespace tdoc_ucp;
34 
35 
36 // DocumentContentFactory Implementation.
37 
38 
39 DocumentContentFactory::DocumentContentFactory(
40  const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
41 : m_xSMgr( xSMgr )
42 {
43 }
44 
45 
46 // virtual
48 {
49 }
50 
51 
52 // XServiceInfo methods.
53 
54 
55 // virtual
57 {
59 }
60 
61 // virtual
62 sal_Bool SAL_CALL
63 DocumentContentFactory::supportsService( const OUString& ServiceName )
64 {
65  return cppu::supportsService(this, ServiceName);
66 }
67 
68 // virtual
69 uno::Sequence< OUString > SAL_CALL
71 {
73 }
74 
75 
76 // static
78 {
79  return
80  "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory";
81 }
82 
83 
84 // static
85 uno::Sequence< OUString >
87 {
88  uno::Sequence< OUString > aSNS { "com.sun.star.frame.TransientDocumentsDocumentContentFactory" };
89  return aSNS;
90 }
91 
92 
93 // XTransientDocumentsDocumentContentFactory methods.
94 
95 
96 // virtual
97 uno::Reference< ucb::XContent > SAL_CALL
99  const uno::Reference< frame::XModel >& Model )
100 {
101  uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
102  try
103  {
104  xDocFac.set( m_xSMgr->createInstance("com.sun.star.ucb.TransientDocumentsContentProvider"),
105  uno::UNO_QUERY );
106  }
107  catch ( uno::Exception const & )
108  {
109  // handled below.
110  }
111 
112  if ( xDocFac.is() )
113  return xDocFac->createDocumentContent( Model );
114 
115  throw uno::RuntimeException(
116  "Unable to obtain document content factory!",
117  static_cast< cppu::OWeakObject * >( this ) );
118 }
119 
120 
121 // Service factory implementation.
122 
124 static uno::Reference< uno::XInterface >
126  const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
127 {
128  return static_cast<lang::XServiceInfo*>(new DocumentContentFactory(rSMgr));
129 }
130 
131 
132 // static
133 uno::Reference< lang::XSingleServiceFactory >
135  const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
136 {
138  rxServiceMgr,
142 }
143 
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::lang::XMultiServiceFactory > m_xSMgr
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
static css::uno::Sequence< OUString > getSupportedServiceNames_Static()
static css::uno::Reference< css::lang::XSingleServiceFactory > createServiceFactory(const css::uno::Reference< css::lang::XMultiServiceFactory > &rxServiceMgr)
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
Reference< XSingleServiceFactory > SAL_CALL createOneInstanceFactory(const Reference< XMultiServiceFactory > &rServiceManager, const OUString &rImplementationName, ComponentInstantiation pCreateFunction, const Sequence< OUString > &rServiceNames, rtl_ModuleCount *)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
static uno::Reference< uno::XInterface > DocumentContentFactory_CreateInstance(const uno::Reference< lang::XMultiServiceFactory > &rSMgr)