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 
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 
39  : m_pMyShell( pMyShell )
40 {
41 }
42 
44 {
45 }
46 
47 
48 void SAL_CALL
50  throw()
51 {
52  OWeakObject::acquire();
53 }
54 
55 
56 void SAL_CALL
58  throw()
59 {
60  OWeakObject::release();
61 }
62 
63 
64 uno::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 
73 uno::Sequence< CommandInfo > SAL_CALL
75 {
76  return m_pMyShell->m_sCommandInfo;
77 }
78 
79 
80 CommandInfo SAL_CALL
82  const OUString& aName )
83 {
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;
88 
89  throw UnsupportedCommandException( THROW_WHERE );
90 }
91 
92 
93 CommandInfo SAL_CALL
95  sal_Int32 Handle )
96 {
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;
101 
102  throw UnsupportedCommandException( THROW_WHERE );
103 }
104 
105 
106 sal_Bool SAL_CALL
108  const OUString& aName )
109 {
110  return std::any_of(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(),
111  [&aName](const CommandInfo& rCommand) { return rCommand.Name == aName; });
112 }
113 
114 
115 sal_Bool SAL_CALL
117  sal_Int32 Handle )
118 {
119  return std::any_of(m_pMyShell->m_sCommandInfo.begin(), m_pMyShell->m_sCommandInfo.end(),
120  [&Handle](const CommandInfo& rCommand) { return rCommand.Handle == Handle; });
121 }
122 
123 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL acquire() override
Definition: filcmd.cxx:49
bool hasValue()
#define THROW_WHERE
Definition: filcmd.cxx:33
virtual sal_Bool SAL_CALL hasCommandByName(const OUString &Name) override
Definition: filcmd.cxx:107
virtual ~XCommandInfo_impl() override
Definition: filcmd.cxx:43
virtual css::ucb::CommandInfo SAL_CALL getCommandInfoByHandle(sal_Int32 Handle) override
Definition: filcmd.cxx:94
XCommandInfo_impl(TaskManager *pMyShell)
Definition: filcmd.cxx:38
TaskManager * m_pMyShell
Definition: filcmd.hxx:76
unsigned char sal_Bool
css::uno::Sequence< css::ucb::CommandInfo > m_sCommandInfo
Definition: filtask.hxx:641
virtual css::uno::Sequence< css::ucb::CommandInfo > SAL_CALL getCommands() override
Definition: filcmd.cxx:74
virtual sal_Bool SAL_CALL hasCommandByHandle(sal_Int32 Handle) override
Definition: filcmd.cxx:116
SQLHANDLE Handle
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: filcmd.cxx:65
css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType, Interface1 *p1)
virtual css::ucb::CommandInfo SAL_CALL getCommandInfoByName(const OUString &Name) override
Definition: filcmd.cxx:81
virtual void SAL_CALL release() override
Definition: filcmd.cxx:57