Coverage Report

Created: 2026-04-09 11:41

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sw/inc/ToxWhitespaceStripper.hxx
Line
Count
Source
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
10
#pragma once
11
12
#include <rtl/ustring.hxx>
13
#include <vector>
14
15
namespace sw
16
{
17
/** This class helps to remove unwanted whitespaces from a string to use in a Tox.
18
 *
19
 * The new string will have
20
 * - Newlines changed to spaces
21
 * - Consecutive spaces merged
22
 * - Trailing spaces removed
23
 *
24
 * It also allows to find the corresponding new positions of the input string in the stripped string.
25
 * This is important for attributes which might have to be imported, e.g., it helps to answer the question:
26
 * The 3rd character of the input string is subscript, which character in the output string is that?
27
 *
28
 * @note One leading whitespace is preserved.
29
 */
30
class ToxWhitespaceStripper
31
{
32
public:
33
    ToxWhitespaceStripper(std::u16string_view);
34
35
    sal_Int32 GetPositionInStrippedString(sal_Int32 pos) const;
36
37
0
    const OUString& GetStrippedString() const { return mStripped; }
38
39
private:
40
    OUString mStripped;
41
    std::vector<sal_Int32> mNewPositions;
42
};
43
44
} // end namespace sw
45
46
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */