diff options
author | Noel Grandin <noel@peralex.com> | 2012-12-14 12:58:00 +0200 |
---|---|---|
committer | Noel Grandin <noel@peralex.com> | 2012-12-21 10:57:09 +0200 |
commit | bb121c864cc3c101ef733a4088c7ba3e36eced14 (patch) | |
tree | 2d528ca830aace6e563b7cdc93eb8f8d6c4f70cf /sfx2/source/menu | |
parent | 6d818ed651aaafcfb12ebc21449d35947d2e85a9 (diff) |
fdo#46808, Convert frame::Desktop to new style service.
I had to drop XEventBroadcaster from the merged interface
because it introduced method name conflicts (addEventListener).
Shouldn't be an issue since it was scheduled to be dropped anyhow,
and the service implementation still implements it, so existing clients
will be fine.
I dropped the interface XPropertySet from the combined IDL because nobody
seems to be using it, and it's primary purpose appears to be to set weird
flags.
I dropped the optional interfaces
XStatusIndicatorFactory
XDispatchInformationProvider
from the combined IDL because the service does not implement them, and
nobody seems to be using them. I suspect they were mistakenly copied
from XFrame.
I also did not convert the Title, UserDefinedAttributes and LayoutManager
properties to attributes, again because no-one is using them.
Change-Id: I678a00006ed2cca2d6c37c4e39465811442c33af
Diffstat (limited to 'sfx2/source/menu')
-rw-r--r-- | sfx2/source/menu/virtmenu.cxx | 71 |
1 files changed, 31 insertions, 40 deletions
diff --git a/sfx2/source/menu/virtmenu.cxx b/sfx2/source/menu/virtmenu.cxx index d056d9cb9ee4..81f186c3e541 100644 --- a/sfx2/source/menu/virtmenu.cxx +++ b/sfx2/source/menu/virtmenu.cxx @@ -23,7 +23,7 @@ #include <svtools/imagemgr.hxx> #include <svl/imageitm.hxx> #include <com/sun/star/container/XEnumeration.hpp> -#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/XFramesSupplier.hpp> #include <comphelper/processfactory.hxx> #include <toolkit/unohlp.hxx> @@ -842,34 +842,29 @@ IMPL_LINK( SfxVirtualMenu, Activate, Menu *, pMenu ) { // update window list ::std::vector< ::rtl::OUString > aNewWindowListVector; - Reference< XDesktop > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( - DEFINE_CONST_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY ); + Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() );; sal_uInt16 nActiveItemId = 0; sal_uInt16 nItemId = START_ITEMID_WINDOWLIST; - if ( xDesktop.is() ) + Reference< XFrame > xCurrentFrame = xDesktop->getCurrentFrame(); + Reference< XIndexAccess > xList ( xDesktop->getFrames(), UNO_QUERY ); + sal_Int32 nFrameCount = xList->getCount(); + for( sal_Int32 i=0; i<nFrameCount; ++i ) { - Reference< XFramesSupplier > xTasksSupplier( xDesktop, UNO_QUERY ); - Reference< XFrame > xCurrentFrame = xDesktop->getCurrentFrame(); - Reference< XIndexAccess > xList ( xTasksSupplier->getFrames(), UNO_QUERY ); - sal_Int32 nFrameCount = xList->getCount(); - for( sal_Int32 i=0; i<nFrameCount; ++i ) - { - Reference< XFrame > xFrame; - Any aVal = xList->getByIndex(i); - if (!(aVal>>=xFrame) || !xFrame.is() ) - continue; + Reference< XFrame > xFrame; + Any aVal = xList->getByIndex(i); + if (!(aVal>>=xFrame) || !xFrame.is() ) + continue; - if ( xFrame == xCurrentFrame ) - nActiveItemId = nItemId; + if ( xFrame == xCurrentFrame ) + nActiveItemId = nItemId; - Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); - if ( pWin && pWin->IsVisible() ) - { - aNewWindowListVector.push_back( pWin->GetText() ); - ++nItemId; - } + Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + if ( pWin && pWin->IsVisible() ) + { + aNewWindowListVector.push_back( pWin->GetText() ); + ++nItemId; } } @@ -974,27 +969,23 @@ IMPL_LINK( SfxVirtualMenu, Select, Menu *, pMenu ) if ( nSlotId >= START_ITEMID_WINDOWLIST && nSlotId <= END_ITEMID_WINDOWLIST ) { // window list menu item selected - Reference< XFramesSupplier > xDesktop( ::comphelper::getProcessServiceFactory()->createInstance( - DEFINE_CONST_OUSTRING( "com.sun.star.frame.Desktop" ) ), UNO_QUERY ); - if ( xDesktop.is() ) + Reference< XDesktop2 > xDesktop = Desktop::create( ::comphelper::getProcessComponentContext() ); + sal_uInt16 nTaskId = START_ITEMID_WINDOWLIST; + Reference< XIndexAccess > xList( xDesktop->getFrames(), UNO_QUERY ); + sal_Int32 nFrameCount = xList->getCount(); + for ( sal_Int32 i=0; i<nFrameCount; ++i ) { - sal_uInt16 nTaskId = START_ITEMID_WINDOWLIST; - Reference< XIndexAccess > xList( xDesktop->getFrames(), UNO_QUERY ); - sal_Int32 nFrameCount = xList->getCount(); - for ( sal_Int32 i=0; i<nFrameCount; ++i ) + Any aItem = xList->getByIndex(i); + Reference< XFrame > xFrame; + if (( aItem >>= xFrame ) && xFrame.is() && nTaskId == nSlotId ) { - Any aItem = xList->getByIndex(i); - Reference< XFrame > xFrame; - if (( aItem >>= xFrame ) && xFrame.is() && nTaskId == nSlotId ) - { - Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); - pWin->GrabFocus(); - pWin->ToTop( TOTOP_RESTOREWHENMIN ); - break; - } - - nTaskId++; + Window* pWin = VCLUnoHelper::GetWindow( xFrame->getContainerWindow() ); + pWin->GrabFocus(); + pWin->ToTop( TOTOP_RESTOREWHENMIN ); + break; } + + nTaskId++; } return sal_True; |