tdf#164793: fix misplaced rounding
[LibreOffice.git] / vcl / source / text / mnemonic.cxx
blob9a63c2e7d785f6668707744a765408f618ba6c60
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.
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 #include <vcl/mnemonic.hxx>
12 OUString removeMnemonicFromString(OUString const& rStr)
14 sal_Int32 nDummy;
15 return removeMnemonicFromString(rStr, nDummy);
18 OUString removeMnemonicFromString(OUString const& rStr, sal_Int32& rMnemonicPos)
20 OUString aStr = rStr;
21 sal_Int32 nLen = aStr.getLength() - 1; // Don't remove trailing ~
23 rMnemonicPos = -1;
24 for (sal_Int32 i = 0; i < nLen; ++i)
26 if (aStr[i] == '~')
28 aStr = aStr.replaceAt(i, 1, u"");
29 nLen--;
30 if (aStr[i] != '~')
32 if (rMnemonicPos == -1)
33 rMnemonicPos = i;
35 // else skip the escaped second ~
39 return aStr;
42 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */