Update ooo320-m1
[ooovba.git] / ucb / source / ucp / tdoc / tdoc_documentcontentfactory.cxx
blob7ce9b01f953dea0cbf9e366e09e02ee10c1c6cf3
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tdoc_documentcontentfactory.cxx,v $
10 * $Revision: 1.6 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_ucb.hxx"
34 /**************************************************************************
35 TODO
36 **************************************************************************
38 *************************************************************************/
40 #include "cppuhelper/factory.hxx"
42 #include "tdoc_documentcontentfactory.hxx"
44 using namespace com::sun::star;
45 using namespace tdoc_ucp;
47 //=========================================================================
48 //=========================================================================
50 // DocumentContentFactory Implementation.
52 //=========================================================================
53 //=========================================================================
55 DocumentContentFactory::DocumentContentFactory(
56 const uno::Reference< lang::XMultiServiceFactory >& xSMgr )
57 : m_xSMgr( xSMgr )
61 //=========================================================================
62 // virtual
63 DocumentContentFactory::~DocumentContentFactory()
67 //=========================================================================
69 // XServiceInfo methods.
71 //=========================================================================
73 // virtual
74 ::rtl::OUString SAL_CALL DocumentContentFactory::getImplementationName()
75 throw ( uno::RuntimeException )
77 return getImplementationName_Static();
80 //=========================================================================
81 // virtual
82 sal_Bool SAL_CALL
83 DocumentContentFactory::supportsService( const ::rtl::OUString& ServiceName )
84 throw ( uno::RuntimeException )
86 uno::Sequence< rtl::OUString > aSNL = getSupportedServiceNames();
87 const rtl::OUString * pArray = aSNL.getConstArray();
88 for ( sal_Int32 i = 0; i < aSNL.getLength(); i++ )
90 if ( pArray[ i ] == ServiceName )
91 return sal_True;
93 return sal_False;
96 //=========================================================================
97 // virtual
98 uno::Sequence< ::rtl::OUString > SAL_CALL
99 DocumentContentFactory::getSupportedServiceNames()
100 throw ( uno::RuntimeException )
102 return getSupportedServiceNames_Static();
105 //=========================================================================
106 // static
107 rtl::OUString DocumentContentFactory::getImplementationName_Static()
109 return rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
110 "com.sun.star.comp.ucb.TransientDocumentsDocumentContentFactory" ) );
113 //=========================================================================
114 // static
115 uno::Sequence< rtl::OUString >
116 DocumentContentFactory::getSupportedServiceNames_Static()
118 uno::Sequence< rtl::OUString > aSNS( 1 );
119 aSNS.getArray()[ 0 ]
120 = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
121 "com.sun.star.frame.TransientDocumentsDocumentContentFactory" ) );
122 return aSNS;
125 //=========================================================================
127 // XTransientDocumentsDocumentContentFactory methods.
129 //=========================================================================
131 // virtual
132 uno::Reference< ucb::XContent > SAL_CALL
133 DocumentContentFactory::createDocumentContent(
134 const uno::Reference< frame::XModel >& Model )
135 throw ( lang::IllegalArgumentException, uno::RuntimeException )
137 uno::Reference< frame::XTransientDocumentsDocumentContentFactory > xDocFac;
140 xDocFac
141 = uno::Reference< frame::XTransientDocumentsDocumentContentFactory >(
142 m_xSMgr->createInstance(
143 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
144 "com.sun.star.ucb.TransientDocumentsContentProvider" ) )
146 uno::UNO_QUERY );
148 catch ( uno::Exception const & )
150 // handled below.
153 if ( xDocFac.is() )
154 return xDocFac->createDocumentContent( Model );
156 throw uno::RuntimeException(
157 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(
158 "Unable to obtain document content factory!" ) ),
159 static_cast< cppu::OWeakObject * >( this ) );
162 //=========================================================================
164 // Service factory implementation.
166 //=========================================================================
168 static uno::Reference< uno::XInterface > SAL_CALL
169 DocumentContentFactory_CreateInstance(
170 const uno::Reference< lang::XMultiServiceFactory> & rSMgr )
171 throw( uno::Exception )
173 lang::XServiceInfo * pX = static_cast< lang::XServiceInfo * >(
174 new DocumentContentFactory( rSMgr ) );
175 return uno::Reference< uno::XInterface >::query( pX );
178 //=========================================================================
179 // static
180 uno::Reference< lang::XSingleServiceFactory >
181 DocumentContentFactory::createServiceFactory(
182 const uno::Reference< lang::XMultiServiceFactory >& rxServiceMgr )
184 return uno::Reference< lang::XSingleServiceFactory >(
185 cppu::createOneInstanceFactory(
186 rxServiceMgr,
187 DocumentContentFactory::getImplementationName_Static(),
188 DocumentContentFactory_CreateInstance,
189 DocumentContentFactory::getSupportedServiceNames_Static() ) );