From 4726cacc24846b63e1177c7ab4dff4ae5b1c4291 Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Mon, 19 Oct 2009 08:08:21 +0000 Subject: #106019# 'reset languages' menu entry --- framework/source/classes/resource.src | 5 + framework/source/helper/mischelper.cxx | 246 ++++++++++++------ .../uielement/langselectionmenucontroller.cxx | 211 ++++++--------- .../uielement/langselectionstatusbarcontroller.cxx | 282 +++++++++------------ 4 files changed, 369 insertions(+), 375 deletions(-) (limited to 'framework/source') diff --git a/framework/source/classes/resource.src b/framework/source/classes/resource.src index 0947abbe9288..3d4a817c85b7 100644 --- a/framework/source/classes/resource.src +++ b/framework/source/classes/resource.src @@ -330,6 +330,11 @@ String STR_LANGSTATUS_NONE Text [ en-US ] = "None (Do not check spelling)" ; Text [ x-comment ] = " "; }; +String STR_RESET_TO_DEFAULT_LANGUAGE +{ + Text [ en-US ] = "Reset to Default Language" ; + Text [ x-comment ] = " "; +}; String STR_LANGSTATUS_MORE { Text [ en-US ] = "More..." ; diff --git a/framework/source/helper/mischelper.cxx b/framework/source/helper/mischelper.cxx index 8e0f79b2607c..8d85873a92e9 100644 --- a/framework/source/helper/mischelper.cxx +++ b/framework/source/helper/mischelper.cxx @@ -32,21 +32,29 @@ #include "precompiled_framework.hxx" #include -#include -#include +#include +#include +#include #include +#include +#include +#include +#include #include #include #include using namespace ::com::sun::star; -using namespace ::com::sun::star::uno; -using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::beans; -using namespace ::com::sun::star::container; -using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::container; +using namespace ::com::sun::star::lang; + +using ::rtl::OUString; + namespace framework { @@ -71,74 +79,162 @@ uno::Reference< linguistic2::XLanguageGuessing > LanguageGuessingHelper::GetGues return m_xLanguageGuesser; } -::rtl::OUString RetrieveLabelFromCommand( const ::rtl::OUString& aCmdURL - ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xServiceFactory - ,::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _xUICommandLabels - ,const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& _xFrame - ,::rtl::OUString& _rModuleIdentifier - ,sal_Bool& _rIni - ,const sal_Char* _pName) -{ - ::rtl::OUString aLabel; - - // Retrieve popup menu labels - if ( !_xUICommandLabels.is() ) - { - try - { - if ( !_rIni ) - { - _rIni = sal_True; - Reference< XModuleManager > xModuleManager( _xServiceFactory->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); - - try - { - _rModuleIdentifier = xModuleManager->identify( _xFrame ); - } - catch( Exception& ) - { - } - } - - Reference< XNameAccess > xNameAccess( _xServiceFactory->createInstance( SERVICENAME_UICOMMANDDESCRIPTION ), UNO_QUERY ); - if ( xNameAccess.is() ) - { - xNameAccess->getByName( _rModuleIdentifier ) >>= _xUICommandLabels; - } - } - catch ( Exception& ) - { - } - } - - if ( _xUICommandLabels.is() ) - { - try - { - if ( aCmdURL.getLength() > 0 ) - { - rtl::OUString aStr; - Sequence< PropertyValue > aPropSeq; - if ( _xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq ) - { - for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) - { - if ( aPropSeq[i].Name.equalsAscii( _pName/*"Label"*/ )) - { - aPropSeq[i].Value >>= aStr; - break; - } - } - } - aLabel = aStr; - } - } - catch ( com::sun::star::uno::Exception& ) - { - } - } - - return aLabel; +//////////////////////////////////////////////////////////// + +::rtl::OUString RetrieveLabelFromCommand( + const ::rtl::OUString& aCmdURL, + const uno::Reference< lang::XMultiServiceFactory >& _xServiceFactory, + uno::Reference< container::XNameAccess >& _xUICommandLabels, + const uno::Reference< frame::XFrame >& _xFrame, + ::rtl::OUString& _rModuleIdentifier, + sal_Bool& _rIni, + const sal_Char* _pName) +{ + ::rtl::OUString aLabel; + + // Retrieve popup menu labels + if ( !_xUICommandLabels.is() ) + { + try + { + if ( !_rIni ) + { + _rIni = sal_True; + Reference< XModuleManager > xModuleManager( _xServiceFactory->createInstance( SERVICENAME_MODULEMANAGER ), UNO_QUERY_THROW ); + + try + { + _rModuleIdentifier = xModuleManager->identify( _xFrame ); + } + catch( Exception& ) + { + } + } + + Reference< XNameAccess > xNameAccess( _xServiceFactory->createInstance( SERVICENAME_UICOMMANDDESCRIPTION ), UNO_QUERY ); + if ( xNameAccess.is() ) + { + xNameAccess->getByName( _rModuleIdentifier ) >>= _xUICommandLabels; + } + } + catch ( Exception& ) + { + } + } + + if ( _xUICommandLabels.is() ) + { + try + { + if ( aCmdURL.getLength() > 0 ) + { + rtl::OUString aStr; + Sequence< PropertyValue > aPropSeq; + if ( _xUICommandLabels->getByName( aCmdURL ) >>= aPropSeq ) + { + for ( sal_Int32 i = 0; i < aPropSeq.getLength(); i++ ) + { + if ( aPropSeq[i].Name.equalsAscii( _pName/*"Label"*/ )) + { + aPropSeq[i].Value >>= aStr; + break; + } + } + } + aLabel = aStr; + } + } + catch ( com::sun::star::uno::Exception& ) + { + } + } + + return aLabel; +} + +//////////////////////////////////////////////////////////// + +void FillLangItems( std::set< OUString > &rLangItems, + const SvtLanguageTable & rLanguageTable, + const uno::Reference< frame::XFrame > & rxFrame, + const LanguageGuessingHelper & rLangGuessHelper, + sal_Int16 nScriptType, + const OUString & rCurLang, + const OUString & rKeyboardLang, + const OUString & rGuessedTextLang ) +{ + rLangItems.clear(); + + //1--add current language + if( rCurLang != OUString() && + LANGUAGE_DONTKNOW != rLanguageTable.GetType( rCurLang )) + rLangItems.insert( rCurLang ); + + //2--System + const AllSettings& rAllSettings = Application::GetSettings(); + LanguageType rSystemLanguage = rAllSettings.GetLanguage(); + if( rSystemLanguage != LANGUAGE_DONTKNOW ) + { + if ( IsScriptTypeMatchingToLanguage( nScriptType, rSystemLanguage )) + rLangItems.insert( OUString( rLanguageTable.GetString( rSystemLanguage )) ); + } + + //3--UI + LanguageType rUILanguage = rAllSettings.GetUILanguage(); + if( rUILanguage != LANGUAGE_DONTKNOW ) + { + if ( IsScriptTypeMatchingToLanguage( nScriptType, rUILanguage )) + rLangItems.insert( OUString( rLanguageTable.GetString( rUILanguage )) ); + } + + //4--guessed language + uno::Reference< linguistic2::XLanguageGuessing > xLangGuesser( rLangGuessHelper.GetGuesser() ); + if ( xLangGuesser.is() && rGuessedTextLang.getLength() > 0) + { + ::com::sun::star::lang::Locale aLocale(xLangGuesser->guessPrimaryLanguage( rGuessedTextLang, 0, rGuessedTextLang.getLength()) ); + LanguageType nLang = MsLangId::convertLocaleToLanguageWithFallback( aLocale ); + if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_NONE && nLang != LANGUAGE_SYSTEM + && IsScriptTypeMatchingToLanguage( nScriptType, nLang )) + rLangItems.insert( rLanguageTable.GetString( nLang )); + } + + //5--keyboard language + if( rKeyboardLang != OUString()) + { + if ( IsScriptTypeMatchingToLanguage( nScriptType, rLanguageTable.GetType( rKeyboardLang ))) + rLangItems.insert( rKeyboardLang ); + } + + //6--all languages used in current document + Reference< com::sun::star::frame::XModel > xModel; + if ( rxFrame.is() ) + { + Reference< com::sun::star::frame::XController > xController( rxFrame->getController(), UNO_QUERY ); + if ( xController.is() ) + xModel = xController->getModel(); + } + Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, UNO_QUERY ); + /*the description of nScriptType + LATIN : 0x001 + ASIAN : 0x002 + COMPLEX: 0x004 + */ + const sal_Int16 nMaxCount = 7; + if ( xDocumentLanguages.is() ) + { + Sequence< Locale > rLocales( xDocumentLanguages->getDocumentLanguages( nScriptType, nMaxCount )); + if ( rLocales.getLength() > 0 ) + { + for ( USHORT i = 0; i < rLocales.getLength(); ++i ) + { + if ( rLangItems.size() == static_cast< size_t >(nMaxCount) ) + break; + const Locale& rLocale=rLocales[i]; + if( IsScriptTypeMatchingToLanguage( nScriptType, rLanguageTable.GetType( rLocale.Language ))) + rLangItems.insert( OUString( rLocale.Language ) ); + } + } + } } } // namespace framework diff --git a/framework/source/uielement/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx index 555682677e33..8d5e5b6ddfce 100644 --- a/framework/source/uielement/langselectionmenucontroller.cxx +++ b/framework/source/uielement/langselectionmenucontroller.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include //_________________________________________________________________________________________________________________ @@ -66,7 +67,7 @@ #include #include #include -#include + #include #include #include @@ -80,6 +81,9 @@ #include "helper/mischelper.hxx" +#include +#include + //_________________________________________________________________________________________________________________ // Defines //_________________________________________________________________________________________________________________ @@ -91,6 +95,7 @@ using namespace com::sun::star::frame; using namespace com::sun::star::beans; using namespace com::sun::star::util; +using ::rtl::OUString; namespace framework { @@ -105,8 +110,8 @@ DEFINE_INIT_SERVICE ( LanguageSelectionMenuController, {} LanguageSelectionMenuController::LanguageSelectionMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : PopupMenuControllerBase( xServiceManager ), - m_bShowMenu( sal_True ) - ,m_aLangGuessHelper(xServiceManager) + m_bShowMenu( sal_True ), + m_aLangGuessHelper(xServiceManager) { } @@ -139,25 +144,21 @@ void SAL_CALL LanguageSelectionMenuController::statusChanged( const FeatureState return; m_bShowMenu = sal_True; - m_nScriptType=7;//set the default value + m_nScriptType = LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX; //set the default value - rtl::OUString aStrValue; - Sequence< ::rtl::OUString > aSeq; + OUString aStrValue; + Sequence< OUString > aSeq; - if ( Event.State >>= aStrValue ) - { - m_aCurrentLanguage=aStrValue; - } - else if ( Event.State >>= aSeq ) + if ( Event.State >>= aSeq ) { if ( aSeq.getLength() == 4 ) { // Retrieve all other values from the sequence and // store it members! - m_aCurLang=aSeq[0]; - m_nScriptType= static_cast< sal_Int16 >(aSeq[1].toInt32()); - m_aKeyboardLang=aSeq[2]; - m_aGuessedText=aSeq[3]; + m_aCurLang = aSeq[0]; + m_nScriptType = static_cast< sal_Int16 >(aSeq[1].toInt32()); + m_aKeyboardLang = aSeq[2]; + m_aGuessedTextLang = aSeq[3]; } } else if ( !Event.State.hasValue() ) @@ -188,14 +189,14 @@ void LanguageSelectionMenuController::impl_select(const Reference< XDispatch >& { Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); if ( xDispatchProvider.is() ) - xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + xDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); } if ( xDispatch.is() ) { Sequence aArgs; if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("LanguageSelectionMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgs); + UiEventLogHelper( OUString::createFromAscii("LanguageSelectionMenuController")).log( m_xServiceManager, m_xFrame, aTargetURL, aArgs ); xDispatch->dispatch( aTargetURL, aArgs ); } } @@ -210,22 +211,22 @@ void LanguageSelectionMenuController::impl_setPopupMenu() // Register for language updates aTargetURL.Complete = m_aLangStatusCommandURL; m_xURLTransformer->parseStrict( aTargetURL ); - m_xLanguageDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + m_xLanguageDispatch = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); // Register for setting languages and opening language dialog aTargetURL.Complete = m_aMenuCommandURL_Lang; m_xURLTransformer->parseStrict( aTargetURL ); - m_xMenuDispatch_Lang = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + m_xMenuDispatch_Lang = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); // Register for opening character dialog aTargetURL.Complete = m_aMenuCommandURL_Font; m_xURLTransformer->parseStrict( aTargetURL ); - m_xMenuDispatch_Font = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + m_xMenuDispatch_Font = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); // Register for opening character dialog with preselected paragraph aTargetURL.Complete = m_aMenuCommandURL_CharDlgForParagraph; m_xURLTransformer->parseStrict( aTargetURL ); - m_xMenuDispatch_CharDlgForParagraph = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); + m_xMenuDispatch_CharDlgForParagraph = xDispatchProvider->queryDispatch( aTargetURL, OUString(), 0 ); } void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu , const Mode eMode ) @@ -247,137 +248,77 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup String aCmd_Language; if( eMode == MODE_SetLanguageSelectionMenu ) { - aCmd_Dialog+=String::CreateFromAscii(".uno:FontDialog?Language:string=*"); - aCmd_Language+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Current_"); + aCmd_Dialog.AppendAscii(".uno:FontDialog?Language:string=*"); + aCmd_Language.AppendAscii(".uno:LanguageStatus?Language:string=Current_"); } else if ( eMode == MODE_SetLanguageParagraphMenu ) { - aCmd_Dialog+=String::CreateFromAscii(".uno:FontDialogForParagraph"); - aCmd_Language+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Paragraph_"); + aCmd_Dialog.AppendAscii(".uno:FontDialogForParagraph"); + aCmd_Language.AppendAscii(".uno:LanguageStatus?Language:string=Paragraph_"); } else if ( eMode == MODE_SetLanguageAllTextMenu ) { - aCmd_Dialog+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=*"); - aCmd_Language+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Default_"); + aCmd_Dialog.AppendAscii(".uno:LanguageStatus?Language:string=*"); + aCmd_Language.AppendAscii(".uno:LanguageStatus?Language:string=Default_"); } - //Reference< awt::XMenuExtended > m_xMenuExtended( m_xPopupMenu, UNO_QUERY ); - std::map< ::rtl::OUString, ::rtl::OUString > LangItems; - - SvtLanguageTable aLanguageTable; - USHORT nItemId = 1; - - //1--add current language - if(m_aCurLang.getLength()) + SvtLanguageTable aLanguageTable; + + // get languages to be displayed in the menu + std::set< OUString > aLangItems; + FillLangItems( aLangItems, aLanguageTable, m_xFrame, m_aLangGuessHelper, + m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedTextLang ); + + // + // now add menu entries + // the different menues purpose will be handled by the different string + // for aCmd_Dialog and aCmd_Language + // + + sal_Int16 nItemId = 1; // in this control the item id is not important for executing the command + const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); // multiple languages in current selection + const OUString sEmpty; // 'no language found' from language guessing + std::map< sal_Int16, OUString > aLangMap; + std::set< OUString >::const_iterator it; + for (it = aLangItems.begin(); it != aLangItems.end(); ++it) { - LangItems[m_aCurLang]=m_aCurLang; - } - - SvtLanguageTable aLangTable; - //2--System - const AllSettings& rAllSettings=Application::GetSettings(); - LanguageType rSystemLanguage = rAllSettings.GetLanguage(); - if(rSystemLanguage!=LANGUAGE_DONTKNOW) - { - if (IsScriptTypeMatchingToLanguage(m_nScriptType,rSystemLanguage )) - LangItems[::rtl::OUString(aLangTable.GetString(rSystemLanguage))]=::rtl::OUString(aLangTable.GetString(rSystemLanguage)); - } - - //3--UI - LanguageType rUILanguage = rAllSettings.GetUILanguage(); - if(rUILanguage!=LANGUAGE_DONTKNOW) - { - if (IsScriptTypeMatchingToLanguage(m_nScriptType, rUILanguage )) - LangItems[::rtl::OUString(aLangTable.GetString(rUILanguage))]=::rtl::OUString(aLangTable.GetString(rUILanguage)); - } - - //4--guessed language - uno::Reference< linguistic2::XLanguageGuessing > xLangGuesser( m_aLangGuessHelper.GetGuesser() ); - if (xLangGuesser.is() && m_aGuessedText.getLength() > 0) - { - ::com::sun::star::lang::Locale aLocale(xLangGuesser->guessPrimaryLanguage( m_aGuessedText, 0, m_aGuessedText.getLength()) ); - LanguageType nLang = MsLangId::convertLocaleToLanguageWithFallback( aLocale ); - if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_NONE && nLang != LANGUAGE_SYSTEM - && IsScriptTypeMatchingToLanguage( m_nScriptType, nLang )) - LangItems[aLangTable.GetString(nLang)]=aLangTable.GetString(nLang); - } - - //5--keyboard language - if(m_aKeyboardLang!=::rtl::OUString::createFromAscii("")) - { - if (IsScriptTypeMatchingToLanguage(m_nScriptType, aLanguageTable.GetType(m_aKeyboardLang))) - LangItems[m_aKeyboardLang] = m_aKeyboardLang; - } - - //6--all languages used in current document - Reference< com::sun::star::frame::XModel > xModel; - if ( m_xFrame.is() ) - { - Reference< com::sun::star::frame::XController > xController( m_xFrame->getController(), UNO_QUERY ); - if ( xController.is() ) - xModel = xController->getModel(); - } - Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, UNO_QUERY ); - /*the description of m_nScriptType - LATIN : 1 - ASIAN : 2 - COMPLEX:4 - LATIN + ASIAN : 3 - LATIN + COMPLEX : 5 - ASIAN + COMPLEX : 6 - LATIN + ASIAN + COMPLEX : 7 - */ - - sal_Int16 nCount=7; - if(xDocumentLanguages.is()) - { - Sequence< Locale > rLocales(xDocumentLanguages->getDocumentLanguages(m_nScriptType,nCount)); - if(rLocales.getLength()>0) - { - for(USHORT i = 0; i LangTable; - - const ::rtl::OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); - for(std::map< ::rtl::OUString, ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it) - { - if(it->first != ::rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&& - it->first != sAsterix && - it->first.getLength()) + const OUString & rStr( *it ); + if (rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&& + rStr != sAsterix && + rStr != sEmpty) { - ++nItemId; - pPopupMenu->InsertItem( nItemId,it->first); - LangTable[nItemId] = it->first; - if(it->first == m_aCurLang && eMode == MODE_SetLanguageSelectionMenu ) + pPopupMenu->InsertItem( nItemId, rStr ); + aCmd = aCmd_Language; + aCmd += String( rStr ); + pPopupMenu->SetItemCommand( nItemId, aCmd ); + if (rStr == m_aCurLang && eMode == MODE_SetLanguageSelectionMenu ) { //make a sign for the current language - pPopupMenu->CheckItem(nItemId,TRUE); + pPopupMenu->CheckItem( nItemId, TRUE ); } - aCmd=aCmd_Language; - aCmd+=(String)it->first; - pPopupMenu->SetItemCommand(nItemId,aCmd); + aLangMap[ nItemId ] = rStr; + ++nItemId; } } - //7--none - nItemId++; + // entry for LANGUAGE_NONE + ++nItemId; pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_NONE )) ); aCmd=aCmd_Language; - aCmd+=String::CreateFromAscii("LANGUAGE_NONE"); - pPopupMenu->SetItemCommand(nItemId,aCmd); + aCmd.AppendAscii("LANGUAGE_NONE"); + pPopupMenu->SetItemCommand( nItemId, aCmd ); + + // entry for 'Reset to default language' + ++nItemId; + pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_RESET_TO_DEFAULT_LANGUAGE )) ); + aCmd=aCmd_Language; + aCmd.AppendAscii("RESET_LANGUAGES"); + pPopupMenu->SetItemCommand( nItemId, aCmd ); - //More... - nItemId++; + // entry for opening the Format/Character dialog + ++nItemId; pPopupMenu->InsertItem( nItemId, String(FwlResId( STR_LANGSTATUS_MORE ))); - pPopupMenu->SetItemCommand(nItemId,aCmd_Dialog); + pPopupMenu->SetItemCommand( nItemId, aCmd_Dialog ); } @@ -427,10 +368,10 @@ void SAL_CALL LanguageSelectionMenuController::initialize( const Sequence< Any > if ( m_bInitialized ) { - m_aLangStatusCommandURL = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LanguageStatus" )); + m_aLangStatusCommandURL = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:LanguageStatus" )); m_aMenuCommandURL_Lang = m_aLangStatusCommandURL; - m_aMenuCommandURL_Font = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialog" )); - m_aMenuCommandURL_CharDlgForParagraph = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialogForParagraph" )); + m_aMenuCommandURL_Font = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialog" )); + m_aMenuCommandURL_CharDlgForParagraph = OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontDialogForParagraph" )); } } } diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index bccd553b57d3..3edc7466942a 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -30,6 +30,7 @@ // MARKER(update_precomp.py): autogen include statement, do not remove #include "precompiled_framework.hxx" + #include #include #include @@ -56,8 +57,6 @@ #include #include -#include -#include #include #ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_ #include @@ -77,6 +76,9 @@ #include "helper/mischelper.hxx" +#include +#include + using namespace ::cppu; using namespace ::com::sun::star; using namespace ::com::sun::star::uno; @@ -85,9 +87,14 @@ using namespace ::com::sun::star::frame; using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::document; +using ::rtl::OUString; + + namespace framework { +//////////////////////////////////////////////////////////// + DEFINE_XSERVICEINFO_MULTISERVICE ( LangSelectionStatusbarController , OWeakObject , SERVICENAME_STATUSBARCONTROLLER , @@ -97,10 +104,10 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( LangSelectionStatusbarController DEFINE_INIT_SERVICE ( LangSelectionStatusbarController, {} ) LangSelectionStatusbarController::LangSelectionStatusbarController( const uno::Reference< lang::XMultiServiceFactory >& xServiceManager ) : - svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), rtl::OUString(), 0 ), + svt::StatusbarController( xServiceManager, uno::Reference< frame::XFrame >(), OUString(), 0 ), m_bShowMenu( sal_True ), - m_nScriptType( 7 ) - ,m_aLangGuessHelper(xServiceManager) + m_nScriptType( LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX ), + m_aLangGuessHelper( xServiceManager ) { } @@ -181,216 +188,157 @@ throw (::com::sun::star::uno::RuntimeException) return sal_False; } -void LangSelectionStatusbarController::LangMenu()throw (::com::sun::star::uno::RuntimeException) +void LangSelectionStatusbarController::LangMenu() +throw (::com::sun::star::uno::RuntimeException) { RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::LangMenu" ); if (!m_bShowMenu) return; //add context menu - const static ::rtl::OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu")); + const static OUString s_sPopupMenu(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.PopupMenu")); Reference< awt::XPopupMenu > xPopupMenu( m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY ); //sub menu that contains all items except the last two items: Separator + Set Language for Paragraph Reference< awt::XPopupMenu > subPopupMenu(m_xServiceManager->createInstance( s_sPopupMenu ), UNO_QUERY ); - std::set< ::rtl::OUString > LangItems; - - SvtLanguageTable aLanguageTable; - USHORT nItemId=1; - - //1--add current language - if( m_aCurLang != ::rtl::OUString( ) && - LANGUAGE_DONTKNOW != aLanguageTable.GetType( m_aCurLang )) - LangItems.insert( m_aCurLang ); - - //2--System - SvtLanguageTable aLangTable; - const AllSettings& rAllSettings = Application::GetSettings(); - LanguageType rSystemLanguage = rAllSettings.GetLanguage(); - if( rSystemLanguage != LANGUAGE_DONTKNOW ) - { - if ( IsScriptTypeMatchingToLanguage( m_nScriptType, rSystemLanguage )) - LangItems.insert( ::rtl::OUString( aLangTable.GetString( rSystemLanguage )) ); - } - - //3--UI - LanguageType rUILanguage = rAllSettings.GetUILanguage(); - if( rUILanguage != LANGUAGE_DONTKNOW ) - { - if ( IsScriptTypeMatchingToLanguage( m_nScriptType, rUILanguage )) - LangItems.insert( ::rtl::OUString( aLangTable.GetString( rUILanguage )) ); - } - - //4--guessed language - uno::Reference< linguistic2::XLanguageGuessing > xLangGuesser( m_aLangGuessHelper.GetGuesser() ); - if ( xLangGuesser.is() && m_aGuessedText.getLength() > 0) - { - ::com::sun::star::lang::Locale aLocale(xLangGuesser->guessPrimaryLanguage( m_aGuessedText, 0, m_aGuessedText.getLength()) ); - LanguageType nLang = MsLangId::convertLocaleToLanguageWithFallback( aLocale ); - if (nLang != LANGUAGE_DONTKNOW && nLang != LANGUAGE_NONE && nLang != LANGUAGE_SYSTEM - && IsScriptTypeMatchingToLanguage( m_nScriptType, nLang )) - LangItems.insert( aLangTable.GetString( nLang )); - } - - //5--keyboard language - if( m_aKeyboardLang != ::rtl::OUString::createFromAscii( "" )) + SvtLanguageTable aLanguageTable; + + // get languages to be displayed in the menu + std::set< OUString > aLangItems; + FillLangItems( aLangItems, aLanguageTable, m_xFrame, m_aLangGuessHelper, + m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedTextLang ); + + // + // add first few entries to main menu + // + sal_Int16 nItemId = static_cast< sal_Int16 >(MID_LANG_SEL_1); + const OUString sAsterix(RTL_CONSTASCII_USTRINGPARAM("*")); // multiple languages in current selection + const OUString sEmpty; // 'no language found' from language guessing + std::map< sal_Int16, OUString > aLangMap; + std::set< OUString >::const_iterator it; + for (it = aLangItems.begin(); it != aLangItems.end(); ++it) { - if ( IsScriptTypeMatchingToLanguage( m_nScriptType, aLanguageTable.GetType( m_aKeyboardLang ))) - LangItems.insert( m_aKeyboardLang ); - } - - //6--all languages used in current document - Reference< com::sun::star::frame::XModel > xModel; - if ( m_xFrame.is() ) - { - Reference< com::sun::star::frame::XController > xController( m_xFrame->getController(), UNO_QUERY ); - if ( xController.is() ) - xModel = xController->getModel(); - } - Reference< document::XDocumentLanguages > xDocumentLanguages( xModel, UNO_QUERY ); - /*the description of m_nScriptType - LATIN : 1 - ASIAN : 2 - COMPLEX:4 - LATIN + ASIAN : 3 - LATIN + COMPLEX : 5 - ASIAN + COMPLEX : 6 - LATIN + ASIAN + COMPLEX : 7 - */ - - sal_Int16 nCount=7; - if ( xDocumentLanguages.is() ) - { - Sequence< Locale > rLocales( xDocumentLanguages->getDocumentLanguages( m_nScriptType, nCount )); - if ( rLocales.getLength() > 0 ) - { - for ( USHORT i = 0; i LangTable; - - for( std::set< ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it ) - { - if ( *it != ::rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&& - *it != ::rtl::OUString::createFromAscii( "*" ) && - *it != ::rtl::OUString::createFromAscii( "" )) + const OUString & rStr( *it ); + if ( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) ) && + rStr != sAsterix && + rStr != sEmpty) { - //nItemId = xPopupMenu->getItemCount()+1; - nItemId++; - xPopupMenu->insertItem( nItemId, *it, css::awt::MenuItemStyle::RADIOCHECK, nItemId ); - LangTable[nItemId]=*it; - if( *it == m_aCurLang ) + DBG_ASSERT( MID_LANG_SEL_1 <= nItemId && nItemId <= MID_LANG_SEL_9, + "nItemId outside of expected range!" ); + xPopupMenu->insertItem( nItemId, rStr, css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + if ( rStr == m_aCurLang ) { //make a sign for the current language xPopupMenu->checkItem( nItemId, TRUE ); } + aLangMap[ nItemId ] = rStr; + ++nItemId; } } - - //7--none - nItemId++; - xPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); - //More... - nItemId++; - xPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); - - for( ::std::set< ::rtl::OUString >::const_iterator it = LangItems.begin(); it != LangItems.end(); ++it ) + xPopupMenu->insertItem( MID_LANG_SEL_NONE, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_NONE ); + xPopupMenu->insertItem( MID_LANG_SEL_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_RESET ); + xPopupMenu->insertItem( MID_LANG_SEL_MORE, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_SEL_MORE ); + + // + // add entries to submenu ('set language for paragraph') + // + nItemId = static_cast< sal_Int16 >(MID_LANG_PARA_1); + for (it = aLangItems.begin(); it != aLangItems.end(); ++it) { - if( *it != ::rtl::OUString( aLangTable.GetString( LANGUAGE_NONE ) )&& - *it != ::rtl::OUString::createFromAscii( "*" ) && - *it != ::rtl::OUString::createFromAscii( "" )) + const OUString & rStr( *it ); + if( rStr != OUString( aLanguageTable.GetString( LANGUAGE_NONE ) )&& + rStr != OUString::createFromAscii( "*" ) && + rStr != OUString::createFromAscii( "" )) { - nItemId++; - subPopupMenu->insertItem( nItemId, *it, css::awt::MenuItemStyle::RADIOCHECK, nItemId ); - LangTable[nItemId]=*it; + DBG_ASSERT( MID_LANG_PARA_1 <= nItemId && nItemId <= MID_LANG_PARA_9, + "nItemId outside of expected range!" ); + subPopupMenu->insertItem( nItemId, rStr, css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + aLangMap[nItemId] = rStr; + ++nItemId; } } - //7--none - nItemId++; - subPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); - //More - nItemId++; - subPopupMenu->insertItem( nItemId, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); + subPopupMenu->insertItem( MID_LANG_PARA_NONE, String( FwkResId( STR_LANGSTATUS_NONE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_NONE ); + subPopupMenu->insertItem( MID_LANG_PARA_RESET, String( FwkResId( STR_RESET_TO_DEFAULT_LANGUAGE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_RESET ); + subPopupMenu->insertItem( MID_LANG_PARA_MORE, String( FwkResId( STR_LANGSTATUS_MORE )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_MORE ); - nItemId++; - xPopupMenu->insertSeparator(nItemId); + // + // add last two entries to main menu + // + xPopupMenu->insertSeparator( MID_LANG_PARA_SEPERATOR ); + xPopupMenu->insertItem( MID_LANG_PARA_STRING, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), css::awt::MenuItemStyle::RADIOCHECK, MID_LANG_PARA_STRING ); + xPopupMenu->setPopupMenu( MID_LANG_PARA_STRING, subPopupMenu ); - nItemId++; - xPopupMenu->insertItem( nItemId, String( FwkResId( STR_SET_LANGUAGE_FOR_PARAGRAPH )), css::awt::MenuItemStyle::RADIOCHECK, nItemId ); - xPopupMenu->setPopupMenu( nItemId, subPopupMenu ); - //display the popup menu and execute every command + // + // now display the popup menu and execute every command ... + // Reference< awt::XWindowPeer > xParent( m_xParentWindow, UNO_QUERY ); - com::sun::star::awt::Rectangle mRectangle; + com::sun::star::awt::Rectangle aRectangle; Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow ); - const Point mMousePos = pWindow->GetPointerPosPixel(); - mRectangle.X = mMousePos.X(); - mRectangle.Y = mMousePos.Y(); - sal_Int16 nId = xPopupMenu->execute( xParent, mRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 ); - //click "More..." + const Point aMousePos = pWindow->GetPointerPosPixel(); + aRectangle.X = aMousePos.X(); + aRectangle.Y = aMousePos.Y(); + sal_Int16 nId = xPopupMenu->execute( xParent, aRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 ); if ( m_xFrame.is() ) { uno::Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); util::URL aURL; - if ( nId < nItemId-3-subPopupMenu->getItemCount() ) + if (MID_LANG_SEL_1 <= nId && nId <= MID_LANG_SEL_9) { - //1..7 //set selected language as current language for selection - String SelectedLang = LangTable[nId]; - aURL.Complete+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Current_"); - aURL.Complete+=SelectedLang; + String aSelectedLang = aLangMap[nId]; + aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_"); + aURL.Complete += aSelectedLang; } - else if ( nId == nItemId-3-subPopupMenu->getItemCount() ) + else if (nId == MID_LANG_SEL_NONE) { - //8 //set None as current language for selection - aURL.Complete+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE"); + aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_LANGUAGE_NONE"); + } + else if (nId == MID_LANG_SEL_RESET) + { + // reset language attributes for selection + aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Current_RESET_LANGUAGES"); } - else if ( nId == nItemId-2-subPopupMenu->getItemCount() ) + else if (nId == MID_LANG_SEL_MORE) { - //9 (more)... //open the dialog "format/character" for current selection - aURL.Complete+=String::CreateFromAscii(".uno:FontDialog?Language:string=*"); + aURL.Complete += OUString::createFromAscii(".uno:FontDialog?Language:string=*"); } - else if ( nId < nItemId-3 && nId>nItemId-2-subPopupMenu->getItemCount() ) + else if (MID_LANG_PARA_1 <= nId && nId <= MID_LANG_PARA_9) { - //1..7 para //set selected language for current paragraph - String SelectedLang = LangTable[nId]; - aURL.Complete+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Paragraph_"); - aURL.Complete+=SelectedLang; + String aSelectedLang = aLangMap[nId]; + aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_"); + aURL.Complete += aSelectedLang; } - else if ( nId==nItemId-3 ) + else if (nId == MID_LANG_PARA_NONE) { - //8 para //set None as language for current paragraph - aURL.Complete+=String::CreateFromAscii(".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE"); + aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_LANGUAGE_NONE"); } - else if ( nId==nItemId-2 ) + else if (nId == MID_LANG_PARA_RESET) + { + // reset language attributes for paragraph + aURL.Complete += OUString::createFromAscii(".uno:LanguageStatus?Language:string=Paragraph_RESET_LANGUAGES"); + } + else if (nId == MID_LANG_PARA_MORE) { - //9 (more) para... //open the dialog "format/character" for current paragraph - aURL.Complete+=String::CreateFromAscii(".uno:FontDialogForParagraph"); + aURL.Complete += OUString::createFromAscii(".uno:FontDialogForParagraph"); } - uno::Reference< util::XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( rtl::OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY ); + uno::Reference< util::XURLTransformer > xURLTransformer( m_xServiceManager->createInstance( OUString::createFromAscii("com.sun.star.util.URLTransformer" )), uno::UNO_QUERY ); xURLTransformer->parseStrict( aURL ); - uno::Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL,::rtl::OUString(),0); + uno::Reference< XDispatch > xDispatch = xDispatchProvider->queryDispatch(aURL, OUString(), 0); if( xDispatch.is() ) { uno::Sequence< beans::PropertyValue > aPV; if(::comphelper::UiEventsLogger::isEnabled()) //#i88653# - UiEventLogHelper(::rtl::OUString::createFromAscii("ButtonToolbarController")).log(m_xServiceManager, m_xFrame, aURL, aPV); + UiEventLogHelper( OUString::createFromAscii("ButtonToolbarController")).log(m_xServiceManager, m_xFrame, aURL, aPV); xDispatch->dispatch( aURL, aPV); } } @@ -439,6 +387,13 @@ throw (::com::sun::star::uno::RuntimeException) void SAL_CALL LangSelectionStatusbarController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) { + // This function will be called when observed data changes, + // for example the selection or keyboard language. + // - It displays the language in use in the status bar + // - and it stores the relevant data for creating the menu + // at some later point in the member variables + // m_nScriptType, m_aCurLang, m_aKeyboardLang, m_aGuessedText + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "LangSelectionStatusbarController::statusChanged" ); vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); @@ -447,25 +402,22 @@ throw ( RuntimeException ) m_bShowMenu = sal_True; - m_nScriptType=7;//set the default value + m_nScriptType = LS_SCRIPT_LATIN | LS_SCRIPT_ASIAN | LS_SCRIPT_COMPLEX; //set the default value Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow ); if ( pWindow && pWindow->GetType() == WINDOW_STATUSBAR && m_nID != 0 ) { - rtl::OUString aStrValue; - Sequence< ::rtl::OUString > aSeq; + OUString aStrValue; + Sequence< OUString > aSeq; StatusBar* pStatusBar = (StatusBar *)pWindow; if ( Event.State >>= aStrValue ) - { pStatusBar->SetItemText( m_nID, aStrValue ); - m_aCurrentLanguage = aStrValue; - } else if ( Event.State >>= aSeq ) { if ( aSeq.getLength() == 4 ) { const String aMultipleLangText( FwkResId( STR_LANGSTATUS_MULTIPLE_LANGUAGES ) ); - ::rtl::OUString aStatusText = aSeq[0]; + OUString aStatusText = aSeq[0]; if ( 0 == aStatusText.compareToAscii( "*" )) aStatusText = aMultipleLangText; pStatusBar->SetItemText( m_nID, aStatusText ); @@ -475,7 +427,7 @@ throw ( RuntimeException ) m_aCurLang = aSeq[0]; m_nScriptType = static_cast< sal_Int16 >( aSeq[1].toInt32() ); m_aKeyboardLang = aSeq[2]; - m_aGuessedText = aSeq[3]; + m_aGuessedTextLang = aSeq[3]; } } else if ( !Event.State.hasValue() ) -- cgit From d8acb8300eaf5cee6d6445722e12221cfc4059a4 Mon Sep 17 00:00:00 2001 From: "Thomas Lange [tl]" Date: Mon, 11 Jan 2010 13:22:59 +0100 Subject: cws tl74: build errors --- framework/source/uielement/langselectionstatusbarcontroller.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'framework/source') diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index a2a3a02877ca..eb2832c1216e 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -278,9 +278,9 @@ throw (::com::sun::star::uno::RuntimeException) com::sun::star::awt::Rectangle aRectangle; Window* pWindow = VCLUnoHelper::GetWindow( m_xParentWindow ); const Point mMousePos = pWindow->GetPointerPosPixel(); - mRectangle.X = mMousePos.X(); - mRectangle.Y = mMousePos.Y(); - sal_Int16 nId = xPopupMenu->execute( xParent, mRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 ); + aRectangle.X = mMousePos.X(); + aRectangle.Y = mMousePos.Y(); + sal_Int16 nId = xPopupMenu->execute( xParent, aRectangle, com::sun::star::awt::PopupMenuDirection::EXECUTE_UP+16 ); //click "More..." if ( nId && m_xFrame.is() ) { -- cgit From 5b84b9f616734dca66bce10eac11e62462fcf26a Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 16 Mar 2010 23:15:08 +0100 Subject: slidecopy: minor edit ... let GetImage/ByURL take a 'const Reference&', not a 'Reference&' --- framework/source/helper/imageproducer.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework/source') diff --git a/framework/source/helper/imageproducer.cxx b/framework/source/helper/imageproducer.cxx index 76f1238efd31..4a72c0b686a3 100644 --- a/framework/source/helper/imageproducer.cxx +++ b/framework/source/helper/imageproducer.cxx @@ -47,7 +47,7 @@ pfunc_getImage SAL_CALL SetImageProducer( pfunc_getImage pNewGetImageFunc ) } -Image SAL_CALL GetImageFromURL( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast ) +Image SAL_CALL GetImageFromURL( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& rFrame, const ::rtl::OUString& aURL, BOOL bBig, BOOL bHiContrast ) { if ( _pGetImageFunc ) return _pGetImageFunc( rFrame, aURL, bBig, bHiContrast ); -- cgit From b3ca4b3cbdce79eb3b387da6e84126c7a9f20eaa Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Sun, 21 Mar 2010 20:01:33 +0100 Subject: Adding PopupMenuController to allow PopupMenuControllerBase dervivates to be used in toolbars --- framework/source/helper/makefile.mk | 1 - .../source/helper/popupmenucontrollerbase.cxx | 429 --------------------- .../source/helper/uiconfigelementwrapperbase.cxx | 1 - framework/source/register/registertemp.cxx | 5 +- .../source/uielement/comboboxtoolbarcontroller.cxx | 1 - .../source/uielement/controlmenucontroller.cxx | 18 +- .../uielement/dropdownboxtoolbarcontroller.cxx | 1 - .../source/uielement/edittoolbarcontroller.cxx | 1 - framework/source/uielement/fontmenucontroller.cxx | 17 +- .../source/uielement/fontsizemenucontroller.cxx | 18 +- .../source/uielement/headermenucontroller.cxx | 19 +- .../uielement/imagebuttontoolbarcontroller.cxx | 1 - .../uielement/langselectionmenucontroller.cxx | 17 +- .../source/uielement/macrosmenucontroller.cxx | 7 +- framework/source/uielement/makefile.mk | 1 + framework/source/uielement/newmenucontroller.cxx | 13 +- .../source/uielement/objectmenucontroller.cxx | 7 +- framework/source/uielement/popupmenucontroller.cxx | 248 ++++++++++++ framework/source/uielement/progressbarwrapper.cxx | 1 + .../source/uielement/recentfilesmenucontroller.cxx | 44 +-- .../uielement/spinfieldtoolbarcontroller.cxx | 1 - framework/source/uielement/statusbarmanager.cxx | 1 + .../uielement/togglebuttontoolbarcontroller.cxx | 1 - framework/source/uielement/toolbarmanager.cxx | 5 + .../source/uielement/toolbarsmenucontroller.cxx | 24 +- framework/source/uielement/toolbarwrapper.cxx | 1 + 26 files changed, 352 insertions(+), 531 deletions(-) delete mode 100644 framework/source/helper/popupmenucontrollerbase.cxx create mode 100644 framework/source/uielement/popupmenucontroller.cxx (limited to 'framework/source') diff --git a/framework/source/helper/makefile.mk b/framework/source/helper/makefile.mk index 556a9829d27c..ed54c381160c 100644 --- a/framework/source/helper/makefile.mk +++ b/framework/source/helper/makefile.mk @@ -53,7 +53,6 @@ SLOFILES= $(SLO)$/ocomponentaccess.obj \ $(SLO)$/networkdomain.obj \ $(SLO)$/acceleratorinfo.obj \ $(SLO)$/uielementwrapperbase.obj \ - $(SLO)$/popupmenucontrollerbase.obj \ $(SLO)$/dockingareadefaultacceptor.obj \ $(SLO)$/uiconfigelementwrapperbase.obj \ $(SLO)$/shareablemutex.obj \ diff --git a/framework/source/helper/popupmenucontrollerbase.cxx b/framework/source/helper/popupmenucontrollerbase.cxx deleted file mode 100644 index cc5d388de9a8..000000000000 --- a/framework/source/helper/popupmenucontrollerbase.cxx +++ /dev/null @@ -1,429 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_framework.hxx" -#include - -//_________________________________________________________________________________________________________________ -// my own includes -//_________________________________________________________________________________________________________________ -#include -#include "services.h" - -//_________________________________________________________________________________________________________________ -// interface includes -//_________________________________________________________________________________________________________________ -#include -#include -#include -#include -#include - -//_________________________________________________________________________________________________________________ -// includes of other projects -//_________________________________________________________________________________________________________________ - -#ifndef _VCL_MENU_HXX_ -#include -#endif -#include -#include -#include -//_________________________________________________________________________________________________________________ -// Defines -//_________________________________________________________________________________________________________________ -// - -using namespace com::sun::star::uno; -using namespace com::sun::star::lang; -using namespace com::sun::star::frame; -using namespace com::sun::star::beans; -using namespace com::sun::star::util; - -namespace framework -{ - -//***************************************************************************************************************** -// XInterface, XTypeProvider, XServiceInfo -//***************************************************************************************************************** -DEFINE_XINTERFACE_11 ( PopupMenuControllerBase , - OWeakObject , - DIRECT_INTERFACE( css::lang::XTypeProvider ), - DIRECT_INTERFACE( css::lang::XServiceInfo ), - DIRECT_INTERFACE( ::com::sun::star::frame::XPopupMenuController ), - DIRECT_INTERFACE( css::lang::XInitialization ), - DIRECT_INTERFACE( css::frame::XStatusListener ), - DIRECT_INTERFACE( css::awt::XMenuListener ), - DIRECT_INTERFACE( css::frame::XDispatchProvider ), - DIRECT_INTERFACE( css::frame::XDispatch ), - DIRECT_INTERFACE( css::lang::XComponent ), - DERIVED_INTERFACE( css::lang::XEventListener, css::frame::XStatusListener ), - DERIVED_INTERFACE( css::lang::XEventListener, css::awt::XMenuListener ) - ) - -DEFINE_XTYPEPROVIDER_10 ( PopupMenuControllerBase , - css::lang::XTypeProvider , - css::lang::XServiceInfo , - ::com::sun::star::frame::XPopupMenuController , - css::lang::XInitialization , - css::frame::XStatusListener , - css::awt::XMenuListener , - css::lang::XEventListener , - css::frame::XDispatchProvider , - css::frame::XDispatch , - css::lang::XComponent - ) - -PopupMenuControllerBase::PopupMenuControllerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - ThreadHelpBase(), - ::cppu::OBroadcastHelperVar< ::cppu::OMultiTypeInterfaceContainerHelper, ::cppu::OMultiTypeInterfaceContainerHelper::keyType >( m_aLock.getShareableOslMutex() ), - m_bInitialized( false ), - m_bDisposed( false ), - m_xServiceManager( xServiceManager ), - m_aListenerContainer( m_aLock.getShareableOslMutex() ) -{ - if ( m_xServiceManager.is() ) - m_xURLTransformer.set( m_xServiceManager->createInstance( - SERVICENAME_URLTRANSFORMER), - UNO_QUERY ); -} - -PopupMenuControllerBase::~PopupMenuControllerBase() -{ -} - -// protected function -void PopupMenuControllerBase::resetPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu ) -{ - VCLXPopupMenu* pPopupMenu = 0; - if ( rPopupMenu.is() && rPopupMenu->getItemCount() > 0 ) - { - pPopupMenu = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu ); - if ( pPopupMenu ) - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - pVCLPopupMenu->Clear(); - } - } -} - -void SAL_CALL PopupMenuControllerBase::dispose() -throw (::com::sun::star::uno::RuntimeException) -{ - css::uno::Reference< css::lang::XComponent > xThis( static_cast< ::cppu::OWeakObject* >(this), UNO_QUERY ); - - // Send message to all listener and forget their references. - css::lang::EventObject aEvent( xThis ); - m_aListenerContainer.disposeAndClear( aEvent ); - - // Reset our members and set disposed flag - ResetableGuard aLock( m_aLock ); - m_xFrame.clear(); - m_xDispatch.clear(); - m_xPopupMenu.clear(); - m_xServiceManager.clear(); - m_bDisposed = true; -} - -void SAL_CALL PopupMenuControllerBase::addEventListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) -throw (::com::sun::star::uno::RuntimeException) -{ - m_aListenerContainer.addInterface( ::getCppuType( (const css::uno::Reference< css::lang::XEventListener >*)NULL ), xListener ); -} - -void SAL_CALL PopupMenuControllerBase::removeEventListener( - const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) -throw (::com::sun::star::uno::RuntimeException) -{ - m_aListenerContainer.removeInterface( ::getCppuType( (const css::uno::Reference< css::lang::XEventListener >*)NULL ), xListener ); -} - -// XEventListener -void SAL_CALL PopupMenuControllerBase::disposing( const EventObject& ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - m_xFrame.clear(); - m_xDispatch.clear(); - m_xPopupMenu.clear(); -} - -// XMenuListener -void SAL_CALL PopupMenuControllerBase::highlight( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void PopupMenuControllerBase::impl_select(const Reference< XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aURL) -{ - Sequence aArgs; - OSL_ENSURE(_xDispatch.is(),"PopupMenuControllerBase::impl_select: No dispatch"); - if ( _xDispatch.is() ) - _xDispatch->dispatch( aURL, aArgs ); -} - -void SAL_CALL PopupMenuControllerBase::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException) -{ - Reference< css::awt::XPopupMenu > xPopupMenu; - Reference< XDispatch > xDispatch; - Reference< XMultiServiceFactory > xServiceManager; - - if ( m_bDisposed ) - throw DisposedException(); - - ResetableGuard aLock( m_aLock ); - xPopupMenu = m_xPopupMenu; - xDispatch = m_xDispatch; - xServiceManager = m_xServiceManager; - aLock.unlock(); - - if ( xPopupMenu.is() ) - { - VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu ); - if ( pPopupMenu ) - { - css::util::URL aTargetURL; - { - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - PopupMenu* pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu(); - aTargetURL.Complete = pVCLPopupMenu->GetItemCommand( rEvent.MenuId ); - } - - m_xURLTransformer->parseStrict( aTargetURL ); - impl_select(xDispatch,aTargetURL); - } - } -} - -void SAL_CALL PopupMenuControllerBase::activate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL PopupMenuControllerBase::deactivate( const css::awt::MenuEvent& ) throw (RuntimeException) -{ -} - -void SAL_CALL PopupMenuControllerBase::updatePopupMenu() throw ( ::com::sun::star::uno::RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); - Reference< XDispatch > xDispatch( m_xDispatch ); - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - m_xURLTransformer->parseStrict( aTargetURL ); - aLock.unlock(); - - // Add/remove status listener to get a status update once - if ( xDispatch.is() ) - { - xDispatch->addStatusListener( xStatusListener, aTargetURL ); - xDispatch->removeStatusListener( xStatusListener, aTargetURL ); - } -} - -// XDispatchProvider -Reference< XDispatch > SAL_CALL -PopupMenuControllerBase::queryDispatch( - const URL& /*aURL*/, - const rtl::OUString& /*sTarget*/, - sal_Int32 /*nFlags*/ ) -throw( RuntimeException ) -{ - // must be implemented by subclass - ResetableGuard aLock( m_aLock ); - if ( m_bDisposed ) - throw DisposedException(); - - return Reference< XDispatch >(); -} - -Sequence< Reference< XDispatch > > SAL_CALL PopupMenuControllerBase::queryDispatches( const Sequence< DispatchDescriptor >& lDescriptor ) throw( RuntimeException ) -{ - // Create return list - which must have same size then the given descriptor - // It's not allowed to pack it! - ResetableGuard aLock( m_aLock ); - if ( m_bDisposed ) - throw DisposedException(); - aLock.unlock(); - - sal_Int32 nCount = lDescriptor.getLength(); - css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > lDispatcher( nCount ); - - // Step over all descriptors and try to get any dispatcher for it. - for( sal_Int32 i=0; i& /*seqProperties*/ ) -throw( ::com::sun::star::uno::RuntimeException ) -{ - // must be implemented by subclass - ResetableGuard aLock( m_aLock ); - if ( m_bDisposed ) - throw DisposedException(); -} - -void SAL_CALL -PopupMenuControllerBase::addStatusListener( - const Reference< XStatusListener >& xControl, - const URL& aURL ) -throw( ::com::sun::star::uno::RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - if ( m_bDisposed ) - throw DisposedException(); - aLock.unlock(); - - bool bStatusUpdate( false ); - m_aListenerContainer.addInterface( ::getCppuType( (const css::uno::Reference< css::frame::XStatusListener >*)NULL ), xControl ); - - aLock.lock(); - if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 ) - bStatusUpdate = true; - aLock.unlock(); - - if ( bStatusUpdate ) - { - // Dummy update for popup menu controllers - FeatureStateEvent aEvent; - aEvent.FeatureURL = aURL; - aEvent.IsEnabled = sal_True; - aEvent.Requery = sal_False; - aEvent.State = Any(); - xControl->statusChanged( aEvent ); - } -} - -void SAL_CALL PopupMenuControllerBase::removeStatusListener( - const Reference< XStatusListener >& xControl, - const URL& /*aURL*/ ) -throw( ::com::sun::star::uno::RuntimeException ) -{ - m_aListenerContainer.removeInterface( ::getCppuType( (const css::uno::Reference< css::frame::XStatusListener >*)NULL ), xControl ); -} - -::rtl::OUString PopupMenuControllerBase::determineBaseURL( const ::rtl::OUString& aURL ) -{ - // Just use the main part of the URL for popup menu controllers - sal_Int32 nQueryPart( 0 ); - sal_Int32 nSchemePart( 0 ); - rtl::OUString aMainURL( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.popup:" )); - - nSchemePart = aURL.indexOf( ':' ); - if (( nSchemePart > 0 ) && - ( aURL.getLength() > ( nSchemePart+1 ))) - { - nQueryPart = aURL.indexOf( '?', nSchemePart ); - if ( nQueryPart > 0 ) - aMainURL += aURL.copy( nSchemePart, nQueryPart-nSchemePart ); - else if ( nQueryPart == -1 ) - aMainURL += aURL.copy( nSchemePart+1 ); - } - - return aMainURL; -} - -// XInitialization -void SAL_CALL PopupMenuControllerBase::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - sal_Bool bInitalized( m_bInitialized ); - if ( !bInitalized ) - { - PropertyValue aPropValue; - rtl::OUString aCommandURL; - Reference< XFrame > xFrame; - - for ( int i = 0; i < aArguments.getLength(); i++ ) - { - if ( aArguments[i] >>= aPropValue ) - { - if ( aPropValue.Name.equalsAscii( "Frame" )) - aPropValue.Value >>= xFrame; - else if ( aPropValue.Name.equalsAscii( "CommandURL" )) - aPropValue.Value >>= aCommandURL; - } - } - - if ( xFrame.is() && aCommandURL.getLength() ) - { - m_xFrame = xFrame; - m_aCommandURL = aCommandURL; - m_aBaseURL = determineBaseURL( aCommandURL ); - m_bInitialized = true; - } - } -} -// XPopupMenuController -void SAL_CALL PopupMenuControllerBase::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) -{ - ResetableGuard aLock( m_aLock ); - - if ( m_bDisposed ) - throw DisposedException(); - - if ( m_xFrame.is() && !m_xPopupMenu.is() ) - { - // Create popup menu on demand - vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - - m_xPopupMenu = xPopupMenu; - m_xPopupMenu->addMenuListener( Reference< css::awt::XMenuListener >( (OWeakObject*)this, UNO_QUERY )); - - Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); - - com::sun::star::util::URL aTargetURL; - aTargetURL.Complete = m_aCommandURL; - m_xURLTransformer->parseStrict( aTargetURL ); - m_xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString(), 0 ); - - impl_setPopupMenu(); - - updatePopupMenu(); - } -} -void PopupMenuControllerBase::impl_setPopupMenu() -{ -} -} diff --git a/framework/source/helper/uiconfigelementwrapperbase.cxx b/framework/source/helper/uiconfigelementwrapperbase.cxx index 1ddda0eb0f4d..5660e5a310e3 100644 --- a/framework/source/helper/uiconfigelementwrapperbase.cxx +++ b/framework/source/helper/uiconfigelementwrapperbase.cxx @@ -45,7 +45,6 @@ #include #include #include -#include //_________________________________________________________________________________________________________________ // includes of other projects diff --git a/framework/source/register/registertemp.cxx b/framework/source/register/registertemp.cxx index dc5682c7d398..7382380ef525 100644 --- a/framework/source/register/registertemp.cxx +++ b/framework/source/register/registertemp.cxx @@ -78,6 +78,7 @@ #include #include #include +#include COMPONENTGETIMPLEMENTATIONENVIRONMENT @@ -103,6 +104,7 @@ COMPONENTWRITEINFO ( COMPONENTINFO( ::framework::MediaTypeDetectionHelper COMPONENTINFO( ::framework::DispatchRecorderSupplier ) COMPONENTINFO( ::framework::Oxt_Handler ) COMPONENTINFO( ::framework::License ) + COMPONENTINFO( ::framework::PopupMenuController ) ) COMPONENTGETFACTORY ( IFFACTORY( ::framework::MediaTypeDetectionHelper ) @@ -126,5 +128,6 @@ COMPONENTGETFACTORY ( IFFACTORY( ::framework::MediaTypeDetectionHelper IFFACTORY( ::framework::FooterMenuController ) else IFFACTORY( ::framework::HeaderMenuController ) else IFFACTORY( ::framework::LanguageSelectionMenuController ) else - IFFACTORY( ::framework::Oxt_Handler ) + IFFACTORY( ::framework::Oxt_Handler ) else + IFFACTORY( ::framework::PopupMenuController ) ) diff --git a/framework/source/uielement/comboboxtoolbarcontroller.cxx b/framework/source/uielement/comboboxtoolbarcontroller.cxx index 3921625cc76f..058005ffdc40 100644 --- a/framework/source/uielement/comboboxtoolbarcontroller.cxx +++ b/framework/source/uielement/comboboxtoolbarcontroller.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/framework/source/uielement/controlmenucontroller.cxx b/framework/source/uielement/controlmenucontroller.cxx index 0672ac69d351..49501194a014 100644 --- a/framework/source/uielement/controlmenucontroller.cxx +++ b/framework/source/uielement/controlmenucontroller.cxx @@ -61,6 +61,7 @@ #include #include #include +#include // Copied from svx // Function-Id's @@ -213,7 +214,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( ControlMenuController DEFINE_INIT_SERVICE ( ControlMenuController, {} ) ControlMenuController::ControlMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ), + svt::PopupMenuControllerBase( xServiceManager ), m_pResPopupMenu( 0 ) { const StyleSettings& rSettings = Application::GetSettings().GetStyleSettings(); @@ -272,7 +273,7 @@ void SAL_CALL ControlMenuController::disposing( const EventObject& ) throw ( Run { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::ResettableMutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xServiceManager.clear(); @@ -286,7 +287,7 @@ void SAL_CALL ControlMenuController::disposing( const EventObject& ) throw ( Run // XStatusListener void SAL_CALL ControlMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::ResettableMutexGuard aLock( m_aMutex ); USHORT nMenuId = 0; for (sal_uInt32 i=0; i < sizeof(aCommands)/sizeof(aCommands[0]); ++i) @@ -351,7 +352,7 @@ void ControlMenuController::impl_select(const Reference< XDispatch >& /*_xDispat void SAL_CALL ControlMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::ResettableMutexGuard aLock( m_aMutex ); if ( m_xPopupMenu.is() ) { @@ -404,10 +405,9 @@ void ControlMenuController::impl_setPopupMenu() void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::ResettableMutexGuard aLock( m_aMutex ); - if ( m_bDisposed ) - throw DisposedException(); + throwIfDisposed(); if ( m_xFrame.is() && m_xPopupMenu.is() ) { @@ -435,8 +435,8 @@ void SAL_CALL ControlMenuController::updatePopupMenu() throw (::com::sun::star:: // XInitialization void SAL_CALL ControlMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - ResetableGuard aLock( m_aLock ); - PopupMenuControllerBase::initialize(aArguments); + osl::ResettableMutexGuard aLock( m_aMutex ); + svt::PopupMenuControllerBase::initialize(aArguments); m_aBaseURL = ::rtl::OUString(); } diff --git a/framework/source/uielement/dropdownboxtoolbarcontroller.cxx b/framework/source/uielement/dropdownboxtoolbarcontroller.cxx index 43b50eb2a49a..0800103c743e 100644 --- a/framework/source/uielement/dropdownboxtoolbarcontroller.cxx +++ b/framework/source/uielement/dropdownboxtoolbarcontroller.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/framework/source/uielement/edittoolbarcontroller.cxx b/framework/source/uielement/edittoolbarcontroller.cxx index 3ad4b11fd1e9..387213d7c3eb 100644 --- a/framework/source/uielement/edittoolbarcontroller.cxx +++ b/framework/source/uielement/edittoolbarcontroller.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include #include diff --git a/framework/source/uielement/fontmenucontroller.cxx b/framework/source/uielement/fontmenucontroller.cxx index 7110ea5aa519..c2625a951efb 100644 --- a/framework/source/uielement/fontmenucontroller.cxx +++ b/framework/source/uielement/fontmenucontroller.cxx @@ -59,6 +59,7 @@ #include #endif #include +#include //_________________________________________________________________________________________________________________ // Defines @@ -91,7 +92,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( FontMenuController DEFINE_INIT_SERVICE ( FontMenuController, {} ) FontMenuController::FontMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ) + svt::PopupMenuControllerBase( xServiceManager ) { } @@ -145,7 +146,7 @@ void SAL_CALL FontMenuController::disposing( const EventObject& ) throw ( Runtim { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xFontListDispatch.clear(); @@ -164,12 +165,12 @@ void SAL_CALL FontMenuController::statusChanged( const FeatureStateEvent& Event if ( Event.State >>= aFontDescriptor ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_aFontFamilyName = aFontDescriptor.Name; } else if ( Event.State >>= aFontNameSeq ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); if ( m_xPopupMenu.is() ) fillPopupMenu( aFontNameSeq, m_xPopupMenu ); } @@ -192,7 +193,7 @@ void FontMenuController::impl_select(const Reference< XDispatch >& _xDispatch,co void SAL_CALL FontMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); if ( m_xPopupMenu.is() ) { @@ -241,14 +242,14 @@ void FontMenuController::impl_setPopupMenu() void SAL_CALL FontMenuController::updatePopupMenu() throw ( ::com::sun::star::uno::RuntimeException ) { - PopupMenuControllerBase::updatePopupMenu(); + svt::PopupMenuControllerBase::updatePopupMenu(); - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); Reference< XDispatch > xDispatch( m_xFontListDispatch ); com::sun::star::util::URL aTargetURL; aTargetURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:FontNameList" )); m_xURLTransformer->parseStrict( aTargetURL ); - aLock.unlock(); + aLock.clear(); if ( xDispatch.is() ) { diff --git a/framework/source/uielement/fontsizemenucontroller.cxx b/framework/source/uielement/fontsizemenucontroller.cxx index 8dbd608a28e0..58cf3a3b02be 100644 --- a/framework/source/uielement/fontsizemenucontroller.cxx +++ b/framework/source/uielement/fontsizemenucontroller.cxx @@ -64,6 +64,7 @@ #include #endif #include +#include //_________________________________________________________________________________________________________________ // Defines @@ -90,7 +91,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( FontSizeMenuController DEFINE_INIT_SERVICE ( FontSizeMenuController, {} ) FontSizeMenuController::FontSizeMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ), + svt::PopupMenuControllerBase( xServiceManager ), m_pHeightArray( 0 ), m_bRebuildMenu( sal_True ) { @@ -280,7 +281,7 @@ void SAL_CALL FontSizeMenuController::disposing( const EventObject& ) throw ( Ru { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xCurrentFontDispatch.clear(); @@ -297,7 +298,7 @@ void SAL_CALL FontSizeMenuController::statusChanged( const FeatureStateEvent& Ev if ( Event.State >>= aFontDescriptor ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_aFontDescriptor = aFontDescriptor; if ( m_xPopupMenu.is() ) @@ -306,7 +307,7 @@ void SAL_CALL FontSizeMenuController::statusChanged( const FeatureStateEvent& Ev } else if ( Event.State >>= aFontHeight ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_aFontHeight = aFontHeight; if ( m_xPopupMenu.is() ) @@ -341,16 +342,15 @@ void FontSizeMenuController::impl_setPopupMenu() void SAL_CALL FontSizeMenuController::updatePopupMenu() throw ( ::com::sun::star::uno::RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); - if ( m_bDisposed ) - throw DisposedException(); + throwIfDisposed(); Reference< XDispatch > xDispatch( m_xCurrentFontDispatch ); com::sun::star::util::URL aTargetURL; aTargetURL.Complete = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:CharFontName" )); m_xURLTransformer->parseStrict( aTargetURL ); - aLock.unlock(); + aLock.clear(); if ( xDispatch.is() ) { @@ -358,6 +358,6 @@ void SAL_CALL FontSizeMenuController::updatePopupMenu() throw ( ::com::sun::star xDispatch->removeStatusListener( SAL_STATIC_CAST( XStatusListener*, this ), aTargetURL ); } - PopupMenuControllerBase::updatePopupMenu(); + svt::PopupMenuControllerBase::updatePopupMenu(); } } diff --git a/framework/source/uielement/headermenucontroller.cxx b/framework/source/uielement/headermenucontroller.cxx index 50b2ed65e2d2..c0d7b48a401b 100644 --- a/framework/source/uielement/headermenucontroller.cxx +++ b/framework/source/uielement/headermenucontroller.cxx @@ -50,7 +50,6 @@ #include #include #include -#include //_________________________________________________________________________________________________________________ // includes of other projects @@ -65,6 +64,7 @@ #include //#include #include +#include //_________________________________________________________________________________________________________________ // Defines @@ -97,7 +97,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( HeaderMenuController DEFINE_INIT_SERVICE ( HeaderMenuController, {} ) HeaderMenuController::HeaderMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager,bool _bFooter ) : - PopupMenuControllerBase( xServiceManager ) + svt::PopupMenuControllerBase( xServiceManager ) ,m_bFooter(_bFooter) { } @@ -221,7 +221,7 @@ void SAL_CALL HeaderMenuController::disposing( const EventObject& ) throw ( Runt { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xServiceManager.clear(); @@ -238,7 +238,7 @@ void SAL_CALL HeaderMenuController::statusChanged( const FeatureStateEvent& Even if ( Event.State >>= xModel ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xModel = xModel; if ( m_xPopupMenu.is() ) fillPopupMenu( xModel, m_xPopupMenu ); @@ -258,18 +258,17 @@ void HeaderMenuController::impl_select(const Reference< XDispatch >& _xDispatch, void SAL_CALL HeaderMenuController::updatePopupMenu() throw (::com::sun::star::uno::RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::ResettableMutexGuard aLock( m_aMutex ); - if ( m_bDisposed ) - throw DisposedException(); + throwIfDisposed(); Reference< com::sun::star::frame::XModel > xModel( m_xModel ); - aLock.unlock(); + aLock.clear(); if ( !xModel.is() ) - PopupMenuControllerBase::updatePopupMenu(); + svt::PopupMenuControllerBase::updatePopupMenu(); - aLock.lock(); + aLock.reset(); if ( m_xPopupMenu.is() && m_xModel.is() ) fillPopupMenu( m_xModel, m_xPopupMenu ); } diff --git a/framework/source/uielement/imagebuttontoolbarcontroller.cxx b/framework/source/uielement/imagebuttontoolbarcontroller.cxx index d9af2fb4f9f9..5126ffdd253a 100644 --- a/framework/source/uielement/imagebuttontoolbarcontroller.cxx +++ b/framework/source/uielement/imagebuttontoolbarcontroller.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include "com/sun/star/util/XMacroExpander.hpp" #include "com/sun/star/uno/XComponentContext.hpp" diff --git a/framework/source/uielement/langselectionmenucontroller.cxx b/framework/source/uielement/langselectionmenucontroller.cxx index 9c8e68e24734..f9ead6c585c2 100644 --- a/framework/source/uielement/langselectionmenucontroller.cxx +++ b/framework/source/uielement/langselectionmenucontroller.cxx @@ -76,6 +76,7 @@ #include #include "helper/mischelper.hxx" +#include //_________________________________________________________________________________________________________________ // Defines @@ -101,7 +102,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( LanguageSelectionMenuController DEFINE_INIT_SERVICE ( LanguageSelectionMenuController, {} ) LanguageSelectionMenuController::LanguageSelectionMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ), + svt::PopupMenuControllerBase( xServiceManager ), m_bShowMenu( sal_True ) ,m_aLangGuessHelper(xServiceManager) { @@ -116,7 +117,7 @@ void SAL_CALL LanguageSelectionMenuController::disposing( const EventObject& ) t { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xLanguageDispatch.clear(); @@ -132,7 +133,7 @@ void SAL_CALL LanguageSelectionMenuController::statusChanged( const FeatureState { vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); - if ( m_bDisposed ) + if (rBHelper.bDisposed || rBHelper.bInDispose) return; m_bShowMenu = sal_True; @@ -380,15 +381,15 @@ void LanguageSelectionMenuController::fillPopupMenu( Reference< css::awt::XPopup void SAL_CALL LanguageSelectionMenuController::updatePopupMenu() throw ( ::com::sun::star::uno::RuntimeException ) { - PopupMenuControllerBase::updatePopupMenu(); + svt::PopupMenuControllerBase::updatePopupMenu(); // Force status update to get information about the current languages - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); Reference< XDispatch > xDispatch( m_xLanguageDispatch ); com::sun::star::util::URL aTargetURL; aTargetURL.Complete = m_aLangStatusCommandURL; m_xURLTransformer->parseStrict( aTargetURL ); - aLock.unlock(); + aLock.clear(); if ( xDispatch.is() ) { @@ -415,12 +416,12 @@ void SAL_CALL LanguageSelectionMenuController::updatePopupMenu() throw ( ::com:: // XInitialization void SAL_CALL LanguageSelectionMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); sal_Bool bInitalized( m_bInitialized ); if ( !bInitalized ) { - PopupMenuControllerBase::initialize(aArguments); + svt::PopupMenuControllerBase::initialize(aArguments); if ( m_bInitialized ) { diff --git a/framework/source/uielement/macrosmenucontroller.cxx b/framework/source/uielement/macrosmenucontroller.cxx index f0f5d52a47d6..2905d0c0bd05 100644 --- a/framework/source/uielement/macrosmenucontroller.cxx +++ b/framework/source/uielement/macrosmenucontroller.cxx @@ -48,6 +48,7 @@ #include #include #include "helper/mischelper.hxx" +#include using namespace com::sun::star::uno; using namespace com::sun::star::lang; @@ -70,7 +71,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( MacrosMenuController DEFINE_INIT_SERVICE ( MacrosMenuController, {} ) MacrosMenuController::MacrosMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ), + svt::PopupMenuControllerBase( xServiceManager ), m_xServiceManager( xServiceManager) { } @@ -109,7 +110,7 @@ void SAL_CALL MacrosMenuController::disposing( const EventObject& ) throw ( Runt { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); OSL_TRACE("disposing"); m_xFrame.clear(); m_xDispatch.clear(); @@ -126,7 +127,7 @@ void SAL_CALL MacrosMenuController::disposing( const EventObject& ) throw ( Runt // XStatusListener void SAL_CALL MacrosMenuController::statusChanged( const FeatureStateEvent& ) throw ( RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); if ( m_xPopupMenu.is() ) { fillPopupMenu( m_xPopupMenu ); diff --git a/framework/source/uielement/makefile.mk b/framework/source/uielement/makefile.mk index da4ab3d34c74..b74adb1e176f 100644 --- a/framework/source/uielement/makefile.mk +++ b/framework/source/uielement/makefile.mk @@ -79,6 +79,7 @@ SLOFILES= \ $(SLO)$/toolbarmerger.obj \ $(SLO)$/toolbarsmenucontroller.obj \ $(SLO)$/toolbarwrapper.obj \ + $(SLO)$/popupmenucontroller.obj \ $(SLO)$/uicommanddescription.obj \ # --- Targets ------------------------------------------------------ diff --git a/framework/source/uielement/newmenucontroller.cxx b/framework/source/uielement/newmenucontroller.cxx index 3ac78726d799..786795ff1d14 100644 --- a/framework/source/uielement/newmenucontroller.cxx +++ b/framework/source/uielement/newmenucontroller.cxx @@ -67,6 +67,7 @@ #include #include #include +#include //_________________________________________________________________________________________________________________ // Defines @@ -326,7 +327,7 @@ void NewMenuController::retrieveShortcutsFromConfiguration( } NewMenuController::NewMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ), + svt::PopupMenuControllerBase( xServiceManager ), m_bShowImages( sal_True ), m_bHiContrast( sal_False ), m_bNewMenu( sal_False ), @@ -399,7 +400,7 @@ void SAL_CALL NewMenuController::disposing( const EventObject& ) throw ( Runtime { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xServiceManager.clear(); @@ -423,12 +424,12 @@ void SAL_CALL NewMenuController::select( const css::awt::MenuEvent& rEvent ) thr Reference< XMultiServiceFactory > xServiceManager; Reference< XURLTransformer > xURLTransformer; - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); xPopupMenu = m_xPopupMenu; xDispatchProvider = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY ); xServiceManager = m_xServiceManager; xURLTransformer = m_xURLTransformer; - aLock.unlock(); + aLock.clear(); css::util::URL aTargetURL; Sequence< PropertyValue > aArgsList( 1 ); @@ -548,12 +549,12 @@ void NewMenuController::impl_setPopupMenu() // XInitialization void SAL_CALL NewMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); sal_Bool bInitalized( m_bInitialized ); if ( !bInitalized ) { - PopupMenuControllerBase::initialize( aArguments ); + svt::PopupMenuControllerBase::initialize( aArguments ); if ( m_bInitialized ) { diff --git a/framework/source/uielement/objectmenucontroller.cxx b/framework/source/uielement/objectmenucontroller.cxx index f4d6aea0d82b..80dccb76db05 100644 --- a/framework/source/uielement/objectmenucontroller.cxx +++ b/framework/source/uielement/objectmenucontroller.cxx @@ -59,6 +59,7 @@ #include #include #include +#include //_________________________________________________________________________________________________________________ // Defines @@ -83,7 +84,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( ObjectMenuController DEFINE_INIT_SERVICE ( ObjectMenuController, {} ) ObjectMenuController::ObjectMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ) + svt::PopupMenuControllerBase( xServiceManager ) { } @@ -128,7 +129,7 @@ void SAL_CALL ObjectMenuController::disposing( const EventObject& ) throw ( Runt { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xObjectUpdateDispatch.clear(); @@ -145,7 +146,7 @@ void SAL_CALL ObjectMenuController::statusChanged( const FeatureStateEvent& Even Sequence < com::sun::star::embed::VerbDescriptor > aVerbCommandSeq; if ( Event.State >>= aVerbCommandSeq ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); if ( m_xPopupMenu.is() ) fillPopupMenu( aVerbCommandSeq, m_xPopupMenu ); } diff --git a/framework/source/uielement/popupmenucontroller.cxx b/framework/source/uielement/popupmenucontroller.cxx new file mode 100644 index 000000000000..867a395f6916 --- /dev/null +++ b/framework/source/uielement/popupmenucontroller.cxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_framework.hxx" + +#include +#include + +#include +//#include + +#include + +#include +#include +#include +#include + +#include "uielement/popupmenucontroller.hxx" +#include "services.h" + +using rtl::OUString; +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; +using namespace ::com::sun::star::lang; +using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::beans; + +// -------------------------------------------------------------------- + + +namespace framework +{ + +DEFINE_XSERVICEINFO_MULTISERVICE ( PopupMenuController , + OWeakObject , + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ToolbarController" ) ) , + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.framework.PopupMenuController" ) ) + ) + +DEFINE_INIT_SERVICE ( PopupMenuController, {} ) + +class PopupMenuControllerImpl +{ +}; + +//======================================================================== +// class PopupMenuController +//======================================================================== + +PopupMenuController::PopupMenuController( const Reference< lang::XMultiServiceFactory >& rServiceManager ) +: svt::ToolboxController( rServiceManager, Reference< frame::XFrame >(), OUString() ) +{ +} + +// -------------------------------------------------------------------- + +PopupMenuController::~PopupMenuController() +{ +} + +// -------------------------------------------------------------------- +// XInterface +// -------------------------------------------------------------------- + +Any SAL_CALL PopupMenuController::queryInterface( const Type& aType ) throw (RuntimeException) +{ + Any a( ToolboxController::queryInterface( aType ) ); + if ( a.hasValue() ) + return a; + + return ::cppu::queryInterface( aType, static_cast< lang::XServiceInfo* >( this )); +} + +// -------------------------------------------------------------------- + +void SAL_CALL PopupMenuController::acquire() throw () +{ + ToolboxController::acquire(); +} + +// -------------------------------------------------------------------- + +void SAL_CALL PopupMenuController::release() throw () +{ + ToolboxController::release(); +} + +// -------------------------------------------------------------------- +// XComponent +// -------------------------------------------------------------------- + +void SAL_CALL PopupMenuController::dispose() throw (RuntimeException) +{ + if( mxPopupMenuController.is() ) + { + Reference< XComponent > xComponent( mxPopupMenuController, UNO_QUERY ); + if( xComponent.is() ) + xComponent->dispose(); + mxPopupMenuController.clear(); + } + + mxPopupMenu.clear(); + + svt::ToolboxController::dispose(); +} + +// -------------------------------------------------------------------- +// XStatusListener +// -------------------------------------------------------------------- + +void SAL_CALL PopupMenuController::statusChanged( const frame::FeatureStateEvent& rEvent ) throw ( RuntimeException ) +{ + svt::ToolboxController::statusChanged(rEvent); + enable( rEvent.IsEnabled ); +} + +// -------------------------------------------------------------------- +// XToolbarController +// -------------------------------------------------------------------- + +void SAL_CALL PopupMenuController::execute( sal_Int16 KeyModifier ) throw (RuntimeException) +{ + svt::ToolboxController::execute( KeyModifier ); +} + +// -------------------------------------------------------------------- + +void SAL_CALL PopupMenuController::click() throw (RuntimeException) +{ + svt::ToolboxController::click(); +} + +// -------------------------------------------------------------------- + +void SAL_CALL PopupMenuController::doubleClick() throw (RuntimeException) +{ + svt::ToolboxController::doubleClick(); +} + +// -------------------------------------------------------------------- + +bool PopupMenuController::CreatePopupMenuController() throw (Exception) +{ + Reference< XMultiComponentFactory > xPopupMenuControllerRegistration( getServiceManager()->createInstance( SERVICENAME_POPUPMENUCONTROLLERFACTORY ), UNO_QUERY_THROW ); + + Sequence< Any > aSeq( 2 ); + PropertyValue aPropValue; + + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" )); + aPropValue.Value <<= getModuleName(); + aSeq[0] <<= aPropValue; + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Frame" )); + aPropValue.Value <<= m_xFrame; + aSeq[1] <<= aPropValue; + + Reference< XPropertySet > xProps( getServiceManager(), UNO_QUERY_THROW ); + Reference< XComponentContext > xComponentContext( xProps->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ))), UNO_QUERY_THROW ); + + Reference< XPopupMenuController > xPopupMenuController( xPopupMenuControllerRegistration->createInstanceWithArgumentsAndContext( getCommandURL(), aSeq, xComponentContext ), UNO_QUERY ); + if ( xPopupMenuController.is() ) + { + mxPopupMenuController = xPopupMenuController; + return true; + } + return false; +} + +Reference< awt::XWindow > SAL_CALL PopupMenuController::createPopupWindow() throw (RuntimeException) +{ + ::vos::OGuard aSolarLock(Application::GetSolarMutex()); + + Reference< awt::XWindow > xRet; + + try + { + ToolBox* pToolBox = dynamic_cast< ToolBox* >( VCLUnoHelper::GetWindow( getParent() ) ); + if( !pToolBox ) + return xRet; + + // get selected button + USHORT nItemId = pToolBox->GetDownItemId(); + if( !nItemId ) + return xRet; + + ::Rectangle aRect( pToolBox->GetItemRect( nItemId ) ); + + if( !mxPopupMenuController.is() && !CreatePopupMenuController() ) + return xRet; + + if( !mxPopupMenu.is() ) + { + mxPopupMenu = Reference< awt::XPopupMenu >( getServiceManager()->createInstance( DECLARE_ASCII( "stardiv.Toolkit.VCLXPopupMenu" ) ), UNO_QUERY_THROW ); + mxPopupMenuController->setPopupMenu( mxPopupMenu ); + } + else + { + mxPopupMenuController->updatePopupMenu(); + + } + pToolBox->SetItemDown( nItemId, TRUE ); + Reference< awt::XWindowPeer > xPeer( getParent(), UNO_QUERY_THROW ); + mxPopupMenu->execute( xPeer, VCLUnoHelper::ConvertToAWTRect( aRect ), 0 ); + pToolBox->SetItemDown( nItemId, FALSE ); + } + catch( Exception& ) + { + } + + return xRet; +} + +// -------------------------------------------------------------------- + +Reference< awt::XWindow > SAL_CALL PopupMenuController::createItemWindow( const Reference< awt::XWindow >& Parent ) throw (RuntimeException) +{ + return Reference< awt::XWindow >(); +} + +// -------------------------------------------------------------------- + +} + diff --git a/framework/source/uielement/progressbarwrapper.cxx b/framework/source/uielement/progressbarwrapper.cxx index 2cd0ed891db6..a20f107ea22e 100644 --- a/framework/source/uielement/progressbarwrapper.cxx +++ b/framework/source/uielement/progressbarwrapper.cxx @@ -43,6 +43,7 @@ // interface includes //_________________________________________________________________________________________________________________ #include +#include //_________________________________________________________________________________________________________________ // includes of other projects diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index cec95485dacd..64f05ed642cb 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -47,7 +47,6 @@ #include #include #include -#include //_________________________________________________________________________________________________________________ // includes of other projects //_________________________________________________________________________________________________________________ @@ -64,6 +63,7 @@ #include //#include #include +#include //_________________________________________________________________________________________________________________ // Defines @@ -105,7 +105,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( RecentFilesMenuController DEFINE_INIT_SERVICE ( RecentFilesMenuController, {} ) RecentFilesMenuController::RecentFilesMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ), + svt::PopupMenuControllerBase( xServiceManager ), m_bDisabled( sal_False ) { } @@ -245,11 +245,11 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) Reference< XDispatchProvider > xDispatchProvider; Reference< XMultiServiceFactory > xServiceManager; - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); xPopupMenu = m_xPopupMenu; xDispatchProvider = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY ); xServiceManager = m_xServiceManager; - aLock.unlock(); + aLock.clear(); css::util::URL aTargetURL; Sequence< PropertyValue > aArgsList; @@ -312,7 +312,7 @@ void SAL_CALL RecentFilesMenuController::disposing( const EventObject& ) throw ( { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xServiceManager.clear(); @@ -325,7 +325,7 @@ void SAL_CALL RecentFilesMenuController::disposing( const EventObject& ) throw ( // XStatusListener void SAL_CALL RecentFilesMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_bDisabled = !Event.IsEnabled; } @@ -336,11 +336,11 @@ void SAL_CALL RecentFilesMenuController::select( const css::awt::MenuEvent& rEve Reference< XDispatchProvider > xDispatchProvider; Reference< XMultiServiceFactory > xServiceManager; - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); xPopupMenu = m_xPopupMenu; xDispatchProvider = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY ); xServiceManager = m_xServiceManager; - aLock.unlock(); + aLock.clear(); css::util::URL aTargetURL; Sequence< PropertyValue > aArgsList; @@ -355,7 +355,7 @@ void SAL_CALL RecentFilesMenuController::select( const css::awt::MenuEvent& rEve void SAL_CALL RecentFilesMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); impl_setPopupMenu(); } @@ -368,17 +368,16 @@ void RecentFilesMenuController::impl_setPopupMenu() void SAL_CALL RecentFilesMenuController::updatePopupMenu() throw (RuntimeException) { - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); - if ( m_bDisposed ) - throw DisposedException(); + throwIfDisposed(); Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY ); Reference< XDispatch > xDispatch( m_xDispatch ); com::sun::star::util::URL aTargetURL; aTargetURL.Complete = m_aCommandURL; m_xURLTransformer->parseStrict( aTargetURL ); - aLock.unlock(); + aLock.clear(); // Add/remove status listener to get a status update once if ( xDispatch.is() ) @@ -395,10 +394,9 @@ Reference< XDispatch > SAL_CALL RecentFilesMenuController::queryDispatch( sal_Int32 /*nFlags*/ ) throw( RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); - if ( m_bDisposed ) - throw DisposedException(); + throwIfDisposed(); if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 ) return Reference< XDispatch >( static_cast< OWeakObject* >( this ), UNO_QUERY ); @@ -412,10 +410,9 @@ void SAL_CALL RecentFilesMenuController::dispatch( const Sequence< PropertyValue >& /*seqProperties*/ ) throw( RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); - if ( m_bDisposed ) - throw DisposedException(); + throwIfDisposed(); if ( aURL.Complete.indexOf( m_aBaseURL ) == 0 ) { @@ -448,12 +445,11 @@ void SAL_CALL RecentFilesMenuController::addStatusListener( const URL& aURL ) throw( RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); - if ( m_bDisposed ) - throw DisposedException(); + throwIfDisposed(); - PopupMenuControllerBase::addStatusListener( xControl, aURL ); + svt::PopupMenuControllerBase::addStatusListener( xControl, aURL ); } void SAL_CALL RecentFilesMenuController::removeStatusListener( @@ -461,7 +457,7 @@ void SAL_CALL RecentFilesMenuController::removeStatusListener( const URL& aURL ) throw( RuntimeException ) { - PopupMenuControllerBase::removeStatusListener( xControl, aURL ); + svt::PopupMenuControllerBase::removeStatusListener( xControl, aURL ); } IMPL_STATIC_LINK_NOINSTANCE( RecentFilesMenuController, ExecuteHdl_Impl, LoadRecentFile*, pLoadRecentFile ) diff --git a/framework/source/uielement/spinfieldtoolbarcontroller.cxx b/framework/source/uielement/spinfieldtoolbarcontroller.cxx index 43ad09ffc1ee..dad2775dc453 100644 --- a/framework/source/uielement/spinfieldtoolbarcontroller.cxx +++ b/framework/source/uielement/spinfieldtoolbarcontroller.cxx @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include diff --git a/framework/source/uielement/statusbarmanager.cxx b/framework/source/uielement/statusbarmanager.cxx index cb9cbb2896f7..0bbdbc339a34 100644 --- a/framework/source/uielement/statusbarmanager.cxx +++ b/framework/source/uielement/statusbarmanager.cxx @@ -56,6 +56,7 @@ #include #include #include +#include //_________________________________________________________________________________________________________________ // other includes diff --git a/framework/source/uielement/togglebuttontoolbarcontroller.cxx b/framework/source/uielement/togglebuttontoolbarcontroller.cxx index a5e4263385fa..cf39edec2a7c 100644 --- a/framework/source/uielement/togglebuttontoolbarcontroller.cxx +++ b/framework/source/uielement/togglebuttontoolbarcontroller.cxx @@ -46,7 +46,6 @@ #include #include #include -#include #include #include "com/sun/star/util/XMacroExpander.hpp" #include "com/sun/star/uno/XComponentContext.hpp" diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index d89b81c0f9b6..5da7db82c363 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -75,6 +75,7 @@ #include #include #include +#include //_________________________________________________________________________________________________________________ // other includes @@ -1028,6 +1029,10 @@ void ToolBarManager::CreateControllers() aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParentWindow" )); aPropValue.Value <<= xToolbarWindow; aPropertyVector.push_back( makeAny( aPropValue )); + aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleName" )); + aPropValue.Value <<= m_aModuleIdentifier; + aPropertyVector.push_back( makeAny( aPropValue )); + if ( nWidth > 0 ) { aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Width" )); diff --git a/framework/source/uielement/toolbarsmenucontroller.cxx b/framework/source/uielement/toolbarsmenucontroller.cxx index 02402205bd1c..d0ddeccfab20 100644 --- a/framework/source/uielement/toolbarsmenucontroller.cxx +++ b/framework/source/uielement/toolbarsmenucontroller.cxx @@ -58,7 +58,6 @@ #include #include #include -#include //_________________________________________________________________________________________________________________ // includes of other projects @@ -167,7 +166,7 @@ DEFINE_XSERVICEINFO_MULTISERVICE ( ToolbarsMenuController DEFINE_INIT_SERVICE ( ToolbarsMenuController, {} ) ToolbarsMenuController::ToolbarsMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ) : - PopupMenuControllerBase( xServiceManager ), + svt::PopupMenuControllerBase( xServiceManager ), m_aPropUIName( RTL_CONSTASCII_USTRINGPARAM( "UIName" )), m_aPropResourceURL( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" )), m_bModuleIdentified( sal_False ), @@ -563,7 +562,7 @@ void SAL_CALL ToolbarsMenuController::disposing( const EventObject& ) throw ( Ru { Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY ); - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); m_xFrame.clear(); m_xDispatch.clear(); m_xDocCfgMgr.clear(); @@ -584,9 +583,9 @@ void SAL_CALL ToolbarsMenuController::statusChanged( const FeatureStateEvent& Ev sal_Bool bSetCheckmark = sal_False; sal_Bool bCheckmark = sal_False; - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); Reference< css::awt::XPopupMenu > xPopupMenu( m_xPopupMenu ); - aLock.unlock(); + aLock.clear(); if ( xPopupMenu.is() ) { @@ -633,13 +632,13 @@ void SAL_CALL ToolbarsMenuController::select( const css::awt::MenuEvent& rEvent Reference< XFrame > xFrame; Reference< XNameAccess > xPersistentWindowState; - ResetableGuard aLock( m_aLock ); + osl::ClearableMutexGuard aLock( m_aMutex ); xPopupMenu = m_xPopupMenu; xServiceManager = m_xServiceManager; xURLTransformer = m_xURLTransformer; xFrame = m_xFrame; xPersistentWindowState = m_xPersistentWindowState; - aLock.unlock(); + aLock.clear(); if ( xPopupMenu.is() ) { @@ -792,7 +791,7 @@ void SAL_CALL ToolbarsMenuController::activate( const css::awt::MenuEvent& ) thr Reference< XDispatchProvider > xDispatchProvider( m_xFrame, UNO_QUERY ); Reference< XURLTransformer > xURLTransformer( m_xURLTransformer ); { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); fillPopupMenu( m_xPopupMenu ); aCmdVector = m_aCommandVector; } @@ -829,10 +828,9 @@ void SAL_CALL ToolbarsMenuController::activate( const css::awt::MenuEvent& ) thr // XPopupMenuController void SAL_CALL ToolbarsMenuController::setPopupMenu( const Reference< css::awt::XPopupMenu >& xPopupMenu ) throw ( RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); - if ( m_bDisposed ) - throw DisposedException(); + throwIfDisposed(); if ( m_xFrame.is() && !m_xPopupMenu.is() ) { @@ -848,11 +846,11 @@ void SAL_CALL ToolbarsMenuController::setPopupMenu( const Reference< css::awt::X // XInitialization void SAL_CALL ToolbarsMenuController::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException ) { - ResetableGuard aLock( m_aLock ); + osl::MutexGuard aLock( m_aMutex ); sal_Bool bInitalized( m_bInitialized ); if ( !bInitalized ) { - PopupMenuControllerBase::initialize(aArguments); + svt::PopupMenuControllerBase::initialize(aArguments); if ( m_bInitialized ) { diff --git a/framework/source/uielement/toolbarwrapper.cxx b/framework/source/uielement/toolbarwrapper.cxx index 0e73b5616aa7..5a4fb7cddde4 100644 --- a/framework/source/uielement/toolbarwrapper.cxx +++ b/framework/source/uielement/toolbarwrapper.cxx @@ -53,6 +53,7 @@ #include #include #include +#include //_________________________________________________________________________________________________________________ // other includes -- cgit From f6b04c513837462449c4c4308bd76dec41cd5ed4 Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Tue, 30 Mar 2010 10:07:55 +0200 Subject: fixed compile warnings --- framework/source/uielement/popupmenucontroller.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework/source') diff --git a/framework/source/uielement/popupmenucontroller.cxx b/framework/source/uielement/popupmenucontroller.cxx index 867a395f6916..328777db2b79 100644 --- a/framework/source/uielement/popupmenucontroller.cxx +++ b/framework/source/uielement/popupmenucontroller.cxx @@ -237,7 +237,7 @@ Reference< awt::XWindow > SAL_CALL PopupMenuController::createPopupWindow() thro // -------------------------------------------------------------------- -Reference< awt::XWindow > SAL_CALL PopupMenuController::createItemWindow( const Reference< awt::XWindow >& Parent ) throw (RuntimeException) +Reference< awt::XWindow > SAL_CALL PopupMenuController::createItemWindow( const Reference< awt::XWindow >& /*Parent*/ ) throw (RuntimeException) { return Reference< awt::XWindow >(); } -- cgit From f0cd4535a2d40ce66c346596bedbc7eac97a0b63 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 7 Apr 2010 22:36:25 +0200 Subject: slidecopy: UIElementType::TOOLPANEL --- framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'framework/source') diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index 663c2d0d6dd8..20a3d18d12f0 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -123,7 +123,8 @@ static const char* UIELEMENTTYPENAMES[] = UIELEMENTTYPE_TOOLBAR_NAME, UIELEMENTTYPE_STATUSBAR_NAME, UIELEMENTTYPE_FLOATINGWINDOW_NAME, - UIELEMENTTYPE_PROGRESSBAR_NAME + UIELEMENTTYPE_PROGRESSBAR_NAME, + UIELEMENTTYPE_TOOLPANEL_NAME }; static const char RESOURCEURL_PREFIX[] = "private:resource/"; -- cgit From e96760a74a9a65f99a5acfaeaf13fc31eb243d82 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 8 Apr 2010 11:21:05 +0200 Subject: fwk127: #i106491# Substitute possible variables inside impl_setPathValue --- framework/source/services/pathsettings.cxx | 1 + 1 file changed, 1 insertion(+) (limited to 'framework/source') diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx index e99e08895a3f..5227cb9f302c 100644 --- a/framework/source/services/pathsettings.cxx +++ b/framework/source/services/pathsettings.cxx @@ -855,6 +855,7 @@ void PathSettings::impl_setPathValue( sal_Int32 nID , ::rtl::OUString sVal; aVal >>= sVal; OUStringList lList = impl_convertOldStyle2Path(sVal); + impl_subst(lList, fa_getSubstitution(), sal_False); impl_purgeKnownPaths(aChangePath, lList); if (! impl_isValidPath(lList)) throw css::lang::IllegalArgumentException(); -- cgit From 4c700c32a3f70c1d5ebe636fdd52f79feefe0d14 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 8 Apr 2010 17:26:09 +0200 Subject: fwk139: #i100512# Eliminate flicker when toolbar buttons make themselves invisible --- framework/source/uielement/toolbarmanager.cxx | 78 +++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) (limited to 'framework/source') diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index d89b81c0f9b6..ea1cc2cda7e4 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -510,7 +510,47 @@ void ToolBarManager::UpdateControllers() } m_bUpdateControllers = sal_False; } +//for update toolbar controller via Support Visible by shizhoubo +void ToolBarManager::UpdateController( ::com::sun::star::uno::Reference< ::com::sun::star::frame::XToolbarController > xController) +{ + RTL_LOGFILE_CONTEXT( aLog, "framework (cd100003) ::ToolBarManager::UpdateControllers" ); + + if ( !m_bUpdateControllers ) + { + m_bUpdateControllers = sal_True; + try + { if(xController.is()) + { + Reference< XUpdatable > xUpdatable( xController, UNO_QUERY ); + if ( xUpdatable.is() ) + xUpdatable->update(); + } + } + catch ( Exception& ) + { + } + + /* m_bUpdateControllers = sal_True; + ToolBarControllerMap::iterator pIter = m_aControllerMap.begin(); + while ( pIter != m_aControllerMap.end() ) + { + try + { + Reference< XUpdatable > xUpdatable( pIter->second, UNO_QUERY ); + if ( xUpdatable.is() ) + xUpdatable->update(); + } + catch ( Exception& ) + { + } + ++pIter; + }*/ + + } + m_bUpdateControllers = sal_False; +} +//end void ToolBarManager::frameAction( const FrameActionEvent& Action ) throw ( RuntimeException ) { @@ -1037,6 +1077,19 @@ void ToolBarManager::CreateControllers() Sequence< Any > aArgs( comphelper::containerToSequence( aPropertyVector )); xInit->initialize( aArgs ); + //for Support Visiblitly by shizhoubo + if (pController) + { + // rtl::OUString aCommandURL = pController->m_aCommandURL; + if(aCommandURL == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:SwitchXFormsDesignMode" )) || + aCommandURL == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ViewDataSourceBrowser" )) || + aCommandURL == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ParaLeftToRight" )) || + aCommandURL == rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ".uno:ParaRightToLeft" )) + ) + pController->setFastPropertyValue_NoBroadcast(1,makeAny(sal_True)); + } + + //end } // Request a item window from the toolbar controller and set it at the VCL toolbar @@ -1057,6 +1110,31 @@ void ToolBarManager::CreateControllers() } } } + //for update Controller via support visiable state by shizhoubo + Reference< XPropertySet > xPropSet( xController, UNO_QUERY ); + if ( xPropSet.is() ) + { + try + { + sal_Bool bSupportVisiable = sal_True; + Any a( xPropSet->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "SupportsVisiable" ))) ); + a >>= bSupportVisiable; + if ( bSupportVisiable ) + { + Reference< XToolbarController > xTbxController( xController, UNO_QUERY ); + UpdateController(xTbxController); + } + } + catch ( RuntimeException& ) + { + throw; + } + catch ( Exception& ) + { + } + } + //end + } AddFrameActionListener(); -- cgit From d30937f3ef1f1c8c2f38d0923ab30607c0aceb7f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 9 Apr 2010 11:05:09 +0200 Subject: slidecopy: separate resource ID number circles for svl and svtools (thanks to MBA for the patch) --- framework/source/services/backingwindow.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework/source') diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index 3e9071052011..12f8743f7032 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -45,7 +45,7 @@ #include "unotools/dynamicmenuoptions.hxx" #include "svtools/imagemgr.hxx" -#include "svl/svtools.hrc" +#include "svtools/svtools.hrc" #include "comphelper/processfactory.hxx" #include "comphelper/sequenceashashmap.hxx" -- cgit From 7c9c5e1d801b32d99d9ca2aa46b3071a9f497f2f Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 9 Apr 2010 11:07:43 +0200 Subject: slidecopy: moved Frame/ResourceURL/Type from css.ui.UIElement to css.ui.XUIElement --- .../source/helper/uiconfigelementwrapperbase.cxx | 19 +++++++++++++++++++ framework/source/helper/uielementwrapperbase.cxx | 17 +++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'framework/source') diff --git a/framework/source/helper/uiconfigelementwrapperbase.cxx b/framework/source/helper/uiconfigelementwrapperbase.cxx index 1f93e356f290..034a510187be 100644 --- a/framework/source/helper/uiconfigelementwrapperbase.cxx +++ b/framework/source/helper/uiconfigelementwrapperbase.cxx @@ -553,4 +553,23 @@ Reference< XIndexAccess > SAL_CALL UIConfigElementWrapperBase::getSettings( sal_ return m_xConfigData; } +Reference< XFrame > SAL_CALL UIConfigElementWrapperBase::getFrame() throw (RuntimeException) +{ + ResetableGuard aLock( m_aLock ); + Reference< XFrame > xFrame( m_xWeakFrame ); + return xFrame; +} + +::rtl::OUString SAL_CALL UIConfigElementWrapperBase::getResourceURL() throw (RuntimeException) +{ + ResetableGuard aLock( m_aLock ); + return m_aResourceURL; +} + +::sal_Int16 SAL_CALL UIConfigElementWrapperBase::getType() throw (RuntimeException) +{ + ResetableGuard aLock( m_aLock ); + return m_nType; +} + } diff --git a/framework/source/helper/uielementwrapperbase.cxx b/framework/source/helper/uielementwrapperbase.cxx index e406e19df81b..d90c8d387655 100644 --- a/framework/source/helper/uielementwrapperbase.cxx +++ b/framework/source/helper/uielementwrapperbase.cxx @@ -154,6 +154,23 @@ throw ( Exception, RuntimeException ) } } +// XUIElement +::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL UIElementWrapperBase::getFrame() throw (::com::sun::star::uno::RuntimeException) +{ + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame( m_xWeakFrame ); + return xFrame; +} + +::rtl::OUString SAL_CALL UIElementWrapperBase::getResourceURL() throw (::com::sun::star::uno::RuntimeException) +{ + return m_aResourceURL; +} + +::sal_Int16 SAL_CALL UIElementWrapperBase::getType() throw (::com::sun::star::uno::RuntimeException) +{ + return m_nType; +} + // XUpdatable void SAL_CALL UIElementWrapperBase::update() throw (::com::sun::star::uno::RuntimeException) { -- cgit From 6117ebac60ab7acb84b45b57d49150abf469667d Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Tue, 13 Apr 2010 18:47:19 +0200 Subject: vcl111: #i97017# add yet another recent file list --- framework/source/services/backingwindow.cxx | 156 +++++++++++++++++++++++++++- framework/source/services/backingwindow.hxx | 20 +++- framework/source/services/fwk_services.src | 2 +- 3 files changed, 170 insertions(+), 8 deletions(-) (limited to 'framework/source') diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index bbbefdbdbda1..6cad7f6e6adf 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -41,6 +41,7 @@ #include "tools/urlobj.hxx" #include "unotools/dynamicmenuoptions.hxx" +#include "unotools/historyoptions.hxx" #include "svtools/imagemgr.hxx" #include "svl/svtools.hrc" @@ -48,18 +49,23 @@ #include "comphelper/sequenceashashmap.hxx" #include "comphelper/configurationhelper.hxx" +#include "cppuhelper/implbase1.hxx" + #include "rtl/strbuf.hxx" #include "rtl/ustrbuf.hxx" +#include "osl/file.h" #include "com/sun/star/lang/XMultiServiceFactory.hpp" #include "com/sun/star/container/XNameAccess.hpp" #include "com/sun/star/system/XSystemShellExecute.hpp" #include "com/sun/star/system/SystemShellExecuteFlags.hpp" #include "com/sun/star/task/XJobExecutor.hpp" +#include "com/sun/star/util/XStringWidth.hpp" using namespace ::com::sun::star::beans; using namespace ::com::sun::star::frame; +using namespace ::com::sun::star::util; using namespace ::com::sun::star::uno; using namespace ::com::sun::star; using namespace framework; @@ -110,6 +116,20 @@ Size DecoToolBox::getMinSize() return maMinSize; } +class RecentFilesStringLength : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XStringWidth > +{ + public: + RecentFilesStringLength() {} + virtual ~RecentFilesStringLength() {} + + // XStringWidth + sal_Int32 SAL_CALL queryStringWidth( const ::rtl::OUString& aString ) + throw (::com::sun::star::uno::RuntimeException) + { + return aString.getLength(); + } +}; + #define STC_BUTTON_STYLE (WB_LEFT | WB_VCENTER | WB_FLATBUTTON | WB_BEVELBUTTON) BackingWindow::BackingWindow( Window* i_pParent ) : @@ -141,7 +161,8 @@ BackingWindow::BackingWindow( Window* i_pParent ) : mbInitControls( false ), mnLayoutStyle( 0 ), mpAccExec( NULL ), - mnBtnPos( 120 ) + mnBtnPos( 120 ), + mpRecentMenu( NULL ) { mnColumnWidth[0] = mnColumnWidth[1] = 0; mnTextColumnWidth[0] = mnTextColumnWidth[1] = 0; @@ -249,6 +270,7 @@ BackingWindow::BackingWindow( Window* i_pParent ) : BackingWindow::~BackingWindow() { + delete mpRecentMenu; delete mpAccExec; } @@ -277,6 +299,116 @@ void BackingWindow::DataChanged( const DataChangedEvent& rDCEvt ) } } +void BackingWindow::prepareRecentFileMenu() +{ + if( ! mpRecentMenu ) + mpRecentMenu = new PopupMenu(); + mpRecentMenu->Clear(); + maRecentFiles.clear(); + + // get recent file list and dispatch arguments + Sequence< Sequence< PropertyValue > > aHistoryList( SvtHistoryOptions().GetList( ePICKLIST ) ); + + sal_Int32 nPickListMenuItems = ( aHistoryList.getLength() > 99 ) ? 99 : aHistoryList.getLength(); + + if( ( nPickListMenuItems > 0 ) ) + { + maRecentFiles.reserve( nPickListMenuItems ); + for ( sal_Int32 i = 0; i < nPickListMenuItems; i++ ) + { + Sequence< PropertyValue >& rPickListEntry = aHistoryList[i]; + rtl::OUString aURL, aFilter, aFilterOpt, aTitle; + + for ( sal_Int32 j = 0; j < rPickListEntry.getLength(); j++ ) + { + const Any& a = rPickListEntry[j].Value; + + if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_URL ) + a >>= aURL; + else if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_FILTER ) + { + a >>= aFilter; + sal_Int32 nPos = aFilter.indexOf( '|' ); + if ( nPos >= 0 ) + { + if ( nPos < ( aFilter.getLength() - 1 ) ) + aFilterOpt = aFilter.copy( nPos+1 ); + aFilter = aFilter.copy( 0, nPos-1 ); + } + } + else if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_TITLE ) + a >>= aTitle; + } + maRecentFiles.push_back( LoadRecentFile() ); + maRecentFiles.back().aTargetURL = aURL; + + sal_Int32 nArgs = aFilterOpt.getLength() ? 4 : 3; + Sequence< PropertyValue >& rArgsList( maRecentFiles.back().aArgSeq ); + rArgsList.realloc( nArgs ); + + nArgs--; + rArgsList[nArgs].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" )); + rArgsList[nArgs].Value = makeAny( aFilter ); + + if( aFilterOpt.getLength() ) + { + nArgs--; + rArgsList[nArgs].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterOptions" )); + rArgsList[nArgs].Value = makeAny( aFilterOpt ); + } + + // documents in the picklist will never be opened as templates + nArgs--; + rArgsList[nArgs].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AsTemplate" )); + rArgsList[nArgs].Value = makeAny( (sal_Bool) sal_False ); + + nArgs--; + rArgsList[nArgs].Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" )); + rArgsList[nArgs].Value = makeAny( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "private:user" ) ) ); + + // and finally create an entry in the popupmenu + rtl::OUString aMenuTitle; + INetURLObject aURLObj( aURL ); + + if ( aURLObj.GetProtocol() == INET_PROT_FILE ) + { + // Do handle file URL differently => convert it to a system + // path and abbreviate it with a special function: + String aFileSystemPath( aURLObj.getFSysPath( INetURLObject::FSYS_DETECT ) ); + + rtl::OUString aSystemPath( aFileSystemPath ); + rtl::OUString aCompactedSystemPath; + + oslFileError nError = osl_abbreviateSystemPath( aSystemPath.pData, &aCompactedSystemPath.pData, 46, NULL ); + if ( !nError ) + aMenuTitle = String( aCompactedSystemPath ); + else + aMenuTitle = aSystemPath; + } + else + { + // Use INetURLObject to abbreviate all other URLs + Reference< XStringWidth > xStringLength( new RecentFilesStringLength() ); + aMenuTitle = aURLObj.getAbbreviated( xStringLength, 46, INetURLObject::DECODE_UNAMBIGUOUS ); + } + rtl::OUStringBuffer aBuf( aMenuTitle.getLength() + 5 ); + if( i < 9 ) + { + aBuf.append( sal_Unicode( '~' ) ); + aBuf.append( i+1 ); + } + else if( i == 9 ) + aBuf.appendAscii( "1~0" ); + else + aBuf.append( i+1 ); + aBuf.appendAscii( ": " ); + aBuf.append( aMenuTitle ); + mpRecentMenu->InsertItem( i+1, aBuf.makeStringAndClear() ); + } + maOpenButton.SetPopupMenu( mpRecentMenu ); + } +} + void BackingWindow::initBackground() { SetBackground( GetSettings().GetStyleSettings().GetWorkspaceGradient() ); @@ -348,6 +480,10 @@ void BackingWindow::initBackground() else mnBtnPos = maBackgroundLeft.GetSizePixel().Width() + 40; } + + maOpenButton.SetMenuMode( MENUBUTTON_MENUMODE_TIMED ); + maOpenButton.SetSelectHdl( LINK( this, BackingWindow, SelectHdl ) ); + prepareRecentFileMenu(); } void BackingWindow::initControls() @@ -534,7 +670,7 @@ void BackingWindow::initControls() Resize(); } -void BackingWindow::loadImage( const ResId& i_rId, ImageButton& i_rButton ) +void BackingWindow::loadImage( const ResId& i_rId, PushButton& i_rButton ) { BitmapEx aBmp( i_rId ); Size aImgSize( aBmp.GetSizePixel() ); @@ -549,7 +685,7 @@ void BackingWindow::layoutButtonAndText( const char* i_pURL, int nColumn, const std::set& i_rURLS, SvtModuleOptions& i_rOpt, SvtModuleOptions::EModule i_eMod, - ImageButton& i_rBtn, FixedText& i_rText, + PushButton& i_rBtn, FixedText& i_rText, MnemonicGenerator& i_rMnemns, const String& i_rStr ) @@ -865,6 +1001,20 @@ IMPL_LINK( BackingWindow, ClickHdl, Button*, pButton ) return 0; } +IMPL_LINK( BackingWindow, SelectHdl, Button*, pButton ) +{ + if( pButton == &maOpenButton ) + { + sal_Int32 nItem = sal_Int32(maOpenButton.GetCurItemId())-1; + if( nItem >= 0 && nItem < sal_Int32(maRecentFiles.size()) ) + { + Reference< XDispatchProvider > xFrame( mxFrame, UNO_QUERY ); + dispatchURL( maRecentFiles[nItem].aTargetURL, rtl::OUString(), xFrame, maRecentFiles[nItem].aArgSeq ); + } + } + return 0; +} + Window* BackingWindow::GetParentLabelFor( const Window* pLabel ) const { const Window* pRet = NULL; diff --git a/framework/source/services/backingwindow.hxx b/framework/source/services/backingwindow.hxx index 7b7dfa34b110..597caefce8ad 100644 --- a/framework/source/services/backingwindow.hxx +++ b/framework/source/services/backingwindow.hxx @@ -31,6 +31,7 @@ #include "rtl/ustring.hxx" #include "vcl/button.hxx" +#include "vcl/menubtn.hxx" #include "vcl/fixed.hxx" #include "vcl/bitmapex.hxx" #include "vcl/toolbox.hxx" @@ -77,6 +78,12 @@ namespace framework class BackingWindow : public Window { + struct LoadRecentFile + { + rtl::OUString aTargetURL; + com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > aArgSeq; + }; + com::sun::star::uno::Reference mxDesktop; com::sun::star::uno::Reference mxDesktopDispatchProvider; com::sun::star::uno::Reference mxFrame; @@ -93,7 +100,7 @@ namespace framework FixedText maImpressText; ImageButton maImpressButton; FixedText maOpenText; - ImageButton maOpenButton; + MenuButton maOpenButton; FixedText maDrawText; ImageButton maDrawButton; FixedText maDBText; @@ -130,6 +137,9 @@ namespace framework svt::AcceleratorExecute* mpAccExec; long mnBtnPos; + PopupMenu* mpRecentMenu; + std::vector< LoadRecentFile > maRecentFiles; + static const int nItemId_Extensions = 1; static const int nItemId_Reg = 2; static const int nItemId_Info = 3; @@ -139,11 +149,11 @@ namespace framework static const int nShadowRight = 45; static const int nShadowBottom = 50; - void loadImage( const ResId& i_rId, ImageButton& i_rButton ); + void loadImage( const ResId& i_rId, PushButton& i_rButton ); void layoutButtonAndText( const char* i_pURL, int nColumn, const std::set& i_rURLS, SvtModuleOptions& i_rOpt, SvtModuleOptions::EModule i_eMod, - ImageButton& i_rBtn, FixedText& i_rText, + PushButton& i_rBtn, FixedText& i_rText, MnemonicGenerator& i_rMnemonicGen, const String& i_rStr = String() ); @@ -155,10 +165,12 @@ namespace framework ); DECL_LINK( ClickHdl, Button* ); + DECL_LINK( SelectHdl, Button* ); DECL_LINK( ToolboxHdl, void* ); void initControls(); void initBackground(); + void prepareRecentFileMenu(); public: BackingWindow( Window* pParent ); ~BackingWindow(); @@ -169,7 +181,7 @@ namespace framework virtual void DataChanged( const DataChangedEvent& rDCEvt ); virtual Window* GetParentLabelFor( const Window* pLabel ) const; virtual Window* GetParentLabeledBy( const Window* pLabeled ) const; - virtual void GetFocus(); + virtual void GetFocus(); void setOwningFrame( const com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame ); }; diff --git a/framework/source/services/fwk_services.src b/framework/source/services/fwk_services.src index 7e2ee3253e71..a615cbd55d73 100644 --- a/framework/source/services/fwk_services.src +++ b/framework/source/services/fwk_services.src @@ -51,7 +51,7 @@ Window DLG_BACKING }; String STR_BACKING_FILE { - Text [ en-US ] = "~Open a document..."; + Text [ en-US ] = "~Open..."; }; Bitmap BMP_BACKING_WRITER { -- cgit From 1573d8facf56516e459d722ef4acf84fb5609f8c Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 30 Apr 2010 12:23:37 +0200 Subject: slidecopy: missing UIELEMENTTYPENAME, detected by smoketest on unxsols4 only (why didn't this crash earlier??) --- framework/source/uiconfiguration/uiconfigurationmanager.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'framework/source') diff --git a/framework/source/uiconfiguration/uiconfigurationmanager.cxx b/framework/source/uiconfiguration/uiconfigurationmanager.cxx index 4adebdd36c47..e704fe680ae9 100644 --- a/framework/source/uiconfiguration/uiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/uiconfigurationmanager.cxx @@ -118,7 +118,8 @@ static const char* UIELEMENTTYPENAMES[] = UIELEMENTTYPE_TOOLBAR_NAME, UIELEMENTTYPE_STATUSBAR_NAME, UIELEMENTTYPE_FLOATINGWINDOW_NAME, - UIELEMENTTYPE_PROGRESSBAR_NAME + UIELEMENTTYPE_PROGRESSBAR_NAME, + UIELEMENTTYPE_TOOLPANEL_NAME }; static const char RESOURCEURL_PREFIX[] = "private:resource/"; -- cgit From 5c3614277d347e72c403135f5c92c0c13fb55d5f Mon Sep 17 00:00:00 2001 From: Christian Lippka Date: Thu, 6 May 2010 14:54:49 +0200 Subject: #i109296# add shortcuts to toolbar items --- framework/source/uielement/toolbarmanager.cxx | 145 +++++++++++++++++++++++++- 1 file changed, 143 insertions(+), 2 deletions(-) (limited to 'framework/source') diff --git a/framework/source/uielement/toolbarmanager.cxx b/framework/source/uielement/toolbarmanager.cxx index 5da7db82c363..25cd6f5ff4c5 100644 --- a/framework/source/uielement/toolbarmanager.cxx +++ b/framework/source/uielement/toolbarmanager.cxx @@ -52,6 +52,7 @@ #endif #include #include +#include //_________________________________________________________________________________________________________________ // interface includes @@ -98,11 +99,14 @@ #include #include #include +#include //_________________________________________________________________________________________________________________ // namespaces //_________________________________________________________________________________________________________________ +using rtl::OUString; + using namespace ::com::sun::star::awt; using namespace ::com::sun::star::beans; using namespace ::com::sun::star::uno; @@ -258,7 +262,8 @@ ToolBarManager::ToolBarManager( const Reference< XMultiServiceFactory >& rServic m_xFrame( rFrame ), m_aListenerContainer( m_aLock.getShareableOslMutex() ), m_xServiceManager( rServiceManager ), - m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() ) + m_nSymbolsStyle( SvtMiscOptions().GetCurrentSymbolsStyle() ), + m_bAcceleratorCfg( sal_False ) { Window* pWindow = m_pToolBar; while ( pWindow && !pWindow->IsSystemWindow() ) @@ -664,6 +669,9 @@ void SAL_CALL ToolBarManager::dispose() throw( RuntimeException ) m_xFrame.clear(); m_xServiceManager.clear(); + m_xGlobalAcceleratorManager.clear(); + m_xModuleAcceleratorManager.clear(); + m_xDocAcceleratorManager.clear(); m_bDisposed = sal_True; } @@ -1262,13 +1270,31 @@ void ToolBarManager::FillToolbar( const Reference< XIndexAccess >& rItemContaine m_pToolBar->InsertItem( nId, aString, nItemBits ); m_pToolBar->SetItemCommand( nId, aCommandURL ); if ( aTooltip.getLength() ) + { m_pToolBar->SetQuickHelpText( nId, aTooltip ); + } else - m_pToolBar->SetQuickHelpText( nId, aString ); + { + ::rtl::OUString sQuickHelp( aString ); + ::rtl::OUString sShortCut; + if( RetrieveShortcut( aCommandURL, sShortCut ) ) + { + sQuickHelp += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( " (" ) ); + sQuickHelp += sShortCut; + sQuickHelp += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ")" ) ); + } + + m_pToolBar->SetQuickHelpText( nId, sQuickHelp ); + } + if ( aLabel.getLength() > 0 ) + { m_pToolBar->SetItemText( nId, aLabel ); + } else + { m_pToolBar->SetItemText( nId, aString ); + } m_pToolBar->EnableItem( nId, sal_True ); m_pToolBar->SetItemState( nId, STATE_NOCHECK ); @@ -2107,6 +2133,121 @@ Image ToolBarManager::QueryAddonsImage( const ::rtl::OUString& aCommandURL, bool return aImage; } +bool ToolBarManager::impl_RetrieveShortcutsFromConfiguration( + const Reference< XAcceleratorConfiguration >& rAccelCfg, + const rtl::OUString& rCommand, + rtl::OUString& rShortCut ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ToolBarManager::impl_RetrieveShortcutsFromConfiguration" ); + if ( rAccelCfg.is() ) + { + try + { + com::sun::star::awt::KeyEvent aKeyEvent; + Sequence< OUString > aCommands(1); + aCommands[0] = rCommand; + + Sequence< Any > aSeqKeyCode( rAccelCfg->getPreferredKeyEventsForCommandList( aCommands ) ); + if( aSeqKeyCode.getLength() == 1 ) + { + if ( aSeqKeyCode[0] >>= aKeyEvent ) + { + rShortCut = svt::AcceleratorExecute::st_AWTKey2VCLKey( aKeyEvent ).GetName(); + return true; + } + } + } + catch ( IllegalArgumentException& ) + { + } + } + + return false; +} + +bool ToolBarManager::RetrieveShortcut( const rtl::OUString& rCommandURL, rtl::OUString& rShortCut ) +{ + RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "framework", "Ocke.Janssen@sun.com", "ToolBarManager::RetrieveShortcuts" ); + if ( m_bModuleIdentified ) + { + Reference< XAcceleratorConfiguration > xDocAccelCfg( m_xDocAcceleratorManager ); + Reference< XAcceleratorConfiguration > xModuleAccelCfg( m_xModuleAcceleratorManager ); + Reference< XAcceleratorConfiguration > xGlobalAccelCfg( m_xGlobalAcceleratorManager ); + + if ( !m_bAcceleratorCfg ) + { + // Retrieve references on demand + m_bAcceleratorCfg = sal_True; + if ( !xDocAccelCfg.is() ) + { + Reference< XController > xController = m_xFrame->getController(); + Reference< XModel > xModel; + if ( xController.is() ) + { + xModel = xController->getModel(); + if ( xModel.is() ) + { + Reference< XUIConfigurationManagerSupplier > xSupplier( xModel, UNO_QUERY ); + if ( xSupplier.is() ) + { + Reference< XUIConfigurationManager > xDocUICfgMgr( xSupplier->getUIConfigurationManager(), UNO_QUERY ); + if ( xDocUICfgMgr.is() ) + { + xDocAccelCfg = Reference< XAcceleratorConfiguration >( xDocUICfgMgr->getShortCutManager(), UNO_QUERY ); + m_xDocAcceleratorManager = xDocAccelCfg; + } + } + } + } + } + + if ( !xModuleAccelCfg.is() ) + { + Reference< XModuleUIConfigurationManagerSupplier > xModuleCfgMgrSupplier( m_xServiceManager->createInstance( + SERVICENAME_MODULEUICONFIGURATIONMANAGERSUPPLIER ), + UNO_QUERY ); + try + { + Reference< XUIConfigurationManager > xUICfgMgr = xModuleCfgMgrSupplier->getUIConfigurationManager( m_aModuleIdentifier ); + if ( xUICfgMgr.is() ) + { + xModuleAccelCfg = Reference< XAcceleratorConfiguration >( xUICfgMgr->getShortCutManager(), UNO_QUERY ); + m_xModuleAcceleratorManager = xModuleAccelCfg; + } + } + catch ( RuntimeException& ) + { + throw; + } + catch ( Exception& ) + { + } + } + + if ( !xGlobalAccelCfg.is() ) + { + xGlobalAccelCfg = Reference< XAcceleratorConfiguration >( m_xServiceManager->createInstance( + SERVICENAME_GLOBALACCELERATORCONFIGURATION ), + UNO_QUERY ); + m_xGlobalAcceleratorManager = xGlobalAccelCfg; + } + } + + bool bFound = false; + + if ( m_xGlobalAcceleratorManager.is() ) + bFound = impl_RetrieveShortcutsFromConfiguration( xGlobalAccelCfg, rCommandURL, rShortCut ); + if ( !bFound && m_xModuleAcceleratorManager.is() ) + bFound = impl_RetrieveShortcutsFromConfiguration( xModuleAccelCfg, rCommandURL, rShortCut ); + if ( !bFound && m_xDocAcceleratorManager.is() ) + impl_RetrieveShortcutsFromConfiguration( xGlobalAccelCfg, rCommandURL, rShortCut ); + + if( bFound ) + return true; + } + return false; +} + } -- cgit From 0434aa5708d99334f445b894c48b7650732cc2cb Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 7 May 2010 10:19:42 +0200 Subject: slidecopy: allow activating a tool panel view XLayoutManager::showElement --- framework/source/classes/sfxhelperfunctions.cxx | 23 +++++++++++++++++++++++ framework/source/layoutmanager/layoutmanager.cxx | 8 ++++++++ 2 files changed, 31 insertions(+) (limited to 'framework/source') diff --git a/framework/source/classes/sfxhelperfunctions.cxx b/framework/source/classes/sfxhelperfunctions.cxx index 655d96cdb681..c6953b1ea2b9 100644 --- a/framework/source/classes/sfxhelperfunctions.cxx +++ b/framework/source/classes/sfxhelperfunctions.cxx @@ -32,11 +32,14 @@ #include #endif +#include + static pfunc_setToolBoxControllerCreator pToolBoxControllerCreator = NULL; static pfunc_setStatusBarControllerCreator pStatusBarControllerCreator = NULL; static pfunc_getRefreshToolbars pRefreshToolbars = NULL; static pfunc_createDockingWindow pCreateDockingWindow = NULL; static pfunc_isDockingWindowVisible pIsDockingWindowVisible = NULL; +static pfunc_activateToolPanel pActivateToolPanel = NULL; @@ -155,4 +158,24 @@ bool SAL_CALL IsDockingWindowVisible( const ::com::sun::star::uno::Reference< :: return false; } +pfunc_activateToolPanel SAL_CALL SetActivateToolPanel( pfunc_activateToolPanel i_pActivator ) +{ + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pfunc_activateToolPanel pOldFunc = pActivateToolPanel; + pActivateToolPanel = i_pActivator; + return pOldFunc; +} + +void SAL_CALL ActivateToolPanel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& i_rFrame, const ::rtl::OUString& i_rPanelURL ) +{ + pfunc_activateToolPanel pActivator = NULL; + { + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + pActivator = pActivateToolPanel; + } + + ENSURE_OR_RETURN_VOID( pActivator, "framework::ActivateToolPanel: no activator function!" ); + (*pActivator)( i_rFrame, i_rPanelURL ); +} + } diff --git a/framework/source/layoutmanager/layoutmanager.cxx b/framework/source/layoutmanager/layoutmanager.cxx index 458368bd6581..f72759891acb 100644 --- a/framework/source/layoutmanager/layoutmanager.cxx +++ b/framework/source/layoutmanager/layoutmanager.cxx @@ -4707,6 +4707,14 @@ throw (RuntimeException) impl_setDockingWindowVisibility( xSMGR, xFrame, aElementName, true ); } + else if ( aElementType.equalsIgnoreAsciiCaseAscii( "toolpanel" )) + { + ReadGuard aReadGuard( m_aLock ); + css::uno::Reference< css::frame::XFrame > xFrame( m_xFrame ); + aReadGuard.unlock(); + + ActivateToolPanel( m_xFrame, aName ); + } } if ( bNotify ) -- cgit From b5054d32e6238b8f335f36f794604030a0ac1080 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Mon, 17 May 2010 10:08:23 +0200 Subject: fwk139: Check popup menu pointer --- framework/source/uielement/macrosmenucontroller.cxx | 3 +++ 1 file changed, 3 insertions(+) (limited to 'framework/source') diff --git a/framework/source/uielement/macrosmenucontroller.cxx b/framework/source/uielement/macrosmenucontroller.cxx index f0f5d52a47d6..9bb0f2cf9f90 100644 --- a/framework/source/uielement/macrosmenucontroller.cxx +++ b/framework/source/uielement/macrosmenucontroller.cxx @@ -92,6 +92,9 @@ void MacrosMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPo if ( pVCLPopupMenu ) pPopupMenu = (PopupMenu *)pVCLPopupMenu->GetMenu(); + if (!pPopupMenu) + return; + // insert basic String aCommand = String::CreateFromAscii( ".uno:MacroDialog" ); String aDisplayName = RetrieveLabelFromCommand( aCommand ); -- cgit From 7b822aa1a80c6adc847495c584ddde1f88f20072 Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 20 May 2010 11:00:14 +0200 Subject: fwk139: #i105546# Remove unused MenuManager ctor --- framework/source/classes/menumanager.cxx | 2 ++ 1 file changed, 2 insertions(+) (limited to 'framework/source') diff --git a/framework/source/classes/menumanager.cxx b/framework/source/classes/menumanager.cxx index 0b2f30093ca8..61cb8eb4a253 100644 --- a/framework/source/classes/menumanager.cxx +++ b/framework/source/classes/menumanager.cxx @@ -357,6 +357,7 @@ MenuManager::MenuManager( SetHdl(); } +#if 0 // #110897# MenuManager::MenuManager( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, @@ -413,6 +414,7 @@ MenuManager::MenuManager( SetHdl(); } +#endif void MenuManager::SetHdl() { -- cgit From 97e96b230c86d10cb31793d3737c7d1d97041dfb Mon Sep 17 00:00:00 2001 From: Carsten Driesner Date: Thu, 27 May 2010 17:52:15 +0200 Subject: uimigration01: #i101513# Migration of user settings necessary --- framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'framework/source') diff --git a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx index 8840aee6a634..684e62d45377 100644 --- a/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx +++ b/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx @@ -292,11 +292,12 @@ void ModuleUIConfigurationManager::impl_preloadUIElementTypeList( Layer eLayer, rHashMap.insert( UIElementDataHashMap::value_type( aUIElementData.aResourceURL, aUIElementData )); } } + rElementTypeData.bLoaded = true; } } } - rElementTypeData.bLoaded = true; + //rElementTypeData.bLoaded = true; } void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData ) -- cgit From 95bd2079a501ba3083e150b2d42afe07bed31883 Mon Sep 17 00:00:00 2001 From: "Philipp Lohmann [pl]" Date: Mon, 31 May 2010 13:57:10 +0200 Subject: solve ambiguity between ::Color and com::sun::star::util::Color --- framework/source/services/backingwindow.cxx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'framework/source') diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index f39426190b27..19afbc29d843 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -65,7 +65,6 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::frame; -using namespace ::com::sun::star::util; using namespace ::com::sun::star::uno; using namespace ::com::sun::star; using namespace framework; @@ -372,7 +371,7 @@ void BackingWindow::prepareRecentFileMenu() else { // Use INetURLObject to abbreviate all other URLs - Reference< XStringWidth > xStringLength( new RecentFilesStringLength() ); + Reference< util::XStringWidth > xStringLength( new RecentFilesStringLength() ); aMenuTitle = aURLObj.getAbbreviated( xStringLength, 46, INetURLObject::DECODE_UNAMBIGUOUS ); } rtl::OUStringBuffer aBuf( aMenuTitle.getLength() + 5 ); -- cgit From 2ff2cdeb55a0a7a66b26d78eda8f8632d043ed1c Mon Sep 17 00:00:00 2001 From: hdu Date: Mon, 7 Jun 2010 09:49:07 +0200 Subject: #100000# WaE: avoid compiler warning on wntmsci12 --- framework/source/services/backingwindow.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'framework/source') diff --git a/framework/source/services/backingwindow.cxx b/framework/source/services/backingwindow.cxx index 19afbc29d843..1db8e7c9bf05 100644 --- a/framework/source/services/backingwindow.cxx +++ b/framework/source/services/backingwindow.cxx @@ -386,7 +386,7 @@ void BackingWindow::prepareRecentFileMenu() aBuf.append( i+1 ); aBuf.appendAscii( ": " ); aBuf.append( aMenuTitle ); - mpRecentMenu->InsertItem( i+1, aBuf.makeStringAndClear() ); + mpRecentMenu->InsertItem( static_cast(i+1), aBuf.makeStringAndClear() ); } maOpenButton.SetPopupMenu( mpRecentMenu ); } -- cgit From 634bd66a83cffb00d41d434e77c80eef06a0c813 Mon Sep 17 00:00:00 2001 From: obo Date: Fri, 11 Jun 2010 08:13:02 +0200 Subject: masterfix: #i10000# bNothingSelected obsolete --- framework/source/uielement/langselectionstatusbarcontroller.cxx | 1 - 1 file changed, 1 deletion(-) (limited to 'framework/source') diff --git a/framework/source/uielement/langselectionstatusbarcontroller.cxx b/framework/source/uielement/langselectionstatusbarcontroller.cxx index e84ca9e4f09d..021ee4e8f8df 100644 --- a/framework/source/uielement/langselectionstatusbarcontroller.cxx +++ b/framework/source/uielement/langselectionstatusbarcontroller.cxx @@ -227,7 +227,6 @@ throw (::com::sun::star::uno::RuntimeException) { //make a sign for the current language xPopupMenu->checkItem( nItemId, TRUE ); - bNothingSelected = false; } aLangMap[ nItemId ] = rStr; ++nItemId; -- cgit