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 : #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"
25 :
26 : #include <stdio.h>
27 :
28 : using namespace com::sun::star;
29 :
30 : namespace gio
31 : {
32 : uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
33 3766 : ContentProvider::queryContent(
34 : const uno::Reference<
35 : com::sun::star::ucb::XContentIdentifier >& Identifier )
36 : throw( com::sun::star::ucb::IllegalIdentifierException,
37 : uno::RuntimeException )
38 : {
39 : #if OSL_DEBUG_LEVEL > 1
40 : fprintf(stderr, "QueryContent: '%s'",
41 : OUStringToOString
42 : (Identifier->getContentIdentifier(), RTL_TEXTENCODING_UTF8).getStr());
43 : #endif
44 :
45 3766 : osl::MutexGuard aGuard( m_aMutex );
46 :
47 : // Check, if a content with given id already exists...
48 3766 : uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get();
49 3766 : if ( xContent.is() )
50 0 : return xContent;
51 :
52 : try
53 : {
54 3766 : xContent = new ::gio::Content(m_xContext, this, Identifier);
55 : }
56 0 : catch ( com::sun::star::ucb::ContentCreationException const & )
57 : {
58 0 : throw com::sun::star::ucb::IllegalIdentifierException();
59 : }
60 :
61 3766 : if ( !xContent->getIdentifier().is() )
62 0 : throw com::sun::star::ucb::IllegalIdentifierException();
63 :
64 3766 : return xContent;
65 : }
66 :
67 30 : ContentProvider::ContentProvider(
68 : const uno::Reference< uno::XComponentContext >& rxContext )
69 30 : : ::ucbhelper::ContentProviderImplHelper( rxContext )
70 : {
71 30 : }
72 :
73 60 : ContentProvider::~ContentProvider()
74 : {
75 60 : }
76 :
77 103518 : XINTERFACE_IMPL_3( ContentProvider,
78 : lang::XTypeProvider,
79 : lang::XServiceInfo,
80 : com::sun::star::ucb::XContentProvider );
81 :
82 0 : XTYPEPROVIDER_IMPL_3( ContentProvider,
83 : lang::XTypeProvider,
84 : lang::XServiceInfo,
85 : com::sun::star::ucb::XContentProvider );
86 :
87 120 : XSERVICEINFO_IMPL_1_CTX( ContentProvider,
88 : OUString( "com.sun.star.comp.GIOContentProvider" ),
89 : OUString( "com.sun.star.ucb.GIOContentProvider" ) );
90 :
91 30 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
92 :
93 : }
94 :
95 30 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL ucpgio1_component_getFactory( const sal_Char *pImplName,
96 : void *pServiceManager, void * )
97 : {
98 30 : void * pRet = 0;
99 :
100 : uno::Reference< lang::XMultiServiceFactory > xSMgr
101 30 : (reinterpret_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
102 60 : uno::Reference< lang::XSingleServiceFactory > xFactory;
103 : #if !GLIB_CHECK_VERSION(2,36,0)
104 : g_type_init();
105 : #endif
106 30 : if ( !::gio::ContentProvider::getImplementationName_Static().compareToAscii( pImplName ) )
107 30 : xFactory = ::gio::ContentProvider::createServiceFactory( xSMgr );
108 :
109 30 : if ( xFactory.is() )
110 : {
111 30 : xFactory->acquire();
112 30 : pRet = xFactory.get();
113 : }
114 :
115 60 : return pRet;
116 : }
117 :
118 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|