/src/libreoffice/editeng/inc/TextPortionList.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 | | |
20 | | #pragma once |
21 | | |
22 | | #include "TextPortion.hxx" |
23 | | #include <vector> |
24 | | |
25 | | class TextPortionList |
26 | | { |
27 | | typedef std::vector<std::unique_ptr<TextPortion>> PortionsType; |
28 | | PortionsType maPortions; |
29 | | |
30 | | public: |
31 | 18.1M | TextPortionList() = default; |
32 | | |
33 | 788k | void Reset() { maPortions.clear(); } |
34 | | |
35 | | sal_Int32 FindPortion(sal_Int32 nCharPos, sal_Int32& rPortionStart, |
36 | | bool bPreferStartingPortion = false) const; |
37 | | sal_Int32 GetStartPos(sal_Int32 nPortion); |
38 | | void DeleteFromPortion(sal_Int32 nDelFrom); |
39 | | |
40 | 41.7M | sal_Int32 Count() const { return sal_Int32(maPortions.size()); } |
41 | | |
42 | 6.84M | const TextPortion& operator[](sal_Int32 nPosition) const { return *maPortions[nPosition]; } |
43 | | |
44 | 352M | TextPortion& operator[](sal_Int32 nPosition) { return *maPortions[nPosition]; } |
45 | | |
46 | | void Append(TextPortion* pTextPortion) |
47 | 13.6M | { |
48 | 13.6M | maPortions.push_back(std::unique_ptr<TextPortion>(pTextPortion)); |
49 | 13.6M | } |
50 | | |
51 | | void Insert(sal_Int32 nPosition, TextPortion* pTextPortion) |
52 | 2.15M | { |
53 | 2.15M | maPortions.insert(maPortions.begin() + nPosition, |
54 | 2.15M | std::unique_ptr<TextPortion>(pTextPortion)); |
55 | 2.15M | } |
56 | | |
57 | 0 | void Remove(sal_Int32 nPosition) { maPortions.erase(maPortions.begin() + nPosition); } |
58 | | |
59 | | sal_Int32 GetPos(const TextPortion* p) const; |
60 | | |
61 | 4.51M | bool isEmpty() { return Count() == 1 && maPortions[0]->GetLen() == 0; } |
62 | | |
63 | 0 | PortionsType::iterator begin() { return maPortions.begin(); } |
64 | 0 | PortionsType::iterator end() { return maPortions.end(); } |
65 | 0 | PortionsType::const_iterator cbegin() const { return maPortions.cbegin(); } |
66 | 0 | PortionsType::const_iterator cend() const { return maPortions.cend(); } |
67 | | }; |
68 | | |
69 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |