1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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"
28 using namespace com::sun::star
;
32 uno::Reference
< com::sun::star::ucb::XContent
> SAL_CALL
33 ContentProvider::queryContent(
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'",
42 (Identifier
->getContentIdentifier(), RTL_TEXTENCODING_UTF8
).getStr());
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();
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();
67 ContentProvider::ContentProvider(
68 const uno::Reference
< uno::XComponentContext
>& rxContext
)
69 : ::ucbhelper::ContentProviderImplHelper( rxContext
)
73 ContentProvider::~ContentProvider()
77 XINTERFACE_IMPL_3( ContentProvider
,
80 com::sun::star::ucb::XContentProvider
);
82 XTYPEPROVIDER_IMPL_3( ContentProvider
,
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 * )
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)
106 if ( !::gio::ContentProvider::getImplementationName_Static().compareToAscii( pImplName
) )
107 xFactory
= ::gio::ContentProvider::createServiceFactory( xSMgr
);
112 pRet
= xFactory
.get();
118 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */