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 : using namespace com::sun::star;
27 :
28 : namespace gio
29 : {
30 : uno::Reference< com::sun::star::ucb::XContent > SAL_CALL
31 3380 : 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 )
36 : {
37 : SAL_INFO("ucb.ucp.gio", "QueryContent: " << Identifier->getContentIdentifier());
38 3380 : osl::MutexGuard aGuard( m_aMutex );
39 :
40 : // Check, if a content with given id already exists...
41 3380 : uno::Reference< ucb::XContent > xContent = queryExistingContent( Identifier ).get();
42 3380 : if ( xContent.is() )
43 0 : return xContent;
44 :
45 : try
46 : {
47 3380 : xContent = new ::gio::Content(m_xContext, this, Identifier);
48 : }
49 0 : catch ( com::sun::star::ucb::ContentCreationException const & )
50 : {
51 0 : throw com::sun::star::ucb::IllegalIdentifierException();
52 : }
53 :
54 3380 : if ( !xContent->getIdentifier().is() )
55 0 : throw com::sun::star::ucb::IllegalIdentifierException();
56 :
57 3380 : return xContent;
58 : }
59 :
60 42 : ContentProvider::ContentProvider(
61 : const uno::Reference< uno::XComponentContext >& rxContext )
62 42 : : ::ucbhelper::ContentProviderImplHelper( rxContext )
63 : {
64 42 : }
65 :
66 84 : ContentProvider::~ContentProvider()
67 : {
68 84 : }
69 :
70 : // XInterface
71 41703 : void SAL_CALL ContentProvider::acquire()
72 : throw()
73 : {
74 41703 : OWeakObject::acquire();
75 41703 : }
76 :
77 41703 : void SAL_CALL ContentProvider::release()
78 : throw()
79 : {
80 41703 : OWeakObject::release();
81 41703 : }
82 :
83 3572 : css::uno::Any SAL_CALL ContentProvider::queryInterface( const css::uno::Type & rType )
84 : throw( css::uno::RuntimeException, std::exception )
85 : {
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))
90 3572 : );
91 3572 : return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
92 : }
93 :
94 0 : XTYPEPROVIDER_IMPL_3( ContentProvider,
95 : lang::XTypeProvider,
96 : lang::XServiceInfo,
97 : com::sun::star::ucb::XContentProvider );
98 :
99 172 : XSERVICEINFO_IMPL_1_CTX( ContentProvider,
100 : OUString( "com.sun.star.comp.GIOContentProvider" ),
101 : "com.sun.star.ucb.GIOContentProvider" );
102 :
103 42 : ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider );
104 :
105 : }
106 :
107 42 : extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL ucpgio1_component_getFactory( const sal_Char *pImplName,
108 : void *pServiceManager, void * )
109 : {
110 42 : void * pRet = 0;
111 :
112 : uno::Reference< lang::XMultiServiceFactory > xSMgr
113 42 : (static_cast< lang::XMultiServiceFactory * >( pServiceManager ) );
114 84 : uno::Reference< lang::XSingleServiceFactory > xFactory;
115 : #if !GLIB_CHECK_VERSION(2,36,0)
116 : g_type_init();
117 : #endif
118 42 : if ( ::gio::ContentProvider::getImplementationName_Static().equalsAscii( pImplName ) )
119 42 : xFactory = ::gio::ContentProvider::createServiceFactory( xSMgr );
120 :
121 42 : if ( xFactory.is() )
122 : {
123 42 : xFactory->acquire();
124 42 : pRet = xFactory.get();
125 : }
126 :
127 84 : return pRet;
128 : }
129 :
130 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|