1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: bookmarkcontainer.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _DBA_CORE_BOOKMARKCONTAINER_HXX_
32 #define _DBA_CORE_BOOKMARKCONTAINER_HXX_
34 #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
35 #include <cppuhelper/interfacecontainer.hxx>
37 #ifndef _CPPUHELPER_IMPLBASE6_HXX_
38 #include <cppuhelper/implbase6.hxx>
40 #ifndef _COMPHELPER_STLTYPES_HXX_
41 #include <comphelper/stl_types.hxx>
43 #ifndef _OSL_MUTEX_HXX_
44 #include <osl/mutex.hxx>
46 #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
47 #include <com/sun/star/container/XChild.hpp>
49 #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
50 #include <com/sun/star/container/XNameContainer.hpp>
52 #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
53 #include <com/sun/star/container/XContainer.hpp>
55 #ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
56 #include <com/sun/star/container/XEnumerationAccess.hpp>
58 #ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
59 #include <com/sun/star/container/XIndexAccess.hpp>
61 #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
62 #include <com/sun/star/lang/XServiceInfo.hpp>
64 #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
65 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
67 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
68 #include <com/sun/star/beans/XPropertySet.hpp>
70 #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
71 #include <com/sun/star/lang/DisposedException.hpp>
74 //........................................................................
77 //........................................................................
79 //==========================================================================
80 //= OBookmarkContainer - base class of collections of database definition
82 //==========================================================================
83 typedef ::cppu::WeakImplHelper6
<
84 ::com::sun::star::container::XIndexAccess
85 , ::com::sun::star::container::XNameContainer
86 , ::com::sun::star::container::XEnumerationAccess
87 , ::com::sun::star::container::XContainer
88 , ::com::sun::star::lang::XServiceInfo
89 , ::com::sun::star::container::XChild
90 > OBookmarkContainer_Base
;
92 class OBookmarkContainer
93 :public OBookmarkContainer_Base
96 DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString
, MapString2String
);
97 DECLARE_STL_VECTOR(MapString2StringIterator
, MapIteratorVector
);
99 MapString2String m_aBookmarks
; // the bookmarks itself
100 MapIteratorVector m_aBookmarksIndexed
; // for index access to the
103 ::cppu::OWeakObject
& m_rParent
; // for the ref counting
104 ::cppu::OInterfaceContainerHelper
105 m_aContainerListeners
;
106 ::osl::Mutex
& m_rMutex
;
110 /** constructs the container.<BR>
111 after the construction of the object the creator has to call <code>initialize</code>.
112 @param _rParent the parent object which is used for ref counting
113 @param _rMutex the parent's mutex object for access safety
116 ::cppu::OWeakObject
& _rParent
,
117 ::osl::Mutex
& _rMutex
120 /** looks like the dtor ...
122 virtual ~OBookmarkContainer();
124 // ::com::sun::star::uno::XInterface
125 virtual void SAL_CALL
acquire( ) throw();
126 virtual void SAL_CALL
release( ) throw();
128 // ::com::sun::star::lang::XServiceInfo
129 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
130 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
131 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
133 // ::com::sun::star::container::XElementAccess
134 virtual ::com::sun::star::uno::Type SAL_CALL
getElementType( ) throw(::com::sun::star::uno::RuntimeException
);
135 virtual sal_Bool SAL_CALL
hasElements( ) throw(::com::sun::star::uno::RuntimeException
);
137 // ::com::sun::star::container::XEnumerationAccess
138 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::container::XEnumeration
> SAL_CALL
createEnumeration( ) throw(::com::sun::star::uno::RuntimeException
);
140 // ::com::sun::star::container::XIndexAccess
141 virtual sal_Int32 SAL_CALL
getCount( ) throw(::com::sun::star::uno::RuntimeException
);
142 virtual ::com::sun::star::uno::Any SAL_CALL
getByIndex( sal_Int32 _nIndex
) throw(::com::sun::star::lang::IndexOutOfBoundsException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
144 // ::com::sun::star::container::XNameContainer
145 virtual void SAL_CALL
insertByName( const ::rtl::OUString
& _rName
, const ::com::sun::star::uno::Any
& aElement
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::ElementExistException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
146 virtual void SAL_CALL
removeByName( const ::rtl::OUString
& _rName
) throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
148 // ::com::sun::star::container::XNameReplace
149 virtual void SAL_CALL
replaceByName( const ::rtl::OUString
& _rName
, const ::com::sun::star::uno::Any
& aElement
) throw(::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
151 // ::com::sun::star::container::XNameAccess
152 virtual ::com::sun::star::uno::Any SAL_CALL
getByName( const ::rtl::OUString
& aName
) throw(::com::sun::star::container::NoSuchElementException
, ::com::sun::star::lang::WrappedTargetException
, ::com::sun::star::uno::RuntimeException
);
153 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getElementNames( ) throw(::com::sun::star::uno::RuntimeException
);
154 virtual sal_Bool SAL_CALL
hasByName( const ::rtl::OUString
& aName
) throw(::com::sun::star::uno::RuntimeException
);
156 // ::com::sun::star::container::XContainer
157 virtual void SAL_CALL
addContainerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
158 virtual void SAL_CALL
removeContainerListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::container::XContainerListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
160 // ::com::sun::star::container::XChild
161 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
getParent( ) throw (::com::sun::star::uno::RuntimeException
);
162 virtual void SAL_CALL
setParent( const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
>& Parent
) throw (::com::sun::star::lang::NoSupportException
, ::com::sun::star::uno::RuntimeException
);
165 /** tell the container to free all resources. After that it's in a state like after the construction, i.e.
166 you may call <code>initialize</code> again (maybe with another configuration node).
168 virtual void dispose();
172 /** checks whether the object is basically alive, i.e. it has been fully initialized (@see initialize) and
173 not disposed (@see dispose)
174 @param _bIntendWriteAccess determines whether or not the caller intends to modify the configuration.
175 if sal_True and the configuration is readonly, a runtime exception with
176 a description string is thrown.
178 void checkValid(sal_Bool _bIntendWriteAccess
) const throw (::com::sun::star::uno::RuntimeException
, ::com::sun::star::lang::DisposedException
);
180 /** quickly checks if there already is an element with a given name. No access to the configuration occures, i.e.
181 if there is such an object which is not already loaded, it won't be loaded now.
182 @param _rName the object name to check
183 @return sal_True if there already exists such an object
185 inline sal_Bool
checkExistence(const ::rtl::OUString
& _rName
);
188 const ::rtl::OUString
& _rName
,
189 const ::rtl::OUString
& _rDocumentLocation
192 void implRemove(const ::rtl::OUString
& _rName
);
195 const ::rtl::OUString
& _rName
,
196 const ::rtl::OUString
& _rNewLink
);
200 //--------------------------------------------------------------------------
201 inline sal_Bool
OBookmarkContainer::checkExistence(const ::rtl::OUString
& _rName
)
203 return m_aBookmarks
.find(_rName
) != m_aBookmarks
.end();
206 //........................................................................
207 } // namespace dbaccess
208 //........................................................................
210 #endif // _DBA_CORE_BOOKMARKCONTAINER_HXX_