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