/src/libreoffice/ucb/source/ucp/file/filcmd.cxx
Line | Count | Source |
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 | | XCommandInfo_impl::XCommandInfo_impl( TaskManager* pMyShell ) |
33 | 0 | : m_pMyShell( pMyShell ) |
34 | 0 | { |
35 | 0 | } |
36 | | |
37 | | XCommandInfo_impl::~XCommandInfo_impl() |
38 | 0 | { |
39 | 0 | } |
40 | | |
41 | | |
42 | | void SAL_CALL |
43 | | XCommandInfo_impl::acquire() |
44 | | noexcept |
45 | 0 | { |
46 | 0 | OWeakObject::acquire(); |
47 | 0 | } |
48 | | |
49 | | |
50 | | void SAL_CALL |
51 | | XCommandInfo_impl::release() |
52 | | noexcept |
53 | 0 | { |
54 | 0 | OWeakObject::release(); |
55 | 0 | } |
56 | | |
57 | | |
58 | | uno::Any SAL_CALL |
59 | | XCommandInfo_impl::queryInterface( const uno::Type& rType ) |
60 | 0 | { |
61 | 0 | uno::Any aRet = cppu::queryInterface( rType, |
62 | 0 | static_cast< XCommandInfo* >(this) ); |
63 | 0 | return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType ); |
64 | 0 | } |
65 | | |
66 | | |
67 | | uno::Sequence< CommandInfo > SAL_CALL |
68 | | XCommandInfo_impl::getCommands() |
69 | 0 | { |
70 | 0 | return m_pMyShell->m_sCommandInfo; |
71 | 0 | } |
72 | | |
73 | | |
74 | | CommandInfo SAL_CALL |
75 | | XCommandInfo_impl::getCommandInfoByName( |
76 | | const OUString& aName ) |
77 | 0 | { |
78 | 0 | auto pCommand = std::find_if(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), |
79 | 0 | [&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; }); |
80 | 0 | if (pCommand != std::cend(m_pMyShell->m_sCommandInfo)) |
81 | 0 | return *pCommand; |
82 | | |
83 | 0 | throw UnsupportedCommandException(); |
84 | 0 | } |
85 | | |
86 | | |
87 | | CommandInfo SAL_CALL |
88 | | XCommandInfo_impl::getCommandInfoByHandle( |
89 | | sal_Int32 Handle ) |
90 | 0 | { |
91 | 0 | auto pCommand = std::find_if(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), |
92 | 0 | [&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; }); |
93 | 0 | if (pCommand != std::cend(m_pMyShell->m_sCommandInfo)) |
94 | 0 | return *pCommand; |
95 | | |
96 | 0 | throw UnsupportedCommandException(); |
97 | 0 | } |
98 | | |
99 | | |
100 | | sal_Bool SAL_CALL |
101 | | XCommandInfo_impl::hasCommandByName( |
102 | | const OUString& aName ) |
103 | 0 | { |
104 | 0 | return std::any_of(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), |
105 | 0 | [&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; }); |
106 | 0 | } |
107 | | |
108 | | |
109 | | sal_Bool SAL_CALL |
110 | | XCommandInfo_impl::hasCommandByHandle( |
111 | | sal_Int32 Handle ) |
112 | 0 | { |
113 | 0 | return std::any_of(std::cbegin(m_pMyShell->m_sCommandInfo), std::cend(m_pMyShell->m_sCommandInfo), |
114 | 0 | [&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; }); |
115 | 0 | } |
116 | | |
117 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |