12e2212a7SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
32e2212a7SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
42e2212a7SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
52e2212a7SAndrew Rist  * distributed with this work for additional information
62e2212a7SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
72e2212a7SAndrew Rist  * to you under the Apache License, Version 2.0 (the
82e2212a7SAndrew Rist  * "License"); you may not use this file except in compliance
92e2212a7SAndrew Rist  * with the License.  You may obtain a copy of the License at
102e2212a7SAndrew Rist  *
112e2212a7SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
122e2212a7SAndrew Rist  *
132e2212a7SAndrew Rist  * Unless required by applicable law or agreed to in writing,
142e2212a7SAndrew Rist  * software distributed under the License is distributed on an
152e2212a7SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
162e2212a7SAndrew Rist  * KIND, either express or implied.  See the License for the
172e2212a7SAndrew Rist  * specific language governing permissions and limitations
182e2212a7SAndrew Rist  * under the License.
192e2212a7SAndrew Rist  *
202e2212a7SAndrew Rist  *************************************************************/
212e2212a7SAndrew Rist 
222e2212a7SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef _DBA_CORE_BOOKMARKCONTAINER_HXX_
25cdf0e10cSrcweir #define _DBA_CORE_BOOKMARKCONTAINER_HXX_
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #ifndef _CPPUHELPER_INTERFACECONTAINER_HXX_
28cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.hxx>
29cdf0e10cSrcweir #endif
30cdf0e10cSrcweir #ifndef _CPPUHELPER_IMPLBASE6_HXX_
31cdf0e10cSrcweir #include <cppuhelper/implbase6.hxx>
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _COMPHELPER_STLTYPES_HXX_
34cdf0e10cSrcweir #include <comphelper/stl_types.hxx>
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #ifndef _OSL_MUTEX_HXX_
37cdf0e10cSrcweir #include <osl/mutex.hxx>
38cdf0e10cSrcweir #endif
39cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
40cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
41cdf0e10cSrcweir #endif
42cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
43cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
44cdf0e10cSrcweir #endif
45cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCONTAINER_HPP_
46cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
47cdf0e10cSrcweir #endif
48cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XENUMERATIONACCESS_HPP_
49cdf0e10cSrcweir #include <com/sun/star/container/XEnumerationAccess.hpp>
50cdf0e10cSrcweir #endif
51cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XINDEXACCESS_HPP_
52cdf0e10cSrcweir #include <com/sun/star/container/XIndexAccess.hpp>
53cdf0e10cSrcweir #endif
54cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
55cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp>
56cdf0e10cSrcweir #endif
57cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XSINGLESERVICEFACTORY_HPP_
58cdf0e10cSrcweir #include <com/sun/star/lang/XSingleServiceFactory.hpp>
59cdf0e10cSrcweir #endif
60cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
61cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
62cdf0e10cSrcweir #endif
63cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_DISPOSEDEXCEPTION_HPP_
64cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
65cdf0e10cSrcweir #endif
66cdf0e10cSrcweir 
67cdf0e10cSrcweir //........................................................................
68cdf0e10cSrcweir namespace dbaccess
69cdf0e10cSrcweir {
70cdf0e10cSrcweir //........................................................................
71cdf0e10cSrcweir 
72cdf0e10cSrcweir //==========================================================================
73cdf0e10cSrcweir //= OBookmarkContainer -	base class of collections of database definition
74cdf0e10cSrcweir //=							documents
75cdf0e10cSrcweir //==========================================================================
76cdf0e10cSrcweir typedef ::cppu::WeakImplHelper6	<
77cdf0e10cSrcweir 									::com::sun::star::container::XIndexAccess
78cdf0e10cSrcweir 								,	::com::sun::star::container::XNameContainer
79cdf0e10cSrcweir 								,	::com::sun::star::container::XEnumerationAccess
80cdf0e10cSrcweir 								,	::com::sun::star::container::XContainer
81cdf0e10cSrcweir 								,	::com::sun::star::lang::XServiceInfo
82cdf0e10cSrcweir 								,	::com::sun::star::container::XChild
83cdf0e10cSrcweir 								>	OBookmarkContainer_Base;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir class OBookmarkContainer
86cdf0e10cSrcweir 			:public OBookmarkContainer_Base
87cdf0e10cSrcweir {
88cdf0e10cSrcweir protected:
89cdf0e10cSrcweir 	DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString, MapString2String);
90cdf0e10cSrcweir 	DECLARE_STL_VECTOR(MapString2StringIterator, MapIteratorVector);
91cdf0e10cSrcweir 
92cdf0e10cSrcweir 	MapString2String		m_aBookmarks;			// the bookmarks itself
93cdf0e10cSrcweir 	MapIteratorVector		m_aBookmarksIndexed;	// for index access to the
94cdf0e10cSrcweir 
95cdf0e10cSrcweir protected:
96cdf0e10cSrcweir 	::cppu::OWeakObject&	m_rParent;		// for the ref counting
97cdf0e10cSrcweir 	::cppu::OInterfaceContainerHelper
98cdf0e10cSrcweir 							m_aContainerListeners;
99cdf0e10cSrcweir 	::osl::Mutex&			m_rMutex;
100cdf0e10cSrcweir 
101cdf0e10cSrcweir 
102cdf0e10cSrcweir public:
103cdf0e10cSrcweir 	/** constructs the container.<BR>
104cdf0e10cSrcweir 		after the construction of the object the creator has to call <code>initialize</code>.
105cdf0e10cSrcweir 		@param		_rParent				the parent object which is used for ref counting
106cdf0e10cSrcweir 		@param		_rMutex					the parent's mutex object for access safety
107cdf0e10cSrcweir 	*/
108cdf0e10cSrcweir 	OBookmarkContainer(
109cdf0e10cSrcweir 		::cppu::OWeakObject& _rParent,
110cdf0e10cSrcweir 		::osl::Mutex& _rMutex
111cdf0e10cSrcweir 		);
112cdf0e10cSrcweir 
113cdf0e10cSrcweir 	/** looks like the dtor ...
114cdf0e10cSrcweir 	*/
115cdf0e10cSrcweir 	virtual ~OBookmarkContainer();
116cdf0e10cSrcweir 
117cdf0e10cSrcweir // ::com::sun::star::uno::XInterface
118cdf0e10cSrcweir     virtual void SAL_CALL acquire(  ) throw();
119cdf0e10cSrcweir     virtual void SAL_CALL release(  ) throw();
120cdf0e10cSrcweir 
121cdf0e10cSrcweir // ::com::sun::star::lang::XServiceInfo
122cdf0e10cSrcweir 	virtual ::rtl::OUString SAL_CALL getImplementationName(  ) throw(::com::sun::star::uno::RuntimeException);
123cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
124cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames(  ) throw(::com::sun::star::uno::RuntimeException);
125cdf0e10cSrcweir 
126cdf0e10cSrcweir // ::com::sun::star::container::XElementAccess
127cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Type SAL_CALL getElementType(  ) throw(::com::sun::star::uno::RuntimeException);
128cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL hasElements(  ) throw(::com::sun::star::uno::RuntimeException);
129cdf0e10cSrcweir 
130cdf0e10cSrcweir // ::com::sun::star::container::XEnumerationAccess
131cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration(  ) throw(::com::sun::star::uno::RuntimeException);
132cdf0e10cSrcweir 
133cdf0e10cSrcweir // ::com::sun::star::container::XIndexAccess
134cdf0e10cSrcweir 	virtual sal_Int32 SAL_CALL getCount(  ) throw(::com::sun::star::uno::RuntimeException);
135cdf0e10cSrcweir 	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);
136cdf0e10cSrcweir 
137cdf0e10cSrcweir // ::com::sun::star::container::XNameContainer
138cdf0e10cSrcweir     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);
139cdf0e10cSrcweir     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);
140cdf0e10cSrcweir 
141cdf0e10cSrcweir // ::com::sun::star::container::XNameReplace
142cdf0e10cSrcweir     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);
143cdf0e10cSrcweir 
144cdf0e10cSrcweir // ::com::sun::star::container::XNameAccess
145cdf0e10cSrcweir 	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);
146cdf0e10cSrcweir 	virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames(  ) throw(::com::sun::star::uno::RuntimeException);
147cdf0e10cSrcweir 	virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // ::com::sun::star::container::XContainer
150cdf0e10cSrcweir     virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
151cdf0e10cSrcweir     virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
152cdf0e10cSrcweir 
153cdf0e10cSrcweir // ::com::sun::star::container::XChild
154cdf0e10cSrcweir     virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent(  ) throw (::com::sun::star::uno::RuntimeException);
155cdf0e10cSrcweir     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);
156cdf0e10cSrcweir 
157cdf0e10cSrcweir // helper
158cdf0e10cSrcweir 	/** tell the container to free all resources. After that it's in a state like after the construction, i.e.
159cdf0e10cSrcweir 		you may call <code>initialize</code> again (maybe with another configuration node).
160cdf0e10cSrcweir 	*/
161cdf0e10cSrcweir 	virtual void	dispose();
162cdf0e10cSrcweir 
163cdf0e10cSrcweir 
164cdf0e10cSrcweir protected:
165cdf0e10cSrcweir 	/**	checks whether the object is basically alive, i.e. it has been fully initialized (@see initialize) and
166cdf0e10cSrcweir 		not disposed (@see dispose)
167cdf0e10cSrcweir 		@param		_bIntendWriteAccess		determines whether or not the caller intends to modify the configuration.
168cdf0e10cSrcweir 											if sal_True and the configuration is readonly, a runtime exception with
169cdf0e10cSrcweir 											a description string is thrown.
170cdf0e10cSrcweir 	*/
171cdf0e10cSrcweir 	void		checkValid(sal_Bool _bIntendWriteAccess) const throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::DisposedException);
172cdf0e10cSrcweir 
173*30acf5e8Spfg 	/** quickly checks if there already is an element with a given name. No access to the configuration occurs, i.e.
174cdf0e10cSrcweir 		if there is such an object which is not already loaded, it won't be loaded now.
175cdf0e10cSrcweir 		@param		_rName		the object name to check
176cdf0e10cSrcweir 		@return					sal_True if there already exists such an object
177cdf0e10cSrcweir 	*/
178cdf0e10cSrcweir 	inline	sal_Bool	checkExistence(const ::rtl::OUString& _rName);
179cdf0e10cSrcweir 
180cdf0e10cSrcweir 	void	implAppend(
181cdf0e10cSrcweir 		const ::rtl::OUString& _rName,
182cdf0e10cSrcweir 		const ::rtl::OUString& _rDocumentLocation
183cdf0e10cSrcweir 		);
184cdf0e10cSrcweir 
185cdf0e10cSrcweir 	void implRemove(const ::rtl::OUString& _rName);
186cdf0e10cSrcweir 
187cdf0e10cSrcweir 	void implReplace(
188cdf0e10cSrcweir 		const ::rtl::OUString& _rName,
189cdf0e10cSrcweir 		const ::rtl::OUString& _rNewLink);
190cdf0e10cSrcweir 
191cdf0e10cSrcweir };
192cdf0e10cSrcweir 
193cdf0e10cSrcweir //--------------------------------------------------------------------------
checkExistence(const::rtl::OUString & _rName)194cdf0e10cSrcweir inline	sal_Bool OBookmarkContainer::checkExistence(const ::rtl::OUString& _rName)
195cdf0e10cSrcweir {
196cdf0e10cSrcweir 	return m_aBookmarks.find(_rName) != m_aBookmarks.end();
197cdf0e10cSrcweir }
198cdf0e10cSrcweir 
199cdf0e10cSrcweir //........................................................................
200cdf0e10cSrcweir }	// namespace dbaccess
201cdf0e10cSrcweir //........................................................................
202cdf0e10cSrcweir 
203cdf0e10cSrcweir #endif // _DBA_CORE_BOOKMARKCONTAINER_HXX_
204cdf0e10cSrcweir 
205