LibreOffice Module framework (master) 1
rootactiontriggercontainer.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
29#include <utility>
30#include <vcl/svapp.hxx>
31
32using namespace cppu;
33using namespace com::sun::star::uno;
34using namespace com::sun::star::lang;
35using namespace com::sun::star::container;
36using namespace com::sun::star::beans;
37
38namespace framework
39{
40
41RootActionTriggerContainer::RootActionTriggerContainer(css::uno::Reference<css::awt::XPopupMenu> xMenu,
42 const OUString* pMenuIdentifier)
43 : m_bContainerCreated(false)
44 , m_xMenu(std::move(xMenu))
45 , m_pMenuIdentifier(pMenuIdentifier)
46{
47}
48
50{
51}
52
53// XInterface
55{
56 Any a = ::cppu::queryInterface(
57 aType ,
58 static_cast< XMultiServiceFactory* >(this),
59 static_cast< XServiceInfo* >(this),
60 static_cast< XTypeProvider* >(this),
61 static_cast< XNamed* >(this));
62
63 if( a.hasValue() )
64 {
65 return a;
66 }
67
69}
70
72{
74}
75
77{
79}
80
81// XMultiServiceFactory
82Reference< XInterface > SAL_CALL RootActionTriggerContainer::createInstance( const OUString& aServiceSpecifier )
83{
84 if ( aServiceSpecifier == SERVICENAME_ACTIONTRIGGER )
85 return static_cast<OWeakObject *>( new ActionTriggerPropertySet());
86 else if ( aServiceSpecifier == SERVICENAME_ACTIONTRIGGERCONTAINER )
87 return static_cast<OWeakObject *>( new ActionTriggerContainer());
88 else if ( aServiceSpecifier == SERVICENAME_ACTIONTRIGGERSEPARATOR )
89 return static_cast<OWeakObject *>( new ActionTriggerSeparatorPropertySet());
90 else
91 throw css::uno::RuntimeException("Unknown service specifier!", static_cast<OWeakObject *>(this) );
92}
93
94Reference< XInterface > SAL_CALL RootActionTriggerContainer::createInstanceWithArguments( const OUString& ServiceSpecifier, const Sequence< Any >& /*Arguments*/ )
95{
96 return createInstance( ServiceSpecifier );
97}
98
100{
104 return aSeq;
105}
106
107// XIndexContainer
108void SAL_CALL RootActionTriggerContainer::insertByIndex( sal_Int32 Index, const Any& Element )
109{
111
112 if ( !m_bContainerCreated )
114
116}
117
119{
121
122 if ( !m_bContainerCreated )
124
126}
127
128// XIndexReplace
129void SAL_CALL RootActionTriggerContainer::replaceByIndex( sal_Int32 Index, const Any& Element )
130{
132
133 if ( !m_bContainerCreated )
135
137}
138
139// XIndexAccess
141{
143
144 if ( !m_bContainerCreated )
145 {
146 if ( m_xMenu )
147 return m_xMenu->getItemCount();
148 else
149 return 0;
150 }
151 else
152 {
154 }
155}
156
158{
160
161 if ( !m_bContainerCreated )
163
165}
166
167// XElementAccess
169{
171}
172
174{
175 if (m_xMenu)
176 return m_xMenu->getItemCount() > 0;
177 return false;
178}
179
180// XServiceInfo
182{
184}
185
186sal_Bool SAL_CALL RootActionTriggerContainer::supportsService( const OUString& ServiceName )
187{
189}
190
192{
194}
195
196// XTypeProvider
198{
199 // Create a static typecollection ...
200 static ::cppu::OTypeCollection ourTypeCollection(
207
208 return ourTypeCollection.getTypes();
209}
210
212{
213 return css::uno::Sequence<sal_Int8>();
214}
215
216// private implementation helper
218{
219 m_bContainerCreated = true;
221 this, m_xMenu);
222}
224{
225 OUString sRet;
227 sRet = *m_pMenuIdentifier;
228 return sRet;
229}
230
232{
233 throw RuntimeException();
234}
235}
236
237/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _ADOIndex Index
constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGERCONTAINER
constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGER
constexpr OUStringLiteral SERVICENAME_ACTIONTRIGGERSEPARATOR
css::uno::Type const & get()
static void FillActionTriggerContainerFromMenu(css::uno::Reference< css::container::XIndexContainer > const &rActionTriggerContainer, const css::uno::Reference< css::awt::XPopupMenu > &rMenu)
virtual void SAL_CALL acquire() noexcept override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
virtual void SAL_CALL insertByIndex(sal_Int32 Index, const css::uno::Any &Element) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
virtual void SAL_CALL release() noexcept override
virtual sal_Int32 SAL_CALL getCount() override
virtual void SAL_CALL removeByIndex(sal_Int32 Index) override
virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const css::uno::Any &Element) override
virtual css::uno::Type SAL_CALL getElementType() override
virtual void SAL_CALL release() noexcept override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstanceWithArguments(const OUString &ServiceSpecifier, const css::uno::Sequence< css::uno::Any > &Arguments) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL getName() override
virtual sal_Bool SAL_CALL hasElements() override
virtual sal_Int32 SAL_CALL getCount() override
virtual void SAL_CALL insertByIndex(sal_Int32 Index, const css::uno::Any &Element) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
css::uno::Reference< css::awt::XPopupMenu > m_xMenu
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL setName(const OUString &aName) override
RootActionTriggerContainer(css::uno::Reference< css::awt::XPopupMenu > xMenu, const OUString *pMenuIdentifier)
virtual void SAL_CALL removeByIndex(sal_Int32 Index) override
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL createInstance(const OUString &aServiceSpecifier) override
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL replaceByIndex(sal_Int32 Index, const css::uno::Any &Element) override
uno_Any a
Sequence< sal_Int8 > aSeq
Type
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
constexpr OUStringLiteral IMPLEMENTATIONNAME_ROOTACTIONTRIGGERCONTAINER
unsigned char sal_Bool