LibreOffice Module dbaccess (master) 1
bookmarkcontainer.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <sal/config.h>
23
24#include <map>
25#include <vector>
26
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>
36
37namespace dbaccess
38{
39
40// OBookmarkContainer - base class of collections of database definition
41// documents
42typedef ::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
50
53{
54 typedef std::map<OUString, OUString> MapString2String;
55 typedef std::vector<MapString2String::iterator> MapIteratorVector;
56
57 MapString2String m_aBookmarks; // the bookmarks itself
58 MapIteratorVector m_aBookmarksIndexed; // for index access to the
59
60 ::cppu::OWeakObject& m_rParent; // for the ref counting
63 ::osl::Mutex& m_rMutex;
64
65public:
72 ::cppu::OWeakObject& _rParent,
73 ::osl::Mutex& _rMutex
74 );
75
78 virtual ~OBookmarkContainer() override;
79
80// css::uno::XInterface
81 virtual void SAL_CALL acquire( ) noexcept override;
82 virtual void SAL_CALL release( ) noexcept override;
83
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;
88
89// css::container::XElementAccess
90 virtual css::uno::Type SAL_CALL getElementType( ) override;
91 virtual sal_Bool SAL_CALL hasElements( ) override;
92
93// css::container::XEnumerationAccess
94 virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration( ) override;
95
96// css::container::XIndexAccess
97 virtual sal_Int32 SAL_CALL getCount( ) override;
98 virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 _nIndex ) override;
99
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;
103
104// css::container::XNameReplace
105 virtual void SAL_CALL replaceByName( const OUString& _rName, const css::uno::Any& aElement ) override;
106
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;
111
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;
115
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;
119
120private:
126 inline bool checkExistence(const OUString& _rName);
127
128 void implAppend(
129 const OUString& _rName,
130 const OUString& _rDocumentLocation
131 );
132
133 void implRemove(const OUString& _rName);
134
135 void implReplace(
136 const OUString& _rName,
137 const OUString& _rNewLink);
138
139};
140
141inline bool OBookmarkContainer::checkExistence(const OUString& _rName)
142{
143 return m_aBookmarks.find(_rName) != m_aBookmarks.end();
144}
145
146} // namespace dbaccess
147
148/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 _nIndex) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
virtual void SAL_CALL replaceByName(const OUString &_rName, const css::uno::Any &aElement) override
::cppu::OWeakObject & m_rParent
bool checkExistence(const OUString &_rName)
quickly checks if there already is an element with a given name.
void implAppend(const OUString &_rName, const OUString &_rDocumentLocation)
virtual sal_Bool SAL_CALL hasElements() override
::comphelper::OInterfaceContainerHelper3< css::container::XContainerListener > m_aContainerListeners
void implReplace(const OUString &_rName, const OUString &_rNewLink)
virtual void SAL_CALL removeByName(const OUString &_rName) override
MapIteratorVector m_aBookmarksIndexed
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
std::vector< MapString2String::iterator > MapIteratorVector
virtual void SAL_CALL setParent(const css::uno::Reference< css::uno::XInterface > &Parent) override
virtual css::uno::Type SAL_CALL getElementType() override
std::map< OUString, OUString > MapString2String
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
virtual void SAL_CALL release() noexcept override
virtual void SAL_CALL removeContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
void implRemove(const OUString &_rName)
virtual void SAL_CALL addContainerListener(const css::uno::Reference< css::container::XContainerListener > &xListener) override
virtual void SAL_CALL acquire() noexcept override
virtual sal_Int32 SAL_CALL getCount() override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL insertByName(const OUString &_rName, const css::uno::Any &aElement) override
OBookmarkContainer(::cppu::OWeakObject &_rParent, ::osl::Mutex &_rMutex)
constructs the container.
virtual ~OBookmarkContainer() override
looks like the dtor ...
virtual css::uno::Reference< css::uno::XInterface > SAL_CALL getParent() override
Type
::cppu::WeakImplHelper< css::container::XIndexAccess, css::container::XNameContainer, css::container::XEnumerationAccess, css::container::XContainer, css::lang::XServiceInfo, css::container::XChild > OBookmarkContainer_Base
unsigned char sal_Bool