Branch data Line data Source code
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 : :
20 : : #ifndef _DBA_CORE_BOOKMARKCONTAINER_HXX_
21 : : #define _DBA_CORE_BOOKMARKCONTAINER_HXX_
22 : :
23 : : #include <cppuhelper/interfacecontainer.hxx>
24 : : #include <cppuhelper/implbase6.hxx>
25 : : #include <comphelper/stl_types.hxx>
26 : : #include <osl/mutex.hxx>
27 : : #include <com/sun/star/container/XChild.hpp>
28 : : #include <com/sun/star/container/XNameContainer.hpp>
29 : : #include <com/sun/star/container/XContainer.hpp>
30 : : #include <com/sun/star/container/XEnumerationAccess.hpp>
31 : : #include <com/sun/star/container/XIndexAccess.hpp>
32 : : #include <com/sun/star/lang/XServiceInfo.hpp>
33 : : #include <com/sun/star/lang/XSingleServiceFactory.hpp>
34 : : #include <com/sun/star/beans/XPropertySet.hpp>
35 : : #include <com/sun/star/lang/DisposedException.hpp>
36 : :
37 : : namespace dbaccess
38 : : {
39 : :
40 : : //==========================================================================
41 : : //= OBookmarkContainer - base class of collections of database definition
42 : : //= documents
43 : : //==========================================================================
44 : : typedef ::cppu::WeakImplHelper6 <
45 : : ::com::sun::star::container::XIndexAccess
46 : : , ::com::sun::star::container::XNameContainer
47 : : , ::com::sun::star::container::XEnumerationAccess
48 : : , ::com::sun::star::container::XContainer
49 : : , ::com::sun::star::lang::XServiceInfo
50 : : , ::com::sun::star::container::XChild
51 : : > OBookmarkContainer_Base;
52 : :
53 : : class OBookmarkContainer
54 : : :public OBookmarkContainer_Base
55 : : {
56 : : protected:
57 : : DECLARE_STL_USTRINGACCESS_MAP(::rtl::OUString, MapString2String);
58 : : DECLARE_STL_VECTOR(MapString2StringIterator, MapIteratorVector);
59 : :
60 : : MapString2String m_aBookmarks; // the bookmarks itself
61 : : MapIteratorVector m_aBookmarksIndexed; // for index access to the
62 : :
63 : : protected:
64 : : ::cppu::OWeakObject& m_rParent; // for the ref counting
65 : : ::cppu::OInterfaceContainerHelper
66 : : m_aContainerListeners;
67 : : ::osl::Mutex& m_rMutex;
68 : :
69 : :
70 : : public:
71 : : /** constructs the container.<BR>
72 : : after the construction of the object the creator has to call <code>initialize</code>.
73 : : @param _rParent the parent object which is used for ref counting
74 : : @param _rMutex the parent's mutex object for access safety
75 : : */
76 : : OBookmarkContainer(
77 : : ::cppu::OWeakObject& _rParent,
78 : : ::osl::Mutex& _rMutex
79 : : );
80 : :
81 : : /** looks like the dtor ...
82 : : */
83 : : virtual ~OBookmarkContainer();
84 : :
85 : : // ::com::sun::star::uno::XInterface
86 : : virtual void SAL_CALL acquire( ) throw();
87 : : virtual void SAL_CALL release( ) throw();
88 : :
89 : : // ::com::sun::star::lang::XServiceInfo
90 : : virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException);
91 : : virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException);
92 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException);
93 : :
94 : : // ::com::sun::star::container::XElementAccess
95 : : virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException);
96 : : virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException);
97 : :
98 : : // ::com::sun::star::container::XEnumerationAccess
99 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException);
100 : :
101 : : // ::com::sun::star::container::XIndexAccess
102 : : virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException);
103 : : 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);
104 : :
105 : : // ::com::sun::star::container::XNameContainer
106 : : 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);
107 : : 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);
108 : :
109 : : // ::com::sun::star::container::XNameReplace
110 : : 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);
111 : :
112 : : // ::com::sun::star::container::XNameAccess
113 : : 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);
114 : : virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException);
115 : : virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName ) throw(::com::sun::star::uno::RuntimeException);
116 : :
117 : : // ::com::sun::star::container::XContainer
118 : : virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
119 : : virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException);
120 : :
121 : : // ::com::sun::star::container::XChild
122 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException);
123 : : 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);
124 : :
125 : : // helper
126 : : /** tell the container to free all resources. After that it's in a state like after the construction, i.e.
127 : : you may call <code>initialize</code> again (maybe with another configuration node).
128 : : */
129 : : virtual void dispose();
130 : :
131 : :
132 : : protected:
133 : : /** checks whether the object is basically alive, i.e. it has been fully initialized (@see initialize) and
134 : : not disposed (@see dispose)
135 : : @param _bIntendWriteAccess determines whether or not the caller intends to modify the configuration.
136 : : if sal_True and the configuration is readonly, a runtime exception with
137 : : a description string is thrown.
138 : : */
139 : : void checkValid(sal_Bool _bIntendWriteAccess) const throw (::com::sun::star::uno::RuntimeException, ::com::sun::star::lang::DisposedException);
140 : :
141 : : /** quickly checks if there already is an element with a given name. No access to the configuration occures, i.e.
142 : : if there is such an object which is not already loaded, it won't be loaded now.
143 : : @param _rName the object name to check
144 : : @return sal_True if there already exists such an object
145 : : */
146 : : inline sal_Bool checkExistence(const ::rtl::OUString& _rName);
147 : :
148 : : void implAppend(
149 : : const ::rtl::OUString& _rName,
150 : : const ::rtl::OUString& _rDocumentLocation
151 : : );
152 : :
153 : : void implRemove(const ::rtl::OUString& _rName);
154 : :
155 : : void implReplace(
156 : : const ::rtl::OUString& _rName,
157 : : const ::rtl::OUString& _rNewLink);
158 : :
159 : : };
160 : :
161 : 0 : inline sal_Bool OBookmarkContainer::checkExistence(const ::rtl::OUString& _rName)
162 : : {
163 [ # # ]: 0 : return m_aBookmarks.find(_rName) != m_aBookmarks.end();
164 : : }
165 : :
166 : : } // namespace dbaccess
167 : :
168 : : #endif // _DBA_CORE_BOOKMARKCONTAINER_HXX_
169 : :
170 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|