From a1d10eb8d7ee73d901041fdf550d2196a63c9d1d Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Thu, 26 Mar 2015 15:19:45 +0200 Subject: [PATCH] convert AVMEDIA_ constants to enum class Change-Id: Ic4918f57a1575a24cf0b9251cc7e7c6180ee25fd --- avmedia/source/framework/mediacontrol.cxx | 4 +- avmedia/source/framework/mediaitem.cxx | 51 +++++++++++----------- avmedia/source/framework/mediatoolbox.cxx | 2 +- avmedia/source/viewer/mediawindow_impl.cxx | 16 +++---- include/avmedia/mediaitem.hxx | 36 +++++++++------ svx/source/svdraw/svdomedia.cxx | 14 +++--- 6 files changed, 66 insertions(+), 57 deletions(-) diff --git a/avmedia/source/framework/mediacontrol.cxx b/avmedia/source/framework/mediacontrol.cxx index d41783ff9107..13592611093f 100644 --- a/avmedia/source/framework/mediacontrol.cxx +++ b/avmedia/source/framework/mediacontrol.cxx @@ -64,7 +64,7 @@ namespace avmedia MediaControl::MediaControl( vcl::Window* pParent, MediaControlStyle eControlStyle ) : Control( pParent ), maImageList( SvtMiscOptions().AreCurrentSymbolsLarge() ? AVMEDIA_RESID( AVMEDIA_IMGLST_L ) : AVMEDIA_RESID( AVMEDIA_IMGLST ) ), - maItem( 0, AVMEDIA_SETMASK_ALL ), + maItem( 0, AVMediaSetMask::ALL ), maPlayToolBox( this, WB_3DLOOK ), maTimeSlider( this, WB_HORZ | WB_DRAG | WB_3DLOOK | WB_SLIDERSET ), maMuteToolBox( this, WB_3DLOOK ), @@ -549,7 +549,7 @@ IMPL_LINK( MediaControl, implSelectHdl, ToolBox*, p ) break; } - if( aExecItem.getMaskSet() != AVMEDIA_SETMASK_NONE ) + if( aExecItem.getMaskSet() != AVMediaSetMask::NONE ) execute( aExecItem ); } diff --git a/avmedia/source/framework/mediaitem.cxx b/avmedia/source/framework/mediaitem.cxx index 3b3352916c77..2543df5d08f9 100644 --- a/avmedia/source/framework/mediaitem.cxx +++ b/avmedia/source/framework/mediaitem.cxx @@ -52,7 +52,7 @@ struct MediaItem::Impl OUString m_TempFileURL; OUString m_Referer; OUString m_sMimeType; - sal_uInt32 m_nMaskSet; + AVMediaSetMask m_nMaskSet; MediaState m_eState; double m_fTime; double m_fDuration; @@ -61,7 +61,7 @@ struct MediaItem::Impl bool m_bMute; ::com::sun::star::media::ZoomLevel m_eZoom; - Impl(sal_uInt32 const nMaskSet) + Impl(AVMediaSetMask nMaskSet) : m_nMaskSet( nMaskSet ) , m_eState( MEDIASTATE_STOP ) , m_fTime( 0.0 ) @@ -89,7 +89,7 @@ struct MediaItem::Impl } }; -MediaItem::MediaItem( sal_uInt16 const i_nWhich, sal_uInt32 const nMaskSet ) +MediaItem::MediaItem( sal_uInt16 i_nWhich, AVMediaSetMask nMaskSet ) : SfxPoolItem( i_nWhich ) , m_pImpl( new Impl(nMaskSet) ) { @@ -142,7 +142,7 @@ bool MediaItem::QueryValue( com::sun::star::uno::Any& rVal, sal_uInt8 ) const uno::Sequence< uno::Any > aSeq( 10 ); aSeq[ 0 ] <<= m_pImpl->m_URL; - aSeq[ 1 ] <<= m_pImpl->m_nMaskSet; + aSeq[ 1 ] <<= static_cast(m_pImpl->m_nMaskSet); aSeq[ 2 ] <<= static_cast< sal_Int32 >( m_pImpl->m_eState ); aSeq[ 3 ] <<= m_pImpl->m_fTime; aSeq[ 4 ] <<= m_pImpl->m_fDuration; @@ -167,7 +167,8 @@ bool MediaItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 ) sal_Int32 nInt32 = 0; aSeq[ 0 ] >>= m_pImpl->m_URL; - aSeq[ 1 ] >>= m_pImpl->m_nMaskSet; + aSeq[ 1 ] >>= nInt32; + m_pImpl->m_nMaskSet = static_cast(nInt32); aSeq[ 2 ] >>= nInt32; m_pImpl->m_eState = static_cast< MediaState >( nInt32 ); aSeq[ 3 ] >>= m_pImpl->m_fTime; @@ -186,44 +187,44 @@ bool MediaItem::PutValue( const com::sun::star::uno::Any& rVal, sal_uInt8 ) void MediaItem::merge( const MediaItem& rMediaItem ) { - const sal_uInt32 nMaskSet = rMediaItem.getMaskSet(); + const AVMediaSetMask nMaskSet = rMediaItem.getMaskSet(); - if( AVMEDIA_SETMASK_URL & nMaskSet ) + if( AVMediaSetMask::URL & nMaskSet ) setURL( rMediaItem.getURL(), rMediaItem.getTempURL(), rMediaItem.getReferer() ); - if( AVMEDIA_SETMASK_MIME_TYPE & nMaskSet ) + if( AVMediaSetMask::MIME_TYPE & nMaskSet ) setMimeType( rMediaItem.getMimeType() ); - if( AVMEDIA_SETMASK_STATE & nMaskSet ) + if( AVMediaSetMask::STATE & nMaskSet ) setState( rMediaItem.getState() ); - if( AVMEDIA_SETMASK_DURATION & nMaskSet ) + if( AVMediaSetMask::DURATION & nMaskSet ) setDuration( rMediaItem.getDuration() ); - if( AVMEDIA_SETMASK_TIME & nMaskSet ) + if( AVMediaSetMask::TIME & nMaskSet ) setTime( rMediaItem.getTime() ); - if( AVMEDIA_SETMASK_LOOP & nMaskSet ) + if( AVMediaSetMask::LOOP & nMaskSet ) setLoop( rMediaItem.isLoop() ); - if( AVMEDIA_SETMASK_MUTE & nMaskSet ) + if( AVMediaSetMask::MUTE & nMaskSet ) setMute( rMediaItem.isMute() ); - if( AVMEDIA_SETMASK_VOLUMEDB & nMaskSet ) + if( AVMediaSetMask::VOLUMEDB & nMaskSet ) setVolumeDB( rMediaItem.getVolumeDB() ); - if( AVMEDIA_SETMASK_ZOOM & nMaskSet ) + if( AVMediaSetMask::ZOOM & nMaskSet ) setZoom( rMediaItem.getZoom() ); } -sal_uInt32 MediaItem::getMaskSet() const +AVMediaSetMask MediaItem::getMaskSet() const { return m_pImpl->m_nMaskSet; } void MediaItem::setURL( const OUString& rURL, const OUString& rTempURL, const OUString& rReferer ) { - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_URL; + m_pImpl->m_nMaskSet |= AVMediaSetMask::URL; m_pImpl->m_URL = rURL; m_pImpl->m_TempFileURL = rTempURL; m_pImpl->m_Referer = rReferer; @@ -246,7 +247,7 @@ const OUString& MediaItem::getReferer() const void MediaItem::setMimeType( const OUString& rMimeType ) { - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_MIME_TYPE; + m_pImpl->m_nMaskSet |= AVMediaSetMask::MIME_TYPE; m_pImpl->m_sMimeType = rMimeType; } @@ -258,7 +259,7 @@ OUString MediaItem::getMimeType() const void MediaItem::setState( MediaState eState ) { m_pImpl->m_eState = eState; - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_STATE; + m_pImpl->m_nMaskSet |= AVMediaSetMask::STATE; } MediaState MediaItem::getState() const @@ -269,7 +270,7 @@ MediaState MediaItem::getState() const void MediaItem::setDuration( double fDuration ) { m_pImpl->m_fDuration = fDuration; - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_DURATION; + m_pImpl->m_nMaskSet |= AVMediaSetMask::DURATION; } double MediaItem::getDuration() const @@ -280,7 +281,7 @@ double MediaItem::getDuration() const void MediaItem::setTime( double fTime ) { m_pImpl->m_fTime = fTime; - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_TIME; + m_pImpl->m_nMaskSet |= AVMediaSetMask::TIME; } double MediaItem::getTime() const @@ -291,7 +292,7 @@ double MediaItem::getTime() const void MediaItem::setLoop( bool bLoop ) { m_pImpl->m_bLoop = bLoop; - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_LOOP; + m_pImpl->m_nMaskSet |= AVMediaSetMask::LOOP; } bool MediaItem::isLoop() const @@ -302,7 +303,7 @@ bool MediaItem::isLoop() const void MediaItem::setMute( bool bMute ) { m_pImpl->m_bMute = bMute; - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_MUTE; + m_pImpl->m_nMaskSet |= AVMediaSetMask::MUTE; } bool MediaItem::isMute() const @@ -313,7 +314,7 @@ bool MediaItem::isMute() const void MediaItem::setVolumeDB( sal_Int16 nDB ) { m_pImpl->m_nVolumeDB = nDB; - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_VOLUMEDB; + m_pImpl->m_nMaskSet |= AVMediaSetMask::VOLUMEDB; } sal_Int16 MediaItem::getVolumeDB() const @@ -324,7 +325,7 @@ sal_Int16 MediaItem::getVolumeDB() const void MediaItem::setZoom( ::com::sun::star::media::ZoomLevel eZoom ) { m_pImpl->m_eZoom = eZoom; - m_pImpl->m_nMaskSet |= AVMEDIA_SETMASK_ZOOM; + m_pImpl->m_nMaskSet |= AVMediaSetMask::ZOOM; } ::com::sun::star::media::ZoomLevel MediaItem::getZoom() const diff --git a/avmedia/source/framework/mediatoolbox.cxx b/avmedia/source/framework/mediatoolbox.cxx index 280cdb5e1e1f..ea4131fe4713 100644 --- a/avmedia/source/framework/mediatoolbox.cxx +++ b/avmedia/source/framework/mediatoolbox.cxx @@ -115,7 +115,7 @@ void MediaToolBoxControl::StateChanged( sal_uInt16 /* nSID */, SfxItemState eSta pCtrl->Enable( false, false ); pCtrl->SetText( OUString() ); - const MediaItem aEmptyMediaItem( 0, AVMEDIA_SETMASK_ALL ); + const MediaItem aEmptyMediaItem( 0, AVMediaSetMask::ALL ); pCtrl->setState( aEmptyMediaItem ); } else diff --git a/avmedia/source/viewer/mediawindow_impl.cxx b/avmedia/source/viewer/mediawindow_impl.cxx index e5fffff82aeb..26877f653bb5 100644 --- a/avmedia/source/viewer/mediawindow_impl.cxx +++ b/avmedia/source/viewer/mediawindow_impl.cxx @@ -369,33 +369,33 @@ void MediaWindowImpl::updateMediaItem( MediaItem& rItem ) const void MediaWindowImpl::executeMediaItem( const MediaItem& rItem ) { - const sal_uInt32 nMaskSet = rItem.getMaskSet(); + const AVMediaSetMask nMaskSet = rItem.getMaskSet(); // set URL first - if( nMaskSet & AVMEDIA_SETMASK_URL ) + if( nMaskSet & AVMediaSetMask::URL ) { m_sMimeType = rItem.getMimeType(); setURL( rItem.getURL(), rItem.getTempURL(), rItem.getReferer() ); } // set different states next - if( nMaskSet & AVMEDIA_SETMASK_TIME ) + if( nMaskSet & AVMediaSetMask::TIME ) setMediaTime( ::std::min( rItem.getTime(), getDuration() ) ); - if( nMaskSet & AVMEDIA_SETMASK_LOOP ) + if( nMaskSet & AVMediaSetMask::LOOP ) setPlaybackLoop( rItem.isLoop() ); - if( nMaskSet & AVMEDIA_SETMASK_MUTE ) + if( nMaskSet & AVMediaSetMask::MUTE ) setMute( rItem.isMute() ); - if( nMaskSet & AVMEDIA_SETMASK_VOLUMEDB ) + if( nMaskSet & AVMediaSetMask::VOLUMEDB ) setVolumeDB( rItem.getVolumeDB() ); - if( nMaskSet & AVMEDIA_SETMASK_ZOOM ) + if( nMaskSet & AVMediaSetMask::ZOOM ) setZoom( rItem.getZoom() ); // set play state at last - if( nMaskSet & AVMEDIA_SETMASK_STATE ) + if( nMaskSet & AVMediaSetMask::STATE ) { switch( rItem.getState() ) { diff --git a/include/avmedia/mediaitem.hxx b/include/avmedia/mediaitem.hxx index 84cb4246ca8f..fc424d5564df 100644 --- a/include/avmedia/mediaitem.hxx +++ b/include/avmedia/mediaitem.hxx @@ -27,18 +27,26 @@ #include #include #include +#include -#define AVMEDIA_SETMASK_NONE ((sal_uInt32)(0x00000000)) -#define AVMEDIA_SETMASK_STATE ((sal_uInt32)(0x00000001)) -#define AVMEDIA_SETMASK_DURATION ((sal_uInt32)(0x00000002)) -#define AVMEDIA_SETMASK_TIME ((sal_uInt32)(0x00000004)) -#define AVMEDIA_SETMASK_LOOP ((sal_uInt32)(0x00000008)) -#define AVMEDIA_SETMASK_MUTE ((sal_uInt32)(0x00000010)) -#define AVMEDIA_SETMASK_VOLUMEDB ((sal_uInt32)(0x00000020)) -#define AVMEDIA_SETMASK_ZOOM ((sal_uInt32)(0x00000040)) -#define AVMEDIA_SETMASK_URL ((sal_uInt32)(0x00000080)) -#define AVMEDIA_SETMASK_MIME_TYPE ((sal_uInt32)(0x00000100)) -#define AVMEDIA_SETMASK_ALL ((sal_uInt32)(0xffffffff)) +enum class AVMediaSetMask +{ + NONE = 0x000, + STATE = 0x001, + DURATION = 0x002, + TIME = 0x004, + LOOP = 0x008, + MUTE = 0x010, + VOLUMEDB = 0x020, + ZOOM = 0x040, + URL = 0x080, + MIME_TYPE = 0x100, + ALL = 0x1ff, +}; +namespace o3tl +{ + template<> struct typed_flags : is_typed_flags {}; +} class SvStream; @@ -65,8 +73,8 @@ class AVMEDIA_DLLPUBLIC MediaItem : public SfxPoolItem public: TYPEINFO_OVERRIDE(); - explicit MediaItem( sal_uInt16 const i_nWhich = 0, - sal_uInt32 const nMaskSet = AVMEDIA_SETMASK_NONE ); + explicit MediaItem( sal_uInt16 i_nWhich = 0, + AVMediaSetMask nMaskSet = AVMediaSetMask::NONE ); MediaItem( const MediaItem& rMediaItem ); virtual ~MediaItem(); @@ -82,7 +90,7 @@ public: void merge( const MediaItem& rMediaItem ); - sal_uInt32 getMaskSet() const; + AVMediaSetMask getMaskSet() const; void setState( MediaState eState ); MediaState getState() const; diff --git a/svx/source/svdraw/svdomedia.cxx b/svx/source/svdraw/svdomedia.cxx index 2bead84706f1..05c5589c32fe 100644 --- a/svx/source/svdraw/svdomedia.cxx +++ b/svx/source/svdraw/svdomedia.cxx @@ -420,13 +420,13 @@ static bool lcl_HandlePackageURL( void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProperties ) { bool bBroadcastChanged = false; - const sal_uInt32 nMaskSet = rNewProperties.getMaskSet(); + const AVMediaSetMask nMaskSet = rNewProperties.getMaskSet(); // use only a subset of MediaItem properties for own own properties - if( AVMEDIA_SETMASK_MIME_TYPE & nMaskSet ) + if( AVMediaSetMask::MIME_TYPE & nMaskSet ) m_xImpl->m_MediaProperties.setMimeType( rNewProperties.getMimeType() ); - if( ( AVMEDIA_SETMASK_URL & nMaskSet ) && + if( ( AVMediaSetMask::URL & nMaskSet ) && ( rNewProperties.getURL() != getURL() )) { m_xImpl->m_xCachedSnapshot.clear(); @@ -475,16 +475,16 @@ void SdrMediaObj::mediaPropertiesChanged( const ::avmedia::MediaItem& rNewProper bBroadcastChanged = true; } - if( AVMEDIA_SETMASK_LOOP & nMaskSet ) + if( AVMediaSetMask::LOOP & nMaskSet ) m_xImpl->m_MediaProperties.setLoop( rNewProperties.isLoop() ); - if( AVMEDIA_SETMASK_MUTE & nMaskSet ) + if( AVMediaSetMask::MUTE & nMaskSet ) m_xImpl->m_MediaProperties.setMute( rNewProperties.isMute() ); - if( AVMEDIA_SETMASK_VOLUMEDB & nMaskSet ) + if( AVMediaSetMask::VOLUMEDB & nMaskSet ) m_xImpl->m_MediaProperties.setVolumeDB( rNewProperties.getVolumeDB() ); - if( AVMEDIA_SETMASK_ZOOM & nMaskSet ) + if( AVMediaSetMask::ZOOM & nMaskSet ) m_xImpl->m_MediaProperties.setZoom( rNewProperties.getZoom() ); if( bBroadcastChanged )