Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / ucb / source / ucp / tdoc / tdoc_documentcontentfactory.cxx
blobeadd8fcd681f20b6a2854c212852d6c4d988e8cf
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 /**************************************************************************
22 TODO
23 **************************************************************************
25 *************************************************************************/
27 #include <cppuhelper/factory.hxx>
28 #include <cppuhelper/supportsservice.hxx>
30 #include "tdoc_documentcontentfactory.hxx"
32 using namespace com::sun::star;
33 using namespace tdoc_ucp;
36 // DocumentContentFactory Implementation.
39 DocumentContentFactory::DocumentContentFactory(
40 const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
41 : m_xSMgr( xSMgr )
46 // virtual
47 DocumentContentFactory::~DocumentContentFactory()
52 // XServiceInfo methods.
55 // virtual
56 OUString SAL_CALL DocumentContentFactory::getImplementationName()
58 return getImplementationName_Static();
61 // virtual
62 sal_Bool SAL_CALL
63 DocumentContentFactory::supportsService( const OUString& ServiceName )
65 return cppu::supportsService(this, ServiceName);
68 // virtual
69 uno::Sequence< OUString > SAL_CALL
70 DocumentContentFactory::getSupportedServiceNames()
72 return getSupportedServiceNames_Static();
76 // static
77 OUString DocumentContentFactory::getImplementationName_Static()
79 return
80 "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory";
84 // static
85 uno::Sequence< OUString >
86 DocumentContentFactory::getSupportedServiceNames_Static()
88 uno::Sequence< OUString > aSNS { "com.sun.star.frame.TransientDocumentsDocumentContentFactory" };
89 return aSNS;
93 // XTransientDocumentsDocumentContentFactory methods.
96 // virtual
97 uno::Reference< ucb::XContent > SAL_CALL
98 DocumentContentFactory::createDocumentContent(
99 const uno::Reference< frame::XModel >& Model )
101 uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
104 xDocFac.set( m_xSMgr->createInstance("com.sun.star.ucb.TransientDocumentsContentProvider"),
105 uno::UNO_QUERY );
107 catch ( uno::Exception const & )
109 // handled below.
112 if ( xDocFac.is() )
113 return xDocFac->createDocumentContent( Model );
115 throw uno::RuntimeException(
116 "Unable to obtain document content factory!",
117 static_cast< cppu::OWeakObject * >( this ) );
121 // Service factory implementation.
123 /// @throws uno::Exception
124 static uno::Reference< uno::XInterface >
125 DocumentContentFactory_CreateInstance(
126 const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
128 return static_cast<lang::XServiceInfo*>(new DocumentContentFactory(rSMgr));
132 // static
133 uno::Reference< lang::XSingleServiceFactory >
134 DocumentContentFactory::createServiceFactory(
135 const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
137 return cppu::createOneInstanceFactory(
138 rxServiceMgr,
139 DocumentContentFactory::getImplementationName_Static(),
140 DocumentContentFactory_CreateInstance,
141 DocumentContentFactory::getSupportedServiceNames_Static() );
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */