LibreOffice Module sw (master) 1
frameformats.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#pragma once
20
21#include "docary.hxx"
22#include <boost/multi_index_container.hpp>
23#include <boost/multi_index/composite_key.hpp>
24#include <boost/multi_index/identity.hpp>
25#include <boost/multi_index/mem_fun.hpp>
26#include <boost/multi_index/ordered_index.hpp>
27#include <boost/multi_index/random_access_index.hpp>
28
29// Like o3tl::find_partialorder_ptrequals
30// We don't allow duplicated object entries!
32 : boost::multi_index::composite_key<
33 SwFrameFormat*,
34 boost::multi_index::const_mem_fun<SwFormat, const OUString&, &SwFormat::GetName>,
35 boost::multi_index::const_mem_fun<SwFormat, sal_uInt16, &SwFormat::Which>,
36 boost::multi_index::identity<SwFrameFormat*> // the actual object pointer
37 >
38{
39};
40
41typedef boost::multi_index_container<
43 boost::multi_index::indexed_by<boost::multi_index::random_access<>,
44 boost::multi_index::ordered_unique<type_name_key>>>
46
49{
50 // function updating ByName index via modify
51 friend void SwFrameFormat::SetFormatName(const OUString&, bool);
52
53public:
54 typedef SwFrameFormatsBase::nth_index<0>::type ByPos;
55 typedef SwFrameFormatsBase::nth_index<1>::type ByTypeAndName;
56 typedef ByPos::iterator iterator;
57
58private:
62
63public:
64 typedef ByPos::const_iterator const_iterator;
65 typedef SwFrameFormatsBase::size_type size_type;
66 typedef SwFrameFormatsBase::value_type value_type;
67
69 // frees all SwFrameFormat!
70 virtual ~SwFrameFormats() override;
71
72 bool empty() const { return m_Array.empty(); }
73 size_t size() const { return m_Array.size(); }
74
75 // Only fails, if you try to insert the same object twice
76 std::pair<const_iterator, bool> push_back(const value_type& x);
77
78 // This will try to remove the exact object!
79 bool erase(const value_type& x);
80 void erase(size_type index);
81 void erase(const_iterator const& position);
82
83 // Get the iterator of the exact object (includes pointer!),
84 // e.g for position with std::distance.
85 // There is also ContainsFormat, if you don't need the position.
86 const_iterator find(const value_type& x) const;
87
88 ByTypeAndName::const_iterator findByTypeAndName(sal_uInt16 type, const OUString& name) const;
89 // search for formats by name
90 std::pair<ByTypeAndName::const_iterator, ByTypeAndName::const_iterator>
91 findRangeByName(const OUString& name) const;
92 // So we can actually check for end()
93 ByTypeAndName::const_iterator typeAndNameEnd() const { return m_TypeAndNameIndex.end(); }
94
95 const value_type& operator[](size_t index_) const { return m_PosIndex.operator[](index_); }
96 const value_type& front() const { return m_PosIndex.front(); }
97 const value_type& back() const { return m_PosIndex.back(); }
98 const_iterator begin() const { return m_PosIndex.begin(); }
99 const_iterator end() const { return m_PosIndex.end(); }
100
101 void dumpAsXml(xmlTextWriterPtr pWriter, const char* pName) const;
102
103 virtual size_t GetFormatCount() const override { return m_Array.size(); }
104 virtual SwFormat* GetFormat(size_t idx) const override { return operator[](idx); }
105
108 bool ContainsFormat(SwFrameFormat const& rFormat) const;
110 bool IsAlive(SwFrameFormat const*) const;
111
112 void DeleteAndDestroyAll(bool keepDefault = false);
113
114 bool newDefault(const value_type& x);
115 void newDefault(const_iterator const& position);
116
117 // Override return type to reduce casting
118 virtual SwFrameFormat* FindFormatByName(const OUString& rName) const override;
119};
120
121/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
struct _xmlTextWriter * xmlTextWriterPtr
Base class for various Writer styles.
Definition: format.hxx:47
provides some methods for generic operations on lists that contain SwFormat* subclasses.
Definition: docary.hxx:44
virtual SwFormat * FindFormatByName(const OUString &rName) const
Definition: format.cxx:766
Style of a layout element.
Definition: frmfmt.hxx:62
virtual void SetFormatName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2568
Specific frame formats (frames, DrawObjects).
ByPos::iterator iterator
ByPos::const_iterator const_iterator
bool empty() const
const value_type & operator[](size_t index_) const
virtual size_t GetFormatCount() const override
SwFrameFormatsBase m_Array
SwFrameFormatsBase::size_type size_type
size_t size() const
SwFrameFormatsBase::value_type value_type
const_iterator begin() const
ByTypeAndName & m_TypeAndNameIndex
ByTypeAndName::const_iterator typeAndNameEnd() const
const value_type & back() const
virtual SwFormat * GetFormat(size_t idx) const override
const_iterator end() const
SwFrameFormatsBase::nth_index< 1 >::type ByTypeAndName
ByPos & m_PosIndex
SwFrameFormatsBase::nth_index< 0 >::type ByPos
const value_type & front() const
boost::multi_index_container< SwFrameFormat *, boost::multi_index::indexed_by< boost::multi_index::random_access<>, boost::multi_index::ordered_unique< type_name_key > > > SwFrameFormatsBase
const sal_uInt16 idx[]
sal_uInt32 index_
OSQLColumns::const_iterator find(const OSQLColumns::const_iterator &first, const OSQLColumns::const_iterator &last, std::u16string_view _rVal, const ::comphelper::UStringMixEqual &_rCase)
#define SW_DLLPUBLIC
Definition: swdllapi.h:28