framework/source/uielement/menubarmanager.cxx | 6 include/vcl/menu.hxx | 28 ++-- include/vcl/outdev.hxx | 4 svtools/source/uno/contextmenuhelper.cxx | 2 vcl/source/gdi/outdev3.cxx | 24 +-- vcl/source/gdi/pdfwriter_impl.cxx | 2 vcl/source/window/menu.cxx | 159 +++++++++++++------------- 7 files changed, 115 insertions(+), 110 deletions(-)
New commits: commit f89637e329e765bce0bd513c843e4e2b673c38fd Author: Kohei Yoshida <kohei.yosh...@gmail.com> Date: Wed Jul 31 13:01:36 2013 -0400 Revert "convert vcl/menu.hxx from XubString to OUString" This reverts commit 43b1ac3651732a1ceb193268ab72b4aaa90dee65. diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx index 23baa74..7f7f69a 100644 --- a/framework/source/uielement/menubarmanager.cxx +++ b/framework/source/uielement/menubarmanager.cxx @@ -845,7 +845,7 @@ IMPL_LINK( MenuBarManager, Activate, Menu *, pMenu ) { sal_uInt16 nItemId = pMenu->GetItemId( nPos ); if (( pMenu->GetItemType( nPos ) != MENUITEM_SEPARATOR ) && - ( pMenu->GetItemText( nItemId ).isEmpty() )) + ( pMenu->GetItemText( nItemId ).Len() == 0 )) { String aCommand = pMenu->GetItemCommand( nItemId ); if ( aCommand.Len() > 0 ) { @@ -1252,7 +1252,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF } if (( pMenu->IsMenuBar() || bAccessibilityEnabled ) && - ( pMenu->GetItemText( nItemId ).isEmpty() )) + ( pMenu->GetItemText( nItemId ).Len() == 0 )) { if ( !aItemCommand.isEmpty() ) pMenu->SetItemText( nItemId, RetrieveLabelFromCommand( aItemCommand )); @@ -1272,7 +1272,7 @@ void MenuBarManager::FillMenuManager( Menu* pMenu, const Reference< XFrame >& rF { // Retrieve module identifier from Help Command entry OUString aModuleIdentifier( rModuleIdentifier ); - if ( !pMenu->GetHelpCommand( nItemId ).isEmpty() ) + if ( pMenu->GetHelpCommand( nItemId ).Len() > 0 ) { aModuleIdentifier = pMenu->GetHelpCommand( nItemId ); pMenu->SetHelpCommand( nItemId, aEmpty ); diff --git a/include/vcl/menu.hxx b/include/vcl/menu.hxx index 8328166..f05ee5d 100644 --- a/include/vcl/menu.hxx +++ b/include/vcl/menu.hxx @@ -164,7 +164,7 @@ protected: SAL_DLLPRIVATE void ImplFillLayoutData() const; SAL_DLLPRIVATE SalMenu* ImplGetSalMenu() { return mpSalMenu; } SAL_DLLPRIVATE void ImplSetSalMenu( SalMenu *pMenu ); - SAL_DLLPRIVATE const OUString& ImplGetHelpText( sal_uInt16 nItemId ) const; + SAL_DLLPRIVATE const XubString& ImplGetHelpText( sal_uInt16 nItemId ) const; // returns native check and option menu symbol height in rCheckHeight and rRadioHeight // return value is maximum width and height of checkboxes and radiobuttons @@ -194,7 +194,7 @@ public: virtual void Select(); virtual void RequestHelp( const HelpEvent& rHEvt ); - void InsertItem( sal_uInt16 nItemId, const OUString& rStr, + void InsertItem( sal_uInt16 nItemId, const XubString& rStr, MenuItemBits nItemBits = 0, const OString &rIdent = OString(), sal_uInt16 nPos = MENU_APPEND ); @@ -203,7 +203,7 @@ public: const OString &rIdent = OString(), sal_uInt16 nPos = MENU_APPEND ); void InsertItem( sal_uInt16 nItemId, - const OUString& rString, const Image& rImage, + const XubString& rString, const Image& rImage, MenuItemBits nItemBits = 0, const OString &rIdent = OString(), sal_uInt16 nPos = MENU_APPEND ); @@ -267,8 +267,8 @@ public: void RemoveDisabledEntries( sal_Bool bCheckPopups = sal_True, sal_Bool bRemoveEmptyPopups = sal_False ); sal_Bool HasValidEntries( sal_Bool bCheckPopups = sal_True ); - void SetItemText( sal_uInt16 nItemId, const OUString& rStr ); - OUString GetItemText( sal_uInt16 nItemId ) const; + void SetItemText( sal_uInt16 nItemId, const XubString& rStr ); + XubString GetItemText( sal_uInt16 nItemId ) const; void SetItemImage( sal_uInt16 nItemId, const Image& rImage ); Image GetItemImage( sal_uInt16 nItemId ) const; @@ -280,14 +280,14 @@ public: void SetItemCommand( sal_uInt16 nItemId, const OUString& rCommand ); const OUString GetItemCommand( sal_uInt16 nItemId ) const; - void SetHelpText( sal_uInt16 nItemId, const OUString& rString ); - const OUString& GetHelpText( sal_uInt16 nItemId ) const; + void SetHelpText( sal_uInt16 nItemId, const XubString& rString ); + const XubString& GetHelpText( sal_uInt16 nItemId ) const; - void SetTipHelpText( sal_uInt16 nItemId, const OUString& rString ); - const OUString& GetTipHelpText( sal_uInt16 nItemId ) const; + void SetTipHelpText( sal_uInt16 nItemId, const XubString& rString ); + const XubString& GetTipHelpText( sal_uInt16 nItemId ) const; - void SetHelpCommand( sal_uInt16 nItemId, const OUString& rString ); - const OUString& GetHelpCommand( sal_uInt16 nItemId ) const; + void SetHelpCommand( sal_uInt16 nItemId, const XubString& rString ); + const XubString& GetHelpCommand( sal_uInt16 nItemId ) const; void SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ); OString GetHelpId( sal_uInt16 nItemId ) const; @@ -343,8 +343,8 @@ public: Window* GetWindow() const { return pWindow; } - void SetAccessibleName( sal_uInt16 nItemId, const OUString& rStr ); - OUString GetAccessibleName( sal_uInt16 nItemId ) const; + void SetAccessibleName( sal_uInt16 nItemId, const XubString& rStr ); + XubString GetAccessibleName( sal_uInt16 nItemId ) const; // returns whether the item a position nItemPos is highlighted or not. bool IsHighlighted( sal_uInt16 nItemPos ) const; @@ -420,7 +420,7 @@ public: // add an arbitrary button to the menubar (will appear next to closer) // passed link will be call with a MenuBarButtonCallbackArg on press // passed string will be set as tooltip - sal_uInt16 AddMenuBarButton( const Image&, const Link&, const OUString&, sal_uInt16 nPos = 0 ); + sal_uInt16 AddMenuBarButton( const Image&, const Link&, const String&, sal_uInt16 nPos = 0 ); // set the highlight link for additional button with ID nId // highlight link will be called with a MenuBarButtonHighlightArg // the bHighlight member of that struct shall contain the new state diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx index 696a928..2e5ad68 100644 --- a/include/vcl/outdev.hxx +++ b/include/vcl/outdev.hxx @@ -629,9 +629,9 @@ public: long GetCtrlTextWidth( const OUString& rStr, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, sal_uInt16 nStyle = TEXT_DRAW_MNEMONIC ) const; - static OUString GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos ); + static OUString GetNonMnemonicString( const OUString& rStr, xub_StrLen& rMnemonicPos ); static OUString GetNonMnemonicString( const OUString& rStr ) - { sal_Int32 nDummy; return GetNonMnemonicString( rStr, nDummy ); } + { xub_StrLen nDummy; return GetNonMnemonicString( rStr, nDummy ); } sal_Bool GetTextBoundRect( Rectangle& rRect, const OUString& rStr, xub_StrLen nBase = 0, xub_StrLen nIndex = 0, xub_StrLen nLen = STRING_LEN, diff --git a/svtools/source/uno/contextmenuhelper.cxx b/svtools/source/uno/contextmenuhelper.cxx index 7e48cb3..5a39529 100644 --- a/svtools/source/uno/contextmenuhelper.cxx +++ b/svtools/source/uno/contextmenuhelper.cxx @@ -588,7 +588,7 @@ ContextMenuHelper::completeMenuProperties( else pMenu->SetItemImage( nId, Image() ); - if ( pMenu->GetItemText( nId ).isEmpty() ) + if ( pMenu->GetItemText( nId ).Len() == 0 ) { OUString aLabel( getLabelFromCommandURL( aCmdURL )); pMenu->SetItemText( nId, aLabel ); diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx index 40e65b9..a0315ee 100644 --- a/vcl/source/gdi/outdev3.cxx +++ b/vcl/source/gdi/outdev3.cxx @@ -6142,7 +6142,7 @@ void OutputDevice::ImplDrawText( OutputDevice& rTargetDevice, const Rectangle& r long nTextHeight = rTargetDevice.GetTextHeight(); TextAlign eAlign = rTargetDevice.GetTextAlign(); - sal_Int32 nMnemonicPos = STRING_NOTFOUND; + xub_StrLen nMnemonicPos = STRING_NOTFOUND; OUString aStr = rOrigStr; if ( nStyle & TEXT_DRAW_MNEMONIC ) @@ -6718,7 +6718,7 @@ void OutputDevice::DrawCtrlText( const Point& rPos, const OUString& rStr, nLen = rStr.getLength() - nIndex; OUString aStr = rStr; - sal_Int32 nMnemonicPos = STRING_NOTFOUND; + xub_StrLen nMnemonicPos = STRING_NOTFOUND; long nMnemonicX = 0; long nMnemonicY = 0; @@ -6832,14 +6832,14 @@ long OutputDevice::GetCtrlTextWidth( const OUString& rStr, if ( nStyle & TEXT_DRAW_MNEMONIC ) { - sal_Int32 nMnemonicPos; + xub_StrLen nMnemonicPos; OUString aStr = GetNonMnemonicString( rStr, nMnemonicPos ); if ( nMnemonicPos != STRING_NOTFOUND ) { if ( nMnemonicPos < nIndex ) nIndex--; else if ( (nLen < STRING_LEN) && - (nMnemonicPos >= nIndex) && ((sal_uLong)nMnemonicPos < (sal_uLong)(nIndex+nLen)) ) + (nMnemonicPos >= nIndex) && (nMnemonicPos < (sal_uLong)(nIndex+nLen)) ) nLen--; } return GetTextWidth( aStr, nIndex, nLen ); @@ -6848,27 +6848,27 @@ long OutputDevice::GetCtrlTextWidth( const OUString& rStr, return GetTextWidth( rStr, nIndex, nLen ); } -OUString OutputDevice::GetNonMnemonicString( const OUString& rStr, sal_Int32& rMnemonicPos ) +OUString OutputDevice::GetNonMnemonicString( const OUString& rStr, xub_StrLen& rMnemonicPos ) { - OUString aStr = rStr; - sal_Int32 nLen = aStr.getLength(); - sal_Int32 i = 0; + String aStr = rStr; + xub_StrLen nLen = aStr.Len(); + xub_StrLen i = 0; rMnemonicPos = STRING_NOTFOUND; while ( i < nLen ) { - if ( aStr[ i ] == '~' ) + if ( aStr.GetChar( i ) == '~' ) { - if ( aStr[ i+1 ] != '~' ) + if ( aStr.GetChar( i+1 ) != '~' ) { if ( rMnemonicPos == STRING_NOTFOUND ) rMnemonicPos = i; - aStr = aStr.replaceAt( i, 1, "" ); + aStr.Erase( i, 1 ); nLen--; } else { - aStr = aStr.replaceAt( i, 1, "" ); + aStr.Erase( i, 1 ); nLen--; i++; } diff --git a/vcl/source/gdi/pdfwriter_impl.cxx b/vcl/source/gdi/pdfwriter_impl.cxx index baa82e5..2757f76 100644 --- a/vcl/source/gdi/pdfwriter_impl.cxx +++ b/vcl/source/gdi/pdfwriter_impl.cxx @@ -7909,7 +7909,7 @@ void PDFWriterImpl::drawText( const Rectangle& rRect, const OUString& rOrigStr, Point aPos = rRect.TopLeft(); long nTextHeight = m_pReferenceDevice->GetTextHeight(); - sal_Int32 nMnemonicPos = STRING_NOTFOUND; + xub_StrLen nMnemonicPos = STRING_NOTFOUND; OUString aStr = rOrigStr; if ( nStyle & TEXT_DRAW_MNEMONIC ) diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx index e6edd9e..8d91515 100644 --- a/vcl/source/window/menu.cxx +++ b/vcl/source/window/menu.cxx @@ -113,11 +113,11 @@ struct MenuItemData MenuItemBits nBits; // MenuItem-Bits Menu* pSubMenu; // Pointer to SubMenu Menu* pAutoSubMenu; // Pointer to SubMenu from Resource - OUString aText; // Menu-Text - OUString aHelpText; // Help-String - OUString aTipHelpText; // TipHelp-String (eg, expanded filenames) - OUString aCommandStr; // CommandString - OUString aHelpCommandStr; // Help command string (to reference external help) + XubString aText; // Menu-Text + XubString aHelpText; // Help-String + XubString aTipHelpText; // TipHelp-String (eg, expanded filenames) + XubString aCommandStr; // CommandString + XubString aHelpCommandStr; // Help command string (to reference external help) OString sIdent; OString aHelpId; // Help-Id sal_uLong nUserValue; // User value @@ -130,15 +130,15 @@ struct MenuItemData sal_Bool bMirrorMode; long nItemImageAngle; Size aSz; // only temporarily valid - OUString aAccessibleName; // accessible name - OUString aAccessibleDescription; // accessible description + XubString aAccessibleName; // accessible name + XubString aAccessibleDescription; // accessible description SalMenuItem* pSalMenuItem; // access to native menu MenuItemData() : pSubMenu(NULL), pAutoSubMenu(NULL), nItemImageAngle(0), pSalMenuItem ( NULL ) {} - MenuItemData( const OUString& rStr, const Image& rImage ) : + MenuItemData( const XubString& rStr, const Image& rImage ) : pSubMenu(NULL), pAutoSubMenu(NULL), aText( rStr ), @@ -181,7 +181,7 @@ public: sal_uInt16 nId, MenuItemType eType, MenuItemBits nBits, - const OUString& rStr, + const XubString& rStr, const Image& rImage, Menu* pMenu, size_t nPos, @@ -229,7 +229,7 @@ MenuItemData* MenuItemList::Insert( sal_uInt16 nId, MenuItemType eType, MenuItemBits nBits, - const OUString& rStr, + const XubString& rStr, const Image& rImage, Menu* pMenu, size_t nPos, @@ -292,7 +292,7 @@ void MenuItemList::InsertSeparator(const OString &rIdent, size_t nPos) aSalMIData.eType = MENUITEM_SEPARATOR; aSalMIData.nBits = 0; aSalMIData.pMenu = NULL; - aSalMIData.aText = ""; + aSalMIData.aText = XubString(); aSalMIData.aImage = Image(); // Native-support: returns NULL if not supported @@ -370,11 +370,11 @@ MenuItemData* MenuItemList::SearchItem( MenuItemData* pData = maItemList[ rPos ]; if ( pData->bEnabled ) { - sal_Int32 n = pData->aText.indexOf( '~' ); - if ( n != -1 ) + sal_uInt16 n = pData->aText.Search( '~' ); + if ( n != STRING_NOTFOUND ) { KeyCode mnKeyCode; - sal_Unicode mnUnicode = pData->aText[n+1]; + sal_Unicode mnUnicode = pData->aText.GetChar(n+1); Window* pDefWindow = ImplGetDefaultWindow(); if( ( pDefWindow && pDefWindow->ImplGetFrame()->MapUnicodeToKeyCode( mnUnicode, @@ -430,15 +430,15 @@ size_t MenuItemList::GetItemCount( KeyCode aKeyCode ) const MenuItemData* pData = maItemList[ --nPos ]; if ( pData->bEnabled ) { - sal_Int32 n = pData->aText.indexOf( '~' ); - if ( n != -1 ) + sal_uInt16 n = pData->aText.Search( '~' ); + if ( n != STRING_NOTFOUND ) { KeyCode mnKeyCode; // if MapUnicodeToKeyCode fails or is unsupported we try the pure ascii mapping of the keycodes // so we have working shortcuts when ascii mnemonics are used Window* pDefWindow = ImplGetDefaultWindow(); if( ( pDefWindow - && pDefWindow->ImplGetFrame()->MapUnicodeToKeyCode( pData->aText[n+1], + && pDefWindow->ImplGetFrame()->MapUnicodeToKeyCode( pData->aText.GetChar(n+1), Application::GetSettings().GetUILanguageTag().getLanguageType(), mnKeyCode ) && aKeyCode.GetCode() == mnKeyCode.GetCode() ) @@ -741,7 +741,7 @@ public: Size MinCloseButtonSize(); // add an arbitrary button to the menubar (will appear next to closer) - sal_uInt16 AddMenuBarButton( const Image&, const Link&, const OUString&, sal_uInt16 nPos ); + sal_uInt16 AddMenuBarButton( const Image&, const Link&, const String&, sal_uInt16 nPos ); void SetMenuBarButtonHighlightHdl( sal_uInt16 nId, const Link& ); Rectangle GetMenuBarButtonRectPixel( sal_uInt16 nId ); void RemoveMenuBarButton( sal_uInt16 nId ); @@ -769,7 +769,7 @@ static void ImplSetMenuItemData( MenuItemData* pData ) // convert data if ( !pData->aImage ) pData->eType = MENUITEM_STRING; - else if ( pData->aText.isEmpty() ) + else if ( !pData->aText.Len() ) pData->eType = MENUITEM_IMAGE; else pData->eType = MENUITEM_STRINGIMAGE; @@ -810,7 +810,7 @@ static bool ImplHandleHelpEvent( Window* pMenuWindow, Menu* pMenu, sal_uInt16 nH aPos = rHEvt.GetMousePosPixel(); Rectangle aRect( aPos, Size() ); - if( !pMenu->GetHelpText( nId ).isEmpty() ) + if( pMenu->GetHelpText( nId ).Len() ) Help::ShowBalloon( pMenuWindow, aPos, pMenu->GetHelpText( nId ) ); else { @@ -841,12 +841,12 @@ static bool ImplHandleHelpEvent( Window* pMenuWindow, Menu* pMenu, sal_uInt16 nH { // is an id available, then call help with the id, otherwise // use help-index - OUString aCommand = pMenu->GetItemCommand( nId ); + String aCommand = pMenu->GetItemCommand( nId ); OString aHelpId( pMenu->GetHelpId( nId ) ); if( aHelpId.isEmpty() ) aHelpId = OOO_HELP_INDEX; - if ( !aCommand.isEmpty() ) + if ( aCommand.Len() ) pHelp->Start( aCommand, NULL ); else pHelp->Start( OStringToOUString( aHelpId, RTL_TEXTENCODING_UTF8 ), NULL ); @@ -1202,7 +1202,7 @@ void Menu::RemoveEventListener( const Link& rEventListener ) maEventListeners.removeListener( rEventListener ); } -void Menu::InsertItem(sal_uInt16 nItemId, const OUString& rStr, MenuItemBits nItemBits, +void Menu::InsertItem(sal_uInt16 nItemId, const XubString& rStr, MenuItemBits nItemBits, const OString &rIdent, sal_uInt16 nPos) { DBG_ASSERT( nItemId, "Menu::InsertItem(): ItemId == 0" ); @@ -1239,7 +1239,7 @@ void Menu::InsertItem(sal_uInt16 nItemId, const Image& rImage, SetItemImage( nItemId, rImage ); } -void Menu::InsertItem(sal_uInt16 nItemId, const OUString& rStr, +void Menu::InsertItem(sal_uInt16 nItemId, const XubString& rStr, const Image& rImage, MenuItemBits nItemBits, const OString &rIdent, sal_uInt16 nPos) { @@ -1270,7 +1270,7 @@ void Menu::InsertItem( const ResId& rResId, sal_uInt16 nPos ) if ( nObjMask & RSC_MENUITEM_STATUS ) nStatus = sal::static_int_cast<MenuItemBits>(ReadLongRes()); - OUString aText; + String aText; if ( nObjMask & RSC_MENUITEM_TEXT ) aText = ReadStringRes(); @@ -1280,7 +1280,7 @@ void Menu::InsertItem( const ResId& rResId, sal_uInt16 nPos ) if ( !bSep ) { Bitmap aBmp( ResId( (RSHEADER_TYPE*)GetClassRes(), *pMgr ) ); - if ( !aText.isEmpty() ) + if ( aText.Len() ) InsertItem( nItemId, aText, aBmp, nStatus, OString(), nPos ); else InsertItem( nItemId, aBmp, nStatus, OString(), nPos ); @@ -1292,7 +1292,7 @@ void Menu::InsertItem( const ResId& rResId, sal_uInt16 nPos ) if ( bSep ) InsertSeparator(OString(), nPos); - OUString aHelpText; + String aHelpText; if ( nObjMask & RSC_MENUITEM_HELPTEXT ) { aHelpText = ReadStringRes(); @@ -1328,7 +1328,7 @@ void Menu::InsertItem( const ResId& rResId, sal_uInt16 nPos ) } if ( nObjMask & RSC_MENUITEM_COMMAND ) { - OUString aCommandStr = ReadStringRes(); + String aCommandStr = ReadStringRes(); if ( !bSep ) SetItemCommand( nItemId, aCommandStr ); } @@ -1675,11 +1675,11 @@ KeyEvent Menu::GetActivationKey( sal_uInt16 nItemId ) const MenuItemData* pData = pItemList->GetData( nItemId ); if( pData ) { - sal_Int32 nPos = pData->aText.indexOf( '~' ); - if( nPos != -1 && nPos < pData->aText.getLength()-1 ) + sal_uInt16 nPos = pData->aText.Search( '~' ); + if( nPos != STRING_NOTFOUND && nPos < pData->aText.Len()-1 ) { sal_uInt16 nCode = 0; - sal_Unicode cAccel = pData->aText[ nPos+1 ]; + sal_Unicode cAccel = pData->aText.GetChar( nPos+1 ); if( cAccel >= 'a' && cAccel <= 'z' ) nCode = KEY_A + (cAccel-'a'); else if( cAccel >= 'A' && cAccel <= 'Z' ) @@ -1837,7 +1837,7 @@ void Menu::ShowItem( sal_uInt16 nItemId, sal_Bool bVisible ) } } -void Menu::SetItemText( sal_uInt16 nItemId, const OUString& rStr ) +void Menu::SetItemText( sal_uInt16 nItemId, const XubString& rStr ) { size_t nPos; MenuItemData* pData = pItemList->GetData( nItemId, nPos ); @@ -1845,7 +1845,7 @@ void Menu::SetItemText( sal_uInt16 nItemId, const OUString& rStr ) if ( !pData ) return; - if ( rStr != pData->aText ) + if ( !rStr.Equals( pData->aText ) ) { pData->aText = rStr; ImplSetMenuItemData( pData ); @@ -1866,7 +1866,7 @@ void Menu::SetItemText( sal_uInt16 nItemId, const OUString& rStr ) } } -OUString Menu::GetItemText( sal_uInt16 nItemId ) const +XubString Menu::GetItemText( sal_uInt16 nItemId ) const { size_t nPos; MenuItemData* pData = pItemList->GetData( nItemId, nPos ); @@ -1997,7 +1997,7 @@ const OUString Menu::GetItemCommand( sal_uInt16 nItemId ) const return OUString(); } -void Menu::SetHelpCommand( sal_uInt16 nItemId, const OUString& rStr ) +void Menu::SetHelpCommand( sal_uInt16 nItemId, const XubString& rStr ) { MenuItemData* pData = pItemList->GetData( nItemId ); @@ -2005,16 +2005,17 @@ void Menu::SetHelpCommand( sal_uInt16 nItemId, const OUString& rStr ) pData->aHelpCommandStr = rStr; } -const OUString& Menu::GetHelpCommand( sal_uInt16 nItemId ) const +const XubString& Menu::GetHelpCommand( sal_uInt16 nItemId ) const { MenuItemData* pData = pItemList->GetData( nItemId ); - assert ( pData ); - - return pData->aHelpCommandStr; + if ( pData ) + return pData->aHelpCommandStr; + else + return ImplGetSVEmptyStr(); } -void Menu::SetHelpText( sal_uInt16 nItemId, const OUString& rStr ) +void Menu::SetHelpText( sal_uInt16 nItemId, const XubString& rStr ) { MenuItemData* pData = pItemList->GetData( nItemId ); @@ -2022,35 +2023,38 @@ void Menu::SetHelpText( sal_uInt16 nItemId, const OUString& rStr ) pData->aHelpText = rStr; } -const OUString& Menu::ImplGetHelpText( sal_uInt16 nItemId ) const +const XubString& Menu::ImplGetHelpText( sal_uInt16 nItemId ) const { MenuItemData* pData = pItemList->GetData( nItemId ); - assert ( pData ); - - if ( pData->aHelpText.isEmpty() && - (( !pData->aHelpId.isEmpty() ) || ( !pData->aCommandStr.isEmpty() ))) + if ( pData ) { - Help* pHelp = Application::GetHelp(); - if ( pHelp ) + if ( !pData->aHelpText.Len() && + (( !pData->aHelpId.isEmpty() ) || ( pData->aCommandStr.Len() ))) { - if ( !pData->aCommandStr.isEmpty() ) - pData->aHelpText = pHelp->GetHelpText( pData->aCommandStr, NULL ); + Help* pHelp = Application::GetHelp(); + if ( pHelp ) + { + if ( pData->aCommandStr.Len() ) + pData->aHelpText = pHelp->GetHelpText( pData->aCommandStr, NULL ); - if( pData->aHelpText.isEmpty() && !pData->aHelpId.isEmpty() ) - pData->aHelpText = pHelp->GetHelpText( OStringToOUString( pData->aHelpId, RTL_TEXTENCODING_UTF8 ), NULL ); + if( !pData->aHelpText.Len() && !pData->aHelpId.isEmpty() ) + pData->aHelpText = pHelp->GetHelpText( OStringToOUString( pData->aHelpId, RTL_TEXTENCODING_UTF8 ), NULL ); + } } - } - return pData->aHelpText; + return pData->aHelpText; + } + else + return ImplGetSVEmptyStr(); } -const OUString& Menu::GetHelpText( sal_uInt16 nItemId ) const +const XubString& Menu::GetHelpText( sal_uInt16 nItemId ) const { return ImplGetHelpText( nItemId ); } -void Menu::SetTipHelpText( sal_uInt16 nItemId, const OUString& rStr ) +void Menu::SetTipHelpText( sal_uInt16 nItemId, const XubString& rStr ) { MenuItemData* pData = pItemList->GetData( nItemId ); @@ -2058,13 +2062,14 @@ void Menu::SetTipHelpText( sal_uInt16 nItemId, const OUString& rStr ) pData->aTipHelpText = rStr; } -const OUString& Menu::GetTipHelpText( sal_uInt16 nItemId ) const +const XubString& Menu::GetTipHelpText( sal_uInt16 nItemId ) const { MenuItemData* pData = pItemList->GetData( nItemId ); - assert ( pData ); - - return pData->aTipHelpText; + if ( pData ) + return pData->aTipHelpText; + else + return ImplGetSVEmptyStr(); } void Menu::SetHelpId( sal_uInt16 nItemId, const OString& rHelpId ) @@ -2471,7 +2476,7 @@ Size Menu::ImplCalcSize( Window* pWin ) // Accel if ( !bIsMenuBar && pData->aAccelKey.GetCode() && !ImplAccelDisabled() ) { - OUString aName = pData->aAccelKey.GetName(); + String aName = pData->aAccelKey.GetName(); long nAccWidth = pWin->GetTextWidth( aName ); nAccWidth += nExtra; nWidth += nAccWidth; @@ -2592,20 +2597,20 @@ static void ImplPaintCheckBackground( Window* i_pWindow, const Rectangle& i_rRec } } -static OUString getShortenedString( const OUString& i_rLong, Window* i_pWin, long i_nMaxWidth ) +static String getShortenedString( const String& i_rLong, Window* i_pWin, long i_nMaxWidth ) { - sal_Int32 nPos = STRING_NOTFOUND; - OUString aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) ); + xub_StrLen nPos = STRING_NOTFOUND; + String aNonMnem( OutputDevice::GetNonMnemonicString( i_rLong, nPos ) ); aNonMnem = i_pWin->GetEllipsisString( aNonMnem, i_nMaxWidth, TEXT_DRAW_CENTERELLIPSIS ); // re-insert mnemonic if( nPos != STRING_NOTFOUND ) { - if( nPos < aNonMnem.getLength() && i_rLong[nPos+1] == aNonMnem[nPos] ) + if( nPos < aNonMnem.Len() && i_rLong.GetChar(nPos+1) == aNonMnem.GetChar(nPos) ) { - OUStringBuffer aBuf( i_rLong.getLength() ); - aBuf.append( aNonMnem.copy( 0, nPos) ); + OUStringBuffer aBuf( i_rLong.Len() ); + aBuf.append( aNonMnem.GetBuffer(), nPos ); aBuf.append( sal_Unicode('~') ); - aBuf.append( aNonMnem.copy(nPos) ); + aBuf.append( aNonMnem.GetBuffer()+nPos ); aNonMnem = aBuf.makeStringAndClear(); } } @@ -2836,15 +2841,15 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa long nMaxItemTextWidth = aOutSz.Width() - aTmpPos.X() - nExtra - nOuterSpaceX; if( !bIsMenuBar && pData->aAccelKey.GetCode() && !ImplAccelDisabled() ) { - OUString aAccText = pData->aAccelKey.GetName(); + XubString aAccText = pData->aAccelKey.GetName(); nMaxItemTextWidth -= pWin->GetTextWidth( aAccText ) + 3*nExtra; } if( !bIsMenuBar && pData->pSubMenu ) { nMaxItemTextWidth -= nFontHeight - nExtra; } - OUString aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) ); - pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.getLength(), nStyle, pVector, pDisplayText ); + String aItemText( getShortenedString( pData->aText, pWin, nMaxItemTextWidth ) ); + pWin->DrawCtrlText( aTmpPos, aItemText, 0, aItemText.Len(), nStyle, pVector, pDisplayText ); if( bSetTmpBackground ) pWin->SetBackground(); } @@ -2852,14 +2857,14 @@ void Menu::ImplPaint( Window* pWin, sal_uInt16 nBorder, long nStartY, MenuItemDa // Accel if ( !bLayout && !bIsMenuBar && pData->aAccelKey.GetCode() && !ImplAccelDisabled() ) { - OUString aAccText = pData->aAccelKey.GetName(); + XubString aAccText = pData->aAccelKey.GetName(); aTmpPos.X() = aOutSz.Width() - pWin->GetTextWidth( aAccText ); aTmpPos.X() -= 4*nExtra; aTmpPos.X() -= nOuterSpaceX; aTmpPos.Y() = aPos.Y(); aTmpPos.Y() += nTextOffsetY; - pWin->DrawCtrlText( aTmpPos, aAccText, 0, aAccText.getLength(), nTextStyle ); + pWin->DrawCtrlText( aTmpPos, aAccText, 0, aAccText.Len(), nTextStyle ); } // SubMenu? @@ -3188,19 +3193,19 @@ Rectangle Menu::GetBoundingRectangle( sal_uInt16 nPos ) const return aRet; } -void Menu::SetAccessibleName( sal_uInt16 nItemId, const OUString& rStr ) +void Menu::SetAccessibleName( sal_uInt16 nItemId, const XubString& rStr ) { size_t nPos; MenuItemData* pData = pItemList->GetData( nItemId, nPos ); - if ( pData && rStr != pData->aAccessibleName ) + if ( pData && !rStr.Equals( pData->aAccessibleName ) ) { pData->aAccessibleName = rStr; ImplCallEventListeners( VCLEVENT_MENU_ACCESSIBLENAMECHANGED, nPos ); } } -OUString Menu::GetAccessibleName( sal_uInt16 nItemId ) const +XubString Menu::GetAccessibleName( sal_uInt16 nItemId ) const { MenuItemData* pData = pItemList->GetData( nItemId ); @@ -3463,7 +3468,7 @@ sal_Bool MenuBar::HandleMenuCommandEvent( Menu *pMenu, sal_uInt16 nCommandEventI return sal_False; } -sal_uInt16 MenuBar::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const OUString& i_rToolTip, sal_uInt16 i_nPos ) +sal_uInt16 MenuBar::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const String& i_rToolTip, sal_uInt16 i_nPos ) { return pWindow ? static_cast<MenuBarWindow*>(pWindow)->AddMenuBarButton( i_rImage, i_rLink, i_rToolTip, i_nPos ) : 0; } @@ -6040,7 +6045,7 @@ void MenuBarWindow::GetFocus() return xAcc; } -sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const OUString& i_rToolTip, sal_uInt16 i_nPos ) +sal_uInt16 MenuBarWindow::AddMenuBarButton( const Image& i_rImage, const Link& i_rLink, const String& i_rToolTip, sal_uInt16 i_nPos ) { // find first free button id sal_uInt16 nId = IID_DOCUMENTCLOSE; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits