summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--accessibility/source/standard/accessiblemenuitemcomponent.cxx5
-rw-r--r--accessibility/source/standard/vclxaccessibleedit.cxx3
-rw-r--r--accessibility/source/standard/vclxaccessibletabpage.cxx3
-rw-r--r--accessibility/source/standard/vclxaccessibletextcomponent.cxx5
-rw-r--r--dbaccess/source/ui/misc/datasourceconnector.cxx3
-rw-r--r--include/vcl/mnemonic.hxx2
-rw-r--r--include/vcl/outdev.hxx5
-rw-r--r--include/vcl/window.hxx2
-rw-r--r--sfx2/source/control/thumbnailviewitem.cxx3
-rw-r--r--vcl/Library_vcl.mk1
-rw-r--r--vcl/source/control/ctrl.cxx5
-rw-r--r--vcl/source/control/tabctrl.cxx3
-rw-r--r--vcl/source/gdi/pdfwriter_impl.cxx3
-rw-r--r--vcl/source/outdev/text.cxx46
-rw-r--r--vcl/source/text/mnemonic.cxx53
-rw-r--r--vcl/source/window/accessibility.cxx3
-rw-r--r--vcl/source/window/menu.cxx3
-rw-r--r--vcl/source/window/menuitemlist.cxx4
18 files changed, 90 insertions, 62 deletions
diff --git a/accessibility/source/standard/accessiblemenuitemcomponent.cxx b/accessibility/source/standard/accessiblemenuitemcomponent.cxx
index b599a66a7282..074cd0bdc531 100644
--- a/accessibility/source/standard/accessiblemenuitemcomponent.cxx
+++ b/accessibility/source/standard/accessiblemenuitemcomponent.cxx
@@ -31,6 +31,7 @@
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
#include <vcl/menu.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/settings.hxx>
#include <i18nlangtag/languagetag.hxx>
@@ -179,7 +180,7 @@ OUString OAccessibleMenuItemComponent::GetAccessibleName()
sName = m_pParent->GetAccessibleName( nItemId );
if ( sName.isEmpty() )
sName = m_pParent->GetItemText( nItemId );
- sName = OutputDevice::GetNonMnemonicString( sName );
+ sName = removeMnemonicFromString( sName );
#if defined(_WIN32)
if ( m_pParent->GetAccelKey( nItemId ).GetName().getLength() )
sName += "\t" + m_pParent->GetAccelKey(nItemId).GetName();
@@ -205,7 +206,7 @@ OUString OAccessibleMenuItemComponent::GetItemText()
{
OUString sText;
if ( m_pParent )
- sText = OutputDevice::GetNonMnemonicString( m_pParent->GetItemText( m_pParent->GetItemId( m_nItemPos ) ) );
+ sText = removeMnemonicFromString( m_pParent->GetItemText( m_pParent->GetItemId( m_nItemPos ) ) );
return sText;
}
diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx
index 4dc19a3e12bf..dc2a39acbf56 100644
--- a/accessibility/source/standard/vclxaccessibleedit.cxx
+++ b/accessibility/source/standard/vclxaccessibleedit.cxx
@@ -31,6 +31,7 @@
#include <comphelper/string.hxx>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/settings.hxx>
#include <vcl/toolkit/edit.hxx>
#include <vcl/toolkit/vclmedit.hxx>
@@ -127,7 +128,7 @@ OUString VCLXAccessibleEdit::implGetText()
VclPtr< Edit > pEdit = GetAs< Edit >();
if ( pEdit )
{
- aText = OutputDevice::GetNonMnemonicString( pEdit->GetText() );
+ aText = removeMnemonicFromString( pEdit->GetText() );
if ( implGetAccessibleRole() == AccessibleRole::PASSWORD_TEXT )
{
diff --git a/accessibility/source/standard/vclxaccessibletabpage.cxx b/accessibility/source/standard/vclxaccessibletabpage.cxx
index 8c483bf733c8..9786b2f761fd 100644
--- a/accessibility/source/standard/vclxaccessibletabpage.cxx
+++ b/accessibility/source/standard/vclxaccessibletabpage.cxx
@@ -29,6 +29,7 @@
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <cppuhelper/supportsservice.hxx>
#include <unotools/accessiblerelationsethelper.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/svapp.hxx>
#include <vcl/unohelp2.hxx>
#include <vcl/tabctrl.hxx>
@@ -132,7 +133,7 @@ OUString VCLXAccessibleTabPage::GetPageText()
{
OUString sText;
if ( m_pTabControl )
- sText = OutputDevice::GetNonMnemonicString( m_pTabControl->GetPageText( m_nPageId ) );
+ sText = removeMnemonicFromString( m_pTabControl->GetPageText( m_nPageId ) );
return sText;
}
diff --git a/accessibility/source/standard/vclxaccessibletextcomponent.cxx b/accessibility/source/standard/vclxaccessibletextcomponent.cxx
index c5dba0df978a..63974960b694 100644
--- a/accessibility/source/standard/vclxaccessibletextcomponent.cxx
+++ b/accessibility/source/standard/vclxaccessibletextcomponent.cxx
@@ -26,6 +26,7 @@
#include <com/sun/star/datatransfer/clipboard/XFlushableClipboard.hpp>
#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
#include <vcl/window.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/svapp.hxx>
#include <vcl/unohelp2.hxx>
#include <vcl/ctrl.hxx>
@@ -47,7 +48,7 @@ VCLXAccessibleTextComponent::VCLXAccessibleTextComponent( VCLXWindow* pVCLXWindo
{
VclPtr<vcl::Window> pWindow = GetWindow();
if ( pWindow )
- m_sText = OutputDevice::GetNonMnemonicString( pWindow->GetText() );
+ m_sText = removeMnemonicFromString( pWindow->GetText() );
}
@@ -86,7 +87,7 @@ OUString VCLXAccessibleTextComponent::implGetText()
OUString aText;
VclPtr<vcl::Window> pWindow = GetWindow();
if ( pWindow )
- aText = OutputDevice::GetNonMnemonicString( pWindow->GetText() );
+ aText = removeMnemonicFromString( pWindow->GetText() );
return aText;
}
diff --git a/dbaccess/source/ui/misc/datasourceconnector.cxx b/dbaccess/source/ui/misc/datasourceconnector.cxx
index 4280d088caf7..9025b24bb5f7 100644
--- a/dbaccess/source/ui/misc/datasourceconnector.cxx
+++ b/dbaccess/source/ui/misc/datasourceconnector.cxx
@@ -31,6 +31,7 @@
#include <com/sun/star/sdbc/XDataSource.hpp>
#include <UITools.hxx>
#include <utility>
+#include <vcl/mnemonic.hxx>
#include <vcl/outdev.hxx>
#include <vcl/stdtext.hxx>
#include <vcl/weld.hxx>
@@ -156,7 +157,7 @@ namespace dbaui
{
OUString sMessage( DBA_RES( STR_WARNINGS_DURING_CONNECT ) );
sMessage = sMessage.replaceFirst( "$buttontext$", GetStandardText( StandardButtonType::More ) );
- sMessage = OutputDevice::GetNonMnemonicString( sMessage );
+ sMessage = removeMnemonicFromString( sMessage );
SQLWarning aContext;
aContext.Message = sMessage;
diff --git a/include/vcl/mnemonic.hxx b/include/vcl/mnemonic.hxx
index 23ea1d1e6273..b730311481dd 100644
--- a/include/vcl/mnemonic.hxx
+++ b/include/vcl/mnemonic.hxx
@@ -48,6 +48,8 @@ namespace com::sun::star::i18n { class XCharacterClassification; }
#define MNEMONIC_CHAR u'~'
#define MNEMONIC_INDEX_NOTFOUND (sal_uInt16(0xFFFF))
+VCL_DLLPUBLIC OUString removeMnemonicFromString(OUString const& rStr, sal_Int32& rMnemonicPos);
+VCL_DLLPUBLIC OUString removeMnemonicFromString(OUString const& rStr);
class VCL_DLLPUBLIC MnemonicGenerator
{
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index 17d5d87289e9..5a13c640a296 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -990,11 +990,6 @@ public:
tools::Long GetCtrlTextWidth( const OUString& rStr,
const SalLayoutGlyphs* pLayoutCache = nullptr ) const;
- static OUString GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos );
-
- static OUString GetNonMnemonicString( const OUString& rStr )
- { sal_Int32 nDummy; return GetNonMnemonicString( rStr, nDummy ); }
-
/** Generate MetaTextActions for the text rect
This method splits up the text rect into multiple
diff --git a/include/vcl/window.hxx b/include/vcl/window.hxx
index 2494f8852a68..bc90e6e55fa0 100644
--- a/include/vcl/window.hxx
+++ b/include/vcl/window.hxx
@@ -1562,8 +1562,6 @@ public:
*/
bool IsNativeControlSupported( ControlType nType, ControlPart nPart ) const;
- static OUString GetNonMnemonicString(const OUString& rStr) { return OutputDevice::GetNonMnemonicString(rStr); }
-
/** Query the native control's actual drawing region (including adornment)
*/
bool GetNativeControlRegion(
diff --git a/sfx2/source/control/thumbnailviewitem.cxx b/sfx2/source/control/thumbnailviewitem.cxx
index 9b75120289be..ca092bc18e1c 100644
--- a/sfx2/source/control/thumbnailviewitem.cxx
+++ b/sfx2/source/control/thumbnailviewitem.cxx
@@ -34,6 +34,7 @@
#include <drawinglayer/primitive2d/textprimitive2d.hxx>
#include <drawinglayer/processor2d/baseprocessor2d.hxx>
#include <vcl/graph.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/outdev.hxx>
#include <vcl/texteng.hxx>
@@ -212,7 +213,7 @@ void ThumbnailViewItem::addTextPrimitives (const OUString& rText, const Thumbnai
aPos.setY(aPos.getY() + aTextDev.getTextHeight());
sal_Int32 nMnemonicPos = -1;
- OUString aOrigText(mrParent.isDrawMnemonic() ? OutputDevice::GetNonMnemonicString(rText, nMnemonicPos) : rText);
+ OUString aOrigText(mrParent.isDrawMnemonic() ? removeMnemonicFromString(rText, nMnemonicPos) : rText);
TextEngine aTextEngine;
aTextEngine.SetFont(getVclFontFromFontAttribute(pAttrs->aFontAttr,
diff --git a/vcl/Library_vcl.mk b/vcl/Library_vcl.mk
index cc5940cf61d0..1faaa57cf336 100644
--- a/vcl/Library_vcl.mk
+++ b/vcl/Library_vcl.mk
@@ -261,6 +261,7 @@ $(eval $(call gb_Library_add_exception_objects,vcl,\
vcl/source/treelist/svlbitm \
vcl/source/treelist/uiobject \
vcl/source/text/ImplLayoutRuns \
+ vcl/source/text/mnemonic \
vcl/source/gdi/configsettings \
vcl/source/gdi/cvtgrf \
vcl/source/gdi/embeddedfontshelper \
diff --git a/vcl/source/control/ctrl.cxx b/vcl/source/control/ctrl.cxx
index 6cb06bc1191d..0ad2247b5488 100644
--- a/vcl/source/control/ctrl.cxx
+++ b/vcl/source/control/ctrl.cxx
@@ -22,6 +22,7 @@
#include <vcl/event.hxx>
#include <vcl/ctrl.hxx>
#include <vcl/decoview.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/settings.hxx>
#include <vcl/uitest/logger.hxx>
#include <sal/log.hxx>
@@ -435,7 +436,7 @@ tools::Rectangle Control::DrawControlText( OutputDevice& _rTargetDevice, const t
if (autoacc && !mbShowAccelerator)
{
- rPStr = GetNonMnemonicString( _rStr );
+ rPStr = removeMnemonicFromString( _rStr );
nPStyle &= ~DrawTextFlags::HideMnemonic;
}
@@ -460,7 +461,7 @@ tools::Rectangle Control::GetControlTextRect( OutputDevice& _rTargetDevice, cons
if (autoacc && !mbShowAccelerator)
{
- rPStr = GetNonMnemonicString( _rStr );
+ rPStr = removeMnemonicFromString( _rStr );
nPStyle &= ~DrawTextFlags::HideMnemonic;
}
diff --git a/vcl/source/control/tabctrl.cxx b/vcl/source/control/tabctrl.cxx
index 88088df14954..c55e2820c297 100644
--- a/vcl/source/control/tabctrl.cxx
+++ b/vcl/source/control/tabctrl.cxx
@@ -30,6 +30,7 @@
#include <vcl/tabctrl.hxx>
#include <vcl/toolbox.hxx>
#include <vcl/layout.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/toolkit/lstbox.hxx>
#include <vcl/settings.hxx>
#include <vcl/uitest/uiobject.hxx>
@@ -1980,7 +1981,7 @@ OUString TabControl::GetAccessibleName( sal_uInt16 nPageId ) const
assert( pItem );
if (!pItem->maAccessibleName.isEmpty())
return pItem->maAccessibleName;
- return OutputDevice::GetNonMnemonicString(pItem->maText);
+ return removeMnemonicFromString(pItem->maText);
}
void TabControl::SetAccessibleDescription(sal_uInt16 nPageId, const OUString& rDesc)
diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx
index 74b7ccdbcf7d..1e8fc7fa5ea9 100644
--- a/vcl/source/gdi/pdfwriter_impl.cxx
+++ b/vcl/source/gdi/pdfwriter_impl.cxx
@@ -66,6 +66,7 @@
#include <vcl/glyphitemcache.hxx>
#include <vcl/lineinfo.hxx>
#include <vcl/metric.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/settings.hxx>
#include <strhelper.hxx>
#include <vcl/svapp.hxx>
@@ -6684,7 +6685,7 @@ void PDFWriterImpl::drawText( const tools::Rectangle& rRect, const OUString& rOr
OUString aStr = rOrigStr;
if ( nStyle & DrawTextFlags::Mnemonic )
- aStr = OutputDevice::GetNonMnemonicString( aStr, nMnemonicPos );
+ aStr = removeMnemonicFromString( aStr, nMnemonicPos );
// multiline text
if ( nStyle & DrawTextFlags::MultiLine )
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index 55ddbde7e1a1..6ca2785e3b1f 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -37,6 +37,7 @@
#include <vcl/gdimtf.hxx>
#include <vcl/metaact.hxx>
#include <vcl/metric.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/textrectinfo.hxx>
#include <vcl/virdev.hxx>
#include <vcl/sysdata.hxx>
@@ -1642,7 +1643,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const tools::Recta
OUString aStr = rOrigStr;
if ( nStyle & DrawTextFlags::Mnemonic )
- aStr = GetNonMnemonicString( aStr, nMnemonicPos );
+ aStr = removeMnemonicFromString( aStr, nMnemonicPos );
const bool bDrawMnemonics = !(rTargetDevice.GetSettings().GetStyleSettings().GetOptions() & StyleSettingsOptions::NoMnemonics) && !pVector;
@@ -1932,7 +1933,7 @@ tools::Rectangle OutputDevice::GetTextRect( const tools::Rectangle& rRect,
OUString aStr = rStr;
if ( nStyle & DrawTextFlags::Mnemonic )
- aStr = GetNonMnemonicString( aStr );
+ aStr = removeMnemonicFromString( aStr );
if ( nStyle & DrawTextFlags::MultiLine )
{
@@ -2226,7 +2227,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr,
tools::Long nMnemonicWidth = 0;
if ( (nStyle & DrawTextFlags::Mnemonic) && nLen > 1 )
{
- aStr = GetNonMnemonicString( aStr, nMnemonicPos );
+ aStr = removeMnemonicFromString( aStr, nMnemonicPos );
if ( nMnemonicPos != -1 )
{
if( nMnemonicPos < nIndex )
@@ -2335,8 +2336,8 @@ tools::Long OutputDevice::GetCtrlTextWidth( const OUString& rStr, const SalLayou
sal_Int32 nLen = rStr.getLength();
sal_Int32 nIndex = 0;
- sal_Int32 nMnemonicPos;
- OUString aStr = GetNonMnemonicString( rStr, nMnemonicPos );
+ sal_Int32 nMnemonicPos;
+ OUString aStr = removeMnemonicFromString( rStr, nMnemonicPos );
if ( nMnemonicPos != -1 )
{
if ( nMnemonicPos < nIndex )
@@ -2347,41 +2348,6 @@ tools::Long OutputDevice::GetCtrlTextWidth( const OUString& rStr, const SalLayou
return GetTextWidth( aStr, nIndex, nLen, nullptr, pGlyphs );
}
-OUString OutputDevice::GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos )
-{
- OUString aStr = rStr;
- sal_Int32 nLen = aStr.getLength();
- sal_Int32 i = 0;
-
- rMnemonicPos = -1;
- while ( i < nLen )
- {
- if ( aStr[ i ] == '~' )
- {
- if ( nLen <= i+1 )
- break;
-
- if ( aStr[ i+1 ] != '~' )
- {
- if ( rMnemonicPos == -1 )
- rMnemonicPos = i;
- aStr = aStr.replaceAt( i, 1, u"" );
- nLen--;
- }
- else
- {
- aStr = aStr.replaceAt( i, 1, u"" );
- nLen--;
- i++;
- }
- }
- else
- i++;
- }
-
- return aStr;
-}
-
bool OutputDevice::GetTextBoundRect( tools::Rectangle& rRect,
const OUString& rStr, sal_Int32 nBase,
sal_Int32 nIndex, sal_Int32 nLen,
diff --git a/vcl/source/text/mnemonic.cxx b/vcl/source/text/mnemonic.cxx
new file mode 100644
index 000000000000..7336032b8d12
--- /dev/null
+++ b/vcl/source/text/mnemonic.cxx
@@ -0,0 +1,53 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <vcl/mnemonic.hxx>
+
+OUString removeMnemonicFromString(OUString const& rStr)
+{
+ sal_Int32 nDummy;
+ return removeMnemonicFromString(rStr, nDummy);
+}
+
+OUString removeMnemonicFromString(OUString const& rStr, sal_Int32& rMnemonicPos)
+{
+ OUString aStr = rStr;
+ sal_Int32 nLen = aStr.getLength();
+ sal_Int32 i = 0;
+
+ rMnemonicPos = -1;
+ while (i < nLen)
+ {
+ if (aStr[i] == '~')
+ {
+ if (nLen <= i + 1)
+ break;
+
+ if (aStr[i + 1] != '~')
+ {
+ if (rMnemonicPos == -1)
+ rMnemonicPos = i;
+ aStr = aStr.replaceAt(i, 1, u"");
+ nLen--;
+ }
+ else
+ {
+ aStr = aStr.replaceAt(i, 1, u"");
+ nLen--;
+ i++;
+ }
+ }
+ else
+ i++;
+ }
+
+ return aStr;
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/vcl/source/window/accessibility.cxx b/vcl/source/window/accessibility.cxx
index a8f65d572eba..89adf9b8ea9e 100644
--- a/vcl/source/window/accessibility.cxx
+++ b/vcl/source/window/accessibility.cxx
@@ -21,6 +21,7 @@
#include <vcl/toolkit/fixed.hxx>
#include <vcl/window.hxx>
#include <vcl/menu.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/wrkwin.hxx>
#include <window.h>
@@ -438,7 +439,7 @@ OUString Window::getDefaultAccessibleName() const
break;
}
- return OutputDevice::GetNonMnemonicString( aAccessibleName );
+ return removeMnemonicFromString( aAccessibleName );
}
void Window::SetAccessibleDescription( const OUString& rDescription )
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index c0222bfdc551..5a9bfaa237d1 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -30,6 +30,7 @@
#include <vcl/toolkit/floatwin.hxx>
#include <vcl/decoview.hxx>
#include <vcl/menu.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/taskpanelist.hxx>
#include <vcl/settings.hxx>
#include <vcl/commandinfoprovider.hxx>
@@ -1648,7 +1649,7 @@ static void ImplPaintCheckBackground(vcl::RenderContext & rRenderContext, vcl::W
static OUString getShortenedString( const OUString& i_rLong, vcl::RenderContext const & rRenderContext, tools::Long i_nMaxWidth )
{
sal_Int32 nPos = -1;
- OUString aNonMnem(OutputDevice::GetNonMnemonicString(i_rLong, nPos));
+ OUString aNonMnem(removeMnemonicFromString(i_rLong, nPos));
aNonMnem = rRenderContext.GetEllipsisString( aNonMnem, i_nMaxWidth, DrawTextFlags::CenterEllipsis);
// re-insert mnemonic
if (nPos != -1)
diff --git a/vcl/source/window/menuitemlist.cxx b/vcl/source/window/menuitemlist.cxx
index 0efae5b43b8c..456474d7e610 100644
--- a/vcl/source/window/menuitemlist.cxx
+++ b/vcl/source/window/menuitemlist.cxx
@@ -23,7 +23,9 @@
#include <salinst.hxx>
#include <salmenu.hxx>
#include <svdata.hxx>
+
#include <vcl/i18nhelp.hxx>
+#include <vcl/mnemonic.hxx>
#include <vcl/settings.hxx>
#include <vcl/vcllayout.hxx>
#include <vcl/window.hxx>
@@ -45,7 +47,7 @@ SalLayoutGlyphs* MenuItemData::GetTextGlyphs(const OutputDevice* pOutputDevice)
// Use pre-calculated result.
return &aTextGlyphs;
- OUString aNonMnemonicString = OutputDevice::GetNonMnemonicString(aText);
+ OUString aNonMnemonicString = removeMnemonicFromString(aText);
std::unique_ptr<SalLayout> pLayout
= pOutputDevice->ImplLayout(aNonMnemonicString, 0, aNonMnemonicString.getLength(),
Point(0, 0), 0, {}, {}, SalLayoutFlags::GlyphItemsOnly);