Line data Source code
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"
28 : #include <cppuhelper/supportsservice.hxx>
29 :
30 : #include "tdoc_documentcontentfactory.hxx"
31 :
32 : using namespace com::sun::star;
33 : using namespace tdoc_ucp;
34 :
35 :
36 :
37 :
38 : // DocumentContentFactory Implementation.
39 :
40 :
41 :
42 :
43 13 : DocumentContentFactory::DocumentContentFactory(
44 : const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
45 13 : : m_xSMgr( xSMgr )
46 : {
47 13 : }
48 :
49 :
50 : // virtual
51 24 : DocumentContentFactory::~DocumentContentFactory()
52 : {
53 24 : }
54 :
55 :
56 :
57 : // XServiceInfo methods.
58 :
59 :
60 :
61 : // virtual
62 1 : OUString SAL_CALL DocumentContentFactory::getImplementationName()
63 : throw ( uno::RuntimeException, std::exception )
64 : {
65 1 : return getImplementationName_Static();
66 : }
67 :
68 : // virtual
69 : sal_Bool SAL_CALL
70 0 : DocumentContentFactory::supportsService( const OUString& ServiceName )
71 : throw ( uno::RuntimeException, std::exception )
72 : {
73 0 : return cppu::supportsService(this, ServiceName);
74 : }
75 :
76 : // virtual
77 : uno::Sequence< OUString > SAL_CALL
78 1 : DocumentContentFactory::getSupportedServiceNames()
79 : throw ( uno::RuntimeException, std::exception )
80 : {
81 1 : return getSupportedServiceNames_Static();
82 : }
83 :
84 :
85 : // static
86 27 : OUString DocumentContentFactory::getImplementationName_Static()
87 : {
88 : return OUString(
89 27 : "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory" );
90 : }
91 :
92 :
93 : // static
94 : uno::Sequence< OUString >
95 14 : DocumentContentFactory::getSupportedServiceNames_Static()
96 : {
97 14 : uno::Sequence< OUString > aSNS( 1 );
98 : aSNS.getArray()[ 0 ]
99 14 : = "com.sun.star.frame.TransientDocumentsDocumentContentFactory";
100 14 : return aSNS;
101 : }
102 :
103 :
104 :
105 : // XTransientDocumentsDocumentContentFactory methods.
106 :
107 :
108 :
109 : // virtual
110 : uno::Reference< ucb::XContent > SAL_CALL
111 157 : DocumentContentFactory::createDocumentContent(
112 : const uno::Reference< frame::XModel >& Model )
113 : throw ( lang::IllegalArgumentException, uno::RuntimeException, std::exception )
114 : {
115 157 : uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
116 : try
117 : {
118 : xDocFac
119 314 : = uno::Reference< frame::XTransientDocumentsDocumentContentFactory >(
120 157 : m_xSMgr->createInstance(
121 : OUString(
122 : "com.sun.star.ucb.TransientDocumentsContentProvider" )
123 157 : ),
124 157 : uno::UNO_QUERY );
125 : }
126 0 : catch ( uno::Exception const & )
127 : {
128 : // handled below.
129 : }
130 :
131 157 : if ( xDocFac.is() )
132 314 : return xDocFac->createDocumentContent( Model );
133 :
134 : throw uno::RuntimeException(
135 : OUString(
136 : "Unable to obtain document content factory!" ),
137 0 : static_cast< cppu::OWeakObject * >( this ) );
138 : }
139 :
140 :
141 :
142 : // Service factory implementation.
143 :
144 :
145 :
146 : static uno::Reference< uno::XInterface > SAL_CALL
147 13 : DocumentContentFactory_CreateInstance(
148 : const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
149 : throw( uno::Exception )
150 : {
151 : lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
152 13 : new DocumentContentFactory( rSMgr ) );
153 13 : return uno::Reference< uno::XInterface >::query( pX );
154 : }
155 :
156 :
157 : // static
158 : uno::Reference< lang::XSingleServiceFactory >
159 13 : DocumentContentFactory::createServiceFactory(
160 : const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
161 : {
162 : return uno::Reference< lang::XSingleServiceFactory >(
163 : cppu::createOneInstanceFactory(
164 : rxServiceMgr,
165 : DocumentContentFactory::getImplementationName_Static(),
166 : DocumentContentFactory_CreateInstance,
167 13 : DocumentContentFactory::getSupportedServiceNames_Static() ) );
168 : }
169 :
170 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|