summaryrefslogtreecommitdiff
path: root/sc/source/ui/drawfunc
diff options
context:
space:
mode:
authorJan-Marek Glogowski <glogow@fbihome.de>2021-05-17 22:59:52 +0200
committerJan-Marek Glogowski <glogow@fbihome.de>2021-05-26 15:37:06 +0200
commit2e30d16bb945042b5c033dc9bdba690ee4a08fed (patch)
tree5122c1b3e6a5859141a35ec897c6a727f9c499bd /sc/source/ui/drawfunc
parent456b87b6b188984579c1d809aab805f6f324ea53 (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 'sc/source/ui/drawfunc')
-rw-r--r--sc/source/ui/drawfunc/mediash.cxx90
1 files changed, 13 insertions, 77 deletions
diff --git a/sc/source/ui/drawfunc/mediash.cxx b/sc/source/ui/drawfunc/mediash.cxx
index 242ee95120b7..b203cfeb7fd4 100644
--- a/sc/source/ui/drawfunc/mediash.cxx
+++ b/sc/source/ui/drawfunc/mediash.cxx
@@ -19,12 +19,8 @@
#include <memory>
#include <sfx2/objface.hxx>
-#include <sfx2/request.hxx>
-#include <avmedia/mediaitem.hxx>
-#include <svl/whiter.hxx>
-#include <svx/svdomedia.hxx>
-#include <svx/sdr/contact/viewcontactofsdrmediaobj.hxx>
#include <vcl/EnumContext.hxx>
+#include <svx/MediaShellHelpers.hxx>
#include <mediash.hxx>
#include <strings.hrc>
@@ -35,95 +31,35 @@
#define ShellClass_ScMediaShell
#include <scslots.hxx>
+using namespace svx;
+
SFX_IMPL_INTERFACE(ScMediaShell, ScDrawShell)
void ScMediaShell::InitInterface_Impl()
{
- GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Media_Objectbar);
+ GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible,
+ ToolbarId::Media_Objectbar);
GetStaticInterface()->RegisterPopupMenu("media");
}
-
-ScMediaShell::ScMediaShell(ScViewData& rData) :
- ScDrawShell(rData)
+ScMediaShell::ScMediaShell(ScViewData& rData)
+ : ScDrawShell(rData)
{
- SetName( ScResId( SCSTR_MEDIASHELL ) );
+ SetName(ScResId(SCSTR_MEDIASHELL));
SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Media));
}
-ScMediaShell::~ScMediaShell()
-{
-}
+ScMediaShell::~ScMediaShell() {}
-void ScMediaShell::GetMediaState( SfxItemSet& rSet )
+void ScMediaShell::GetMediaState(SfxItemSet& rSet)
{
- ScDrawView* pView = GetViewData().GetScDrawView();
-
- if( !pView )
- return;
-
- SfxWhichIter aIter( rSet );
- sal_uInt16 nWhich = aIter.FirstWhich();
-
- while( nWhich )
- {
- if( SID_AVMEDIA_TOOLBOX == nWhich )
- {
- std::unique_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
- bool bDisable = true;
-
- if( 1 == pMarkList->GetMarkCount() )
- {
- SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
-
- if( dynamic_cast<const 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();
- }
+ MediaShellHelpers::GetState(GetViewData().GetScDrawView(), rSet);
}
-void ScMediaShell::ExecuteMedia( const SfxRequest& rReq )
+void ScMediaShell::ExecuteMedia(const SfxRequest& rReq)
{
- ScDrawView* pView = GetViewData().GetScDrawView();
-
- if( pView && SID_AVMEDIA_TOOLBOX == rReq.GetSlot() )
- {
- const SfxItemSet* pArgs = rReq.GetArgs();
- const SfxPoolItem* pItem;
-
- if( !pArgs || ( SfxItemState::SET != pArgs->GetItemState( SID_AVMEDIA_TOOLBOX, false, &pItem ) ) )
- pItem = nullptr;
-
- if( pItem )
- {
- std::unique_ptr<SdrMarkList> pMarkList(new SdrMarkList( pView->GetMarkedObjectList() ));
-
- if( 1 == pMarkList->GetMarkCount() )
- {
- SdrObject* pObj = pMarkList->GetMark( 0 )->GetMarkedSdrObj();
-
- if( dynamic_cast<const SdrMediaObj*>( pObj) )
- {
- static_cast< sdr::contact::ViewContactOfSdrMediaObj& >( pObj->GetViewContact() ).executeMediaItem(
- static_cast< const ::avmedia::MediaItem& >( *pItem ) );
- }
- }
- }
- }
-
+ MediaShellHelpers::Execute(GetViewData().GetScDrawView(), rReq);
Invalidate();
}