/src/libreoffice/vcl/source/text/mnemonic.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ |
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 | | #include <vcl/mnemonic.hxx> |
11 | | |
12 | | OUString removeMnemonicFromString(OUString const& rStr) |
13 | 0 | { |
14 | 0 | sal_Int32 nDummy; |
15 | 0 | return removeMnemonicFromString(rStr, nDummy); |
16 | 0 | } |
17 | | |
18 | | OUString removeMnemonicFromString(OUString const& rStr, sal_Int32& rMnemonicPos) |
19 | 717 | { |
20 | 717 | OUString aStr = rStr; |
21 | 717 | sal_Int32 nLen = aStr.getLength() - 1; // Don't remove trailing ~ |
22 | | |
23 | 717 | rMnemonicPos = -1; |
24 | 2.36M | for (sal_Int32 i = 0; i < nLen; ++i) |
25 | 2.36M | { |
26 | 2.36M | if (aStr[i] == '~') |
27 | 2.12k | { |
28 | 2.12k | aStr = aStr.replaceAt(i, 1, u""); |
29 | 2.12k | nLen--; |
30 | 2.12k | if (aStr[i] != '~') |
31 | 2.10k | { |
32 | 2.10k | if (rMnemonicPos == -1) |
33 | 488 | rMnemonicPos = i; |
34 | 2.10k | } |
35 | | // else skip the escaped second ~ |
36 | 2.12k | } |
37 | 2.36M | } |
38 | | |
39 | 717 | return aStr; |
40 | 717 | } |
41 | | |
42 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |