LibreOffice Module comphelper (master) 1
numberedcollection.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#ifndef INCLUDED_COMPHELPER_NUMBEREDCOLLECTION_HXX
21#define INCLUDED_COMPHELPER_NUMBEREDCOLLECTION_HXX
22
24
25#include <com/sun/star/uno/Reference.h>
26#include <com/sun/star/frame/XUntitledNumbers.hpp>
27
30
31#include <unordered_map>
32#include <mutex>
33#include <vector>
34
35namespace com::sun::star::uno { class XInterface; }
36
37namespace comphelper{
38
48 public ::cppu::WeakImplHelper< css::frame::XUntitledNumbers >
49{
50
51 // types, const
52 private:
53
55 {
56 css::uno::WeakReference< css::uno::XInterface > xItem;
57 ::sal_Int32 nNumber;
58 };
59
60 typedef std::unordered_map<
61 sal_IntPtr,
63
64 typedef ::std::vector< sal_IntPtr > TDeadItemList;
65
66
67 // interface
68 public:
69
70
74
75
78 virtual ~NumberedCollection() override;
79
80
92 void setOwner (const css::uno::Reference< css::uno::XInterface >& xOwner);
93
94
104 void setUntitledPrefix(const OUString& sPrefix);
105
106
108 virtual ::sal_Int32 SAL_CALL leaseNumber(const css::uno::Reference< css::uno::XInterface >& xComponent) override;
109
110
112 virtual void SAL_CALL releaseNumber(::sal_Int32 nNumber) override;
113
114
116 virtual void SAL_CALL releaseNumberForComponent(const css::uno::Reference< css::uno::XInterface >& xComponent) override;
117
118
120 virtual OUString SAL_CALL getUntitledPrefix() override;
121
122
123 // internal
124 private:
125
126
143 ::sal_Int32 impl_searchFreeNumber ();
144
145 static void impl_cleanUpDeadItems ( TNumberedItemHash& lItems ,
146 const TDeadItemList& lDeadItems);
147
148
149 // member
150 private:
151
154
157
159 css::uno::WeakReference< css::uno::XInterface > m_xOwner;
160
162};
163
164} // namespace comphelper
165
166#endif // INCLUDED_COMPHELPER_NUMBEREDCOLLECTION_HXX
167
168/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
defines a collection of UNO components, where every component will get its own unique number.
OUString m_sUntitledPrefix
localized string to be used for untitled components
TNumberedItemHash m_lComponents
cache of all "leased numbers" and its bound components
css::uno::WeakReference< css::uno::XInterface > m_xOwner
used as source of broadcasted messages or exceptions (can be null !)
std::unordered_map< sal_IntPtr, TNumberedItem > TNumberedItemHash
::std::vector< sal_IntPtr > TDeadItemList
#define COMPHELPER_DLLPUBLIC
OUString sPrefix
std::mutex mutex
Definition: random.cxx:41
css::uno::WeakReference< css::uno::XInterface > xItem