Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / ucb / source / ucp / file / filcmd.cxx
bloba6f0f954cc98a0e2bcb609123a5b83391deae758
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 <sal/config.h>
21 #include <cppuhelper/queryinterface.hxx>
23 #include <com/sun/star/ucb/UnsupportedCommandException.hpp>
25 #include "filcmd.hxx"
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
34 #else
35 #define THROW_WHERE ""
36 #endif
38 XCommandInfo_impl::XCommandInfo_impl( TaskManager* pMyShell )
39 : m_pMyShell( pMyShell )
43 XCommandInfo_impl::~XCommandInfo_impl()
48 void SAL_CALL
49 XCommandInfo_impl::acquire()
50 throw()
52 OWeakObject::acquire();
56 void SAL_CALL
57 XCommandInfo_impl::release()
58 throw()
60 OWeakObject::release();
64 uno::Any SAL_CALL
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;
80 CommandInfo SAL_CALL
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())
87 return *pCommand;
89 throw UnsupportedCommandException( THROW_WHERE );
93 CommandInfo SAL_CALL
94 XCommandInfo_impl::getCommandInfoByHandle(
95 sal_Int32 Handle )
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())
100 return *pCommand;
102 throw UnsupportedCommandException( THROW_WHERE );
106 sal_Bool SAL_CALL
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; });
115 sal_Bool SAL_CALL
116 XCommandInfo_impl::hasCommandByHandle(
117 sal_Int32 Handle )
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: */