bump product version to 5.0.4.1
[LibreOffice.git] / ucb / source / ucp / gio / gio_provider.cxx
blob527f1ef0b6276147588cb45caae3fdfd6a535cc2
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 .
20 #include <ucbhelper/contentidentifier.hxx>
21 #include <ucbhelper/contenthelper.hxx>
22 #include <com/sun/star/ucb/ContentCreationException.hpp>
23 #include "gio_provider.hxx"
24 #include "gio_content.hxx"
26 using namespace com::sun::star;
28 namespace gio
30 uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
31 ContentProvider::queryContent(
32 const uno::Reference<
33 com::sun::star::ucb::XContentIdentifier >& Identifier )
34 throw( com::sun::star::ucb::IllegalIdentifierException,
35 uno::RuntimeException, std::exception )
37 SAL_INFO("ucb.ucp.gio", "QueryContent: " << Identifier->getContentIdentifier());
38 osl::MutexGuard aGuard( m_aMutex );
40 // Check, if a content with given id already exists...
41 uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get();
42 if ( xContent.is() )
43 return xContent;
45 try
47 xContent = new ::gio::Content(m_xContext, this, Identifier);
49 catch ( com::sun::star::ucb::ContentCreationException const & )
51 throw com::sun::star::ucb::IllegalIdentifierException();
54 if ( !xContent->getIdentifier().is() )
55 throw com::sun::star::ucb::IllegalIdentifierException();
57 return xContent;
60 ContentProvider::ContentProvider(
61 const uno::Reference< uno::XComponentContext >& rxContext )
62 : ::ucbhelper::ContentProviderImplHelper( rxContext )
66 ContentProvider::~ContentProvider()
70 // XInterface
71 void SAL_CALL ContentProvider::acquire()
72 throw()
74 OWeakObject::acquire();
77 void SAL_CALL ContentProvider::release()
78 throw()
80 OWeakObject::release();
83 css::uno::Any SAL_CALL ContentProvider::queryInterface( const css::uno::Type & rType )
84 throw( css::uno::RuntimeException, std::exception )
86 css::uno::Any aRet = cppu::queryInterface( rType,
87 (static_cast< lang::XTypeProvider* >(this)),
88 (static_cast< lang::XServiceInfo* >(this)),
89 (static_cast< css::ucb::XContentProvider* >(this))
91 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
94 XTYPEPROVIDER_IMPL_3( ContentProvider,
95 lang::XTypeProvider,
96 lang::XServiceInfo,
97 com::sun::star::ucb::XContentProvider );
99 XSERVICEINFO_IMPL_1_CTX( ContentProvider,
100 OUString( "com.sun.star.comp.GIOContentProvider" ),
101 "com.sun.star.ucb.GIOContentProvider" );
103 ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
107 extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL ucpgio1_component_getFactory( const sal_Char *pImplName,
108 void *pServiceManager, void * )
110 void * pRet = 0;
112 uno::Reference< lang::XMultiServiceFactory > xSMgr
113 (static_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
114 uno::Reference< lang::XSingleServiceFactory > xFactory;
115 #if !GLIB_CHECK_VERSION(2,36,0)
116 g_type_init();
117 #endif
118 if ( ::gio::ContentProvider::getImplementationName_Static().equalsAscii( pImplName ) )
119 xFactory = ::gio::ContentProvider::createServiceFactory( xSMgr );
121 if ( xFactory.is() )
123 xFactory->acquire();
124 pRet = xFactory.get();
127 return pRet;
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */