xref: /AOO41X/main/ucb/source/ucp/file/filid.cxx (revision 2f86921c33504fdff5a030df6c0b258927045abb)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_ucb.hxx"
26 #include "filid.hxx"
27 #include "shell.hxx"
28 
29 using namespace fileaccess;
30 using namespace com::sun::star;
31 using namespace com::sun::star::ucb;
32 
33 
FileContentIdentifier(shell * pMyShell,const rtl::OUString & aUnqPath,sal_Bool IsNormalized)34 FileContentIdentifier::FileContentIdentifier(
35     shell* pMyShell,
36     const rtl::OUString& aUnqPath,
37     sal_Bool IsNormalized )
38     : m_pMyShell( pMyShell ),
39       m_bNormalized( IsNormalized )
40 {
41     if( IsNormalized )
42     {
43         m_pMyShell->getUrlFromUnq( aUnqPath,m_aContentId );
44         m_aNormalizedId = aUnqPath;
45         m_pMyShell->getScheme( m_aProviderScheme );
46     }
47     else
48     {
49         m_pMyShell->getUnqFromUrl( aUnqPath,m_aNormalizedId );
50         m_aContentId = aUnqPath;
51         m_pMyShell->getScheme( m_aProviderScheme );
52     }
53 }
54 
~FileContentIdentifier()55 FileContentIdentifier::~FileContentIdentifier()
56 {
57 }
58 
59 
60 void SAL_CALL
acquire(void)61 FileContentIdentifier::acquire(
62     void )
63     throw()
64 {
65     OWeakObject::acquire();
66 }
67 
68 
69 void SAL_CALL
release(void)70 FileContentIdentifier::release(
71                 void )
72   throw()
73 {
74   OWeakObject::release();
75 }
76 
77 
78 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)79 FileContentIdentifier::queryInterface(
80     const uno::Type& rType )
81     throw( uno::RuntimeException )
82 {
83     uno::Any aRet = cppu::queryInterface( rType,
84                                           SAL_STATIC_CAST( lang::XTypeProvider*, this),
85                                           SAL_STATIC_CAST( XContentIdentifier*, this) );
86     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
87 }
88 
89 
90 uno::Sequence< sal_Int8 > SAL_CALL
getImplementationId()91 FileContentIdentifier::getImplementationId()
92     throw( uno::RuntimeException )
93 {
94     static cppu::OImplementationId* pId = NULL;
95     if ( !pId )
96     {
97         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
98         if ( !pId )
99         {
100             static cppu::OImplementationId id( sal_False );
101             pId = &id;
102         }
103     }
104     return (*pId).getImplementationId();
105 }
106 
107 
108 uno::Sequence< uno::Type > SAL_CALL
getTypes(void)109 FileContentIdentifier::getTypes(
110     void )
111     throw( uno::RuntimeException )
112 {
113     static cppu::OTypeCollection* pCollection = NULL;
114     if ( !pCollection ) {
115         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
116         if ( !pCollection )
117         {
118             static cppu::OTypeCollection collection(
119                 getCppuType( static_cast< uno::Reference< lang::XTypeProvider >* >( 0 ) ),
120                 getCppuType( static_cast< uno::Reference< XContentIdentifier >* >( 0 ) ) );
121             pCollection = &collection;
122         }
123     }
124     return (*pCollection).getTypes();
125 }
126 
127 
128 rtl::OUString
129 SAL_CALL
getContentIdentifier(void)130 FileContentIdentifier::getContentIdentifier(
131     void )
132     throw( uno::RuntimeException )
133 {
134     return m_aContentId;
135 }
136 
137 
138 rtl::OUString SAL_CALL
getContentProviderScheme(void)139 FileContentIdentifier::getContentProviderScheme(
140     void )
141     throw( uno::RuntimeException )
142 {
143     return m_aProviderScheme;
144 }
145