1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_ucbhelper.hxx" 30 31 /************************************************************************** 32 TODO 33 ************************************************************************** 34 35 *************************************************************************/ 36 37 #include "osl/diagnose.h" 38 #include "osl/mutex.hxx" 39 40 #include "ucbhelper/contentidentifier.hxx" 41 42 #include "myucp_provider.hxx" 43 #include "myucp_content.hxx" 44 45 using namespace com::sun::star; 46 47 // @@@ Adjust namespace name. 48 namespace myucp { 49 50 //========================================================================= 51 //========================================================================= 52 // 53 // ContentProvider Implementation. 54 // 55 //========================================================================= 56 //========================================================================= 57 58 ContentProvider::ContentProvider( 59 const uno::Reference< lang::XMultiServiceFactory >& rSMgr ) 60 : ::ucbhelper::ContentProviderImplHelper( rSMgr ) 61 { 62 } 63 64 //========================================================================= 65 // virtual 66 ContentProvider::~ContentProvider() 67 { 68 } 69 70 //========================================================================= 71 // 72 // XInterface methods. 73 // 74 //========================================================================= 75 76 // @@@ Add own interfaces. 77 XINTERFACE_IMPL_3( ContentProvider, 78 lang::XTypeProvider, 79 lang::XServiceInfo, 80 ucb::XContentProvider ); 81 82 //========================================================================= 83 // 84 // XTypeProvider methods. 85 // 86 //========================================================================= 87 88 // @@@ Add own interfaces. 89 XTYPEPROVIDER_IMPL_3( ContentProvider, 90 lang::XTypeProvider, 91 lang::XServiceInfo, 92 ucb::XContentProvider ); 93 94 //========================================================================= 95 // 96 // XServiceInfo methods. 97 // 98 //========================================================================= 99 100 // @@@ Adjust implementation name. Keep the prefix "com.sun.star.comp."! 101 // @@@ Adjust service name. 102 XSERVICEINFO_IMPL_1( ContentProvider, 103 rtl::OUString::createFromAscii( 104 "com.sun.star.comp.myucp.ContentProvider" ), 105 rtl::OUString::createFromAscii( 106 MYUCP_CONTENT_PROVIDER_SERVICE_NAME ) ); 107 108 //========================================================================= 109 // 110 // Service factory implementation. 111 // 112 //========================================================================= 113 114 ONE_INSTANCE_SERVICE_FACTORY_IMPL( ContentProvider ); 115 116 //========================================================================= 117 // 118 // XContentProvider methods. 119 // 120 //========================================================================= 121 122 // virtual 123 uno::Reference< ucb::XContent > SAL_CALL ContentProvider::queryContent( 124 const uno::Reference< ucb::XContentIdentifier >& Identifier ) 125 throw( ucb::IllegalIdentifierException, uno::RuntimeException ) 126 { 127 // Check URL scheme... 128 129 rtl::OUString aScheme( rtl::OUString::createFromAscii( MYUCP_URL_SCHEME ) ); 130 if ( !Identifier->getContentProviderScheme().equalsIgnoreAsciiCase( aScheme ) ) 131 throw ucb::IllegalIdentifierException(); 132 133 // @@@ Further id checks may go here... 134 #if 0 135 if ( id-check-failes ) 136 throw ucb::IllegalIdentifierException(); 137 #endif 138 139 // @@@ Id normalization may go here... 140 #if 0 141 // Normalize URL and create new Id. 142 rtl::OUString aCanonicURL = xxxxx( Identifier->getContentIdentifier() ); 143 uno::Reference< ucb::XContentIdentifier > xCanonicId 144 = new ::ucbhelper::ContentIdentifier( m_xSMgr, aCanonicURL ); 145 #else 146 uno::Reference< ucb::XContentIdentifier > xCanonicId = Identifier; 147 #endif 148 149 osl::MutexGuard aGuard( m_aMutex ); 150 151 // Check, if a content with given id already exists... 152 uno::Reference< ucb::XContent > xContent 153 = queryExistingContent( xCanonicId ).get(); 154 if ( xContent.is() ) 155 return xContent; 156 157 // @@@ Decision, which content implementation to instanciate may be 158 // made here ( in case you have different content classes ). 159 160 // Create a new content. 161 162 xContent = new Content( m_xSMgr, this, xCanonicId ); 163 registerNewContent( xContent ); 164 165 if ( !xContent->getIdentifier().is() ) 166 throw ucb::IllegalIdentifierException(); 167 168 return xContent; 169 } 170 171 } // namespace 172