recentfilesmenucontroller.cxx (6d739b60) recentfilesmenucontroller.cxx (6d5620bc)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 9 unchanged lines hidden (view full) ---

18 * under the License.
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_framework.hxx"
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 9 unchanged lines hidden (view full) ---

18 * under the License.
19 *
20 *************************************************************/
21
22
23
24// MARKER(update_precomp.py): autogen include statement, do not remove
25#include "precompiled_framework.hxx"
26#include <uielement/recentfilesmenucontroller.hxx>
27
26
28//_________________________________________________________________________________________________________________
29// my own includes
30//_________________________________________________________________________________________________________________
27#include <uielement/recentfilesmenucontroller.hxx>
31#include <threadhelp/resetableguard.hxx>
28#include <threadhelp/resetableguard.hxx>
32#include "services.h"
33
34#ifndef __FRAMEWORK_CLASSES_RESOURCE_HRC_
35#include <classes/resource.hrc>
29#include <classes/resource.hrc>
36#endif
37#include <classes/fwkresid.hxx>
38
30#include <classes/fwkresid.hxx>
31
39//_________________________________________________________________________________________________________________
40// interface includes
41//_________________________________________________________________________________________________________________
42#include <com/sun/star/awt/XDevice.hpp>
43#include <com/sun/star/beans/PropertyValue.hpp>
44#include <com/sun/star/awt/MenuItemStyle.hpp>
45#include <com/sun/star/util/XStringWidth.hpp>
32#include <com/sun/star/util/XStringWidth.hpp>
46//_________________________________________________________________________________________________________________
47// includes of other projects
48//_________________________________________________________________________________________________________________
49
33
50#ifndef _VCL_MENU_HXX_
51#include <vcl/menu.hxx>
52#endif
53#include <vcl/svapp.hxx>
54#include <vcl/i18nhelp.hxx>
55#include <tools/urlobj.hxx>
56#include <rtl/ustrbuf.hxx>
57#include <unotools/historyoptions.hxx>
58#include <cppuhelper/implbase1.hxx>
34#include <cppuhelper/implbase1.hxx>
59#include <osl/file.hxx>
60//#include <tools/solar.hrc>
61#include <dispatch/uieventloghelper.hxx>
35#include <dispatch/uieventloghelper.hxx>
36#include <osl/file.hxx>
37#include <tools/urlobj.hxx>
38#include <unotools/historyoptions.hxx>
39#include <vcl/menu.hxx>
40#include <vcl/svapp.hxx>
62#include <vos/mutex.hxx>
63
41#include <vos/mutex.hxx>
42
64//_________________________________________________________________________________________________________________
65// Defines
66//_________________________________________________________________________________________________________________
67//
68
69using namespace com::sun::star::uno;
70using namespace com::sun::star::lang;
71using namespace com::sun::star::frame;
72using namespace com::sun::star::beans;
73using namespace com::sun::star::util;
43using namespace com::sun::star::uno;
44using namespace com::sun::star::lang;
45using namespace com::sun::star::frame;
46using namespace com::sun::star::beans;
47using namespace com::sun::star::util;
74using namespace com::sun::star::container;
75
48
49#define MAX_STR_WIDTH 46
50#define MAX_MENU_ITEMS 99
51
76static const char SFX_REFERER_USER[] = "private:user";
52static const char SFX_REFERER_USER[] = "private:user";
53static const char CMD_CLEAR_LIST[] = ".uno:ClearRecentFileList";
54static const char CMD_PREFIX[] = "vnd.sun.star.popup:RecentFileList?entry=";
55static const char MENU_SHOTCUT[] = "~N: ";
77
78namespace framework
79{
80
81class RecentFilesStringLength : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XStringWidth >
82{
83 public:
84 RecentFilesStringLength() {}

--- 23 unchanged lines hidden (view full) ---

108
109RecentFilesMenuController::~RecentFilesMenuController()
110{
111}
112
113// private function
114void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu )
115{
56
57namespace framework
58{
59
60class RecentFilesStringLength : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XStringWidth >
61{
62 public:
63 RecentFilesStringLength() {}

--- 23 unchanged lines hidden (view full) ---

87
88RecentFilesMenuController::~RecentFilesMenuController()
89{
90}
91
92// private function
93void RecentFilesMenuController::fillPopupMenu( Reference< css::awt::XPopupMenu >& rPopupMenu )
94{
116 VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu );
117 PopupMenu* pVCLPopupMenu = 0;
95 VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXMenu::GetImplementation( rPopupMenu );
96 PopupMenu* pVCLPopupMenu = 0;
118
119 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
120
121 resetPopupMenu( rPopupMenu );
122 if ( pPopupMenu )
123 pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
124
125 if ( pVCLPopupMenu )
126 {
127 Sequence< Sequence< PropertyValue > > aHistoryList = SvtHistoryOptions().GetList( ePICKLIST );
128 Reference< XStringWidth > xStringLength( new RecentFilesStringLength );
129
97
98 vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() );
99
100 resetPopupMenu( rPopupMenu );
101 if ( pPopupMenu )
102 pVCLPopupMenu = (PopupMenu *)pPopupMenu->GetMenu();
103
104 if ( pVCLPopupMenu )
105 {
106 Sequence< Sequence< PropertyValue > > aHistoryList = SvtHistoryOptions().GetList( ePICKLIST );
107 Reference< XStringWidth > xStringLength( new RecentFilesStringLength );
108
130 int nPickListMenuItems = ( aHistoryList.getLength() > 99 ) ? 99 : aHistoryList.getLength();
109 int nPickListMenuItems = ( aHistoryList.getLength() > MAX_MENU_ITEMS ) ? MAX_MENU_ITEMS : aHistoryList.getLength();
131
110
132 // New vnd.sun.star.popup: command URL to support direct dispatches
133 const rtl::OUString aCmdPrefix( RTL_CONSTASCII_USTRINGPARAM( "vnd.sun.star.popup:RecentFileList?entry=" ));
134
135 m_aRecentFilesItems.clear();
136 if (( nPickListMenuItems > 0 ) && !m_bDisabled )
137 {
138 for ( int i = 0; i < nPickListMenuItems; i++ )
139 {
140 Sequence< PropertyValue >& rPickListEntry = aHistoryList[i];
141 RecentFile aRecentFile;
142

--- 12 unchanged lines hidden (view full) ---

155 }
156
157 m_aRecentFilesItems.push_back( aRecentFile );
158 }
159 }
160
161 if ( !m_aRecentFilesItems.empty() )
162 {
111 m_aRecentFilesItems.clear();
112 if (( nPickListMenuItems > 0 ) && !m_bDisabled )
113 {
114 for ( int i = 0; i < nPickListMenuItems; i++ )
115 {
116 Sequence< PropertyValue >& rPickListEntry = aHistoryList[i];
117 RecentFile aRecentFile;
118

--- 12 unchanged lines hidden (view full) ---

131 }
132
133 m_aRecentFilesItems.push_back( aRecentFile );
134 }
135 }
136
137 if ( !m_aRecentFilesItems.empty() )
138 {
163 URL aTargetURL;
164
165 const sal_uInt32 nCount = m_aRecentFilesItems.size();
166 for ( sal_uInt32 i = 0; i < nCount; i++ )
167 {
139 const sal_uInt32 nCount = m_aRecentFilesItems.size();
140 for ( sal_uInt32 i = 0; i < nCount; i++ )
141 {
168 char menuShortCut[5] = "~n: ";
169
170 ::rtl::OUString aMenuShortCut;
142 rtl::OUStringBuffer aMenuShortCut;
171 if ( i <= 9 )
172 {
173 if ( i == 9 )
143 if ( i <= 9 )
144 {
145 if ( i == 9 )
174 aMenuShortCut = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "1~0: " ));
146 aMenuShortCut.appendAscii( RTL_CONSTASCII_STRINGPARAM( "1~0: " ) );
175 else
176 {
147 else
148 {
177 menuShortCut[1] = (char)( '1' + i );
178 aMenuShortCut = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( menuShortCut ));
149 aMenuShortCut.appendAscii( RTL_CONSTASCII_STRINGPARAM( MENU_SHOTCUT ) );
150 aMenuShortCut.setCharAt( 1, sal_Unicode( i + '1' ) );
179 }
180 }
181 else
182 {
151 }
152 }
153 else
154 {
183 aMenuShortCut = rtl::OUString::valueOf((sal_Int32)( i + 1 ));
184 aMenuShortCut += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ": " ));
155 aMenuShortCut.append( sal_Int32( i + 1 ) );
156 aMenuShortCut.appendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
185 }
186
157 }
158
159 rtl::OUStringBuffer aStrBuffer;
160 aStrBuffer.appendAscii( RTL_CONSTASCII_STRINGPARAM( CMD_PREFIX ) );
161 aStrBuffer.append( sal_Int32( i ) );
162 rtl::OUString aURLString( aStrBuffer.makeStringAndClear() );
163
187 // Abbreviate URL
164 // Abbreviate URL
188 rtl::OUString aURLString( aCmdPrefix + rtl::OUString::valueOf( sal_Int32( i )));
189 rtl::OUString aTipHelpText;
190 rtl::OUString aMenuTitle;
191 INetURLObject aURL( m_aRecentFilesItems[i].aURL );
192
193 if ( aURL.GetProtocol() == INET_PROT_FILE )
194 {
195 // Do handle file URL differently => convert it to a system
196 // path and abbreviate it with a special function:
165 rtl::OUString aTipHelpText;
166 rtl::OUString aMenuTitle;
167 INetURLObject aURL( m_aRecentFilesItems[i].aURL );
168
169 if ( aURL.GetProtocol() == INET_PROT_FILE )
170 {
171 // Do handle file URL differently => convert it to a system
172 // path and abbreviate it with a special function:
197 String aFileSystemPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
173 rtl::OUString aSystemPath( aURL.getFSysPath( INetURLObject::FSYS_DETECT ) );
174 aTipHelpText = aSystemPath;
198
175
199 ::rtl::OUString aSystemPath( aFileSystemPath );
200 ::rtl::OUString aCompactedSystemPath;
176 ::rtl::OUString aCompactedSystemPath;
201
202 aTipHelpText = aSystemPath;
203 oslFileError nError = osl_abbreviateSystemPath( aSystemPath.pData, &aCompactedSystemPath.pData, 46, NULL );
204 if ( !nError )
205 aMenuTitle = String( aCompactedSystemPath );
177 if ( osl_abbreviateSystemPath( aSystemPath.pData, &aCompactedSystemPath.pData, MAX_STR_WIDTH, NULL ) == osl_File_E_None )
178 aMenuTitle = aCompactedSystemPath;
206 else
207 aMenuTitle = aSystemPath;
208 }
209 else
210 {
211 // Use INetURLObject to abbreviate all other URLs
179 else
180 aMenuTitle = aSystemPath;
181 }
182 else
183 {
184 // Use INetURLObject to abbreviate all other URLs
212 String aShortURL;
213 aShortURL = aURL.getAbbreviated( xStringLength, 46, INetURLObject::DECODE_UNAMBIGUOUS );
214 aMenuTitle += aShortURL;
185 aMenuTitle = aURL.getAbbreviated( xStringLength, MAX_STR_WIDTH, INetURLObject::DECODE_UNAMBIGUOUS );
215 aTipHelpText = aURLString;
216 }
217
186 aTipHelpText = aURLString;
187 }
188
218 ::rtl::OUString aTitle( aMenuShortCut + aMenuTitle );
189 aMenuShortCut.append( aMenuTitle );
219
190
220 pVCLPopupMenu->InsertItem( sal_uInt16( i+1 ), aTitle );
191 pVCLPopupMenu->InsertItem( sal_uInt16( i+1 ), aMenuShortCut.makeStringAndClear() );
221 pVCLPopupMenu->SetTipHelpText( sal_uInt16( i+1 ), aTipHelpText );
222 pVCLPopupMenu->SetItemCommand( sal_uInt16( i+1 ), aURLString );
223 }
192 pVCLPopupMenu->SetTipHelpText( sal_uInt16( i+1 ), aTipHelpText );
193 pVCLPopupMenu->SetItemCommand( sal_uInt16( i+1 ), aURLString );
194 }
195
196 pVCLPopupMenu->InsertSeparator();
197 // Clear List menu entry
198 pVCLPopupMenu->InsertItem( sal_uInt16( nCount + 1 ),
199 String( FwkResId( STR_CLEAR_RECENT_FILES ) ) );
200 pVCLPopupMenu->SetItemCommand( sal_uInt16( nCount + 1 ),
201 rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CMD_CLEAR_LIST ) ) );
202 pVCLPopupMenu->SetHelpText( sal_uInt16( nCount + 1 ),
203 String( FwkResId( STR_CLEAR_RECENT_FILES_HELP ) ) );
224 }
225 else
226 {
227 // No recent documents => insert "no document" string
204 }
205 else
206 {
207 // No recent documents => insert "no document" string
228 String aNoDocumentStr = String( FwkResId( STR_NODOCUMENT ));
229 pVCLPopupMenu->InsertItem( 1, aNoDocumentStr );
208 pVCLPopupMenu->InsertItem( 1, String( FwkResId( STR_NODOCUMENT ) ) );
230 pVCLPopupMenu->EnableItem( 1, sal_False );
231 }
232 }
233}
234
235void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
236{
237 static int NUM_OF_PICKLIST_ARGS = 3;
238
209 pVCLPopupMenu->EnableItem( 1, sal_False );
210 }
211 }
212}
213
214void RecentFilesMenuController::executeEntry( sal_Int32 nIndex )
215{
216 static int NUM_OF_PICKLIST_ARGS = 3;
217
239 Reference< css::awt::XPopupMenu > xPopupMenu;
240 Reference< XDispatch > xDispatch;
241 Reference< XDispatchProvider > xDispatchProvider;
218 Reference< XDispatch > xDispatch;
219 Reference< XDispatchProvider > xDispatchProvider;
242 Reference< XMultiServiceFactory > xServiceManager;
220 css::util::URL aTargetURL;
221 Sequence< PropertyValue > aArgsList;
243
244 osl::ClearableMutexGuard aLock( m_aMutex );
222
223 osl::ClearableMutexGuard aLock( m_aMutex );
245 xPopupMenu = m_xPopupMenu;
246 xDispatchProvider = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY );
247 xServiceManager = m_xServiceManager;
224 xDispatchProvider = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY );
248 aLock.clear();
249
225 aLock.clear();
226
250 css::util::URL aTargetURL;
251 Sequence< PropertyValue > aArgsList;
252
253 if (( nIndex >= 0 ) &&
254 ( nIndex < sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() )))
255 {
256 const RecentFile& rRecentFile = m_aRecentFilesItems[ nIndex ];
257
258 aTargetURL.Complete = rRecentFile.aURL;
259 m_xURLTransformer->parseStrict( aTargetURL );
260
261 aArgsList.realloc( NUM_OF_PICKLIST_ARGS );
262 aArgsList[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" ));
227 if (( nIndex >= 0 ) &&
228 ( nIndex < sal::static_int_cast<sal_Int32>( m_aRecentFilesItems.size() )))
229 {
230 const RecentFile& rRecentFile = m_aRecentFilesItems[ nIndex ];
231
232 aTargetURL.Complete = rRecentFile.aURL;
233 m_xURLTransformer->parseStrict( aTargetURL );
234
235 aArgsList.realloc( NUM_OF_PICKLIST_ARGS );
236 aArgsList[0].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Referer" ));
263 aArgsList[0].Value = makeAny( ::rtl::OUString::createFromAscii( SFX_REFERER_USER ));
237 aArgsList[0].Value = makeAny( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( SFX_REFERER_USER )));
264
265 // documents in the picklist will never be opened as templates
266 aArgsList[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AsTemplate" ));
267 aArgsList[1].Value = makeAny( (sal_Bool) sal_False );
268
269 ::rtl::OUString aFilter( rRecentFile.aFilter );
270 sal_Int32 nPos = aFilter.indexOf( '|' );
271 if ( nPos >= 0 )

--- 8 unchanged lines hidden (view full) ---

280
281 aFilter = aFilter.copy( 0, nPos-1 );
282 aArgsList.realloc( ++NUM_OF_PICKLIST_ARGS );
283 }
284
285 aArgsList[NUM_OF_PICKLIST_ARGS-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ));
286 aArgsList[NUM_OF_PICKLIST_ARGS-1].Value <<= aFilter;
287
238
239 // documents in the picklist will never be opened as templates
240 aArgsList[1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AsTemplate" ));
241 aArgsList[1].Value = makeAny( (sal_Bool) sal_False );
242
243 ::rtl::OUString aFilter( rRecentFile.aFilter );
244 sal_Int32 nPos = aFilter.indexOf( '|' );
245 if ( nPos >= 0 )

--- 8 unchanged lines hidden (view full) ---

254
255 aFilter = aFilter.copy( 0, nPos-1 );
256 aArgsList.realloc( ++NUM_OF_PICKLIST_ARGS );
257 }
258
259 aArgsList[NUM_OF_PICKLIST_ARGS-1].Name = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "FilterName" ));
260 aArgsList[NUM_OF_PICKLIST_ARGS-1].Value <<= aFilter;
261
288 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString::createFromAscii("_default"), 0 );
262 xDispatch = xDispatchProvider->queryDispatch( aTargetURL, ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "_default" ) ), 0 );
289 }
290
291 if ( xDispatch.is() )
292 {
293 // Call dispatch asychronously as we can be destroyed while dispatch is
294 // executed. VCL is not able to survive this as it wants to call listeners
295 // after select!!!
296 LoadRecentFile* pLoadRecentFile = new LoadRecentFile;
297 pLoadRecentFile->xDispatch = xDispatch;
298 pLoadRecentFile->aTargetURL = aTargetURL;
299 pLoadRecentFile->aArgSeq = aArgsList;
263 }
264
265 if ( xDispatch.is() )
266 {
267 // Call dispatch asychronously as we can be destroyed while dispatch is
268 // executed. VCL is not able to survive this as it wants to call listeners
269 // after select!!!
270 LoadRecentFile* pLoadRecentFile = new LoadRecentFile;
271 pLoadRecentFile->xDispatch = xDispatch;
272 pLoadRecentFile->aTargetURL = aTargetURL;
273 pLoadRecentFile->aArgSeq = aArgsList;
274
300 if(::comphelper::UiEventsLogger::isEnabled()) //#i88653#
275 if(::comphelper::UiEventsLogger::isEnabled()) //#i88653#
301 UiEventLogHelper(::rtl::OUString::createFromAscii("RecentFilesMenuController")).log(m_xServiceManager, m_xFrame, aTargetURL, aArgsList);
276 UiEventLogHelper(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("RecentFilesMenuController"))).log(m_xServiceManager, m_xFrame, aTargetURL, aArgsList);
277
302 Application::PostUserEvent( STATIC_LINK(0, RecentFilesMenuController, ExecuteHdl_Impl), pLoadRecentFile );
303 }
304}
305
306// XEventListener
307void SAL_CALL RecentFilesMenuController::disposing( const EventObject& ) throw ( RuntimeException )
308{
309 Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY );

--- 12 unchanged lines hidden (view full) ---

322void SAL_CALL RecentFilesMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException )
323{
324 osl::MutexGuard aLock( m_aMutex );
325 m_bDisabled = !Event.IsEnabled;
326}
327
328void SAL_CALL RecentFilesMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException)
329{
278 Application::PostUserEvent( STATIC_LINK(0, RecentFilesMenuController, ExecuteHdl_Impl), pLoadRecentFile );
279 }
280}
281
282// XEventListener
283void SAL_CALL RecentFilesMenuController::disposing( const EventObject& ) throw ( RuntimeException )
284{
285 Reference< css::awt::XMenuListener > xHolder(( OWeakObject *)this, UNO_QUERY );

--- 12 unchanged lines hidden (view full) ---

298void SAL_CALL RecentFilesMenuController::statusChanged( const FeatureStateEvent& Event ) throw ( RuntimeException )
299{
300 osl::MutexGuard aLock( m_aMutex );
301 m_bDisabled = !Event.IsEnabled;
302}
303
304void SAL_CALL RecentFilesMenuController::select( const css::awt::MenuEvent& rEvent ) throw (RuntimeException)
305{
330 Reference< css::awt::XPopupMenu > xPopupMenu;
331 Reference< XDispatch > xDispatch;
332 Reference< XDispatchProvider > xDispatchProvider;
333 Reference< XMultiServiceFactory > xServiceManager;
306 Reference< css::awt::XPopupMenu > xPopupMenu;
307 Reference< css::awt::XMenuExtended > xMenuExt;
334
335 osl::ClearableMutexGuard aLock( m_aMutex );
336 xPopupMenu = m_xPopupMenu;
308
309 osl::ClearableMutexGuard aLock( m_aMutex );
310 xPopupMenu = m_xPopupMenu;
337 xDispatchProvider = Reference< XDispatchProvider >( m_xFrame, UNO_QUERY );
338 xServiceManager = m_xServiceManager;
311 xMenuExt = Reference< css::awt::XMenuExtended >( m_xPopupMenu, UNO_QUERY );
339 aLock.clear();
340
312 aLock.clear();
313
341 css::util::URL aTargetURL;
342 Sequence< PropertyValue > aArgsList;
343
344 if ( xPopupMenu.is() && xDispatchProvider.is() )
314 if ( xMenuExt.is() )
345 {
315 {
346 VCLXPopupMenu* pPopupMenu = (VCLXPopupMenu *)VCLXPopupMenu::GetImplementation( xPopupMenu );
347 if ( pPopupMenu )
316 const rtl::OUString aCommand( xMenuExt->getCommand( rEvent.MenuId ) );
317 OSL_TRACE( "RecentFilesMenuController::select() - Command : %s",
318 rtl::OUStringToOString( aCommand, RTL_TEXTENCODING_UTF8 ).getStr() );
319
320 if ( aCommand.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( CMD_CLEAR_LIST ) ) )
321 SvtHistoryOptions().Clear( ePICKLIST );
322 else
348 executeEntry( rEvent.MenuId-1 );
349 }
350}
351
352void SAL_CALL RecentFilesMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException)
353{
354 osl::MutexGuard aLock( m_aMutex );
355 impl_setPopupMenu();
356}
357
358// XPopupMenuController
359void RecentFilesMenuController::impl_setPopupMenu()
360{
361 if ( m_xPopupMenu.is() )
362 fillPopupMenu( m_xPopupMenu );
363}
364
323 executeEntry( rEvent.MenuId-1 );
324 }
325}
326
327void SAL_CALL RecentFilesMenuController::activate( const css::awt::MenuEvent& ) throw (RuntimeException)
328{
329 osl::MutexGuard aLock( m_aMutex );
330 impl_setPopupMenu();
331}
332
333// XPopupMenuController
334void RecentFilesMenuController::impl_setPopupMenu()
335{
336 if ( m_xPopupMenu.is() )
337 fillPopupMenu( m_xPopupMenu );
338}
339
365void SAL_CALL RecentFilesMenuController::updatePopupMenu() throw (RuntimeException)
366{
367 osl::ClearableMutexGuard aLock( m_aMutex );
368
369 throwIfDisposed();
370
371 Reference< XStatusListener > xStatusListener( static_cast< OWeakObject* >( this ), UNO_QUERY );
372 Reference< XDispatch > xDispatch( m_xDispatch );
373 com::sun::star::util::URL aTargetURL;
374 aTargetURL.Complete = m_aCommandURL;
375 m_xURLTransformer->parseStrict( aTargetURL );
376 aLock.clear();
377
378 // Add/remove status listener to get a status update once
379 if ( xDispatch.is() )
380 {
381 xDispatch->addStatusListener( xStatusListener, aTargetURL );
382 xDispatch->removeStatusListener( xStatusListener, aTargetURL );
383 }
384}
385
386// XDispatchProvider
387Reference< XDispatch > SAL_CALL RecentFilesMenuController::queryDispatch(
388 const URL& aURL,
389 const ::rtl::OUString& /*sTarget*/,
390 sal_Int32 /*nFlags*/ )
391throw( RuntimeException )
392{
393 osl::MutexGuard aLock( m_aMutex );

--- 37 unchanged lines hidden (view full) ---

431
432 sal_Int32 nEntry = aEntryArg.toInt32();
433 executeEntry( nEntry );
434 }
435 }
436 }
437}
438
340// XDispatchProvider
341Reference< XDispatch > SAL_CALL RecentFilesMenuController::queryDispatch(
342 const URL& aURL,
343 const ::rtl::OUString& /*sTarget*/,
344 sal_Int32 /*nFlags*/ )
345throw( RuntimeException )
346{
347 osl::MutexGuard aLock( m_aMutex );

--- 37 unchanged lines hidden (view full) ---

385
386 sal_Int32 nEntry = aEntryArg.toInt32();
387 executeEntry( nEntry );
388 }
389 }
390 }
391}
392
439void SAL_CALL RecentFilesMenuController::addStatusListener(
440 const Reference< XStatusListener >& xControl,
441 const URL& aURL )
442throw( RuntimeException )
443{
444 osl::MutexGuard aLock( m_aMutex );
445
446 throwIfDisposed();
447
448 svt::PopupMenuControllerBase::addStatusListener( xControl, aURL );
449}
450
451void SAL_CALL RecentFilesMenuController::removeStatusListener(
452 const Reference< XStatusListener >& xControl,
453 const URL& aURL )
454throw( RuntimeException )
455{
456 svt::PopupMenuControllerBase::removeStatusListener( xControl, aURL );
457}
458
459IMPL_STATIC_LINK_NOINSTANCE( RecentFilesMenuController, ExecuteHdl_Impl, LoadRecentFile*, pLoadRecentFile )
460{
461 try
462 {
463 // Asynchronous execution as this can lead to our own destruction!
464 // Framework can recycle our current frame and the layout manager disposes all user interface
465 // elements if a component gets detached from its frame!
466 pLoadRecentFile->xDispatch->dispatch( pLoadRecentFile->aTargetURL, pLoadRecentFile->aArgSeq );
467 }
468 catch ( Exception& )
469 {
470 }
471
472 delete pLoadRecentFile;
473 return 0;
474}
475
476}
393IMPL_STATIC_LINK_NOINSTANCE( RecentFilesMenuController, ExecuteHdl_Impl, LoadRecentFile*, pLoadRecentFile )
394{
395 try
396 {
397 // Asynchronous execution as this can lead to our own destruction!
398 // Framework can recycle our current frame and the layout manager disposes all user interface
399 // elements if a component gets detached from its frame!
400 pLoadRecentFile->xDispatch->dispatch( pLoadRecentFile->aTargetURL, pLoadRecentFile->aArgSeq );
401 }
402 catch ( Exception& )
403 {
404 }
405
406 delete pLoadRecentFile;
407 return 0;
408}
409
410}