| 1 |
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 |
/* |
| 3 |
* This file is part of the LibreOffice project. |
| 4 |
* |
| 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/. |
| 8 |
* |
| 9 |
* This file incorporates work covered by the following license notice: |
| 10 |
* |
| 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 . |
| 18 |
*/ |
| 19 |
|
| 20 |
#include <sal/config.h> |
| 21 |
#include <cppuhelper/queryinterface.hxx> |
| 22 |
|
| 23 |
#include <com/sun/star/ucb/UnsupportedCommandException.hpp> |
| 24 |
|
| 25 |
#include "filcmd.hxx" |
| 26 |
#include "filtask.hxx" |
| 27 |
|
| 28 |
using namespace fileaccess; |
| 29 |
using namespace com::sun::star; |
| 30 |
using namespace com::sun::star::ucb; |
| 31 |
|
| 32 |
#if OSL_DEBUG_LEVEL > 0 |
| 33 |
#define THROW_WHERE SAL_WHERE |
| 34 |
#else |
| 35 |
#define THROW_WHERE "" |
| 36 |
#endif |
| 37 |
|
| 38 |
XCommandInfo_impl::XCommandInfo_impl( TaskManager* pMyShell ) |
| 39 |
: m_pMyShell( pMyShell ) |
| 40 |
{ |
| 41 |
} |
| 42 |
|
| 43 |
XCommandInfo_impl::~XCommandInfo_impl() |
| 44 |
{ |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
void SAL_CALL |
| 49 |
XCommandInfo_impl::acquire() |
| 50 |
noexcept |
| 51 |
{ |
| 52 |
OWeakObject::acquire(); |
| 53 |
} |
| 54 |
|
| 55 |
|
| 56 |
void SAL_CALL |
| 57 |
XCommandInfo_impl::release() |
| 58 |
noexcept |
| 59 |
{ |
| 60 |
OWeakObject::release(); |
| 61 |
} |
| 62 |
|
| 63 |
|
| 64 |
uno::Any SAL_CALL |
| 65 |
XCommandInfo_impl::queryInterface( const uno::Type& rType ) |
| 66 |
{ |
| 67 |
uno::Any aRet = cppu::queryInterface( rType, |
| 68 |
static_cast< XCommandInfo* >(this) ); |
| 69 |
return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); |
| 70 |
} |
| 71 |
|
| 72 |
|
| 73 |
uno::Sequence< CommandInfo > SAL_CALL |
| 74 |
XCommandInfo_impl::getCommands() |
| 75 |
{ |
| 76 |
return m_pMyShell->m_sCommandInfo; |
| 77 |
} |
| 78 |
|
| 79 |
|
| 80 |
CommandInfo SAL_CALL |
| 81 |
XCommandInfo_impl::getCommandInfoByName( |
| 82 |
const OUString& aName ) |
| 83 |
{ |
| 84 |
auto pCommand = std::find_if(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), |
| 85 |
[&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; }); |
| 86 |
if (pCommand != std::cend(m_pMyShell->m_sCommandInfo)) |
| 87 |
return *pCommand; |
| 88 |
|
| 89 |
throw UnsupportedCommandException( THROW_WHERE ); |
| 90 |
} |
| 91 |
|
| 92 |
|
| 93 |
CommandInfo SAL_CALL |
| 94 |
XCommandInfo_impl::getCommandInfoByHandle( |
| 95 |
sal_Int32 Handle ) |
| 96 |
{ |
| 97 |
auto pCommand = std::find_if(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), |
| 98 |
[&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; }); |
| 99 |
if (pCommand != std::cend(m_pMyShell->m_sCommandInfo)) |
| 100 |
return *pCommand; |
| 101 |
|
| 102 |
throw UnsupportedCommandException( THROW_WHERE ); |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
sal_Bool SAL_CALL |
| 107 |
XCommandInfo_impl::hasCommandByName( |
| 108 |
const OUString& aName ) |
| 109 |
{ |
| 110 |
return std::any_of(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), |
| 111 |
[&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; }); |
| 112 |
} |
| 113 |
|
| 114 |
|
| 115 |
sal_Bool SAL_CALL |
| 116 |
XCommandInfo_impl::hasCommandByHandle( |
| 117 |
sal_Int32 Handle ) |
| 118 |
{ |
| 119 |
return std::any_of(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), |
| 120 |
[&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; }); |
| 121 |
} |
| 122 |
|
| 123 |
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |