Version 4.0.2.1, tag libreoffice-4.0.2.1
[LibreOffice.git] / ucb / source / ucp / file / filcmd.cxx
blob2a570704b4b8d3815461e4c29fa6206bac3504cc
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "filcmd.hxx"
21 #include "shell.hxx"
22 #include "prov.hxx"
25 using namespace fileaccess;
26 using namespace com::sun::star;
27 using namespace com::sun::star::ucb;
30 XCommandInfo_impl::XCommandInfo_impl( shell* pMyShell )
31 : m_pMyShell( pMyShell ),
32 m_xProvider( pMyShell->m_pProvider )
36 XCommandInfo_impl::~XCommandInfo_impl()
42 void SAL_CALL
43 XCommandInfo_impl::acquire(
44 void )
45 throw()
47 OWeakObject::acquire();
51 void SAL_CALL
52 XCommandInfo_impl::release(
53 void )
54 throw()
56 OWeakObject::release();
60 uno::Any SAL_CALL
61 XCommandInfo_impl::queryInterface(
62 const uno::Type& rType )
63 throw( uno::RuntimeException )
65 uno::Any aRet = cppu::queryInterface( rType,
66 (static_cast< XCommandInfo* >(this)) );
67 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
71 uno::Sequence< CommandInfo > SAL_CALL
72 XCommandInfo_impl::getCommands(
73 void )
74 throw( uno::RuntimeException )
76 return m_pMyShell->m_sCommandInfo;
80 CommandInfo SAL_CALL
81 XCommandInfo_impl::getCommandInfoByName(
82 const rtl::OUString& aName )
83 throw( UnsupportedCommandException,
84 uno::RuntimeException)
86 for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); i++ )
87 if( m_pMyShell->m_sCommandInfo[i].Name == aName )
88 return m_pMyShell->m_sCommandInfo[i];
90 throw UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
94 CommandInfo SAL_CALL
95 XCommandInfo_impl::getCommandInfoByHandle(
96 sal_Int32 Handle )
97 throw( UnsupportedCommandException,
98 uno::RuntimeException )
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];
104 throw UnsupportedCommandException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( OSL_LOG_PREFIX ) ), uno::Reference< uno::XInterface >() );
108 sal_Bool SAL_CALL
109 XCommandInfo_impl::hasCommandByName(
110 const rtl::OUString& aName )
111 throw( uno::RuntimeException )
113 for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
114 if( m_pMyShell->m_sCommandInfo[i].Name == aName )
115 return true;
117 return false;
121 sal_Bool SAL_CALL
122 XCommandInfo_impl::hasCommandByHandle(
123 sal_Int32 Handle )
124 throw( uno::RuntimeException )
126 for( sal_Int32 i = 0; i < m_pMyShell->m_sCommandInfo.getLength(); ++i )
127 if( m_pMyShell->m_sCommandInfo[i].Handle == Handle )
128 return true;
130 return false;
133 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */