xref: /trunk/main/ucb/source/ucp/file/filid.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
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_ucb.hxx"
30 #include "filid.hxx"
31 #include "shell.hxx"
32 
33 using namespace fileaccess;
34 using namespace com::sun::star;
35 using namespace com::sun::star::ucb;
36 
37 
38 FileContentIdentifier::FileContentIdentifier(
39     shell* pMyShell,
40     const rtl::OUString& aUnqPath,
41     sal_Bool IsNormalized )
42     : m_pMyShell( pMyShell ),
43       m_bNormalized( IsNormalized )
44 {
45     if( IsNormalized )
46     {
47         m_pMyShell->getUrlFromUnq( aUnqPath,m_aContentId );
48         m_aNormalizedId = aUnqPath;
49         m_pMyShell->getScheme( m_aProviderScheme );
50     }
51     else
52     {
53         m_pMyShell->getUnqFromUrl( aUnqPath,m_aNormalizedId );
54         m_aContentId = aUnqPath;
55         m_pMyShell->getScheme( m_aProviderScheme );
56     }
57 }
58 
59 FileContentIdentifier::~FileContentIdentifier()
60 {
61 }
62 
63 
64 void SAL_CALL
65 FileContentIdentifier::acquire(
66     void )
67     throw()
68 {
69     OWeakObject::acquire();
70 }
71 
72 
73 void SAL_CALL
74 FileContentIdentifier::release(
75                 void )
76   throw()
77 {
78   OWeakObject::release();
79 }
80 
81 
82 uno::Any SAL_CALL
83 FileContentIdentifier::queryInterface(
84     const uno::Type& rType )
85     throw( uno::RuntimeException )
86 {
87     uno::Any aRet = cppu::queryInterface( rType,
88                                           SAL_STATIC_CAST( lang::XTypeProvider*, this),
89                                           SAL_STATIC_CAST( XContentIdentifier*, this) );
90     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
91 }
92 
93 
94 uno::Sequence< sal_Int8 > SAL_CALL
95 FileContentIdentifier::getImplementationId()
96     throw( uno::RuntimeException )
97 {
98     static cppu::OImplementationId* pId = NULL;
99     if ( !pId )
100     {
101         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
102         if ( !pId )
103         {
104             static cppu::OImplementationId id( sal_False );
105             pId = &id;
106         }
107     }
108     return (*pId).getImplementationId();
109 }
110 
111 
112 uno::Sequence< uno::Type > SAL_CALL
113 FileContentIdentifier::getTypes(
114     void )
115     throw( uno::RuntimeException )
116 {
117     static cppu::OTypeCollection* pCollection = NULL;
118     if ( !pCollection ) {
119         osl::Guard< osl::Mutex > aGuard( osl::Mutex::getGlobalMutex() );
120         if ( !pCollection )
121         {
122             static cppu::OTypeCollection collection(
123                 getCppuType( static_cast< uno::Reference< lang::XTypeProvider >* >( 0 ) ),
124                 getCppuType( static_cast< uno::Reference< XContentIdentifier >* >( 0 ) ) );
125             pCollection = &collection;
126         }
127     }
128     return (*pCollection).getTypes();
129 }
130 
131 
132 rtl::OUString
133 SAL_CALL
134 FileContentIdentifier::getContentIdentifier(
135     void )
136     throw( uno::RuntimeException )
137 {
138     return m_aContentId;
139 }
140 
141 
142 rtl::OUString SAL_CALL
143 FileContentIdentifier::getContentProviderScheme(
144     void )
145     throw( uno::RuntimeException )
146 {
147     return m_aProviderScheme;
148 }
149