diff options
author | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-05-17 22:59:52 +0200 |
---|---|---|
committer | Jan-Marek Glogowski <glogow@fbihome.de> | 2021-05-26 15:37:06 +0200 |
commit | 2e30d16bb945042b5c033dc9bdba690ee4a08fed (patch) | |
tree | 5122c1b3e6a5859141a35ec897c6a727f9c499bd /sd | |
parent | 456b87b6b188984579c1d809aab805f6f324ea53 (diff) |
Refactor module media item handling
Move common functionality into svx::MediaShellHelpers.
Change-Id: I6f5db59bdcff7cad00a64e76f6aad7b8ecb4ffa9
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116126
Tested-by: Jenkins
Reviewed-by: Jan-Marek Glogowski <glogow@fbihome.de>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/source/ui/view/MediaObjectBar.cxx | 97 |
1 files changed, 17 insertions, 80 deletions
diff --git a/sd/source/ui/view/MediaObjectBar.cxx b/sd/source/ui/view/MediaObjectBar.cxx index b6ee505f98a5..8d77b5b8c501 100644 --- a/sd/source/ui/view/MediaObjectBar.cxx +++ b/sd/source/ui/view/MediaObjectBar.cxx @@ -19,13 +19,9 @@ #include <MediaObjectBar.hxx> #include <avmedia/mediaitem.hxx> -#include <sfx2/msg.hxx> #include <sfx2/sfxsids.hrc> -#include <sfx2/request.hxx> #include <sfx2/objface.hxx> -#include <svl/whiter.hxx> -#include <svx/svdomedia.hxx> -#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx> +#include <svx/MediaShellHelpers.hxx> #include <strings.hrc> #include <DrawDocShell.hxx> @@ -35,100 +31,41 @@ #include <memory> using namespace sd; +using namespace svx; #define ShellClass_MediaObjectBar #include <sdslots.hxx> -namespace sd { - - +namespace sd +{ SFX_IMPL_INTERFACE(MediaObjectBar, SfxShell) -void MediaObjectBar::InitInterface_Impl() -{ -} +void MediaObjectBar::InitInterface_Impl() {} -MediaObjectBar::MediaObjectBar( const ViewShell* pSdViewShell, ::sd::View* pSdView ) : - SfxShell( pSdViewShell->GetViewShell() ), - mpView( pSdView ) +MediaObjectBar::MediaObjectBar(const ViewShell* pSdViewShell, ::sd::View* pSdView) + : SfxShell(pSdViewShell->GetViewShell()) + , mpView(pSdView) { DrawDocShell* pDocShell = pSdViewShell->GetDocSh(); - SetPool( &pDocShell->GetPool() ); - SetUndoManager( pDocShell->GetUndoManager() ); - SetRepeatTarget( mpView ); + SetPool(&pDocShell->GetPool()); + SetUndoManager(pDocShell->GetUndoManager()); + SetRepeatTarget(mpView); SetName(SdResId(RID_DRAW_MEDIA_TOOLBOX)); } -MediaObjectBar::~MediaObjectBar() -{ - SetRepeatTarget( nullptr ); -} +MediaObjectBar::~MediaObjectBar() { SetRepeatTarget(nullptr); } -void MediaObjectBar::GetState( SfxItemSet& rSet ) -{ - SfxWhichIter aIter( rSet ); - sal_uInt16 nWhich = aIter.FirstWhich(); +void MediaObjectBar::GetState(SfxItemSet& rSet) { MediaShellHelpers::GetState(mpView, rSet); } - while( nWhich ) - { - if( SID_AVMEDIA_TOOLBOX == nWhich ) - { - std::unique_ptr<SdrMarkList> pMarkList(new SdrMarkList( mpView->GetMarkedObjectList() )); - bool bDisable = true; - - if( 1 == pMarkList->GetMarkCount() ) - { - SdrObject* pObj =pMarkList->GetMark( 0 )->GetMarkedSdrObj(); - - if( dynamic_cast< SdrMediaObj *>( pObj ) ) - { - ::avmedia::MediaItem aItem( SID_AVMEDIA_TOOLBOX ); - - static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).updateMediaItem( aItem ); - rSet.Put( aItem ); - bDisable = false; - } - } - - if( bDisable ) - rSet.DisableItem( SID_AVMEDIA_TOOLBOX ); - } - - nWhich = aIter.NextWhich(); - } -} - -void MediaObjectBar::Execute( SfxRequest const & rReq ) +void MediaObjectBar::Execute(SfxRequest const& rReq) { - if( SID_AVMEDIA_TOOLBOX != rReq.GetSlot() ) - return; - - const SfxItemSet* pArgs = rReq.GetArgs(); - const SfxPoolItem* pItem; - - if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) ) - pItem = nullptr; - - if( !pItem ) - return; - - std::unique_ptr<SdrMarkList> pMarkList(new SdrMarkList( mpView->GetMarkedObjectList() )); - - if( 1 != pMarkList->GetMarkCount() ) + const ::avmedia::MediaItem* pMediaItem = MediaShellHelpers::Execute(mpView, rReq); + if (!pMediaItem) return; - SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj(); - - if( !dynamic_cast< SdrMediaObj *>( pObj ) ) - return; - - static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem( - static_cast< const ::avmedia::MediaItem& >( *pItem ) ); - - //if only changing state then don't set modified flag (e.g. playing a video) - if( !(static_cast< const ::avmedia::MediaItem& >( *pItem ).getMaskSet() & AVMediaSetMask::STATE)) + if (!(pMediaItem->getMaskSet() & AVMediaSetMask::STATE)) { //fdo #32598: after changing playback opts, set document's modified flag SdDrawDocument& rDoc = mpView->GetDoc(); |