bump product version to 4.1.6.2
[LibreOffice.git] / ucb / source / ucp / gio / gio_provider.cxx
blob6737417c9b9d316f34f92911807347bff8856d11
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 #include <stdio.h>
28 using namespace com::sun::star;
30 namespace gio
32 uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
33 ContentProvider::queryContent(
34 const uno::Reference<
35 com::sun::star::ucb::XContentIdentifier >& Identifier )
36 throw( com::sun::star::ucb::IllegalIdentifierException,
37 uno::RuntimeException )
39 #if OSL_DEBUG_LEVEL > 1
40 fprintf(stderr, "QueryContent: '%s'",
41 OUStringToOString
42 (Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8).getStr());
43 #endif
45 osl::MutexGuard aGuard( m_aMutex );
47 // Check, if a content with given id already exists...
48 uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get();
49 if ( xContent.is() )
50 return xContent;
52 try
54 xContent = new ::gio::Content(m_xContext, this, Identifier);
56 catch ( com::sun::star::ucb::ContentCreationException const & )
58 throw com::sun::star::ucb::IllegalIdentifierException();
61 if ( !xContent->getIdentifier().is() )
62 throw com::sun::star::ucb::IllegalIdentifierException();
64 return xContent;
67 ContentProvider::ContentProvider(
68 const uno::Reference< uno::XComponentContext >& rxContext )
69 : ::ucbhelper::ContentProviderImplHelper( rxContext )
73 ContentProvider::~ContentProvider()
77 XINTERFACE_IMPL_3( ContentProvider,
78 lang::XTypeProvider,
79 lang::XServiceInfo,
80 com::sun::star::ucb::XContentProvider );
82 XTYPEPROVIDER_IMPL_3( ContentProvider,
83 lang::XTypeProvider,
84 lang::XServiceInfo,
85 com::sun::star::ucb::XContentProvider );
87 XSERVICEINFO_IMPL_1_CTX( ContentProvider,
88 OUString( "com.sun.star.comp.GIOContentProvider" ),
89 OUString( "com.sun.star.ucb.GIOContentProvider" ) );
91 ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
95 extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL ucpgio1_component_getFactory( const sal_Char *pImplName,
96 void *pServiceManager, void * )
98 void * pRet = 0;
100 uno::Reference< lang::XMultiServiceFactory > xSMgr
101 (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
102 uno::Reference< lang::XSingleServiceFactory > xFactory;
103 #if !GLIB_CHECK_VERSION(2,36,0)
104 g_type_init();
105 #endif
106 if ( !::gio::ContentProvider::getImplementationName_Static().compareToAscii( pImplName ) )
107 xFactory = ::gio::ContentProvider::createServiceFactory( xSMgr );
109 if ( xFactory.is() )
111 xFactory->acquire();
112 pRet = xFactory.get();
115 return pRet;
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */