LibreOffice Module ucb (master) 1
filcmd.cxx
Go to the documentation of this file.
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>
22
23#include <com/sun/star/ucb/UnsupportedCommandException.hpp>
24
25#include "filcmd.hxx"
26#include "filtask.hxx"
27
28using namespace fileaccess;
29using namespace com::sun::star;
30using 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
38XCommandInfo_impl::XCommandInfo_impl( TaskManager* pMyShell )
39 : m_pMyShell( pMyShell )
40{
41}
42
44{
45}
46
47
48void SAL_CALL
50 noexcept
51{
52 OWeakObject::acquire();
53}
54
55
56void SAL_CALL
58 noexcept
59{
60 OWeakObject::release();
61}
62
63
64uno::Any SAL_CALL
66{
67 uno::Any aRet = cppu::queryInterface( rType,
68 static_cast< XCommandInfo* >(this) );
69 return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
70}
71
72
73uno::Sequence< CommandInfo > SAL_CALL
75{
77}
78
79
80CommandInfo SAL_CALL
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
93CommandInfo SAL_CALL
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
106sal_Bool SAL_CALL
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
115sal_Bool SAL_CALL
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: */
css::uno::Sequence< css::ucb::CommandInfo > m_sCommandInfo
Definition: filtask.hxx:636
virtual ~XCommandInfo_impl() override
Definition: filcmd.cxx:43
virtual sal_Bool SAL_CALL hasCommandByHandle(sal_Int32 Handle) override
Definition: filcmd.cxx:116
virtual void SAL_CALL acquire() noexcept override
Definition: filcmd.cxx:49
virtual sal_Bool SAL_CALL hasCommandByName(const OUString &Name) override
Definition: filcmd.cxx:107
TaskManager * m_pMyShell
Definition: filcmd.hxx:75
virtual void SAL_CALL release() noexcept override
Definition: filcmd.cxx:57
virtual css::ucb::CommandInfo SAL_CALL getCommandInfoByHandle(sal_Int32 Handle) override
Definition: filcmd.cxx:94
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: filcmd.cxx:65
virtual css::uno::Sequence< css::ucb::CommandInfo > SAL_CALL getCommands() override
Definition: filcmd.cxx:74
virtual css::ucb::CommandInfo SAL_CALL getCommandInfoByName(const OUString &Name) override
Definition: filcmd.cxx:81
#define THROW_WHERE
Definition: filcmd.cxx:33
OUString aName
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
bool hasValue()
unsigned char sal_Bool