/src/libreoffice/sw/inc/frameformats.hxx
Line | Count | Source (jump to first uncovered line) |
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 | | #pragma once |
20 | | |
21 | | #include "docary.hxx" |
22 | | #include "frmfmt.hxx" |
23 | | #include "swtblfmt.hxx" |
24 | | #include <boost/multi_index_container.hpp> |
25 | | #include <boost/multi_index/composite_key.hpp> |
26 | | #include <boost/multi_index/identity.hpp> |
27 | | #include <boost/multi_index/mem_fun.hpp> |
28 | | #include <boost/multi_index/ordered_index.hpp> |
29 | | #include <boost/multi_index/random_access_index.hpp> |
30 | | #include <boost/multi_index/tag.hpp> |
31 | | #include <libxml/xmlstring.h> |
32 | | #include <libxml/xmlwriter.h> |
33 | | |
34 | | // Like o3tl::find_partialorder_ptrequals |
35 | | // We don't allow duplicated object entries! |
36 | | namespace sw |
37 | | { |
38 | | template <class value_type> class FrameFormats final : public SwFormatsBase |
39 | | { |
40 | | struct ByPos |
41 | | { |
42 | | }; |
43 | | struct ByTypeAndName |
44 | | { |
45 | | }; |
46 | | struct FrameFormatsKey |
47 | | : boost::multi_index::composite_key< |
48 | | value_type, |
49 | | boost::multi_index::const_mem_fun<SwFormat, const UIName&, &SwFormat::GetName>, |
50 | | boost::multi_index::const_mem_fun<SwFormat, sal_uInt16, &SwFormat::Which>, |
51 | | boost::multi_index::identity<value_type> // the actual object pointer |
52 | | > |
53 | | { |
54 | | }; |
55 | | typedef boost::multi_index_container< |
56 | | value_type, boost::multi_index::indexed_by< |
57 | | boost::multi_index::random_access<boost::multi_index::tag<ByPos>>, |
58 | | boost::multi_index::ordered_unique<boost::multi_index::tag<ByTypeAndName>, |
59 | | FrameFormatsKey>>> |
60 | | FrameFormatsContainer; |
61 | | // function updating ByName index via modify |
62 | | friend class ::SwFrameFormat; |
63 | | |
64 | | public: |
65 | | // getting from T* to T const* ... |
66 | | typedef typename std::add_pointer< |
67 | | typename std::add_const<typename std::remove_pointer<value_type>::type>::type>::type |
68 | | const_value_type; |
69 | | typedef typename FrameFormatsContainer::size_type size_type; |
70 | | typedef typename FrameFormatsContainer::template index<ByPos>::type index_type; |
71 | | typedef typename index_type::iterator iterator; |
72 | | typedef typename index_type::const_iterator const_iterator; |
73 | | typedef typename FrameFormatsContainer::template index<ByTypeAndName>::type name_index_type; |
74 | | typedef typename name_index_type::iterator name_iterator; |
75 | | typedef typename name_index_type::const_iterator const_name_iterator; |
76 | | typedef typename std::pair<const_name_iterator, const_name_iterator> range_type; |
77 | | |
78 | | private: |
79 | | FrameFormatsContainer m_vContainer; |
80 | 1.90M | index_type& GetByPos() { return m_vContainer.template get<ByPos>(); } sw::FrameFormats<SwFrameFormat*>::GetByPos() Line | Count | Source | 80 | 679k | index_type& GetByPos() { return m_vContainer.template get<ByPos>(); } |
sw::FrameFormats<sw::SpzFrameFormat*>::GetByPos() Line | Count | Source | 80 | 1.07M | index_type& GetByPos() { return m_vContainer.template get<ByPos>(); } |
sw::FrameFormats<SwTableFormat*>::GetByPos() Line | Count | Source | 80 | 148k | index_type& GetByPos() { return m_vContainer.template get<ByPos>(); } |
|
81 | | name_index_type& GetByTypeAndName() { return m_vContainer.template get<ByTypeAndName>(); } |
82 | 133M | const index_type& GetByPos() const { return m_vContainer.template get<ByPos>(); } sw::FrameFormats<sw::SpzFrameFormat*>::GetByPos() const Line | Count | Source | 82 | 125M | const index_type& GetByPos() const { return m_vContainer.template get<ByPos>(); } |
sw::FrameFormats<SwFrameFormat*>::GetByPos() const Line | Count | Source | 82 | 2.88M | const index_type& GetByPos() const { return m_vContainer.template get<ByPos>(); } |
sw::FrameFormats<SwTableFormat*>::GetByPos() const Line | Count | Source | 82 | 5.69M | const index_type& GetByPos() const { return m_vContainer.template get<ByPos>(); } |
|
83 | | const name_index_type& GetByTypeAndName() const |
84 | 11.2M | { |
85 | 11.2M | return m_vContainer.template get<ByTypeAndName>(); |
86 | 11.2M | } sw::FrameFormats<SwFrameFormat*>::GetByTypeAndName() const Line | Count | Source | 84 | 212k | { | 85 | 212k | return m_vContainer.template get<ByTypeAndName>(); | 86 | 212k | } |
sw::FrameFormats<sw::SpzFrameFormat*>::GetByTypeAndName() const Line | Count | Source | 84 | 10.9M | { | 85 | 10.9M | return m_vContainer.template get<ByTypeAndName>(); | 86 | 10.9M | } |
sw::FrameFormats<SwTableFormat*>::GetByTypeAndName() const Line | Count | Source | 84 | 89.8k | { | 85 | 89.8k | return m_vContainer.template get<ByTypeAndName>(); | 86 | 89.8k | } |
|
87 | | |
88 | | public: |
89 | 283k | FrameFormats(){}; sw::FrameFormats<SwFrameFormat*>::FrameFormats() Line | Count | Source | 89 | 94.3k | FrameFormats(){}; |
sw::FrameFormats<sw::SpzFrameFormat*>::FrameFormats() Line | Count | Source | 89 | 94.3k | FrameFormats(){}; |
sw::FrameFormats<SwTableFormat*>::FrameFormats() Line | Count | Source | 89 | 94.3k | FrameFormats(){}; |
|
90 | | // frees all SwFrameFormat! |
91 | 283k | virtual ~FrameFormats() override { DeleteAndDestroyAll(); }; sw::FrameFormats<SwFrameFormat*>::~FrameFormats() Line | Count | Source | 91 | 94.3k | virtual ~FrameFormats() override { DeleteAndDestroyAll(); }; |
sw::FrameFormats<sw::SpzFrameFormat*>::~FrameFormats() Line | Count | Source | 91 | 94.3k | virtual ~FrameFormats() override { DeleteAndDestroyAll(); }; |
sw::FrameFormats<SwTableFormat*>::~FrameFormats() Line | Count | Source | 91 | 94.3k | virtual ~FrameFormats() override { DeleteAndDestroyAll(); }; |
|
92 | | |
93 | 538k | bool empty() const { return m_vContainer.empty(); } sw::FrameFormats<SwTableFormat*>::empty() const Line | Count | Source | 93 | 94.3k | bool empty() const { return m_vContainer.empty(); } |
sw::FrameFormats<sw::SpzFrameFormat*>::empty() const Line | Count | Source | 93 | 349k | bool empty() const { return m_vContainer.empty(); } |
sw::FrameFormats<SwFrameFormat*>::empty() const Line | Count | Source | 93 | 94.3k | bool empty() const { return m_vContainer.empty(); } |
|
94 | 12.7M | size_t size() const { return m_vContainer.size(); } sw::FrameFormats<SwTableFormat*>::size() const Line | Count | Source | 94 | 11.2M | size_t size() const { return m_vContainer.size(); } |
sw::FrameFormats<sw::SpzFrameFormat*>::size() const Line | Count | Source | 94 | 1.54M | size_t size() const { return m_vContainer.size(); } |
Unexecuted instantiation: sw::FrameFormats<SwFrameFormat*>::size() const |
95 | | |
96 | | // Only fails, if you try to insert the same object twice |
97 | | std::pair<const_iterator, bool> push_back(const value_type& x) |
98 | 963k | { |
99 | 963k | SAL_WARN_IF(x->m_ffList != nullptr, "sw.core", "Inserting already assigned item"); |
100 | 963k | assert(x->m_ffList == nullptr); |
101 | 963k | x->m_ffList = this; |
102 | 963k | return GetByPos().push_back(const_cast<value_type>(x)); |
103 | 963k | }; sw::FrameFormats<sw::SpzFrameFormat*>::push_back(sw::SpzFrameFormat* const&) Line | Count | Source | 98 | 516k | { | 99 | 516k | SAL_WARN_IF(x->m_ffList != nullptr, "sw.core", "Inserting already assigned item"); | 100 | 516k | assert(x->m_ffList == nullptr); | 101 | 516k | x->m_ffList = this; | 102 | 516k | return GetByPos().push_back(const_cast<value_type>(x)); | 103 | 516k | }; |
sw::FrameFormats<SwTableFormat*>::push_back(SwTableFormat* const&) Line | Count | Source | 98 | 74.0k | { | 99 | 74.0k | SAL_WARN_IF(x->m_ffList != nullptr, "sw.core", "Inserting already assigned item"); | 100 | 74.0k | assert(x->m_ffList == nullptr); | 101 | 74.0k | x->m_ffList = this; | 102 | 74.0k | return GetByPos().push_back(const_cast<value_type>(x)); | 103 | 74.0k | }; |
sw::FrameFormats<SwFrameFormat*>::push_back(SwFrameFormat* const&) Line | Count | Source | 98 | 372k | { | 99 | 372k | SAL_WARN_IF(x->m_ffList != nullptr, "sw.core", "Inserting already assigned item"); | 100 | 372k | assert(x->m_ffList == nullptr); | 101 | 372k | x->m_ffList = this; | 102 | 372k | return GetByPos().push_back(const_cast<value_type>(x)); | 103 | 372k | }; |
|
104 | | |
105 | | // This will try to remove the exact object! |
106 | | bool erase(const value_type& x) |
107 | 610k | { |
108 | 610k | const_iterator const ret = find(x); |
109 | 610k | SAL_WARN_IF(x->m_ffList != this, "sw.core", "Removing invalid / unassigned item"); |
110 | 610k | if (ret != end()) |
111 | 610k | { |
112 | 610k | assert(x == *ret); |
113 | 610k | x->m_ffList = nullptr; |
114 | 610k | GetByPos().erase(ret); |
115 | 610k | return true; |
116 | 610k | } |
117 | 0 | return false; |
118 | 610k | }; sw::FrameFormats<SwFrameFormat*>::erase(SwFrameFormat* const&) Line | Count | Source | 107 | 212k | { | 108 | 212k | const_iterator const ret = find(x); | 109 | 212k | SAL_WARN_IF(x->m_ffList != this, "sw.core", "Removing invalid / unassigned item"); | 110 | 212k | if (ret != end()) | 111 | 212k | { | 112 | 212k | assert(x == *ret); | 113 | 212k | x->m_ffList = nullptr; | 114 | 212k | GetByPos().erase(ret); | 115 | 212k | return true; | 116 | 212k | } | 117 | 0 | return false; | 118 | 212k | }; |
sw::FrameFormats<sw::SpzFrameFormat*>::erase(sw::SpzFrameFormat* const&) Line | Count | Source | 107 | 398k | { | 108 | 398k | const_iterator const ret = find(x); | 109 | 398k | SAL_WARN_IF(x->m_ffList != this, "sw.core", "Removing invalid / unassigned item"); | 110 | 398k | if (ret != end()) | 111 | 398k | { | 112 | 398k | assert(x == *ret); | 113 | 398k | x->m_ffList = nullptr; | 114 | 398k | GetByPos().erase(ret); | 115 | 398k | return true; | 116 | 398k | } | 117 | 0 | return false; | 118 | 398k | }; |
|
119 | | void erase(size_type index) { erase(begin() + index); }; |
120 | | void erase(const_iterator const& position) |
121 | 200k | { |
122 | 200k | (*position)->m_ffList = nullptr; |
123 | 200k | GetByPos().erase(begin() + (position - begin())); |
124 | 200k | } sw::FrameFormats<SwTableFormat*>::erase(boost::multi_index::detail::rnd_node_iterator<boost::multi_index::detail::random_access_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<SwTableFormat*, std::__1::allocator<SwTableFormat*> > > > > const&) Line | Count | Source | 121 | 74.0k | { | 122 | 74.0k | (*position)->m_ffList = nullptr; | 123 | 74.0k | GetByPos().erase(begin() + (position - begin())); | 124 | 74.0k | } |
sw::FrameFormats<SwFrameFormat*>::erase(boost::multi_index::detail::rnd_node_iterator<boost::multi_index::detail::random_access_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<SwFrameFormat*, std::__1::allocator<SwFrameFormat*> > > > > const&) Line | Count | Source | 121 | 94.3k | { | 122 | 94.3k | (*position)->m_ffList = nullptr; | 123 | 94.3k | GetByPos().erase(begin() + (position - begin())); | 124 | 94.3k | } |
sw::FrameFormats<sw::SpzFrameFormat*>::erase(boost::multi_index::detail::rnd_node_iterator<boost::multi_index::detail::random_access_index_node<boost::multi_index::detail::ordered_index_node<boost::multi_index::detail::null_augment_policy, boost::multi_index::detail::index_node_base<sw::SpzFrameFormat*, std::__1::allocator<sw::SpzFrameFormat*> > > > > const&) Line | Count | Source | 121 | 32.0k | { | 122 | 32.0k | (*position)->m_ffList = nullptr; | 123 | 32.0k | GetByPos().erase(begin() + (position - begin())); | 124 | 32.0k | } |
|
125 | | |
126 | | // Get the iterator of the exact object (includes pointer!), |
127 | | // e.g for position with std::distance. |
128 | | // There is also ContainsFormat, if you don't need the position. |
129 | | const_iterator find(const value_type& x) const |
130 | 814k | { |
131 | 814k | auto it = GetByTypeAndName().find(std::make_tuple(x->GetName(), x->Which(), x)); |
132 | 814k | return m_vContainer.template project<ByPos>(it); |
133 | 814k | }; sw::FrameFormats<SwFrameFormat*>::find(SwFrameFormat* const&) const Line | Count | Source | 130 | 212k | { | 131 | 212k | auto it = GetByTypeAndName().find(std::make_tuple(x->GetName(), x->Which(), x)); | 132 | 212k | return m_vContainer.template project<ByPos>(it); | 133 | 212k | }; |
sw::FrameFormats<sw::SpzFrameFormat*>::find(sw::SpzFrameFormat* const&) const Line | Count | Source | 130 | 528k | { | 131 | 528k | auto it = GetByTypeAndName().find(std::make_tuple(x->GetName(), x->Which(), x)); | 132 | 528k | return m_vContainer.template project<ByPos>(it); | 133 | 528k | }; |
sw::FrameFormats<SwTableFormat*>::find(SwTableFormat* const&) const Line | Count | Source | 130 | 74.0k | { | 131 | 74.0k | auto it = GetByTypeAndName().find(std::make_tuple(x->GetName(), x->Which(), x)); | 132 | 74.0k | return m_vContainer.template project<ByPos>(it); | 133 | 74.0k | }; |
|
134 | | |
135 | | const_name_iterator findByTypeAndName(sal_uInt16 type, const UIName& name) const |
136 | 5.20M | { |
137 | 5.20M | return GetByTypeAndName().find(std::make_tuple(name, type)); |
138 | 5.20M | }; |
139 | | // search for formats by name |
140 | | range_type findRangeByName(const UIName& rName) const |
141 | 15.7k | { |
142 | 15.7k | auto& idx = GetByTypeAndName(); |
143 | 15.7k | auto it = idx.lower_bound(std::make_tuple(rName, sal_uInt16(0))); |
144 | 15.7k | auto itEnd = idx.upper_bound(std::make_tuple(rName, SAL_MAX_UINT16)); |
145 | 15.7k | return { it, itEnd }; |
146 | 15.7k | }; |
147 | | // So we can actually check for end() |
148 | 5.20M | const_name_iterator typeAndNameEnd() const { return GetByTypeAndName().end(); } |
149 | | |
150 | 130M | const value_type& operator[](size_t index) const { return GetByPos().operator[](index); } sw::FrameFormats<SwTableFormat*>::operator[](unsigned long) const Line | Count | Source | 150 | 5.51M | const value_type& operator[](size_t index) const { return GetByPos().operator[](index); } |
sw::FrameFormats<sw::SpzFrameFormat*>::operator[](unsigned long) const Line | Count | Source | 150 | 123M | const value_type& operator[](size_t index) const { return GetByPos().operator[](index); } |
sw::FrameFormats<SwFrameFormat*>::operator[](unsigned long) const Line | Count | Source | 150 | 2.08M | const value_type& operator[](size_t index) const { return GetByPos().operator[](index); } |
|
151 | | const value_type& front() const { return GetByPos().front(); } |
152 | | const value_type& back() const { return GetByPos().back(); } |
153 | 1.52M | const_iterator begin() const { return GetByPos().begin(); } sw::FrameFormats<sw::SpzFrameFormat*>::begin() const Line | Count | Source | 153 | 951k | const_iterator begin() const { return GetByPos().begin(); } |
sw::FrameFormats<SwFrameFormat*>::begin() const Line | Count | Source | 153 | 405k | const_iterator begin() const { return GetByPos().begin(); } |
sw::FrameFormats<SwTableFormat*>::begin() const Line | Count | Source | 153 | 165k | const_iterator begin() const { return GetByPos().begin(); } |
|
154 | 1.75M | const_iterator end() const { return GetByPos().end(); } sw::FrameFormats<sw::SpzFrameFormat*>::end() const Line | Count | Source | 154 | 1.34M | const_iterator end() const { return GetByPos().end(); } |
sw::FrameFormats<SwFrameFormat*>::end() const Line | Count | Source | 154 | 401k | const_iterator end() const { return GetByPos().end(); } |
sw::FrameFormats<SwTableFormat*>::end() const Line | Count | Source | 154 | 16.9k | const_iterator end() const { return GetByPos().end(); } |
|
155 | | |
156 | | void dumpAsXml(xmlTextWriterPtr pWriter, const char* pName) const |
157 | 0 | { |
158 | 0 | (void)xmlTextWriterStartElement(pWriter, BAD_CAST(pName)); |
159 | 0 | for (const auto pFormat : GetByPos()) |
160 | 0 | pFormat->dumpAsXml(pWriter); |
161 | 0 | (void)xmlTextWriterEndElement(pWriter); |
162 | 0 | }; Unexecuted instantiation: sw::FrameFormats<SwFrameFormat*>::dumpAsXml(_xmlTextWriter*, char const*) const Unexecuted instantiation: sw::FrameFormats<sw::SpzFrameFormat*>::dumpAsXml(_xmlTextWriter*, char const*) const Unexecuted instantiation: sw::FrameFormats<SwTableFormat*>::dumpAsXml(_xmlTextWriter*, char const*) const |
163 | | |
164 | 119M | virtual size_t GetFormatCount() const override { return m_vContainer.size(); } sw::FrameFormats<SwFrameFormat*>::GetFormatCount() const Line | Count | Source | 164 | 1.95M | virtual size_t GetFormatCount() const override { return m_vContainer.size(); } |
sw::FrameFormats<sw::SpzFrameFormat*>::GetFormatCount() const Line | Count | Source | 164 | 117M | virtual size_t GetFormatCount() const override { return m_vContainer.size(); } |
Unexecuted instantiation: sw::FrameFormats<SwTableFormat*>::GetFormatCount() const |
165 | | virtual SwFormat* GetFormat(size_t idx) const override |
166 | 119M | { |
167 | 119M | return const_cast<value_type&>(operator[](idx)); |
168 | 119M | }; sw::FrameFormats<SwFrameFormat*>::GetFormat(unsigned long) const Line | Count | Source | 166 | 2.08M | { | 167 | 2.08M | return const_cast<value_type&>(operator[](idx)); | 168 | 2.08M | }; |
sw::FrameFormats<sw::SpzFrameFormat*>::GetFormat(unsigned long) const Line | Count | Source | 166 | 117M | { | 167 | 117M | return const_cast<value_type&>(operator[](idx)); | 168 | 117M | }; |
Unexecuted instantiation: sw::FrameFormats<SwTableFormat*>::GetFormat(unsigned long) const |
169 | | virtual void Rename(const SwFrameFormat& rFormat, const UIName& sNewName) override |
170 | 129k | { |
171 | 129k | assert(dynamic_cast<value_type>(const_cast<SwFrameFormat*>(&rFormat))); |
172 | 129k | iterator it = find(static_cast<value_type>(const_cast<SwFrameFormat*>(&rFormat))); |
173 | 129k | assert(end() != it); |
174 | 129k | const auto sOldName = rFormat.GetName(); |
175 | 129k | auto fRenamer |
176 | 129k | = [sNewName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(sNewName, false); }; Unexecuted instantiation: sw::FrameFormats<SwFrameFormat*>::Rename(SwFrameFormat const&, UIName const&)::{lambda(SwFormat*)#1}::operator()(SwFormat*) const sw::FrameFormats<sw::SpzFrameFormat*>::Rename(SwFrameFormat const&, UIName const&)::{lambda(SwFormat*)#1}::operator()(SwFormat*) const Line | Count | Source | 176 | 129k | = [sNewName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(sNewName, false); }; |
Unexecuted instantiation: sw::FrameFormats<SwTableFormat*>::Rename(SwFrameFormat const&, UIName const&)::{lambda(SwFormat*)#1}::operator()(SwFormat*) const |
177 | 129k | auto fRenamerUndo |
178 | 129k | = [sOldName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(sOldName, false); }; Unexecuted instantiation: sw::FrameFormats<SwFrameFormat*>::Rename(SwFrameFormat const&, UIName const&)::{lambda(SwFormat*)#2}::operator()(SwFormat*) const Unexecuted instantiation: sw::FrameFormats<sw::SpzFrameFormat*>::Rename(SwFrameFormat const&, UIName const&)::{lambda(SwFormat*)#2}::operator()(SwFormat*) const Unexecuted instantiation: sw::FrameFormats<SwTableFormat*>::Rename(SwFrameFormat const&, UIName const&)::{lambda(SwFormat*)#2}::operator()(SwFormat*) const |
179 | 129k | bool const renamed = GetByPos().modify(it, fRenamer, fRenamerUndo); |
180 | 129k | assert(renamed); |
181 | 129k | (void)renamed; // unused in NDEBUG |
182 | 129k | }; Unexecuted instantiation: sw::FrameFormats<SwFrameFormat*>::Rename(SwFrameFormat const&, UIName const&) sw::FrameFormats<sw::SpzFrameFormat*>::Rename(SwFrameFormat const&, UIName const&) Line | Count | Source | 170 | 129k | { | 171 | 129k | assert(dynamic_cast<value_type>(const_cast<SwFrameFormat*>(&rFormat))); | 172 | 129k | iterator it = find(static_cast<value_type>(const_cast<SwFrameFormat*>(&rFormat))); | 173 | 129k | assert(end() != it); | 174 | 129k | const auto sOldName = rFormat.GetName(); | 175 | 129k | auto fRenamer | 176 | 129k | = [sNewName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(sNewName, false); }; | 177 | 129k | auto fRenamerUndo | 178 | 129k | = [sOldName](SwFormat* pFormat) { pFormat->SwFormat::SetFormatName(sOldName, false); }; | 179 | 129k | bool const renamed = GetByPos().modify(it, fRenamer, fRenamerUndo); | 180 | 129k | assert(renamed); | 181 | 129k | (void)renamed; // unused in NDEBUG | 182 | 129k | }; |
Unexecuted instantiation: sw::FrameFormats<SwTableFormat*>::Rename(SwFrameFormat const&, UIName const&) |
183 | | |
184 | | /// fast check if given format is contained here |
185 | | /// @precond pFormat must not have been deleted |
186 | 1.00M | bool ContainsFormat(const value_type& rpFormat) const { return rpFormat->m_ffList == this; }; sw::FrameFormats<SwFrameFormat*>::ContainsFormat(SwFrameFormat* const&) const Line | Count | Source | 186 | 610k | bool ContainsFormat(const value_type& rpFormat) const { return rpFormat->m_ffList == this; }; |
sw::FrameFormats<sw::SpzFrameFormat*>::ContainsFormat(sw::SpzFrameFormat* const&) const Line | Count | Source | 186 | 398k | bool ContainsFormat(const value_type& rpFormat) const { return rpFormat->m_ffList == this; }; |
Unexecuted instantiation: sw::FrameFormats<SwTableFormat*>::ContainsFormat(SwTableFormat* const&) const |
187 | | |
188 | | /// not so fast check that given format is still alive (i.e. contained here) |
189 | | bool IsAlive(const_value_type pFrameFormat) const |
190 | 0 | { |
191 | 0 | auto pThisNonConst |
192 | 0 | = const_cast<typename std::remove_const<sw::FrameFormats<value_type>>::type*>(this); |
193 | 0 | return pThisNonConst->find(const_cast<value_type>(pFrameFormat)) != pThisNonConst->end(); |
194 | 0 | }; |
195 | | |
196 | | void DeleteAndDestroyAll(bool keepDefault = false) |
197 | 377k | { |
198 | 377k | if (empty()) |
199 | 333k | return; |
200 | 44.0k | const int offset = keepDefault ? 1 : 0; |
201 | 196k | for (const_iterator it = begin() + offset; it != end(); ++it) |
202 | 152k | delete *it; |
203 | 44.0k | if (offset) |
204 | 0 | GetByPos().erase(begin() + offset, end()); |
205 | 44.0k | else |
206 | 44.0k | m_vContainer.clear(); |
207 | 44.0k | }; sw::FrameFormats<SwTableFormat*>::DeleteAndDestroyAll(bool) Line | Count | Source | 197 | 94.3k | { | 198 | 94.3k | if (empty()) | 199 | 94.3k | return; | 200 | 0 | const int offset = keepDefault ? 1 : 0; | 201 | 0 | for (const_iterator it = begin() + offset; it != end(); ++it) | 202 | 0 | delete *it; | 203 | 0 | if (offset) | 204 | 0 | GetByPos().erase(begin() + offset, end()); | 205 | 0 | else | 206 | 0 | m_vContainer.clear(); | 207 | 0 | }; |
sw::FrameFormats<sw::SpzFrameFormat*>::DeleteAndDestroyAll(bool) Line | Count | Source | 197 | 188k | { | 198 | 188k | if (empty()) | 199 | 172k | return; | 200 | 15.7k | const int offset = keepDefault ? 1 : 0; | 201 | 102k | for (const_iterator it = begin() + offset; it != end(); ++it) | 202 | 86.6k | delete *it; | 203 | 15.7k | if (offset) | 204 | 0 | GetByPos().erase(begin() + offset, end()); | 205 | 15.7k | else | 206 | 15.7k | m_vContainer.clear(); | 207 | 15.7k | }; |
sw::FrameFormats<SwFrameFormat*>::DeleteAndDestroyAll(bool) Line | Count | Source | 197 | 94.3k | { | 198 | 94.3k | if (empty()) | 199 | 66.1k | return; | 200 | 28.2k | const int offset = keepDefault ? 1 : 0; | 201 | 94.4k | for (const_iterator it = begin() + offset; it != end(); ++it) | 202 | 66.2k | delete *it; | 203 | 28.2k | if (offset) | 204 | 0 | GetByPos().erase(begin() + offset, end()); | 205 | 28.2k | else | 206 | 28.2k | m_vContainer.clear(); | 207 | 28.2k | }; |
|
208 | | |
209 | | bool newDefault(const value_type& x) |
210 | 0 | { |
211 | 0 | std::pair<iterator, bool> res = GetByPos().push_front(const_cast<value_type&>(x)); |
212 | 0 | if (!res.second) |
213 | 0 | newDefault(res.first); |
214 | 0 | return res.second; |
215 | 0 | }; |
216 | | void newDefault(const_iterator const& position) |
217 | 0 | { |
218 | 0 | if (position == begin()) |
219 | 0 | return; |
220 | 0 | GetByPos().relocate(begin(), position); |
221 | 0 | }; |
222 | | |
223 | | // Override return type to reduce casting |
224 | | value_type FindFrameFormatByName(const UIName& rName) const |
225 | 0 | { |
226 | 0 | auto& idx = GetByTypeAndName(); |
227 | 0 | auto it = idx.lower_bound(std::make_tuple(rName, sal_uInt16(0))); |
228 | 0 | if (it != idx.end() && (*it)->GetName() == rName) |
229 | 0 | return *it; |
230 | 0 | return nullptr; |
231 | 0 | }; |
232 | | }; |
233 | | typedef FrameFormats<::SwTableFormat*> TableFrameFormats; |
234 | | typedef FrameFormats<sw::SpzFrameFormat*> SpzFrameFormats; |
235 | | } |
236 | | |
237 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |