xref: /aoo42x/main/ucb/source/ucp/file/filcmd.cxx (revision 421ed02e)
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 "filcmd.hxx"
27 #include "shell.hxx"
28 #include "prov.hxx"
29 
30 
31 using namespace fileaccess;
32 using namespace com::sun::star;
33 using namespace com::sun::star::ucb;
34 
35 
XCommandInfo_impl(shell * pMyShell)36 XCommandInfo_impl::XCommandInfo_impl( shell* pMyShell )
37 	: m_pMyShell( pMyShell ),
38 	  m_xProvider( pMyShell->m_pProvider )
39 {
40 }
41 
~XCommandInfo_impl()42 XCommandInfo_impl::~XCommandInfo_impl()
43 {
44 }
45 
46 
47 
48 void SAL_CALL
acquire(void)49 XCommandInfo_impl::acquire(
50 			     void )
51   throw()
52 {
53   OWeakObject::acquire();
54 }
55 
56 
57 void SAL_CALL
release(void)58 XCommandInfo_impl::release(
59 	void )
60   throw()
61 {
62 	OWeakObject::release();
63 }
64 
65 
66 uno::Any SAL_CALL
queryInterface(const uno::Type & rType)67 XCommandInfo_impl::queryInterface(
68 				    const uno::Type& rType )
69   throw( uno::RuntimeException )
70 {
71 	uno::Any aRet = cppu::queryInterface( rType,
72 										  SAL_STATIC_CAST( XCommandInfo*,this) );
73 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
74 }
75 
76 
77 uno::Sequence< CommandInfo > SAL_CALL
getCommands(void)78 XCommandInfo_impl::getCommands(
79 	void )
80 	throw( uno::RuntimeException )
81 {
82 	return m_pMyShell->m_sCommandInfo;
83 }
84 
85 
86 CommandInfo SAL_CALL
getCommandInfoByName(const rtl::OUString & aName)87 XCommandInfo_impl::getCommandInfoByName(
88 	const rtl::OUString& aName )
89 	throw( UnsupportedCommandException,
90 		   uno::RuntimeException)
91 {
92 	for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); i++ )
93 		if( m_pMyShell->m_sCommandInfo[i].Name == aName )
94 			return m_pMyShell->m_sCommandInfo[i];
95 
96 	throw UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
97 }
98 
99 
100 CommandInfo SAL_CALL
getCommandInfoByHandle(sal_Int32 Handle)101 XCommandInfo_impl::getCommandInfoByHandle(
102 	sal_Int32 Handle )
103 	throw( UnsupportedCommandException,
104 		   uno::RuntimeException )
105 {
106 	for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
107 		if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
108 			return m_pMyShell->m_sCommandInfo[i];
109 
110 	throw UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
111 }
112 
113 
114 sal_Bool SAL_CALL
hasCommandByName(const rtl::OUString & aName)115 XCommandInfo_impl::hasCommandByName(
116 	const rtl::OUString& aName )
117 	throw( uno::RuntimeException )
118 {
119 	for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
120 		if( m_pMyShell->m_sCommandInfo[i].Name == aName )
121 			return true;
122 
123 	return false;
124 }
125 
126 
127 sal_Bool SAL_CALL
hasCommandByHandle(sal_Int32 Handle)128 XCommandInfo_impl::hasCommandByHandle(
129 	sal_Int32 Handle )
130 	throw( uno::RuntimeException )
131 {
132 	for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
133 		if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
134 			return true;
135 
136 	return false;
137 }
138