1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_TOOLKIT_CONTROLS_EVENTCONTAINER_HXX
21 #define INCLUDED_TOOLKIT_CONTROLS_EVENTCONTAINER_HXX
23 #include <osl/diagnose.h>
24 #include <com/sun/star/container/XNameContainer.hpp>
25 #include <com/sun/star/container/XContainer.hpp>
27 #include <toolkit/helper/listenermultiplexer.hxx>
29 #include <cppuhelper/implbase2.hxx>
30 #include <unordered_map>
32 typedef ::cppu::WeakImplHelper2
< ::com::sun::star::container::XNameContainer
,
33 ::com::sun::star::container::XContainer
> NameContainerHelper
;
39 // Hashtable to optimize
40 typedef std::unordered_map
49 class NameContainer_Impl
: public NameContainerHelper
51 NameContainerNameMap mHashMap
;
52 ::com::sun::star::uno::Sequence
< OUString
> mNames
;
53 ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
> mValues
;
54 sal_Int32 mnElementCount
;
55 ::com::sun::star::uno::Type mType
;
57 ContainerListenerMultiplexer maContainerListeners
;
60 NameContainer_Impl( ::com::sun::star::uno::Type
const & aType
)
61 : mnElementCount( 0 ),
63 maContainerListeners( *this )
67 // Methods XElementAccess
68 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( )
69 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
70 virtual sal_Bool SAL_CALL
hasElements( )
71 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
73 // Methods XNameAccess
74 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const OUString
& aName
)
75 throw(::com::sun::star::container::NoSuchElementException
,
76 ::com::sun::star::lang::WrappedTargetException
,
77 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
78 virtual ::com::sun::star::uno::Sequence
< OUString
> SAL_CALL
getElementNames( )
79 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
80 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
)
81 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
83 // Methods XNameReplace
84 virtual void SAL_CALL
replaceByName( const OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
)
85 throw(::com::sun::star::lang::IllegalArgumentException
,
86 ::com::sun::star::container::NoSuchElementException
,
87 ::com::sun::star::lang::WrappedTargetException
,
88 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
90 // Methods XNameContainer
91 virtual void SAL_CALL
insertByName( const OUString
& aName
, const ::com::sun::star::uno::Any
& aElement
)
92 throw(::com::sun::star::lang::IllegalArgumentException
,
93 ::com::sun::star::container::ElementExistException
,
94 ::com::sun::star::lang::WrappedTargetException
,
95 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
96 virtual void SAL_CALL
removeByName( const OUString
& Name
)
97 throw(::com::sun::star::container::NoSuchElementException
,
98 ::com::sun::star::lang::WrappedTargetException
,
99 ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
101 // Methods XContainer
102 void SAL_CALL
addContainerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
>& xListener
)
103 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
104 void SAL_CALL
removeContainerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
>& xListener
)
105 throw(::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
108 class ScriptEventContainer
: public NameContainer_Impl
111 ScriptEventContainer();
115 } // namespace toolkit_namecontainer
117 #endif // INCLUDED_TOOLKIT_CONTROLS_EVENTCONTAINER_HXX
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */