convert STR_EVENT constants to scoped enum

- also add needed infrastructure to o3tl::enumarray so we can use
std::find on it
- move the Impl inside the .cxx file, no need to expose it in the header

Change-Id: I7758a6175849f46723d97b1e657f846524c3b7cd
This commit is contained in:
Noel Grandin 2015-04-28 15:01:43 +02:00
parent a9bfa6547a
commit 6bb742b9cb
20 changed files with 132 additions and 145 deletions

View File

@ -2426,7 +2426,7 @@ public:
virtual void SAL_CALL documentEventOccured( const document::DocumentEvent& rEvent ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE
{
// early dosposing on document event "OnUnload", to be sure Basic still exists when calling VBA "UserForm_Terminate"
if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ) )
if( rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::CLOSEDOC ) )
{
removeListener();
mbDisposed = true;

View File

@ -70,6 +70,8 @@ public:
iterator begin() { return iterator(*this, 0); }
iterator end() { return iterator(*this, size()); }
V* data() { return detail_values; }
//private:
V detail_values[max_index + 1];
};
@ -83,6 +85,10 @@ public:
typedef enumarray_iterator<EA> self_type;
typedef typename EA::value_type value_type;
typedef typename EA::key_type key_type;
typedef std::bidirectional_iterator_tag iterator_category; //should be random access, but that would require define subtraction operators on the enums
typedef typename EA::key_type difference_type;
typedef typename EA::value_type* pointer;
typedef typename EA::value_type& reference;
enumarray_iterator(EA& b, size_t start_pos)
: m_buf(b), m_pos(start_pos) {}
@ -90,6 +96,7 @@ public:
value_type *operator->() { return &(operator*()); }
self_type &operator++() { ++m_pos; return *this; }
bool operator!=(const self_type& other) { return &m_buf != &other.m_buf || m_pos != other.m_pos; }
bool operator==(const self_type& other) { return &m_buf == &other.m_buf && m_pos == other.m_pos; }
};
}; // namespace o3tl

View File

@ -121,7 +121,7 @@ public:
const css::uno::Reference< css::frame::XController2 >& xController )
: SfxViewEventHint(
SFX_EVENT_PRINTDOC,
GlobalEventConfig::GetEventName( STR_EVENT_PRINTDOC ),
GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ),
pObj,
xController )
, mnPrintableState( nEvent )

View File

@ -29,65 +29,41 @@
#include <unordered_map>
#include <vector>
#define STR_EVENT_STARTAPP 0
#define STR_EVENT_CLOSEAPP 1
#define STR_EVENT_DOCCREATED 2
#define STR_EVENT_CREATEDOC 3
#define STR_EVENT_LOADFINISHED 4
#define STR_EVENT_OPENDOC 5
#define STR_EVENT_PREPARECLOSEDOC 6
#define STR_EVENT_CLOSEDOC 7
#define STR_EVENT_SAVEDOC 8
#define STR_EVENT_SAVEDOCDONE 9
#define STR_EVENT_SAVEDOCFAILED 10
#define STR_EVENT_SAVEASDOC 11
#define STR_EVENT_SAVEASDOCDONE 12
#define STR_EVENT_SAVEASDOCFAILED 13
#define STR_EVENT_SAVETODOC 14
#define STR_EVENT_SAVETODOCDONE 15
#define STR_EVENT_SAVETODOCFAILED 16
#define STR_EVENT_ACTIVATEDOC 17
#define STR_EVENT_DEACTIVATEDOC 18
#define STR_EVENT_PRINTDOC 19
#define STR_EVENT_VIEWCREATED 20
#define STR_EVENT_PREPARECLOSEVIEW 21
#define STR_EVENT_CLOSEVIEW 22
#define STR_EVENT_MODIFYCHANGED 23
#define STR_EVENT_TITLECHANGED 24
#define STR_EVENT_VISAREACHANGED 25
#define STR_EVENT_MODECHANGED 26
#define STR_EVENT_STORAGECHANGED 27
typedef std::unordered_map< OUString, OUString, OUStringHash, std::equal_to< OUString > > EventBindingHash;
typedef std::vector< css::uno::WeakReference< css::frame::XFrame > > FrameVector;
typedef std::vector< OUString > SupportedEventsVector;
class GlobalEventConfig_Impl : public utl::ConfigItem
enum class GlobalEventId
{
private:
EventBindingHash m_eventBindingHash;
FrameVector m_lFrames;
SupportedEventsVector m_supportedEvents;
void initBindingInfo();
virtual void ImplCommit() SAL_OVERRIDE;
public:
GlobalEventConfig_Impl( );
virtual ~GlobalEventConfig_Impl( );
void Notify( const com::sun::star::uno::Sequence<OUString>& aPropertyNames) SAL_OVERRIDE;
void SAL_CALL replaceByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException);
bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
OUString GetEventName( sal_Int32 nID );
STARTAPP,
CLOSEAPP,
DOCCREATED,
CREATEDOC,
LOADFINISHED,
OPENDOC,
PREPARECLOSEDOC,
CLOSEDOC,
SAVEDOC,
SAVEDOCDONE,
SAVEDOCFAILED,
SAVEASDOC,
SAVEASDOCDONE,
SAVEASDOCFAILED,
SAVETODOC,
SAVETODOCDONE,
SAVETODOCFAILED,
ACTIVATEDOC,
DEACTIVATEDOC,
PRINTDOC,
VIEWCREATED,
PREPARECLOSEVIEW,
CLOSEVIEW,
MODIFYCHANGED,
TITLECHANGED,
VISAREACHANGED,
MODECHANGED,
STORAGECHANGED,
LAST = STORAGECHANGED
};
class GlobalEventConfig_Impl;
class UNOTOOLS_DLLPUBLIC GlobalEventConfig:
public ::cppu::WeakImplHelper2 < ::com::sun::star::document::XEventsSupplier, ::com::sun::star::container::XNameReplace >
{
@ -103,7 +79,7 @@ class UNOTOOLS_DLLPUBLIC GlobalEventConfig:
sal_Bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
sal_Bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
static OUString GetEventName( sal_Int32 nID );
static OUString GetEventName( GlobalEventId nID );
private:
static GlobalEventConfig_Impl* m_pImpl;

View File

@ -564,36 +564,36 @@ ScVbaEventsHelper::~ScVbaEventsHelper()
void SAL_CALL ScVbaEventsHelper::notifyEvent( const css::document::EventObject& rEvent ) throw (css::uno::RuntimeException, std::exception)
{
static const uno::Sequence< uno::Any > saEmptyArgs;
if( (rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CREATEDOC )) ) // CREATEDOC triggered e.g. during VBA Workbooks.Add
if( (rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::OPENDOC )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::CREATEDOC )) ) // CREATEDOC triggered e.g. during VBA Workbooks.Add
{
processVbaEventNoThrow( WORKBOOK_OPEN, saEmptyArgs );
}
else if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ) )
else if( rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::ACTIVATEDOC ) )
{
processVbaEventNoThrow( WORKBOOK_ACTIVATE, saEmptyArgs );
}
else if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ) )
else if( rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::DEACTIVATEDOC ) )
{
processVbaEventNoThrow( WORKBOOK_DEACTIVATE, saEmptyArgs );
}
else if( (rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_SAVEDOCDONE )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_SAVEASDOCDONE )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_SAVETODOCDONE )) )
else if( (rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::SAVEDOCDONE )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::SAVEASDOCDONE )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::SAVETODOCDONE )) )
{
uno::Sequence< uno::Any > aArgs( 1 );
aArgs[ 0 ] <<= true;
processVbaEventNoThrow( WORKBOOK_AFTERSAVE, aArgs );
}
else if( (rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_SAVEDOCFAILED )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_SAVEASDOCFAILED )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_SAVETODOCFAILED )) )
else if( (rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::SAVEDOCFAILED )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::SAVEASDOCFAILED )) ||
(rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::SAVETODOCFAILED )) )
{
uno::Sequence< uno::Any > aArgs( 1 );
aArgs[ 0 ] <<= false;
processVbaEventNoThrow( WORKBOOK_AFTERSAVE, aArgs );
}
else if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ) )
else if( rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::CLOSEDOC ) )
{
/* Trigger the WORKBOOK_WINDOWDEACTIVATE and WORKBOOK_DEACTIVATE
events and stop listening to the model (done in base class). */
@ -606,7 +606,7 @@ void SAL_CALL ScVbaEventsHelper::notifyEvent( const css::document::EventObject&
}
processVbaEventNoThrow( WORKBOOK_DEACTIVATE, saEmptyArgs );
}
else if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ) )
else if( rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::VIEWCREATED ) )
{
uno::Reference< frame::XController > xController( mxModel->getCurrentController() );
if( mxListener.get() && xController.is() )

View File

@ -333,7 +333,7 @@ void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame )
if ( pOldContainerFrame )
{
if ( bTaskActivate )
NotifyEvent( SfxViewEventHint( SFX_EVENT_DEACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_DEACTIVATEDOC), pOldContainerFrame->GetObjectShell(), pOldContainerFrame->GetFrame().GetController() ) );
NotifyEvent( SfxViewEventHint( SFX_EVENT_DEACTIVATEDOC, GlobalEventConfig::GetEventName(GlobalEventId::DEACTIVATEDOC), pOldContainerFrame->GetObjectShell(), pOldContainerFrame->GetFrame().GetController() ) );
pOldContainerFrame->DoDeactivate( bTaskActivate, pFrame );
if( pOldContainerFrame->GetProgress() )
@ -348,7 +348,7 @@ void SfxApplication::SetViewFrame_Impl( SfxViewFrame *pFrame )
if ( bTaskActivate && pNewContainerFrame->GetObjectShell() )
{
pNewContainerFrame->GetObjectShell()->PostActivateEvent_Impl( pNewContainerFrame );
NotifyEvent(SfxViewEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName(STR_EVENT_ACTIVATEDOC), pNewContainerFrame->GetObjectShell(), pNewContainerFrame->GetFrame().GetController() ) );
NotifyEvent(SfxViewEventHint(SFX_EVENT_ACTIVATEDOC, GlobalEventConfig::GetEventName(GlobalEventId::ACTIVATEDOC), pNewContainerFrame->GetObjectShell(), pNewContainerFrame->GetFrame().GetController() ) );
}
SfxProgress *pProgress = pNewContainerFrame->GetProgress();

View File

@ -124,7 +124,7 @@ void SfxObjectShell::SetVisArea( const Rectangle & rVisArea )
if ( IsEnableSetModified() )
SetModified( true );
SfxGetpApp()->NotifyEvent(SfxEventHint( SFX_EVENT_VISAREACHANGED, GlobalEventConfig::GetEventName(STR_EVENT_VISAREACHANGED), this));
SfxGetpApp()->NotifyEvent(SfxEventHint( SFX_EVENT_VISAREACHANGED, GlobalEventConfig::GetEventName(GlobalEventId::VISAREACHANGED), this));
}
}
}

View File

@ -369,7 +369,7 @@ void SfxObjectShell::ModifyChanged()
Invalidate( SID_MACRO_SIGNATURE );
Broadcast( SfxSimpleHint( SFX_HINT_TITLECHANGED ) ); // xmlsec05, signed state might change in title...
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_MODIFYCHANGED, GlobalEventConfig::GetEventName(STR_EVENT_MODIFYCHANGED), this ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_MODIFYCHANGED, GlobalEventConfig::GetEventName(GlobalEventId::MODIFYCHANGED), this ) );
}
@ -1030,9 +1030,9 @@ void SfxObjectShell::PostActivateEvent_Impl( SfxViewFrame* pFrame )
sal_uInt16 nId = pImp->nEventId;
pImp->nEventId = 0;
if ( nId == SFX_EVENT_OPENDOC )
pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_OPENDOC), this, pFrame->GetFrame().GetController() ), false);
pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(GlobalEventId::OPENDOC), this, pFrame->GetFrame().GetController() ), false);
else if (nId == SFX_EVENT_CREATEDOC )
pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(STR_EVENT_CREATEDOC), this, pFrame->GetFrame().GetController() ), false);
pSfxApp->NotifyEvent(SfxViewEventHint( nId, GlobalEventConfig::GetEventName(GlobalEventId::CREATEDOC), this, pFrame->GetFrame().GetController() ), false);
}
}
}

View File

@ -3115,7 +3115,7 @@ uno::Reference< embed::XStorage > SfxObjectShell::GetStorage()
SetupStorage( pImp->m_xDocStorage, SOFFICE_FILEFORMAT_CURRENT, false, false );
pImp->m_bCreateTempStor = false;
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, GlobalEventConfig::GetEventName(STR_EVENT_STORAGECHANGED), this ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, GlobalEventConfig::GetEventName(GlobalEventId::STORAGECHANGED), this ) );
}
catch( uno::Exception& )
{
@ -3266,7 +3266,7 @@ bool SfxObjectShell::SaveCompleted( const uno::Reference< embed::XStorage >& xSt
if ( bSendNotification )
{
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, GlobalEventConfig::GetEventName(STR_EVENT_STORAGECHANGED), this ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_STORAGECHANGED, GlobalEventConfig::GetEventName(GlobalEventId::STORAGECHANGED), this ) );
}
return bResult;

View File

@ -607,7 +607,7 @@ bool SfxObjectShell::PrepareClose
}
SfxApplication *pSfxApp = SfxGetpApp();
pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(STR_EVENT_PREPARECLOSEDOC), this) );
pSfxApp->NotifyEvent( SfxEventHint(SFX_EVENT_PREPARECLOSEDOC, GlobalEventConfig::GetEventName(GlobalEventId::PREPARECLOSEDOC), this) );
if( GetCreateMode() == SfxObjectCreateMode::EMBEDDED )
{
@ -1155,11 +1155,11 @@ void SfxObjectShell::SetInitialized_Impl( const bool i_fromInitNew )
if ( i_fromInitNew )
{
SetActivateEvent_Impl( SFX_EVENT_CREATEDOC );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(STR_EVENT_DOCCREATED), this ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_DOCCREATED, GlobalEventConfig::GetEventName(GlobalEventId::DOCCREATED), this ) );
}
else
{
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(STR_EVENT_LOADFINISHED), this ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_LOADFINISHED, GlobalEventConfig::GetEventName(GlobalEventId::LOADFINISHED), this ) );
}
}

View File

@ -1576,7 +1576,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue >
SfxAllItemSet *pParams = new SfxAllItemSet( SfxGetpApp()->GetPool() );
TransformParameters( nSlotId, aArgs, *pParams );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOC, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOC), m_pData->m_pObjectShell ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOC, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOC), m_pData->m_pObjectShell ) );
bool bRet = false;
@ -1617,7 +1617,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue >
m_pData->m_pObjectShell->AddLog( OUString( OSL_LOG_PREFIX "successful saving." ) );
m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl();
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOCDONE), m_pData->m_pObjectShell ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCDONE, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOCDONE), m_pData->m_pObjectShell ) );
}
else
{
@ -1625,7 +1625,7 @@ void SAL_CALL SfxBaseModel::storeSelf( const Sequence< beans::PropertyValue >
m_pData->m_pObjectShell->StoreLog();
// write the contents of the logger to the file
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCFAILED, GlobalEventConfig::GetEventName(STR_EVENT_SAVEDOCFAILED), m_pData->m_pObjectShell ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEDOCFAILED, GlobalEventConfig::GetEventName(GlobalEventId::SAVEDOCFAILED), m_pData->m_pObjectShell ) );
throw task::ErrorCodeIOException(
"SfxBaseModel::storeSelf: 0x" + OUString::number(nErrCode, 16),
@ -2831,11 +2831,11 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
{
OUString aTitle = m_pData->m_pObjectShell->GetTitle();
addTitle_Impl( m_pData->m_seqArguments, aTitle );
postEvent_Impl( GlobalEventConfig::GetEventName( STR_EVENT_TITLECHANGED ) );
postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::TITLECHANGED ) );
}
if ( pSimpleHint->GetId() == SFX_HINT_MODECHANGED )
{
postEvent_Impl( GlobalEventConfig::GetEventName( STR_EVENT_MODECHANGED ) );
postEvent_Impl( GlobalEventConfig::GetEventName( GlobalEventId::MODECHANGED ) );
}
}
}
@ -3008,7 +3008,7 @@ void SfxBaseModel::impl_store( const OUString& sURL
if ( !bSaved && m_pData->m_pObjectShell )
{
SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOC : SFX_EVENT_SAVEASDOC, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOC : STR_EVENT_SAVEASDOC ),
SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOC : SFX_EVENT_SAVEASDOC, GlobalEventConfig::GetEventName( bSaveTo ? GlobalEventId::SAVETODOC : GlobalEventId::SAVEASDOC ),
m_pData->m_pObjectShell ) );
SfxAllItemSet *aParams = new SfxAllItemSet( SfxGetpApp()->GetPool() );
@ -3108,14 +3108,14 @@ void SfxBaseModel::impl_store( const OUString& sURL
m_pData->m_aPreusedFilterName = GetMediumFilterName_Impl();
m_pData->m_pObjectShell->SetModifyPasswordEntered();
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEASDOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVEASDOCDONE), m_pData->m_pObjectShell ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVEASDOCDONE, GlobalEventConfig::GetEventName(GlobalEventId::SAVEASDOCDONE), m_pData->m_pObjectShell ) );
}
else
{
m_pData->m_pObjectShell->SetModifyPasswordHash( nOldModifyPasswordHash );
m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, GlobalEventConfig::GetEventName(STR_EVENT_SAVETODOCDONE), m_pData->m_pObjectShell ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_SAVETODOCDONE, GlobalEventConfig::GetEventName(GlobalEventId::SAVETODOCDONE), m_pData->m_pObjectShell ) );
}
}
else
@ -3128,7 +3128,7 @@ void SfxBaseModel::impl_store( const OUString& sURL
m_pData->m_pObjectShell->SetModifyPasswordInfo( aOldModifyPasswordInfo );
SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? STR_EVENT_SAVETODOCFAILED : STR_EVENT_SAVEASDOCFAILED),
SfxGetpApp()->NotifyEvent( SfxEventHint( bSaveTo ? SFX_EVENT_SAVETODOCFAILED : SFX_EVENT_SAVEASDOCFAILED, GlobalEventConfig::GetEventName( bSaveTo ? GlobalEventId::SAVETODOCFAILED : GlobalEventId::SAVEASDOCFAILED),
m_pData->m_pObjectShell ) );
throw task::ErrorCodeIOException(

View File

@ -207,7 +207,7 @@ bool SfxFrame::PrepareClose_Impl( bool bUI )
bOther = ( &pFrame->GetFrame() != this );
}
SfxGetpApp()->NotifyEvent( SfxViewEventHint(SFX_EVENT_PREPARECLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEVIEW ), pCur, GetController() ) );
SfxGetpApp()->NotifyEvent( SfxViewEventHint(SFX_EVENT_PREPARECLOSEVIEW, GlobalEventConfig::GetEventName( GlobalEventId::PREPARECLOSEVIEW ), pCur, GetController() ) );
if ( bOther )
// if there are other views only the current view of this frame must be asked

View File

@ -571,7 +571,7 @@ void SAL_CALL SfxBaseController::attachFrame( const Reference< frame::XFrame >&
ShowInfoBars( );
// attaching the frame to the controller is the last step in the creation of a new view, so notify this
SfxViewEventHint aHint( SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( STR_EVENT_VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell(), Reference< frame::XController2 >( this ) );
SfxViewEventHint aHint( SFX_EVENT_VIEWCREATED, GlobalEventConfig::GetEventName( GlobalEventId::VIEWCREATED ), m_pData->m_pViewShell->GetObjectShell(), Reference< frame::XController2 >( this ) );
SfxGetpApp()->NotifyEvent( aHint );
}
}
@ -1000,9 +1000,9 @@ void SAL_CALL SfxBaseController::dispose() throw( RuntimeException, std::excepti
pView = SfxViewFrame::GetNext( *pView, pDoc );
}
SfxGetpApp()->NotifyEvent( SfxViewEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEVIEW ), pDoc, Reference< frame::XController2 >( this ) ) );
SfxGetpApp()->NotifyEvent( SfxViewEventHint(SFX_EVENT_CLOSEVIEW, GlobalEventConfig::GetEventName( GlobalEventId::CLOSEVIEW ), pDoc, Reference< frame::XController2 >( this ) ) );
if ( !pView )
SfxGetpApp()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), pDoc) );
SfxGetpApp()->NotifyEvent( SfxEventHint(SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( GlobalEventId::CLOSEDOC ), pDoc) );
Reference< frame::XModel > xModel = pDoc->GetModel();
Reference < util::XCloseable > xCloseable( xModel, uno::UNO_QUERY );

View File

@ -822,7 +822,7 @@ void SfxViewFrame::ExecReload_Impl( SfxRequest& rReq )
}
// Propagate document closure.
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ), xOldObj ) );
SfxGetpApp()->NotifyEvent( SfxEventHint( SFX_EVENT_CLOSEDOC, GlobalEventConfig::GetEventName( GlobalEventId::CLOSEDOC ), xOldObj ) );
}
// Record as done

View File

@ -316,7 +316,7 @@ void SfxPrinterController::jobStarted()
xDocProps->setPrintDate( now.GetUNODateTime() );
SfxGetpApp()->NotifyEvent( SfxEventHint(SFX_EVENT_PRINTDOC, GlobalEventConfig::GetEventName( STR_EVENT_PRINTDOC ), mpObjectShell ) );
SfxGetpApp()->NotifyEvent( SfxEventHint(SFX_EVENT_PRINTDOC, GlobalEventConfig::GetEventName( GlobalEventId::PRINTDOC ), mpObjectShell ) );
uno::Sequence < beans::PropertyValue > aOpts;
aOpts = getJobProperties( aOpts );

View File

@ -171,7 +171,7 @@ void SmDocShell::SetText(const OUString& rBuffer)
// have SwOleClient::FormatChanged() to align the modified formula properly
// even if the vis area does not change (e.g. when formula text changes from
// "{a over b + c} over d" to "d over {a over b + c}"
SfxGetpApp()->NotifyEvent(SfxEventHint( SFX_EVENT_VISAREACHANGED, GlobalEventConfig::GetEventName(STR_EVENT_VISAREACHANGED), this));
SfxGetpApp()->NotifyEvent(SfxEventHint( SFX_EVENT_VISAREACHANGED, GlobalEventConfig::GetEventName(GlobalEventId::VISAREACHANGED), this));
Repaint();
}

View File

@ -882,7 +882,7 @@ void SwHTMLParser::InsertBodyOptions()
eScriptType2 = STARBASIC;
//fallthrough
case HTML_O_ONLOAD:
aEvent = GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC );
aEvent = GlobalEventConfig::GetEventName( GlobalEventId::OPENDOC );
bSetEvent = true;
break;
@ -890,7 +890,7 @@ void SwHTMLParser::InsertBodyOptions()
eScriptType2 = STARBASIC;
//fallthrough
case HTML_O_ONUNLOAD:
aEvent = GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC );
aEvent = GlobalEventConfig::GetEventName( GlobalEventId::PREPARECLOSEDOC );
bSetEvent = true;
break;
@ -898,7 +898,7 @@ void SwHTMLParser::InsertBodyOptions()
eScriptType2 = STARBASIC;
//fallthrough
case HTML_O_ONFOCUS:
aEvent = GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC );
aEvent = GlobalEventConfig::GetEventName( GlobalEventId::ACTIVATEDOC );
bSetEvent = true;
break;
@ -906,7 +906,7 @@ void SwHTMLParser::InsertBodyOptions()
eScriptType2 = STARBASIC;
//fallthrough
case HTML_O_ONBLUR:
aEvent = GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC );
aEvent = GlobalEventConfig::GetEventName( GlobalEventId::DEACTIVATEDOC );
bSetEvent = true;
break;

View File

@ -657,10 +657,10 @@ void SwDocShell::Execute(SfxRequest& rReq)
pSrcView->SaveContent(aTempFile.GetURL());
bDone = true;
SvxMacro aMac(aEmptyOUStr, aEmptyOUStr, STARBASIC);
SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_OPENDOC ), aMac, this);
SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_PREPARECLOSEDOC ), aMac, this);
SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_ACTIVATEDOC ), aMac, this);
SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( STR_EVENT_DEACTIVATEDOC ), aMac, this);
SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( GlobalEventId::OPENDOC ), aMac, this);
SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( GlobalEventId::PREPARECLOSEDOC ), aMac, this);
SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( GlobalEventId::ACTIVATEDOC ), aMac, this);
SfxEventConfiguration::ConfigureEvent(GlobalEventConfig::GetEventName( GlobalEventId::DEACTIVATEDOC ), aMac, this);
ReloadFromHtml(aTempFile.GetURL(), pSrcView);
nSlot = 0;
}

View File

@ -24,6 +24,8 @@
#include <com/sun/star/uno/Sequence.hxx>
#include <com/sun/star/beans/PropertyValue.hpp>
#include <cppuhelper/weakref.hxx>
#include <o3tl/enumarray.hxx>
#include <o3tl/enumrange.hxx>
#include <rtl/ustrbuf.hxx>
#include <osl/diagnose.h>
@ -43,7 +45,7 @@ static const char ROOTNODE_EVENTS[] = "Office.Events/ApplicationEvents";
#define SETNODE_BINDINGS "Bindings"
#define PROPERTYNAME_BINDINGURL "BindingURL"
const char* pEventAsciiNames[] =
static o3tl::enumarray<GlobalEventId, const char*> pEventAsciiNames =
{
"OnStartApp",
"OnCloseApp",
@ -75,38 +77,43 @@ const char* pEventAsciiNames[] =
"OnStorageChanged"
};
typedef std::unordered_map< OUString, OUString, OUStringHash, std::equal_to< OUString > > EventBindingHash;
typedef std::vector< css::uno::WeakReference< css::frame::XFrame > > FrameVector;
typedef o3tl::enumarray< GlobalEventId, OUString > SupportedEventsVector;
class GlobalEventConfig_Impl : public utl::ConfigItem
{
private:
EventBindingHash m_eventBindingHash;
FrameVector m_lFrames;
SupportedEventsVector m_supportedEvents;
void initBindingInfo();
virtual void ImplCommit() SAL_OVERRIDE;
public:
GlobalEventConfig_Impl( );
virtual ~GlobalEventConfig_Impl( );
void Notify( const com::sun::star::uno::Sequence<OUString>& aPropertyNames) SAL_OVERRIDE;
void SAL_CALL replaceByName( const OUString& aName, const ::com::sun::star::uno::Any& aElement ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Any SAL_CALL getByName( const OUString& aName ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Sequence< OUString > SAL_CALL getElementNames( ) throw (::com::sun::star::uno::RuntimeException);
bool SAL_CALL hasByName( const OUString& aName ) throw (::com::sun::star::uno::RuntimeException);
::com::sun::star::uno::Type SAL_CALL getElementType( ) throw (::com::sun::star::uno::RuntimeException);
bool SAL_CALL hasElements( ) throw (::com::sun::star::uno::RuntimeException);
OUString GetEventName( GlobalEventId nID );
};
GlobalEventConfig_Impl::GlobalEventConfig_Impl()
: ConfigItem( ROOTNODE_EVENTS, CONFIG_MODE_IMMEDIATE_UPDATE )
{
// the supported event names
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_STARTAPP] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_CLOSEAPP] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_DOCCREATED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_CREATEDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_LOADFINISHED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_OPENDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_PREPARECLOSEDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_CLOSEDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVEDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVEDOCDONE] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVEDOCFAILED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVEASDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVEASDOCDONE] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVEASDOCFAILED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVETODOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVETODOCDONE] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_SAVETODOCFAILED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_ACTIVATEDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_DEACTIVATEDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_PRINTDOC] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_VIEWCREATED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_PREPARECLOSEVIEW] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_CLOSEVIEW] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_MODIFYCHANGED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_TITLECHANGED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_VISAREACHANGED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_MODECHANGED] ) );
m_supportedEvents.push_back(OUString::createFromAscii( pEventAsciiNames[STR_EVENT_STORAGECHANGED] ) );
for (GlobalEventId id : o3tl::enumrange<GlobalEventId>())
m_supportedEvents[id] = OUString::createFromAscii( pEventAsciiNames[id] );
initBindingInfo();
@ -125,12 +132,9 @@ GlobalEventConfig_Impl::~GlobalEventConfig_Impl()
assert(!IsModified()); // should have been committed
}
OUString GlobalEventConfig_Impl::GetEventName( sal_Int32 nIndex )
OUString GlobalEventConfig_Impl::GetEventName( GlobalEventId nIndex )
{
if ( nIndex < (sal_Int32) m_supportedEvents.size() )
return m_supportedEvents[nIndex];
else
return OUString();
}
// public method
@ -257,7 +261,7 @@ Any SAL_CALL GlobalEventConfig_Impl::getByName( const OUString& aName ) throw (c
else
{
// not yet accessed - is it a supported name?
SupportedEventsVector::const_iterator pos = ::std::find(
SupportedEventsVector::iterator pos = ::std::find(
m_supportedEvents.begin(), m_supportedEvents.end(), aName );
if ( pos == m_supportedEvents.end() )
throw container::NoSuchElementException( aName );
@ -270,7 +274,7 @@ Any SAL_CALL GlobalEventConfig_Impl::getByName( const OUString& aName ) throw (c
Sequence< OUString > SAL_CALL GlobalEventConfig_Impl::getElementNames( ) throw (RuntimeException)
{
return uno::Sequence< OUString >(m_supportedEvents.data(), m_supportedEvents.size());
return uno::Sequence< OUString >(m_supportedEvents.data(), SupportedEventsVector::size());
}
bool SAL_CALL GlobalEventConfig_Impl::hasByName( const OUString& aName ) throw (RuntimeException)
@ -279,7 +283,7 @@ bool SAL_CALL GlobalEventConfig_Impl::hasByName( const OUString& aName ) throw (
return true;
// never accessed before - is it supported in general?
SupportedEventsVector::const_iterator pos = ::std::find(
SupportedEventsVector::iterator pos = ::std::find(
m_supportedEvents.begin(), m_supportedEvents.end(), aName );
if ( pos != m_supportedEvents.end() )
return true;
@ -381,7 +385,7 @@ Mutex& GlobalEventConfig::GetOwnStaticMutex()
return theGlobalEventConfigMutex::get();
}
OUString GlobalEventConfig::GetEventName( sal_Int32 nIndex )
OUString GlobalEventConfig::GetEventName( GlobalEventId nIndex )
{
return GlobalEventConfig().m_pImpl->GetEventName( nIndex );
}

View File

@ -132,7 +132,7 @@ sal_Bool SAL_CALL VbaEventsHelperBase::processVbaEvent( sal_Int32 nEventId, cons
void SAL_CALL VbaEventsHelperBase::notifyEvent( const document::EventObject& rEvent ) throw (uno::RuntimeException, std::exception)
{
SAL_INFO("vbahelper", "VbaEventsHelperBase::notifyEvent( \"" << rEvent.EventName << "\" )");
if( rEvent.EventName == GlobalEventConfig::GetEventName( STR_EVENT_CLOSEDOC ) )
if( rEvent.EventName == GlobalEventConfig::GetEventName( GlobalEventId::CLOSEDOC ) )
stopListening();
}