Hi Carsten, after I have investigated the FontMenuController::fillPopupMenu() source, I think the pFontNameArray[] array was sorted, so before every new FontName insert into the m_xPopuMenu, the new FontName is compared with every FontName inserted of the xPopupMenu. so that inserting MenuItem efficiency is very low. So I think before the new FontName is inserted, the pFontNameArray[] array should be sorted, than insert it into Menu. Other, I have investigated C's qsort() and STL's sort() via reading some document and found the STL's sort() is very quick then C's qsort(). So I used the STL's sort().
As stated above is what I understand. If you have good suggestions, please tell me. The attachment is source changing, Please, review it. I have tested the changing source and the changing work right, but it trigger other question which is the Chinese FontName was placed in the last place. but before the source was not changed, the Chinese FontName was plased in the first place. why ? Could you give me some advices ? Thanks and Best Regards, Shizhoubo
--- fontmenucontroller_old.cxx 2006-12-13 23:07:08.000000000 +0800 +++ fontmenucontroller_new.cxx 2008-03-11 11:37:12.000000000 +0800 @@ -100,6 +100,11 @@ #include <vcl/mnemonic.hxx> #endif +//shizhoubo added +#include <vector> +#include <algorithm> +//end by shizhoubo //_________________________________________________________________________________________________________________ // Defines //_________________________________________________________________________________________________________________ @@ -110,7 +115,8 @@ using namespace com::sun::star::frame; using namespace com::sun::star::beans; using namespace com::sun::star::util; - +//shizhoubo +using namespace std; namespace framework { @@ -143,8 +149,33 @@ resetPopupMenu( rPopupMenu ); if ( pPopupMenu ) pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - - if ( pVCLPopupMenu ) + + if ( pVCLPopupMenu ) + { + vector<rtl::OUString> aVector; + for ( USHORT i = 0; i < rFontNameSeq.getLength(); i++ ) + { + aVector.push_back(MnemonicGenerator::EraseAllMnemonicChars(pFontNameArray[i])); + } + sort(aVector.begin(), aVector.end()); + + const rtl::OUString aFontNameCommandPrefix( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName?CharFontName.FamilyName:string=" )); + for(USHORT i = 0; i < aVector.size(); i++) + { + const rtl::OUString& rName = aVector[i]; + m_xPopupMenu->insertItem( i+1, rName, css::awt::MenuItemStyle::RADIOCHECK | css::awt::MenuItemStyle::AUTOCHECK, i ); + if ( rName == m_aFontFamilyName ) + m_xPopupMenu->checkItem( i+1, sal_True ); + // use VCL popup menu pointer to set vital information that are not part of the awt implementation + rtl::OUStringBuffer aCommandBuffer( aFontNameCommandPrefix ); + aCommandBuffer.append( INetURLObject::encode( rName, INetURLObject::PART_HTTP_QUERY, '%', INetURLObject::ENCODE_ALL )); + rtl::OUString aFontNameCommand = aCommandBuffer.makeStringAndClear(); + pVCLPopupMenu->SetItemCommand( i+1, aFontNameCommand ); // Store font name into item command. + } + + } + + /* if ( pVCLPopupMenu ) { rtl::OUString aEmpty; const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper(); @@ -176,7 +207,7 @@ rtl::OUString aFontNameCommand = aCommandBuffer.makeStringAndClear(); pVCLPopupMenu->SetItemCommand( i+1, aFontNameCommand ); // Store font name into item command. } - } + }*/ } // XEventListener
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]