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