Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <osl/diagnose.h>
31 : : #include <com/sun/star/container/XNameContainer.hpp>
32 : : #include <com/sun/star/container/XContainer.hpp>
33 : :
34 : : #include <toolkit/helper/listenermultiplexer.hxx>
35 : :
36 : : #include <boost/unordered_map.hpp>
37 : : #include <cppuhelper/implbase2.hxx>
38 : : typedef ::cppu::WeakImplHelper2< ::com::sun::star::container::XNameContainer,
39 : : ::com::sun::star::container::XContainer > NameContainerHelper;
40 : :
41 : :
42 : : namespace toolkit
43 : : {
44 : :
45 : : // Hashtable to optimize
46 : : struct hashName_Impl
47 : : {
48 : 0 : size_t operator()(const ::rtl::OUString Str) const
49 : : {
50 : 0 : return (size_t)Str.hashCode();
51 : : }
52 : : };
53 : :
54 : : struct eqName_Impl
55 : : {
56 : 0 : sal_Bool operator()(const ::rtl::OUString Str1, const ::rtl::OUString Str2) const
57 : : {
58 : 0 : return ( Str1 == Str2 );
59 : : }
60 : : };
61 : :
62 : : typedef boost::unordered_map
63 : : <
64 : : ::rtl::OUString,
65 : : sal_Int32,
66 : : hashName_Impl,
67 : : eqName_Impl
68 : : >
69 : : NameContainerNameMap;
70 : :
71 : :
72 [ + - ][ + - ]: 6 : class NameContainer_Impl : public NameContainerHelper
[ + - ][ + - ]
[ - + ]
73 : : {
74 : : NameContainerNameMap mHashMap;
75 : : ::com::sun::star::uno::Sequence< ::rtl::OUString > mNames;
76 : : ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > mValues;
77 : : sal_Int32 mnElementCount;
78 : : ::com::sun::star::uno::Type mType;
79 : :
80 : : ContainerListenerMultiplexer maContainerListeners;
81 : :
82 : : public:
83 : 12 : NameContainer_Impl( ::com::sun::star::uno::Type const & aType )
84 : : : mnElementCount( 0 ),
85 : : mType( aType ),
86 [ + - ][ + - ]: 12 : maContainerListeners( *this )
[ + - ][ + - ]
87 : : {
88 : 12 : }
89 : :
90 : : // Methods XElementAccess
91 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( )
92 : : throw(::com::sun::star::uno::RuntimeException);
93 : : virtual sal_Bool SAL_CALL hasElements( )
94 : : throw(::com::sun::star::uno::RuntimeException);
95 : :
96 : : // Methods XNameAccess
97 : : virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
98 : : throw(::com::sun::star::container::NoSuchElementException,
99 : : ::com::sun::star::lang::WrappedTargetException,
100 : : ::com::sun::star::uno::RuntimeException);
101 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( )
102 : : throw(::com::sun::star::uno::RuntimeException);
103 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
104 : : throw(::com::sun::star::uno::RuntimeException);
105 : :
106 : : // Methods XNameReplace
107 : : virtual void SAL_CALL replaceByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
108 : : throw(::com::sun::star::lang::IllegalArgumentException,
109 : : ::com::sun::star::container::NoSuchElementException,
110 : : ::com::sun::star::lang::WrappedTargetException,
111 : : ::com::sun::star::uno::RuntimeException);
112 : :
113 : : // Methods XNameContainer
114 : : virtual void SAL_CALL insertByName( const ::rtl::OUString& aName, const ::com::sun::star::uno::Any& aElement )
115 : : throw(::com::sun::star::lang::IllegalArgumentException,
116 : : ::com::sun::star::container::ElementExistException,
117 : : ::com::sun::star::lang::WrappedTargetException,
118 : : ::com::sun::star::uno::RuntimeException);
119 : : virtual void SAL_CALL removeByName( const ::rtl::OUString& Name )
120 : : throw(::com::sun::star::container::NoSuchElementException,
121 : : ::com::sun::star::lang::WrappedTargetException,
122 : : ::com::sun::star::uno::RuntimeException);
123 : :
124 : : // Methods XContainer
125 : : void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener )
126 : : throw(::com::sun::star::uno::RuntimeException);
127 : : void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener )
128 : : throw(::com::sun::star::uno::RuntimeException);
129 : : };
130 : :
131 [ - + ]: 12 : class ScriptEventContainer : public NameContainer_Impl
132 : : {
133 : : public:
134 : : ScriptEventContainer( void );
135 : : };
136 : :
137 : :
138 : : } // namespace toolkit_namecontainer
139 : :
140 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|