framework/source/uielement/recentfilesmenucontroller.cxx | 91 ++------------- 1 file changed, 13 insertions(+), 78 deletions(-)
New commits: commit 01be56c648ba615fed45ca6b8492714cbff65863 Author: Maxim Monastirsky <momonas...@gmail.com> Date: Thu Nov 10 02:35:06 2016 +0200 Type detection can handle empty doc service just fine But actually I can't imagine why the doc service could be empty here, esp. since 8655fa318c1924994eb659b4bb60074c86ad70c1 ("Fix property name: ModuleName -> ModuleIdentifier"). Change-Id: I9a39cf0840910069769b4bedd61930aab2155e1b diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index da721d2..0c7425b 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -250,8 +250,7 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) if (( nIndex >= 0 ) && ( nIndex < sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() ))) { - sal_Int32 nSize = 2; - Sequence< PropertyValue > aArgsList(nSize); + Sequence< PropertyValue > aArgsList(3); aArgsList[0].Name = "Referer"; aArgsList[0].Value = makeAny( OUString( "private:user" ) ); @@ -259,13 +258,9 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) aArgsList[1].Name = "AsTemplate"; aArgsList[1].Value = makeAny( false ); - if (!m_aModuleName.isEmpty()) - { - // Type detection needs to know which app we are opening it from. - aArgsList.realloc(++nSize); - aArgsList[nSize-1].Name = "DocumentService"; - aArgsList[nSize-1].Value <<= m_aModuleName; - } + // Type detection needs to know which app we are opening it from. + aArgsList[2].Name = "DocumentService"; + aArgsList[2].Value <<= m_aModuleName; dispatchCommand( m_aRecentFilesItems[ nIndex ], aArgsList, "_default" ); } commit 2a778b4a4db25cc383e765be4c12b9e47b925d5b Author: Maxim Monastirsky <momonas...@gmail.com> Date: Thu Nov 10 02:10:00 2016 +0200 RecentFile::aTitle is never read Change-Id: Ic9f613f10914113af62fe6876e1a837a610a5782 diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index e490821..da721d2 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -93,16 +93,10 @@ public: private: virtual void impl_setPopupMenu() override; - struct RecentFile - { - OUString aURL; - OUString aTitle; - }; - void fillPopupMenu( css::uno::Reference< css::awt::XPopupMenu >& rPopupMenu ); void executeEntry( sal_Int32 nIndex ); - std::vector< RecentFile > m_aRecentFilesItems; + std::vector< OUString > m_aRecentFilesItems; bool m_bDisabled : 1; bool m_bShowToolbarEntries; }; @@ -152,19 +146,18 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > for ( int i = 0; i < nPickListMenuItems; i++ ) { Sequence< PropertyValue >& rPickListEntry = aHistoryList[i]; - RecentFile aRecentFile; + OUString aURL; for ( int j = 0; j < rPickListEntry.getLength(); j++ ) { - Any a = rPickListEntry[j].Value; - if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_URL ) - a >>= aRecentFile.aURL; - else if ( rPickListEntry[j].Name == HISTORY_PROPERTYNAME_TITLE ) - a >>= aRecentFile.aTitle; + { + rPickListEntry[j].Value >>= aURL; + break; + } } - m_aRecentFilesItems.push_back( aRecentFile ); + m_aRecentFilesItems.push_back( aURL ); } } @@ -195,7 +188,7 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > // Abbreviate URL OUString aMenuTitle; - INetURLObject aURL( m_aRecentFilesItems[i].aURL ); + INetURLObject aURL( m_aRecentFilesItems[i] ); OUString aTipHelpText( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) ); if ( aURL.GetProtocol() == INetProtocol::File ) @@ -257,8 +250,6 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) if (( nIndex >= 0 ) && ( nIndex < sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() ))) { - const RecentFile& rRecentFile = m_aRecentFilesItems[ nIndex ]; - sal_Int32 nSize = 2; Sequence< PropertyValue > aArgsList(nSize); aArgsList[0].Name = "Referer"; @@ -276,7 +267,7 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) aArgsList[nSize-1].Value <<= m_aModuleName; } - dispatchCommand( rRecentFile.aURL, aArgsList, "_default" ); + dispatchCommand( m_aRecentFilesItems[ nIndex ], aArgsList, "_default" ); } } commit ecdb04638c70f4063d146cf9df6d8adb5c91f78f Author: Maxim Monastirsky <momonas...@gmail.com> Date: Thu Nov 10 01:58:20 2016 +0200 RecentFilesMenuController: Remove duplicate dispatch handling Change-Id: I3f2729bfe82c059bbf934510cb4066a77867f3c8 diff --git a/framework/source/uielement/recentfilesmenucontroller.cxx b/framework/source/uielement/recentfilesmenucontroller.cxx index 2786f3c..e490821 100644 --- a/framework/source/uielement/recentfilesmenucontroller.cxx +++ b/framework/source/uielement/recentfilesmenucontroller.cxx @@ -47,13 +47,6 @@ static const char CMD_CLEAR_LIST[] = ".uno:ClearRecentFileList"; static const char CMD_OPEN_AS_TEMPLATE[] = ".uno:OpenTemplate"; static const char CMD_OPEN_REMOTE[] = ".uno:OpenRemote"; -struct LoadRecentFile -{ - util::URL aTargetURL; - uno::Sequence< beans::PropertyValue > aArgSeq; - uno::Reference< frame::XDispatch > xDispatch; -}; - class RecentFilesMenuController : public svt::PopupMenuControllerBase { using svt::PopupMenuControllerBase::disposing; @@ -98,8 +91,6 @@ public: // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) throw ( uno::RuntimeException, std::exception ) override; - DECL_STATIC_LINK( RecentFilesMenuController, ExecuteHdl_Impl, void*, void ); - private: virtual void impl_setPopupMenu() override; struct RecentFile @@ -263,25 +254,13 @@ void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu > void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) { - Reference< XDispatch > xDispatch; - Reference< XDispatchProvider > xDispatchProvider; - css::util::URL aTargetURL; - Sequence< PropertyValue > aArgsList; - - osl::ClearableMutexGuard aLock( m_aMutex ); - xDispatchProvider.set( m_xFrame, UNO_QUERY ); - aLock.clear(); - if (( nIndex >= 0 ) && ( nIndex < sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() ))) { const RecentFile& rRecentFile = m_aRecentFilesItems[ nIndex ]; - aTargetURL.Complete = rRecentFile.aURL; - m_xURLTransformer->parseStrict( aTargetURL ); - sal_Int32 nSize = 2; - aArgsList.realloc( nSize ); + Sequence< PropertyValue > aArgsList(nSize); aArgsList[0].Name = "Referer"; aArgsList[0].Value = makeAny( OUString( "private:user" ) ); @@ -297,20 +276,7 @@ void RecentFilesMenuController::executeEntry( sal_Int32 nIndex ) aArgsList[nSize-1].Value <<= m_aModuleName; } - xDispatch = xDispatchProvider->queryDispatch( aTargetURL, "_default", 0 ); - } - - if ( xDispatch.is() ) - { - // Call dispatch asynchronously as we can be destroyed while dispatch is - // executed. VCL is not able to survive this as it wants to call listeners - // after select!!! - LoadRecentFile* pLoadRecentFile = new LoadRecentFile; - pLoadRecentFile->xDispatch = xDispatch; - pLoadRecentFile->aTargetURL = aTargetURL; - pLoadRecentFile->aArgSeq = aArgsList; - - Application::PostUserEvent( LINK(nullptr, RecentFilesMenuController, ExecuteHdl_Impl), pLoadRecentFile ); + dispatchCommand( rRecentFile.aURL, aArgsList, "_default" ); } } @@ -437,23 +403,6 @@ throw( RuntimeException, std::exception ) } } -IMPL_STATIC_LINK( RecentFilesMenuController, ExecuteHdl_Impl, void*, p, void ) -{ - LoadRecentFile* pLoadRecentFile = static_cast<LoadRecentFile*>(p); - try - { - // Asynchronous execution as this can lead to our own destruction! - // Framework can recycle our current frame and the layout manager disposes all user interface - // elements if a component gets detached from its frame! - pLoadRecentFile->xDispatch->dispatch( pLoadRecentFile->aTargetURL, pLoadRecentFile->aArgSeq ); - } - catch ( const Exception& ) - { - } - - delete pLoadRecentFile; -} - } extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits