summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2014-08-27 16:57:21 +0200
committerNorbert Thiebaud <nthiebaud@gmail.com>2014-09-06 15:47:44 -0500
commit5bce32904091ffe28884fd5c0f4801ee82bad101 (patch)
treefc2573078a858de456a0dc7b7810176d433241c7 /sfx2
parent10143717834d8401d85fdf9564e782a58b9983ec (diff)
SfxHint: convert home-grown RTTI to normal C++ RTTI
Also note that I fixed a bug in SvxFontMenuControl::Notify where the if statement had the check the wrong way around. Change-Id: I611e8929c65818191e36bd80f2b985820ada4411 Reviewed-on: https://gerrit.libreoffice.org/11147 Reviewed-by: Norbert Thiebaud <nthiebaud@gmail.com> Tested-by: Norbert Thiebaud <nthiebaud@gmail.com>
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/appl/appcfg.cxx2
-rw-r--r--sfx2/source/appl/sfxpicklist.cxx9
-rw-r--r--sfx2/source/config/evntconf.cxx2
-rw-r--r--sfx2/source/control/request.cxx2
-rw-r--r--sfx2/source/dialog/basedlgs.cxx10
-rw-r--r--sfx2/source/dialog/templdlg.cxx13
-rw-r--r--sfx2/source/doc/printhelper.cxx2
-rw-r--r--sfx2/source/doc/sfxbasemodel.cxx6
-rw-r--r--sfx2/source/view/viewfrm.cxx15
-rw-r--r--sfx2/source/view/viewprn.cxx7
-rw-r--r--sfx2/source/view/viewsh.cxx5
11 files changed, 38 insertions, 35 deletions
diff --git a/sfx2/source/appl/appcfg.cxx b/sfx2/source/appl/appcfg.cxx
index 23d464219295..8ced478adf56 100644
--- a/sfx2/source/appl/appcfg.cxx
+++ b/sfx2/source/appl/appcfg.cxx
@@ -97,7 +97,7 @@ public:
void SfxEventAsyncer_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
- SfxSimpleHint* pHint = PTR_CAST( SfxSimpleHint, &rHint );
+ const SfxSimpleHint* pHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
if( pHint && pHint->GetId() == SFX_HINT_DYING && pTimer->IsActive() )
{
pTimer->Stop();
diff --git a/sfx2/source/appl/sfxpicklist.cxx b/sfx2/source/appl/sfxpicklist.cxx
index bd965ad423e4..115c95451681 100644
--- a/sfx2/source/appl/sfxpicklist.cxx
+++ b/sfx2/source/appl/sfxpicklist.cxx
@@ -365,17 +365,16 @@ void SfxPickList::ExecuteMenuEntry( sal_uInt16 nId )
void SfxPickList::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
- if ( rHint.IsA( TYPE( SfxStringHint )))
+ const SfxStringHint* pStringHint = dynamic_cast<const SfxStringHint*>(&rHint);
+ if ( pStringHint )
{
- SfxStringHint* pStringHint = (SfxStringHint*) &rHint;
-
if ( pStringHint->GetId() == SID_OPENURL )
INetURLHistory::GetOrCreate()->PutUrl( INetURLObject( pStringHint->GetObject() ));
}
- if ( rHint.IsA( TYPE( SfxEventHint )))
+ const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
+ if ( pEventHint )
{
- SfxEventHint* pEventHint = PTR_CAST(SfxEventHint,&rHint);
// only ObjectShell-related events with media interest
SfxObjectShell* pDocSh = pEventHint ? pEventHint->GetObjShell() : NULL;
if( !pDocSh )
diff --git a/sfx2/source/config/evntconf.cxx b/sfx2/source/config/evntconf.cxx
index 9c43b48a5d46..33dfd04b1c73 100644
--- a/sfx2/source/config/evntconf.cxx
+++ b/sfx2/source/config/evntconf.cxx
@@ -49,9 +49,7 @@
#include <com/sun/star/uno/Reference.hxx>
-TYPEINIT1(SfxEventHint, SfxHint);
TYPEINIT1(SfxEventNamesItem, SfxPoolItem);
-TYPEINIT1(SfxViewEventHint, SfxEventHint);
using namespace com::sun::star;
diff --git a/sfx2/source/control/request.cxx b/sfx2/source/control/request.cxx
index a98302b79fcc..47031aab3cbd 100644
--- a/sfx2/source/control/request.cxx
+++ b/sfx2/source/control/request.cxx
@@ -98,7 +98,7 @@ struct SfxRequest_Impl: public SfxListener
void SfxRequest_Impl::Notify( SfxBroadcaster&, const SfxHint &rHint )
{
- SfxSimpleHint *pSimpleHint = PTR_CAST(SfxSimpleHint, &rHint);
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DYING )
pAnti->Cancel();
}
diff --git a/sfx2/source/dialog/basedlgs.cxx b/sfx2/source/dialog/basedlgs.cxx
index 59ea7c2ceab6..9bb8497cb81d 100644
--- a/sfx2/source/dialog/basedlgs.cxx
+++ b/sfx2/source/dialog/basedlgs.cxx
@@ -58,9 +58,10 @@ public:
void SfxModelessDialog_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
- if ( rHint.IsA(TYPE(SfxSimpleHint)) )
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if ( pSimpleHint )
{
- switch( ( (SfxSimpleHint&) rHint ).GetId() )
+ switch( pSimpleHint->GetId() )
{
case SFX_HINT_DYING:
pMgr->Destroy();
@@ -82,9 +83,10 @@ public:
void SfxFloatingWindow_Impl::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
- if ( rHint.IsA(TYPE(SfxSimpleHint)) )
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if ( pSimpleHint )
{
- switch( ( (SfxSimpleHint&) rHint ).GetId() )
+ switch( pSimpleHint->GetId() )
{
case SFX_HINT_DYING:
pMgr->Destroy();
diff --git a/sfx2/source/dialog/templdlg.cxx b/sfx2/source/dialog/templdlg.cxx
index 6c428468373d..5cf9fa7e3065 100644
--- a/sfx2/source/dialog/templdlg.cxx
+++ b/sfx2/source/dialog/templdlg.cxx
@@ -1572,9 +1572,10 @@ IMPL_LINK( SfxCommonTemplateDialog_Impl, TimeOut, Timer *, pTim )
void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint& rHint)
{
// tap update
- if(rHint.Type() == TYPE(SfxSimpleHint))
+ const SfxSimpleHint* pSfxSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if(pSfxSimpleHint)
{
- switch(((SfxSimpleHint&) rHint ).GetId())
+ switch(pSfxSimpleHint->GetId())
{
case SFX_HINT_UPDATEDONE:
{
@@ -1644,12 +1645,12 @@ void SfxCommonTemplateDialog_Impl::Notify(SfxBroadcaster& /*rBC*/, const SfxHint
// possible that a new one is registered after the timer is up -
// works bad in UpdateStyles_Impl ()!
- sal_uIntPtr nId = rHint.ISA(SfxSimpleHint) ? ( (SfxSimpleHint&)rHint ).GetId() : 0;
+ sal_uIntPtr nId = pSfxSimpleHint ? pSfxSimpleHint->GetId() : 0;
if(!bDontUpdate && nId != SFX_HINT_DYING &&
- (rHint.Type() == TYPE(SfxStyleSheetPoolHint)||
- rHint.Type() == TYPE(SfxStyleSheetHint) ||
- rHint.Type() == TYPE( SfxStyleSheetHintExtended )))
+ (dynamic_cast<const SfxStyleSheetPoolHint*>(&rHint) ||
+ dynamic_cast<const SfxStyleSheetHint*>(&rHint) ||
+ dynamic_cast<const SfxStyleSheetHintExtended*>(&rHint)))
{
if(!pTimer)
{
diff --git a/sfx2/source/doc/printhelper.cxx b/sfx2/source/doc/printhelper.cxx
index 70590590b0ef..ab3c4049a932 100644
--- a/sfx2/source/doc/printhelper.cxx
+++ b/sfx2/source/doc/printhelper.cxx
@@ -795,7 +795,7 @@ void SAL_CALL SfxPrintHelper::print(const uno::Sequence< beans::PropertyValue >&
void IMPL_PrintListener_DataContainer::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- SfxPrintingHint* pPrintHint = PTR_CAST( SfxPrintingHint, &rHint );
+ const SfxPrintingHint* pPrintHint = dynamic_cast<const SfxPrintingHint*>(&rHint);
if ( &rBC != m_pObjectShell
|| !pPrintHint
|| pPrintHint->GetWhich() == SFX_PRINTABLESTATE_CANCELJOB )
diff --git a/sfx2/source/doc/sfxbasemodel.cxx b/sfx2/source/doc/sfxbasemodel.cxx
index eac066e2fb72..8defb3e522f1 100644
--- a/sfx2/source/doc/sfxbasemodel.cxx
+++ b/sfx2/source/doc/sfxbasemodel.cxx
@@ -2746,11 +2746,11 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
if ( &rBC == m_pData->m_pObjectShell )
{
- SfxSimpleHint* pSimpleHint = PTR_CAST( SfxSimpleHint, &rHint );
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
if ( pSimpleHint && pSimpleHint->GetId() == SFX_HINT_DOCCHANGED )
changing();
- SfxEventHint* pNamedHint = PTR_CAST( SfxEventHint, &rHint );
+ const SfxEventHint* pNamedHint = dynamic_cast<const SfxEventHint*>(&rHint);
if ( pNamedHint )
{
@@ -2819,7 +2819,7 @@ void SfxBaseModel::Notify( SfxBroadcaster& rBC ,
}
- SfxViewEventHint* pViewHint = PTR_CAST( SfxViewEventHint, &rHint );
+ const SfxViewEventHint* pViewHint = dynamic_cast<const SfxViewEventHint*>(&rHint);
postEvent_Impl( pNamedHint->GetEventName(), pViewHint ? pViewHint->GetController() : Reference< frame::XController2 >() );
}
diff --git a/sfx2/source/view/viewfrm.cxx b/sfx2/source/view/viewfrm.cxx
index 479dde2f9022..0a89ad9d3dda 100644
--- a/sfx2/source/view/viewfrm.cxx
+++ b/sfx2/source/view/viewfrm.cxx
@@ -245,9 +245,10 @@ public:
void SfxViewNotificatedFrameList_Impl::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- if ( rHint.IsA(TYPE(SfxSimpleHint)) )
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if ( pSimpleHint )
{
- switch( ( (SfxSimpleHint&) rHint ).GetId() )
+ switch( pSimpleHint->GetId() )
{
case SFX_HINT_DYING:
SfxViewFrame* pFrame = (SfxViewFrame*) &rBC;
@@ -1261,9 +1262,10 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
return;
// we know only SimpleHints
- if ( rHint.IsA(TYPE(SfxSimpleHint)) )
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if ( pSimpleHint )
{
- switch( ( (SfxSimpleHint&) rHint ).GetId() )
+ switch( pSimpleHint->GetId() )
{
case SFX_HINT_MODECHANGED:
{
@@ -1327,12 +1329,13 @@ void SfxViewFrame::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
}
}
- else if ( rHint.IsA(TYPE(SfxEventHint)) )
+ else if ( dynamic_cast<const SfxEventHint*>(&rHint) )
{
+ const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
// When the Document is loaded asynchronously, was the Dispatcher
// set as ReadOnly, to what must be returned when the document itself
// is not read only, and the loading is finished.
- switch ( ((SfxEventHint&)rHint).GetEventId() )
+ switch ( pEventHint->GetEventId() )
{
case SFX_EVENT_MODIFYCHANGED:
{
diff --git a/sfx2/source/view/viewprn.cxx b/sfx2/source/view/viewprn.cxx
index 56ac2e64e931..1463248fc425 100644
--- a/sfx2/source/view/viewprn.cxx
+++ b/sfx2/source/view/viewprn.cxx
@@ -54,8 +54,6 @@
using namespace com::sun::star;
using namespace com::sun::star::uno;
-TYPEINIT1(SfxPrintingHint, SfxViewEventHint);
-
class SfxPrinterController : public vcl::PrinterController, public SfxListener
{
Any maCompleteSelection;
@@ -170,9 +168,10 @@ SfxPrinterController::SfxPrinterController( const boost::shared_ptr<Printer>& i_
void SfxPrinterController::Notify( SfxBroadcaster& , const SfxHint& rHint )
{
- if ( rHint.IsA(TYPE(SfxSimpleHint)) )
+ const SfxSimpleHint* pSimpleHint = dynamic_cast<const SfxSimpleHint*>(&rHint);
+ if ( pSimpleHint )
{
- if ( ((SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING )
+ if ( pSimpleHint->GetId() == SFX_HINT_DYING )
{
EndListening(*mpViewShell);
EndListening(*mpObjectShell);
diff --git a/sfx2/source/view/viewsh.cxx b/sfx2/source/view/viewsh.cxx
index e02c25f00321..9b40bb40f6de 100644
--- a/sfx2/source/view/viewsh.cxx
+++ b/sfx2/source/view/viewsh.cxx
@@ -1560,9 +1560,10 @@ SfxViewShell* SfxViewShell::GetNext
void SfxViewShell::Notify( SfxBroadcaster& rBC,
const SfxHint& rHint )
{
- if ( rHint.IsA(TYPE(SfxEventHint)) )
+ const SfxEventHint* pEventHint = dynamic_cast<const SfxEventHint*>(&rHint);
+ if ( pEventHint )
{
- switch ( ((SfxEventHint&)rHint).GetEventId() )
+ switch ( pEventHint->GetEventId() )
{
case SFX_EVENT_LOADFINISHED:
{