1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
22 #include <sal/config.h>
27 #include <comphelper/interfacecontainer3.hxx>
28 #include <cppuhelper/implbase.hxx>
29 #include <osl/mutex.hxx>
30 #include <com/sun/star/container/XChild.hpp>
31 #include <com/sun/star/container/XNameContainer.hpp>
32 #include <com/sun/star/container/XContainer.hpp>
33 #include <com/sun/star/container/XEnumerationAccess.hpp>
34 #include <com/sun/star/container/XIndexAccess.hpp>
35 #include <com/sun/star/lang/XServiceInfo.hpp>
40 // OBookmarkContainer - base class of collections of database definition
42 typedef ::cppu::WeakImplHelper
<
43 css::container::XIndexAccess
44 , css::container::XNameContainer
45 , css::container::XEnumerationAccess
46 , css::container::XContainer
47 , css::lang::XServiceInfo
48 , css::container::XChild
49 > OBookmarkContainer_Base
;
51 class OBookmarkContainer final
52 :public OBookmarkContainer_Base
54 typedef std::map
<OUString
, OUString
> MapString2String
;
55 typedef std::vector
<MapString2String::iterator
> MapIteratorVector
;
57 MapString2String m_aBookmarks
; // the bookmarks itself
58 MapIteratorVector m_aBookmarksIndexed
; // for index access to the
60 ::cppu::OWeakObject
& m_rParent
; // for the ref counting
61 ::comphelper::OInterfaceContainerHelper3
<css::container::XContainerListener
>
62 m_aContainerListeners
;
63 ::osl::Mutex
& m_rMutex
;
66 /** constructs the container.<BR>
67 after the construction of the object the creator has to call <code>initialize</code>.
68 @param _rParent the parent object which is used for ref counting
69 @param _rMutex the parent's mutex object for access safety
72 ::cppu::OWeakObject
& _rParent
,
76 /** looks like the dtor ...
78 virtual ~OBookmarkContainer() override
;
80 // css::uno::XInterface
81 virtual void SAL_CALL
acquire( ) noexcept override
;
82 virtual void SAL_CALL
release( ) noexcept override
;
84 // css::lang::XServiceInfo
85 virtual OUString SAL_CALL
getImplementationName( ) override
;
86 virtual sal_Bool SAL_CALL
supportsService( const OUString
& ServiceName
) override
;
87 virtual css::uno::Sequence
< OUString
> SAL_CALL
getSupportedServiceNames( ) override
;
89 // css::container::XElementAccess
90 virtual css::uno::Type SAL_CALL
getElementType( ) override
;
91 virtual sal_Bool SAL_CALL
hasElements( ) override
;
93 // css::container::XEnumerationAccess
94 virtual css::uno::Reference
< css::container::XEnumeration
> SAL_CALL
createEnumeration( ) override
;
96 // css::container::XIndexAccess
97 virtual sal_Int32 SAL_CALL
getCount( ) override
;
98 virtual css::uno::Any SAL_CALL
getByIndex( sal_Int32 _nIndex
) override
;
100 // css::container::XNameContainer
101 virtual void SAL_CALL
insertByName( const OUString
& _rName
, const css::uno::Any
& aElement
) override
;
102 virtual void SAL_CALL
removeByName( const OUString
& _rName
) override
;
104 // css::container::XNameReplace
105 virtual void SAL_CALL
replaceByName( const OUString
& _rName
, const css::uno::Any
& aElement
) override
;
107 // css::container::XNameAccess
108 virtual css::uno::Any SAL_CALL
getByName( const OUString
& aName
) override
;
109 virtual css::uno::Sequence
< OUString
> SAL_CALL
getElementNames( ) override
;
110 virtual sal_Bool SAL_CALL
hasByName( const OUString
& aName
) override
;
112 // css::container::XContainer
113 virtual void SAL_CALL
addContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
114 virtual void SAL_CALL
removeContainerListener( const css::uno::Reference
< css::container::XContainerListener
>& xListener
) override
;
116 // css::container::XChild
117 virtual css::uno::Reference
< css::uno::XInterface
> SAL_CALL
getParent( ) override
;
118 virtual void SAL_CALL
setParent( const css::uno::Reference
< css::uno::XInterface
>& Parent
) override
;
121 /** quickly checks if there already is an element with a given name. No access to the configuration occurs, i.e.
122 if there is such an object which is not already loaded, it won't be loaded now.
123 @param _rName the object name to check
124 @return sal_True if there already exists such an object
126 inline bool checkExistence(const OUString
& _rName
);
129 const OUString
& _rName
,
130 const OUString
& _rDocumentLocation
133 void implRemove(const OUString
& _rName
);
136 const OUString
& _rName
,
137 const OUString
& _rNewLink
);
141 inline bool OBookmarkContainer::checkExistence(const OUString
& _rName
)
143 return m_aBookmarks
.find(_rName
) != m_aBookmarks
.end();
146 } // namespace dbaccess
148 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */