xref: /aoo41x/main/ucb/source/ucp/file/filprp.cxx (revision 2f86921c)
1*2f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2f86921cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2f86921cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2f86921cSAndrew Rist  * distributed with this work for additional information
6*2f86921cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2f86921cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2f86921cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2f86921cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2f86921cSAndrew Rist  *
11*2f86921cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2f86921cSAndrew Rist  *
13*2f86921cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2f86921cSAndrew Rist  * software distributed under the License is distributed on an
15*2f86921cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2f86921cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2f86921cSAndrew Rist  * specific language governing permissions and limitations
18*2f86921cSAndrew Rist  * under the License.
19*2f86921cSAndrew Rist  *
20*2f86921cSAndrew Rist  *************************************************************/
21*2f86921cSAndrew Rist 
22*2f86921cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_ucb.hxx"
26cdf0e10cSrcweir #include "shell.hxx"
27cdf0e10cSrcweir #include "prov.hxx"
28cdf0e10cSrcweir #include "filprp.hxx"
29cdf0e10cSrcweir 
30cdf0e10cSrcweir using namespace fileaccess;
31cdf0e10cSrcweir using namespace com::sun::star;
32cdf0e10cSrcweir using namespace com::sun::star::uno;
33cdf0e10cSrcweir using namespace com::sun::star::ucb;
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir #include "filinl.hxx"
37cdf0e10cSrcweir 
38cdf0e10cSrcweir 
XPropertySetInfo_impl(shell * pMyShell,const rtl::OUString & aUnqPath)39cdf0e10cSrcweir XPropertySetInfo_impl::XPropertySetInfo_impl( shell* pMyShell,const rtl::OUString& aUnqPath )
40cdf0e10cSrcweir 	: m_pMyShell( pMyShell ),
41cdf0e10cSrcweir 	  m_xProvider( pMyShell->m_pProvider ),
42cdf0e10cSrcweir 	  m_count( 0 ),
43cdf0e10cSrcweir 	  m_seq( 0 )
44cdf0e10cSrcweir {
45cdf0e10cSrcweir 	m_pMyShell->m_pProvider->acquire();
46cdf0e10cSrcweir 
47cdf0e10cSrcweir 	shell::ContentMap::iterator it = m_pMyShell->m_aContent.find( aUnqPath );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir 	shell::PropertySet& properties = *(it->second.properties);
50cdf0e10cSrcweir 	shell::PropertySet::iterator it1 = properties.begin();
51cdf0e10cSrcweir 
52cdf0e10cSrcweir 	m_seq.realloc( properties.size() );
53cdf0e10cSrcweir 
54cdf0e10cSrcweir 	while( it1 != properties.end() )
55cdf0e10cSrcweir 	{
56cdf0e10cSrcweir 		m_seq[ m_count++ ] = beans::Property( it1->getPropertyName(),
57cdf0e10cSrcweir 											  it1->getHandle(),
58cdf0e10cSrcweir 											  it1->getType(),
59cdf0e10cSrcweir 											  it1->getAttributes() );
60cdf0e10cSrcweir 		++it1;
61cdf0e10cSrcweir 	}
62cdf0e10cSrcweir }
63cdf0e10cSrcweir 
64cdf0e10cSrcweir 
XPropertySetInfo_impl(shell * pMyShell,const Sequence<beans::Property> & seq)65cdf0e10cSrcweir XPropertySetInfo_impl::XPropertySetInfo_impl( shell* pMyShell,const Sequence< beans::Property >& seq )
66cdf0e10cSrcweir 	: m_pMyShell( pMyShell ),
67cdf0e10cSrcweir 	  m_count( seq.getLength() ),
68cdf0e10cSrcweir 	  m_seq( seq )
69cdf0e10cSrcweir {
70cdf0e10cSrcweir 	m_pMyShell->m_pProvider->acquire();
71cdf0e10cSrcweir }
72cdf0e10cSrcweir 
73cdf0e10cSrcweir 
~XPropertySetInfo_impl()74cdf0e10cSrcweir XPropertySetInfo_impl::~XPropertySetInfo_impl()
75cdf0e10cSrcweir {
76cdf0e10cSrcweir 	m_pMyShell->m_pProvider->release();
77cdf0e10cSrcweir }
78cdf0e10cSrcweir 
79cdf0e10cSrcweir 
80cdf0e10cSrcweir void SAL_CALL
acquire(void)81cdf0e10cSrcweir XPropertySetInfo_impl::acquire(
82cdf0e10cSrcweir 			      void )
83cdf0e10cSrcweir   throw()
84cdf0e10cSrcweir {
85cdf0e10cSrcweir   OWeakObject::acquire();
86cdf0e10cSrcweir }
87cdf0e10cSrcweir 
88cdf0e10cSrcweir 
89cdf0e10cSrcweir void SAL_CALL
release(void)90cdf0e10cSrcweir XPropertySetInfo_impl::release(
91cdf0e10cSrcweir 		      void )
92cdf0e10cSrcweir   throw()
93cdf0e10cSrcweir {
94cdf0e10cSrcweir   OWeakObject::release();
95cdf0e10cSrcweir }
96cdf0e10cSrcweir 
97cdf0e10cSrcweir 
98cdf0e10cSrcweir 
XTYPEPROVIDER_IMPL_2(XPropertySetInfo_impl,lang::XTypeProvider,beans::XPropertySetInfo)99cdf0e10cSrcweir XTYPEPROVIDER_IMPL_2( XPropertySetInfo_impl,
100cdf0e10cSrcweir 				   	  lang::XTypeProvider,
101cdf0e10cSrcweir 					  beans::XPropertySetInfo )
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir Any SAL_CALL
105cdf0e10cSrcweir XPropertySetInfo_impl::queryInterface(
106cdf0e10cSrcweir 				     const Type& rType )
107cdf0e10cSrcweir   throw( RuntimeException )
108cdf0e10cSrcweir {
109cdf0e10cSrcweir   Any aRet = cppu::queryInterface( rType,
110cdf0e10cSrcweir                     SAL_STATIC_CAST( lang::XTypeProvider*,this),
111cdf0e10cSrcweir 					SAL_STATIC_CAST( beans::XPropertySetInfo*,this) );
112cdf0e10cSrcweir   return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
113cdf0e10cSrcweir }
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 
116cdf0e10cSrcweir beans::Property SAL_CALL
getPropertyByName(const rtl::OUString & aName)117cdf0e10cSrcweir XPropertySetInfo_impl::getPropertyByName(
118cdf0e10cSrcweir 					 const rtl::OUString& aName )
119cdf0e10cSrcweir   throw( beans::UnknownPropertyException,
120cdf0e10cSrcweir 	 RuntimeException)
121cdf0e10cSrcweir {
122cdf0e10cSrcweir   for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
123cdf0e10cSrcweir     if( m_seq[i].Name == aName ) return m_seq[i];
124cdf0e10cSrcweir 
125cdf0e10cSrcweir   throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir 
129cdf0e10cSrcweir 
130cdf0e10cSrcweir Sequence< beans::Property > SAL_CALL
getProperties(void)131cdf0e10cSrcweir XPropertySetInfo_impl::getProperties(
132cdf0e10cSrcweir 				    void )
133cdf0e10cSrcweir   throw( RuntimeException )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir   return m_seq;
136cdf0e10cSrcweir }
137cdf0e10cSrcweir 
138cdf0e10cSrcweir 
139cdf0e10cSrcweir sal_Bool SAL_CALL
hasPropertyByName(const rtl::OUString & aName)140cdf0e10cSrcweir XPropertySetInfo_impl::hasPropertyByName(
141cdf0e10cSrcweir 					 const rtl::OUString& aName )
142cdf0e10cSrcweir   throw( RuntimeException )
143cdf0e10cSrcweir {
144cdf0e10cSrcweir   for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
145cdf0e10cSrcweir     if( m_seq[i].Name == aName ) return true;
146cdf0e10cSrcweir   return false;
147cdf0e10cSrcweir }
148