Bump version to 5.0-14
[LibreOffice.git] / dbaccess / source / core / dataaccess / bookmarkcontainer.hxx
blobb14bfbd9b24e23b7fbb9aa2f1b16f4171ce13927
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_DBACCESS_SOURCE_CORE_DATAACCESS_BOOKMARKCONTAINER_HXX
21 #define INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_BOOKMARKCONTAINER_HXX
23 #include <sal/config.h>
25 #include <map>
26 #include <vector>
28 #include <cppuhelper/interfacecontainer.hxx>
29 #include <cppuhelper/implbase6.hxx>
30 #include <osl/mutex.hxx>
31 #include <com/sun/star/container/XChild.hpp>
32 #include <com/sun/star/container/XNameContainer.hpp>
33 #include <com/sun/star/container/XContainer.hpp>
34 #include <com/sun/star/container/XEnumerationAccess.hpp>
35 #include <com/sun/star/container/XIndexAccess.hpp>
36 #include <com/sun/star/lang/XServiceInfo.hpp>
37 #include <com/sun/star/lang/XSingleServiceFactory.hpp>
38 #include <com/sun/star/beans/XPropertySet.hpp>
39 #include <com/sun/star/lang/DisposedException.hpp>
41 namespace dbaccess
44 // OBookmarkContainer - base class of collections of database definition
45 // documents
46 typedef ::cppu::WeakImplHelper6 <
47 ::com::sun::star::container::XIndexAccess
48 , ::com::sun::star::container::XNameContainer
49 , ::com::sun::star::container::XEnumerationAccess
50 , ::com::sun::star::container::XContainer
51 , ::com::sun::star::lang::XServiceInfo
52 , ::com::sun::star::container::XChild
53 > OBookmarkContainer_Base;
55 class OBookmarkContainer
56 :public OBookmarkContainer_Base
58 protected:
59 typedef std::map<OUString, OUString> MapString2String;
60 typedef std::vector<MapString2String::iterator> MapIteratorVector;
62 MapString2String m_aBookmarks; // the bookmarks itself
63 MapIteratorVector m_aBookmarksIndexed; // for index access to the
65 protected:
66 ::cppu::OWeakObject& m_rParent; // for the ref counting
67 ::cppu::OInterfaceContainerHelper
68 m_aContainerListeners;
69 ::osl::Mutex& m_rMutex;
71 public:
72 /** constructs the container.<BR>
73 after the construction of the object the creator has to call <code>initialize</code>.
74 @param _rParent the parent object which is used for ref counting
75 @param _rMutex the parent's mutex object for access safety
77 OBookmarkContainer(
78 ::cppu::OWeakObject& _rParent,
79 ::osl::Mutex& _rMutex
82 /** looks like the dtor ...
84 virtual ~OBookmarkContainer();
86 // ::com::sun::star::uno::XInterface
87 virtual void SAL_CALL acquire( ) throw() SAL_OVERRIDE;
88 virtual void SAL_CALL release( ) throw() SAL_OVERRIDE;
90 // ::com::sun::star::lang::XServiceInfo
91 virtual OUString SAL_CALL getImplementationName( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
92 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
93 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
95 // ::com::sun::star::container::XElementAccess
96 virtual ::com::sun::star::uno::Type SAL_CALL getElementType( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
97 virtual sal_Bool SAL_CALL hasElements( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
99 // ::com::sun::star::container::XEnumerationAccess
100 virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XEnumeration > SAL_CALL createEnumeration( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
102 // ::com::sun::star::container::XIndexAccess
103 virtual sal_Int32 SAL_CALL getCount( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
104 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, std::exception) SAL_OVERRIDE;
106 // ::com::sun::star::container::XNameContainer
107 virtual void SAL_CALL insertByName( const 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, std::exception) SAL_OVERRIDE;
108 virtual void SAL_CALL removeByName( const OUString& _rName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
110 // ::com::sun::star::container::XNameReplace
111 virtual void SAL_CALL replaceByName( const 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, std::exception) SAL_OVERRIDE;
113 // ::com::sun::star::container::XNameAccess
114 virtual ::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw(::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
115 virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
116 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
118 // ::com::sun::star::container::XContainer
119 virtual void SAL_CALL addContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
120 virtual void SAL_CALL removeContainerListener( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener >& xListener ) throw(::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
122 // ::com::sun::star::container::XChild
123 virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getParent( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
124 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, std::exception) SAL_OVERRIDE;
126 // helper
127 /** tell the container to free all resources. After that it's in a state like after the construction, i.e.
128 you may call <code>initialize</code> again (maybe with another configuration node).
130 void dispose();
132 protected:
133 /** quickly checks if there already is an element with a given name. No access to the configuration occurs, i.e.
134 if there is such an object which is not already loaded, it won't be loaded now.
135 @param _rName the object name to check
136 @return sal_True if there already exists such an object
138 inline bool checkExistence(const OUString& _rName);
140 void implAppend(
141 const OUString& _rName,
142 const OUString& _rDocumentLocation
145 void implRemove(const OUString& _rName);
147 void implReplace(
148 const OUString& _rName,
149 const OUString& _rNewLink);
153 inline bool OBookmarkContainer::checkExistence(const OUString& _rName)
155 return m_aBookmarks.find(_rName) != m_aBookmarks.end();
158 } // namespace dbaccess
160 #endif // INCLUDED_DBACCESS_SOURCE_CORE_DATAACCESS_BOOKMARKCONTAINER_HXX
162 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */