lok: avoid expensive fetching of a property.
[LibreOffice.git] / sw / inc / ToxWhitespaceStripper.hxx
blob9decbc020bf465c66d1ab5d9d541c26b78048ae8
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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 */
10 #ifndef TOXWHITESPACESTRIPPER_HXX_
11 #define TOXWHITESPACESTRIPPER_HXX_
13 #include <rtl/ustring.hxx>
14 #include <vector>
16 namespace sw
18 /** This class helps to remove unwanted whitespaces from a string to use in a Tox.
20 * The new string will have
21 * - Newlines changed to spaces
22 * - Consecutive spaces merged
23 * - Trailing spaces removed
25 * It also allows to find the corresponding new positions of the input string in the stripped string.
26 * This is important for attributes which might have to be imported, e.g., it helps to answer the question:
27 * The 3rd character of the input string is subscript, which character in the output string is that?
29 * @note One leading whitespace is preserved.
31 class ToxWhitespaceStripper
33 public:
34 ToxWhitespaceStripper(const OUString&);
36 sal_Int32 GetPositionInStrippedString(sal_Int32 pos) const;
38 const OUString& GetStrippedString() const { return mStripped; }
40 private:
41 OUString mStripped;
42 std::vector<sal_Int32> mNewPositions;
45 } // end namespace sw
47 #endif /* TOXWHITESPACESTRIPPER_HXX_ */