xref: /aoo41x/main/ucb/source/ucp/file/filprp.cxx (revision cdf0e10c)
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 "shell.hxx"
31 #include "prov.hxx"
32 #include "filprp.hxx"
33 
34 using namespace fileaccess;
35 using namespace com::sun::star;
36 using namespace com::sun::star::uno;
37 using namespace com::sun::star::ucb;
38 
39 
40 #include "filinl.hxx"
41 
42 
43 XPropertySetInfo_impl::XPropertySetInfo_impl( shell* pMyShell,const rtl::OUString& aUnqPath )
44 	: m_pMyShell( pMyShell ),
45 	  m_xProvider( pMyShell->m_pProvider ),
46 	  m_count( 0 ),
47 	  m_seq( 0 )
48 {
49 	m_pMyShell->m_pProvider->acquire();
50 
51 	shell::ContentMap::iterator it = m_pMyShell->m_aContent.find( aUnqPath );
52 
53 	shell::PropertySet& properties = *(it->second.properties);
54 	shell::PropertySet::iterator it1 = properties.begin();
55 
56 	m_seq.realloc( properties.size() );
57 
58 	while( it1 != properties.end() )
59 	{
60 		m_seq[ m_count++ ] = beans::Property( it1->getPropertyName(),
61 											  it1->getHandle(),
62 											  it1->getType(),
63 											  it1->getAttributes() );
64 		++it1;
65 	}
66 }
67 
68 
69 XPropertySetInfo_impl::XPropertySetInfo_impl( shell* pMyShell,const Sequence< beans::Property >& seq )
70 	: m_pMyShell( pMyShell ),
71 	  m_count( seq.getLength() ),
72 	  m_seq( seq )
73 {
74 	m_pMyShell->m_pProvider->acquire();
75 }
76 
77 
78 XPropertySetInfo_impl::~XPropertySetInfo_impl()
79 {
80 	m_pMyShell->m_pProvider->release();
81 }
82 
83 
84 void SAL_CALL
85 XPropertySetInfo_impl::acquire(
86 			      void )
87   throw()
88 {
89   OWeakObject::acquire();
90 }
91 
92 
93 void SAL_CALL
94 XPropertySetInfo_impl::release(
95 		      void )
96   throw()
97 {
98   OWeakObject::release();
99 }
100 
101 
102 
103 XTYPEPROVIDER_IMPL_2( XPropertySetInfo_impl,
104 				   	  lang::XTypeProvider,
105 					  beans::XPropertySetInfo )
106 
107 
108 Any SAL_CALL
109 XPropertySetInfo_impl::queryInterface(
110 				     const Type& rType )
111   throw( RuntimeException )
112 {
113   Any aRet = cppu::queryInterface( rType,
114                     SAL_STATIC_CAST( lang::XTypeProvider*,this),
115 					SAL_STATIC_CAST( beans::XPropertySetInfo*,this) );
116   return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
117 }
118 
119 
120 beans::Property SAL_CALL
121 XPropertySetInfo_impl::getPropertyByName(
122 					 const rtl::OUString& aName )
123   throw( beans::UnknownPropertyException,
124 	 RuntimeException)
125 {
126   for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
127     if( m_seq[i].Name == aName ) return m_seq[i];
128 
129   throw beans::UnknownPropertyException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
130 }
131 
132 
133 
134 Sequence< beans::Property > SAL_CALL
135 XPropertySetInfo_impl::getProperties(
136 				    void )
137   throw( RuntimeException )
138 {
139   return m_seq;
140 }
141 
142 
143 sal_Bool SAL_CALL
144 XPropertySetInfo_impl::hasPropertyByName(
145 					 const rtl::OUString& aName )
146   throw( RuntimeException )
147 {
148   for( sal_Int32 i = 0; i < m_seq.getLength(); ++i )
149     if( m_seq[i].Name == aName ) return true;
150   return false;
151 }
152