1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <sal/config.h>
21 #include <cppuhelper/queryinterface.hxx>
23 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
26 #include "filtask.hxx"
28 using namespace fileaccess
;
29 using namespace com::sun::star
;
30 using namespace com::sun::star::ucb
;
32 #if OSL_DEBUG_LEVEL > 0
33 #define THROW_WHERE SAL_WHERE
35 #define THROW_WHERE ""
38 XCommandInfo_impl::XCommandInfo_impl( TaskManager
* pMyShell
)
39 : m_pMyShell( pMyShell
)
43 XCommandInfo_impl::~XCommandInfo_impl()
49 XCommandInfo_impl::acquire()
52 OWeakObject::acquire();
57 XCommandInfo_impl::release()
60 OWeakObject::release();
65 XCommandInfo_impl::queryInterface( const uno::Type
& rType
)
67 uno::Any aRet
= cppu::queryInterface( rType
,
68 static_cast< XCommandInfo
* >(this) );
69 return aRet
.hasValue() ? aRet
: OWeakObject::queryInterface( rType
);
73 uno::Sequence
< CommandInfo
> SAL_CALL
74 XCommandInfo_impl::getCommands()
76 return m_pMyShell
->m_sCommandInfo
;
81 XCommandInfo_impl::getCommandInfoByName(
82 const OUString
& aName
)
84 auto pCommand
= std::find_if(m_pMyShell
->m_sCommandInfo
.begin(), m_pMyShell
->m_sCommandInfo
.end(),
85 [&aName
](const CommandInfo
& rCommand
) { return rCommand
.Name
== aName
; });
86 if (pCommand
!= m_pMyShell
->m_sCommandInfo
.end())
89 throw UnsupportedCommandException( THROW_WHERE
);
94 XCommandInfo_impl::getCommandInfoByHandle(
97 auto pCommand
= std::find_if(m_pMyShell
->m_sCommandInfo
.begin(), m_pMyShell
->m_sCommandInfo
.end(),
98 [&Handle
](const CommandInfo
& rCommand
) { return rCommand
.Handle
== Handle
; });
99 if (pCommand
!= m_pMyShell
->m_sCommandInfo
.end())
102 throw UnsupportedCommandException( THROW_WHERE
);
107 XCommandInfo_impl::hasCommandByName(
108 const OUString
& aName
)
110 return std::any_of(m_pMyShell
->m_sCommandInfo
.begin(), m_pMyShell
->m_sCommandInfo
.end(),
111 [&aName
](const CommandInfo
& rCommand
) { return rCommand
.Name
== aName
; });
116 XCommandInfo_impl::hasCommandByHandle(
119 return std::any_of(m_pMyShell
->m_sCommandInfo
.begin(), m_pMyShell
->m_sCommandInfo
.end(),
120 [&Handle
](const CommandInfo
& rCommand
) { return rCommand
.Handle
== Handle
; });
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */