/src/libreoffice/vcl/inc/jsdialog/jsdialogregister.hxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
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 | | |
10 | | #pragma once |
11 | | |
12 | | #include <map> |
13 | | #include <rtl/ustring.hxx> |
14 | | |
15 | | namespace jsdialog |
16 | | { |
17 | | template <class T> class WidgetRegister |
18 | | { |
19 | | // Map to remember the LOKWindowId <-> widget binding. |
20 | | std::map<OUString, T> m_aWidgetMap; |
21 | 0 | std::map<OUString, T>& Map() { return m_aWidgetMap; }Unexecuted instantiation: jsdialog::WidgetRegister<weld::Widget*>::Map() Unexecuted instantiation: jsdialog::WidgetRegister<std::__1::shared_ptr<jsdialog::WidgetRegister<weld::Widget*> > >::Map() Unexecuted instantiation: jsdialog::WidgetRegister<VclPtr<vcl::Window> >::Map() Unexecuted instantiation: jsdialog::WidgetRegister<weld::Menu*>::Map() |
22 | 0 | const std::map<OUString, T>& Map() const { return m_aWidgetMap; }Unexecuted instantiation: jsdialog::WidgetRegister<std::__1::shared_ptr<jsdialog::WidgetRegister<weld::Widget*> > >::Map() const Unexecuted instantiation: jsdialog::WidgetRegister<weld::Widget*>::Map() const Unexecuted instantiation: jsdialog::WidgetRegister<VclPtr<vcl::Window> >::Map() const Unexecuted instantiation: jsdialog::WidgetRegister<weld::Menu*>::Map() const |
23 | | |
24 | | public: |
25 | | void Remember(const OUString& rId, const T& pWidget); |
26 | | void Forget(const OUString& rId); |
27 | | T Find(const OUString& rId) const; |
28 | | }; |
29 | | |
30 | | template <class T> void WidgetRegister<T>::Remember(const OUString& nWindowId, const T& pMenu) |
31 | 0 | { |
32 | 0 | Map()[nWindowId] = pMenu; |
33 | 0 | } Unexecuted instantiation: jsdialog::WidgetRegister<weld::Menu*>::Remember(rtl::OUString const&, weld::Menu* const&) Unexecuted instantiation: jsdialog::WidgetRegister<VclPtr<vcl::Window> >::Remember(rtl::OUString const&, VclPtr<vcl::Window> const&) Unexecuted instantiation: jsdialog::WidgetRegister<std::__1::shared_ptr<jsdialog::WidgetRegister<weld::Widget*> > >::Remember(rtl::OUString const&, std::__1::shared_ptr<jsdialog::WidgetRegister<weld::Widget*> > const&) Unexecuted instantiation: jsdialog::WidgetRegister<weld::Widget*>::Remember(rtl::OUString const&, weld::Widget* const&) |
34 | | |
35 | | template <class T> void WidgetRegister<T>::Forget(const OUString& nWindowId) |
36 | 0 | { |
37 | 0 | auto it = Map().find(nWindowId); |
38 | 0 | if (it != Map().end()) |
39 | 0 | Map().erase(it); |
40 | 0 | } Unexecuted instantiation: jsdialog::WidgetRegister<weld::Widget*>::Forget(rtl::OUString const&) Unexecuted instantiation: jsdialog::WidgetRegister<std::__1::shared_ptr<jsdialog::WidgetRegister<weld::Widget*> > >::Forget(rtl::OUString const&) Unexecuted instantiation: jsdialog::WidgetRegister<VclPtr<vcl::Window> >::Forget(rtl::OUString const&) Unexecuted instantiation: jsdialog::WidgetRegister<weld::Menu*>::Forget(rtl::OUString const&) |
41 | | |
42 | | template <class T> T WidgetRegister<T>::Find(const OUString& nWindowId) const |
43 | 0 | { |
44 | 0 | const auto it = Map().find(nWindowId); |
45 | |
|
46 | 0 | if (it != Map().end()) |
47 | 0 | return it->second; |
48 | | |
49 | 0 | return nullptr; |
50 | 0 | } Unexecuted instantiation: jsdialog::WidgetRegister<std::__1::shared_ptr<jsdialog::WidgetRegister<weld::Widget*> > >::Find(rtl::OUString const&) const Unexecuted instantiation: jsdialog::WidgetRegister<weld::Widget*>::Find(rtl::OUString const&) const Unexecuted instantiation: jsdialog::WidgetRegister<VclPtr<vcl::Window> >::Find(rtl::OUString const&) const Unexecuted instantiation: jsdialog::WidgetRegister<weld::Menu*>::Find(rtl::OUString const&) const |
51 | | }; |
52 | | |
53 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |