xref: /trunk/main/ucb/source/ucp/file/filcmd.cxx (revision 91144cd0085a7583d2099b982122deb2184ab956)
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 {
70     uno::Any aRet = cppu::queryInterface( rType,
71                                           SAL_STATIC_CAST( XCommandInfo*,this) );
72     return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
73 }
74 
75 
76 uno::Sequence< CommandInfo > SAL_CALL
getCommands(void)77 XCommandInfo_impl::getCommands(
78     void )
79 {
80     return m_pMyShell->m_sCommandInfo;
81 }
82 
83 
84 CommandInfo SAL_CALL
getCommandInfoByName(const rtl::OUString & aName)85 XCommandInfo_impl::getCommandInfoByName(
86     const rtl::OUString& aName )
87 {
88     for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); i++ )
89         if( m_pMyShell->m_sCommandInfo[i].Name == aName )
90             return m_pMyShell->m_sCommandInfo[i];
91 
92     throw UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
93 }
94 
95 
96 CommandInfo SAL_CALL
getCommandInfoByHandle(sal_Int32 Handle)97 XCommandInfo_impl::getCommandInfoByHandle(
98     sal_Int32 Handle )
99 {
100     for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
101         if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
102             return m_pMyShell->m_sCommandInfo[i];
103 
104     throw UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
105 }
106 
107 
108 sal_Bool SAL_CALL
hasCommandByName(const rtl::OUString & aName)109 XCommandInfo_impl::hasCommandByName(
110     const rtl::OUString& aName )
111 {
112     for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
113         if( m_pMyShell->m_sCommandInfo[i].Name == aName )
114             return true;
115 
116     return false;
117 }
118 
119 
120 sal_Bool SAL_CALL
hasCommandByHandle(sal_Int32 Handle)121 XCommandInfo_impl::hasCommandByHandle(
122     sal_Int32 Handle )
123 {
124     for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
125         if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
126             return true;
127 
128     return false;
129 }
130