IDE: PTR_CAST, ISA to dynamic_cast

Convert the obsolete PTR_CAST and ISA macros (from tools/rtti.hxx) to
C++ dynamic_cast is basctl.

Change-Id: I45530d1d34d132904f812e238ee3b59b1a4f227b
This commit is contained in:
Uray M. János
2012-08-07 14:33:56 +02:00
committed by Tor Lillqvist
parent 69a70bf028
commit 51bb488ac1
18 changed files with 240 additions and 360 deletions

View File

@@ -121,9 +121,7 @@ AccessibleDialogWindow::AccessibleDialogWindow( DialogWindow* pDialogWindow )
for ( sal_uLong i = 0; i < nCount; ++i ) for ( sal_uLong i = 0; i < nCount; ++i )
{ {
SdrObject* pObj = pSdrPage->GetObj( i ); if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrPage->GetObj(i)))
DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
if ( pDlgEdObj )
{ {
ChildDescriptor aDesc( pDlgEdObj ); ChildDescriptor aDesc( pDlgEdObj );
if ( IsChildVisible( aDesc ) ) if ( IsChildVisible( aDesc ) )
@@ -341,16 +339,11 @@ void AccessibleDialogWindow::UpdateChildren()
{ {
if ( m_pDialogWindow ) if ( m_pDialogWindow )
{ {
SdrPage* pSdrPage = m_pDialogWindow->GetPage(); if (SdrPage* pSdrPage = m_pDialogWindow->GetPage())
if ( pSdrPage )
{ {
for ( sal_uLong i = 0, nCount = pSdrPage->GetObjCount(); i < nCount; ++i ) for ( sal_uLong i = 0, nCount = pSdrPage->GetObjCount(); i < nCount; ++i )
{ if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrPage->GetObj(i)))
SdrObject* pObj = pSdrPage->GetObj( i );
DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
if ( pDlgEdObj )
UpdateChild( ChildDescriptor( pDlgEdObj ) ); UpdateChild( ChildDescriptor( pDlgEdObj ) );
}
} }
} }
} }
@@ -368,17 +361,15 @@ void AccessibleDialogWindow::SortChildren()
IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclSimpleEvent*, pEvent ) IMPL_LINK( AccessibleDialogWindow, WindowEventListener, VclSimpleEvent*, pEvent )
{ {
DBG_CHKTHIS( AccessibleDialogWindow, 0 ); DBG_CHKTHIS( AccessibleDialogWindow, 0 );
DBG_ASSERT( pEvent && pEvent->ISA( VclWindowEvent ), "AccessibleDialogWindow::WindowEventListener: unknown window event!" );
if ( pEvent && pEvent->ISA( VclWindowEvent ) ) if (VclWindowEvent* pWinEvent = dynamic_cast<VclWindowEvent*>(pEvent))
{ {
DBG_ASSERT( ((VclWindowEvent*)pEvent)->GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!" ); DBG_ASSERT(pWinEvent->GetWindow(), "AccessibleDialogWindow::WindowEventListener: no window!");
if ( !((VclWindowEvent*)pEvent)->GetWindow()->IsAccessibilityEventsSuppressed() || ( pEvent->GetId() == VCLEVENT_OBJECT_DYING ) ) if (!pWinEvent->GetWindow()->IsAccessibilityEventsSuppressed() || pEvent->GetId() == VCLEVENT_OBJECT_DYING)
{ ProcessWindowEvent(*pWinEvent);
ProcessWindowEvent( *(VclWindowEvent*)pEvent );
}
} }
else
DBG_ASSERT(false, "AccessibleDialogWindow::WindowEventListener: unknown window event!");
return 0; return 0;
} }
@@ -522,16 +513,13 @@ awt::Rectangle AccessibleDialogWindow::implGetBounds() throw (RuntimeException)
void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint ) void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
{ {
if ( rHint.ISA( SdrHint ) ) if (SdrHint* pSdrHint = dynamic_cast<SdrHint*>(&rHint))
{ {
SdrHint* pSdrHint = (SdrHint*)&rHint;
switch ( pSdrHint->GetKind() ) switch ( pSdrHint->GetKind() )
{ {
case HINT_OBJINSERTED: case HINT_OBJINSERTED:
{ {
SdrObject* pObj = (SdrObject*)pSdrHint->GetObject(); if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrHint->GetObject()))
DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
if ( pDlgEdObj )
{ {
ChildDescriptor aDesc( pDlgEdObj ); ChildDescriptor aDesc( pDlgEdObj );
if ( IsChildVisible( aDesc ) ) if ( IsChildVisible( aDesc ) )
@@ -541,18 +529,15 @@ void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
break; break;
case HINT_OBJREMOVED: case HINT_OBJREMOVED:
{ {
SdrObject* pObj = (SdrObject*)pSdrHint->GetObject(); if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrHint->GetObject()))
DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj );
if ( pDlgEdObj )
RemoveChild( ChildDescriptor( pDlgEdObj ) ); RemoveChild( ChildDescriptor( pDlgEdObj ) );
} }
break; break;
default: ; default: ;
} }
} }
else if ( rHint.ISA( DlgEdHint ) ) else if (DlgEdHint* pDlgEdHint = dynamic_cast<DlgEdHint*>(&rHint))
{ {
DlgEdHint* pDlgEdHint = (DlgEdHint*)&rHint;
switch ( pDlgEdHint->GetKind() ) switch ( pDlgEdHint->GetKind() )
{ {
case DLGED_HINT_WINDOWSCROLLED: case DLGED_HINT_WINDOWSCROLLED:
@@ -563,8 +548,7 @@ void AccessibleDialogWindow::Notify( SfxBroadcaster&, const SfxHint& rHint )
break; break;
case DLGED_HINT_LAYERCHANGED: case DLGED_HINT_LAYERCHANGED:
{ {
DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject(); if (DlgEdObj* pDlgEdObj = pDlgEdHint->GetObject())
if ( pDlgEdObj )
UpdateChild( ChildDescriptor( pDlgEdObj ) ); UpdateChild( ChildDescriptor( pDlgEdObj ) );
} }
break; break;

View File

@@ -69,11 +69,7 @@ void LibBoxControl::StateChanged( sal_uInt16, SfxItemState eState, const SfxPool
else else
{ {
pBox->Enable(); pBox->Enable();
pBox->Update(dynamic_cast<SfxStringItem const*>(pState));
if ( pState->ISA(SfxStringItem) )
pBox->Update( (const SfxStringItem*)pState );
else
pBox->Update( NULL );
} }
} }
@@ -357,23 +353,17 @@ LanguageBoxControl::~LanguageBoxControl()
{ {
} }
void LanguageBoxControl::StateChanged( sal_uInt16 _nID, SfxItemState _eState, const SfxPoolItem* _pItem ) void LanguageBoxControl::StateChanged( sal_uInt16 nID, SfxItemState eState, const SfxPoolItem* pItem )
{ {
(void)_nID; (void)nID;
if (BasicLanguageBox* pBox = static_cast<BasicLanguageBox*>(GetToolBox().GetItemWindow(GetId())))
BasicLanguageBox* pBox = (BasicLanguageBox*)( GetToolBox().GetItemWindow( GetId() ) );
if ( pBox )
{ {
if ( _eState != SFX_ITEM_AVAILABLE ) if (eState != SFX_ITEM_AVAILABLE)
pBox->Disable(); pBox->Disable();
else else
{ {
pBox->Enable(); pBox->Enable();
if ( _pItem->ISA(SfxStringItem) ) pBox->Update(dynamic_cast<SfxStringItem const*>(pItem));
pBox->Update( (const SfxStringItem*)_pItem );
else
pBox->Update( NULL );
} }
} }
} }

View File

@@ -49,8 +49,19 @@ using namespace ::com::sun::star::uno;
namespace namespace
{ {
long nVirtToolBoxHeight; // inited in WatchWindow, used in Stackwindow long nVirtToolBoxHeight; // inited in WatchWindow, used in Stackwindow
long nHeaderBarHeight; long nHeaderBarHeight;
// Returns pBase converted to SbxVariable if valid and is not an SbxMethod.
SbxVariable const* IsSbxVariable (SbxBase const* pBase)
{
if (SbxVariable const* pVar = dynamic_cast<SbxVariable const*>(pBase))
if (!dynamic_cast<SbxMethod const*>(pVar))
return pVar;
return 0;
}
} // namespace } // namespace
#define SCROLL_LINE 12 #define SCROLL_LINE 12
@@ -297,9 +308,8 @@ void EditorWindow::RequestHelp( const HelpEvent& rHEvt )
if ( strchr( cSuffixes, aWord.GetChar( nLastChar ) ) ) if ( strchr( cSuffixes, aWord.GetChar( nLastChar ) ) )
aWord.Erase( nLastChar, 1 ); aWord.Erase( nLastChar, 1 );
SbxBase* pSBX = StarBASIC::FindSBXInCurrentScope( aWord ); SbxBase* pSBX = StarBASIC::FindSBXInCurrentScope( aWord );
if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) if (SbxVariable const* pVar = IsSbxVariable(pSBX))
{ {
SbxVariable* pVar = (SbxVariable*)pSBX;
SbxDataType eType = pVar->GetType(); SbxDataType eType = pVar->GetType();
if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT ) if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT )
// might cause a crash e. g. at the selections-object // might cause a crash e. g. at the selections-object
@@ -673,9 +683,9 @@ void EditorWindow::DataChanged(DataChangedEvent const & rDCEvt)
void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint ) void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
{ {
if ( rHint.ISA( TextHint ) ) if (TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint))
{ {
const TextHint& rTextHint = (const TextHint&)rHint; TextHint const& rTextHint = *pTextHint;
if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED ) if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED )
{ {
if ( pModulWindow->GetHScrollBar() ) if ( pModulWindow->GetHScrollBar() )
@@ -1891,10 +1901,7 @@ SbxBase* WatchTreeListBox::ImplGetSBXForEntry( SvLBoxEntry* pEntry, bool& rbArra
if( pObj ) if( pObj )
{ {
pSBX = pObj->Find( aVName, SbxCLASS_DONTCARE ); pSBX = pObj->Find( aVName, SbxCLASS_DONTCARE );
if (SbxVariable const* pVar = IsSbxVariable(pSBX))
SbxVariable* pVar;
if ( pSBX && (pVar = PTR_CAST( SbxVariable, pSBX )) != NULL
&& !pSBX->ISA( SbxMethod ) )
{ {
// Force getting value // Force getting value
SbxValues aRes; SbxValues aRes;
@@ -1926,8 +1933,8 @@ sal_Bool WatchTreeListBox::EditingEntry( SvLBoxEntry* pEntry, Selection& )
{ {
// No out of scope entries // No out of scope entries
bool bArrayElement; bool bArrayElement;
SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement ); SbxBase const* pSbx = ImplGetSBXForEntry( pEntry, bArrayElement );
if ( ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) || bArrayElement ) if (IsSbxVariable(pSbx) || bArrayElement)
{ {
// Accept no objects and only end nodes of arrays for editing // Accept no objects and only end nodes of arrays for editing
if( !pItem->mpObject && (pItem->mpArray == NULL || pItem->nDimLevel == pItem->nDimCount) ) if( !pItem->mpObject && (pItem->mpArray == NULL || pItem->nDimLevel == pItem->nDimCount) )
@@ -1963,9 +1970,8 @@ bool WatchTreeListBox::ImplBasicEntryEdited( SvLBoxEntry* pEntry, const String&
bool bArrayElement; bool bArrayElement;
SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement ); SbxBase* pSBX = ImplGetSBXForEntry( pEntry, bArrayElement );
if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) if (SbxVariable const* pVar = IsSbxVariable(pSBX))
{ {
SbxVariable* pVar = (SbxVariable*)pSBX;
SbxDataType eType = pVar->GetType(); SbxDataType eType = pVar->GetType();
if ( (sal_uInt8)eType != (sal_uInt8)SbxOBJECT if ( (sal_uInt8)eType != (sal_uInt8)SbxOBJECT
&& ( eType & SbxARRAY ) == 0 ) && ( eType & SbxARRAY ) == 0 )
@@ -2082,18 +2088,15 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
} }
bool bCollapse = false; bool bCollapse = false;
if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) ) if (SbxVariable const* pVar = IsSbxVariable(pSBX))
{ {
SbxVariable* pVar = (SbxVariable*)pSBX;
// extra treatment of arrays // extra treatment of arrays
SbxDataType eType = pVar->GetType(); SbxDataType eType = pVar->GetType();
if ( eType & SbxARRAY ) if ( eType & SbxARRAY )
{ {
// consider multidimensinal arrays! // consider multidimensinal arrays!
SbxBase* pBase = pVar->GetObject(); if (SbxDimArray* pNewArray = dynamic_cast<SbxDimArray*>(pVar->GetObject()))
if ( pBase && pBase->ISA( SbxDimArray ) )
{ {
SbxDimArray* pNewArray = (SbxDimArray*)pBase;
SbxDimArray* pOldArray = pItem->mpArray; SbxDimArray* pOldArray = pItem->mpArray;
bool bArrayChanged = false; bool bArrayChanged = false;
@@ -2154,12 +2157,7 @@ void WatchTreeListBox::UpdateWatches( bool bBasicStopped )
} }
else if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT ) else if ( (sal_uInt8)eType == (sal_uInt8)SbxOBJECT )
{ {
SbxObject* pObj = NULL; if (SbxObject* pObj = dynamic_cast<SbxObject*>(pVar->GetObject()))
SbxBase* pBase = pVar->GetObject();
if( pBase && pBase->ISA( SbxObject ) )
pObj = (SbxObject*)pBase;
if( pObj )
{ {
// Check if member list has changed // Check if member list has changed
bool bObjChanged = false; bool bObjChanged = false;

View File

@@ -80,14 +80,10 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
case SID_SHOWLINES: case SID_SHOWLINES:
{ {
SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false); SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false);
bool bValue = false; bool const bValue = pItem && pItem->GetValue();
if ( pItem )
bValue = pItem->GetValue();
lcl_GetSourceLinesEnabledValue() = bValue; lcl_GetSourceLinesEnabledValue() = bValue;
if ( pCurWin && pCurWin->IsA( TYPE( ModulWindow ) ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
{ pMCurWin->SetLineNumberDisplay(bValue);
dynamic_cast<ModulWindow*>(pCurWin)->SetLineNumberDisplay( bValue );
}
} }
break; break;
@@ -103,7 +99,7 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
::rtl::OUString aLibName = pCurWin->GetLibName(); ::rtl::OUString aLibName = pCurWin->GetLibName();
::rtl::OUString aName = pCurWin->GetName(); ::rtl::OUString aName = pCurWin->GetName();
if ( pCurWin->ISA( ModulWindow ) ) if (dynamic_cast<ModulWindow*>(pCurWin))
{ {
if ( QueryDelModule( aName, pCurWin ) ) if ( QueryDelModule( aName, pCurWin ) )
{ {
@@ -133,7 +129,7 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
break; break;
case FID_SEARCH_NOW: case FID_SEARCH_NOW:
{ {
if ( pCurWin->ISA( ModulWindow ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
{ {
DBG_ASSERT( rReq.GetArgs(), "arguments expected" ); DBG_ASSERT( rReq.GetArgs(), "arguments expected" );
const SfxItemSet* pArgs = rReq.GetArgs(); const SfxItemSet* pArgs = rReq.GetArgs();
@@ -141,35 +137,35 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
sal_uInt16 nWhich = pArgs->GetWhichByPos( 0 ); sal_uInt16 nWhich = pArgs->GetWhichByPos( 0 );
DBG_ASSERT( nWhich, "Wich fuer SearchItem ?" ); DBG_ASSERT( nWhich, "Wich fuer SearchItem ?" );
const SfxPoolItem& rItem = pArgs->Get( nWhich ); const SfxPoolItem& rItem = pArgs->Get( nWhich );
DBG_ASSERT( rItem.ISA( SvxSearchItem ), "Kein Searchitem!" );
IDEWindowTable::const_iterator it; IDEWindowTable::const_iterator it;
if ( rItem.ISA( SvxSearchItem ) ) if (SvxSearchItem const* pSearchItem = dynamic_cast<SvxSearchItem const*>(&rItem))
{ {
// memorize item because of the adjustments... // memorize item because of the adjustments...
BasicIDEGlobals::GetExtraData()->SetSearchItem( (const SvxSearchItem&)rItem ); BasicIDEGlobals::GetExtraData()->SetSearchItem(*pSearchItem);
sal_Int32 nFound = 0; sal_Int32 nFound = 0;
bool bCanceled = false; bool bCanceled = false;
if ( ((const SvxSearchItem&)rItem).GetCommand() == SVX_SEARCHCMD_REPLACE_ALL ) if (pSearchItem->GetCommand() == SVX_SEARCHCMD_REPLACE_ALL)
{ {
sal_uInt16 nActModWindows = 0; sal_uInt16 nActModWindows = 0;
for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it ) for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second; IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) ) if (!pWin->IsSuspended() && dynamic_cast<ModulWindow*>(pWin))
nActModWindows++; nActModWindows++;
} }
if ( ( nActModWindows <= 1 ) || ( !((const SvxSearchItem&)rItem).GetSelection() && QueryBox( pCurWin, WB_YES_NO|WB_DEF_YES, String( IDEResId( RID_STR_SEARCHALLMODULES ) ) ).Execute() == RET_YES ) ) if ( ( nActModWindows <= 1 ) || ( !pSearchItem->GetSelection() && QueryBox( pCurWin, WB_YES_NO|WB_DEF_YES, String( IDEResId( RID_STR_SEARCHALLMODULES ) ) ).Execute() == RET_YES ) )
{ {
for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it ) for( it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second; IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) ) if (!pWin->IsSuspended())
nFound = nFound + ((ModulWindow*)pWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem ); if (pModulWindow* pMWin = dynamic_cast<ModulWindow*>(pWin))
nFound += pMWin->StartSearchAndReplace(*pSearchItem);
} }
} }
else else
nFound = ((ModulWindow*)pCurWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem ); nFound = pMCurWin->StartSearchAndReplace(*pSearchItem);
::rtl::OUString aReplStr(IDE_RESSTR(RID_STR_SEARCHREPLACES)); ::rtl::OUString aReplStr(IDE_RESSTR(RID_STR_SEARCHREPLACES));
aReplStr = aReplStr.replaceAll("XX", rtl::OUString::valueOf(nFound)); aReplStr = aReplStr.replaceAll("XX", rtl::OUString::valueOf(nFound));
@@ -177,8 +173,8 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
} }
else else
{ {
nFound = ((ModulWindow*)pCurWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem ); nFound = pMCurWin->StartSearchAndReplace(*pSearchItem);
if ( !nFound && !((const SvxSearchItem&)rItem).GetSelection() ) if ( !nFound && !pSearchItem->GetSelection() )
{ {
// search other modules... // search other modules...
bool bChangeCurWindow = false; bool bChangeCurWindow = false;
@@ -211,20 +207,21 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
bCanceled = true; bCanceled = true;
} }
if ( pWin && !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) ) if (ModulWindow* pMWin = dynamic_cast<ModulWindow*>(pWin))
{ if (!pWin->IsSuspended())
if ( pWin != pCurWin )
{ {
if ( pCurWin ) if ( pWin != pCurWin )
pWin->SetSizePixel( pCurWin->GetSizePixel() ); {
nFound = ((ModulWindow*)pWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem, true ); if ( pCurWin )
pWin->SetSizePixel( pCurWin->GetSizePixel() );
nFound = pMWin->StartSearchAndReplace(*pSearchItem, true);
}
if ( nFound )
{
bChangeCurWindow = true;
break;
}
} }
if ( nFound )
{
bChangeCurWindow = true;
break;
}
}
if ( pWin && ( pWin != pCurWin ) ) if ( pWin && ( pWin != pCurWin ) )
{ {
if ( it != aIDEWindowTable.end() ) if ( it != aIDEWindowTable.end() )
@@ -238,7 +235,7 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
pWin = 0; pWin = 0;
} }
if ( !nFound && bSearchedFromStart ) if ( !nFound && bSearchedFromStart )
nFound = ((ModulWindow*)pCurWin)->StartSearchAndReplace( (const SvxSearchItem&)rItem, true ); nFound = pMCurWin->StartSearchAndReplace(*pSearchItem, true);
if ( bChangeCurWindow ) if ( bChangeCurWindow )
SetCurWindow( pWin, true ); SetCurWindow( pWin, true );
} }
@@ -248,12 +245,14 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
rReq.Done(); rReq.Done();
} }
else
DBG_ASSERT(false, "no searchitem!");
} }
} }
break; break;
case FID_SEARCH_OFF: case FID_SEARCH_OFF:
{ {
if ( pCurWin && pCurWin->ISA( ModulWindow ) ) if (dynamic_cast<ModulWindow*>(pCurWin))
pCurWin->GrabFocus(); pCurWin->GrabFocus();
} }
break; break;
@@ -268,7 +267,7 @@ void BasicIDEShell::ExecuteCurrent( SfxRequest& rReq )
break; break;
case SID_GOTOLINE: case SID_GOTOLINE:
{ {
if ( pCurWin && pCurWin->IsA( TYPE( ModulWindow ) ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
{ {
std::auto_ptr< GotoLineDialog > xGotoDlg( new GotoLineDialog( pCurWin ) ); std::auto_ptr< GotoLineDialog > xGotoDlg( new GotoLineDialog( pCurWin ) );
if ( xGotoDlg->Execute() ) if ( xGotoDlg->Execute() )
@@ -298,8 +297,8 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
case SID_BASICSTOP: case SID_BASICSTOP:
{ {
// maybe do not simply stop if on breakpoint! // maybe do not simply stop if on breakpoint!
if ( pCurWin && pCurWin->IsA( TYPE( ModulWindow ) ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
((ModulWindow*)pCurWin)->BasicStop(); pMCurWin->BasicStop();
BasicIDE::StopBasic(); BasicIDE::StopBasic();
} }
break; break;
@@ -461,13 +460,12 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
if ( aNewName != aOldName ) if ( aNewName != aOldName )
{ {
bool bRenameOk = false; bool bRenameOk = false;
if ( pWin->IsA( TYPE( ModulWindow ) ) ) if (ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin))
{ {
ModulWindow* pModWin = (ModulWindow*)pWin; rtl::OUString aLibName = pModWin->GetLibName();
::rtl::OUString aLibName = ( pModWin->GetLibName() );
ScriptDocument aDocument( pWin->GetDocument() ); ScriptDocument aDocument( pWin->GetDocument() );
if ( BasicIDE::RenameModule( pModWin, aDocument, aLibName, aOldName, aNewName ) ) if ( BasicIDE::RenameModule( pModWin, aDocument, aLibName, aOldName, aNewName ) )
{ {
bRenameOk = true; bRenameOk = true;
// Because we listen for container events for script // Because we listen for container events for script
@@ -477,9 +475,8 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
} }
} }
else if ( pWin->IsA( TYPE( DialogWindow ) ) ) else if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(pWin))
{ {
DialogWindow* pDlgWin = (DialogWindow*)pWin;
bRenameOk = pDlgWin->RenameDialog( aNewName ); bRenameOk = pDlgWin->RenameDialog( aNewName );
} }
if ( bRenameOk ) if ( bRenameOk )
@@ -525,7 +522,7 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it ) for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second; IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() && pWin->IsA( TYPE( ModulWindow ) ) ) if (!pWin->IsSuspended() && dynamic_cast<ModulWindow*>(pWin))
{ {
if ( rReq.GetSlot() == SID_BASICIDE_STOREALLMODULESOURCES ) if ( rReq.GetSlot() == SID_BASICIDE_STOREALLMODULESOURCES )
pWin->StoreData(); pWin->StoreData();
@@ -728,9 +725,8 @@ void BasicIDEShell::ExecuteGlobal( SfxRequest& rReq )
if ( pTabBar ) if ( pTabBar )
pTabBar->MakeVisible( pTabBar->GetCurPageId() ); pTabBar->MakeVisible( pTabBar->GetCurPageId() );
if ( pWin->ISA( ModulWindow ) ) if (ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin))
{ {
ModulWindow* pModWin = (ModulWindow*)pWin;
SFX_REQUEST_ARG( rReq, pLineItem, SfxUInt32Item, SID_BASICIDE_ARG_LINE, false ); SFX_REQUEST_ARG( rReq, pLineItem, SfxUInt32Item, SID_BASICIDE_ARG_LINE, false );
if ( pLineItem ) if ( pLineItem )
{ {
@@ -817,7 +813,7 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
// if this is not a module window hide the // if this is not a module window hide the
// setting, doesn't make sense for example if the // setting, doesn't make sense for example if the
// dialog editor is open // dialog editor is open
if( pCurWin && !pCurWin->IsA( TYPE( ModulWindow ) ) ) if(pCurWin && !dynamic_cast<ModulWindow*>(pCurWin))
{ {
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
rSet.Put(SfxVisibilityItem(nWh, false)); rSet.Put(SfxVisibilityItem(nWh, false));
@@ -881,7 +877,7 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
{ {
// FIXME: hide Object Catalog icon from the toolbar, // FIXME: hide Object Catalog icon from the toolbar,
// when window type is not macro editor. // when window type is not macro editor.
if( pCurWin && !pCurWin->IsA( TYPE( ModulWindow ) ) ) if(pCurWin && !dynamic_cast<ModulWindow*>(pCurWin))
{ {
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
rSet.Put(SfxVisibilityItem(nWh, false)); rSet.Put(SfxVisibilityItem(nWh, false));
@@ -910,7 +906,7 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
case SID_BASICSAVEAS: case SID_BASICSAVEAS:
case SID_BASICIDE_MATCHGROUP: case SID_BASICIDE_MATCHGROUP:
{ {
if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) ) if (!dynamic_cast<ModulWindow*>(pCurWin))
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
else if ( ( nWh == SID_BASICLOAD ) && ( StarBASIC::IsRunning() || ( pCurWin && pCurWin->IsReadOnly() ) ) ) else if ( ( nWh == SID_BASICLOAD ) && ( StarBASIC::IsRunning() || ( pCurWin && pCurWin->IsReadOnly() ) ) )
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
@@ -923,22 +919,25 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
case SID_BASICIDE_TOGGLEBRKPNT: case SID_BASICIDE_TOGGLEBRKPNT:
case SID_BASICIDE_MANAGEBRKPNTS: case SID_BASICIDE_MANAGEBRKPNTS:
{ {
if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
rSet.DisableItem( nWh ); {
else if ( StarBASIC::IsRunning() && !((ModulWindow*)pCurWin)->GetBasicStatus().bIsInReschedule ) if (StarBASIC::IsRunning() && !pMCurWin->GetBasicStatus().bIsInReschedule)
rSet.DisableItem(nWh);
}
else
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
} }
break; break;
case SID_BASICCOMPILE: case SID_BASICCOMPILE:
{ {
if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) || StarBASIC::IsRunning() ) if (StarBASIC::IsRunning() || !dynamic_cast<ModulWindow*>(pCurWin))
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
} }
break; break;
case SID_BASICSTOP: case SID_BASICSTOP:
{ {
// stop is always possible when some Basic is running... // stop is always possible when some Basic is running...
if ( !StarBASIC::IsRunning() ) if (!StarBASIC::IsRunning())
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
} }
break; break;
@@ -952,7 +951,7 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
case SID_INSERT_FORM_HSCROLL: case SID_INSERT_FORM_HSCROLL:
case SID_INSERT_FORM_SPIN: case SID_INSERT_FORM_SPIN:
{ {
if( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) ) if (!dynamic_cast<DialogWindow*>(pCurWin))
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
} }
break; break;
@@ -1092,7 +1091,7 @@ void BasicIDEShell::GetState(SfxItemSet &rSet)
// if this is not a module window hide the // if this is not a module window hide the
// setting, doesn't make sense for example if the // setting, doesn't make sense for example if the
// dialog editor is open // dialog editor is open
if( pCurWin && !pCurWin->IsA( TYPE( ModulWindow ) ) ) if (pCurWin && !dynamic_cast<ModulWindow*>(pCurWin))
{ {
rSet.DisableItem( nWh ); rSet.DisableItem( nWh );
rSet.Put(SfxVisibilityItem(nWh, false)); rSet.Put(SfxVisibilityItem(nWh, false));
@@ -1112,7 +1111,7 @@ sal_Bool BasicIDEShell::HasUIFeature( sal_uInt32 nFeature )
if ( (nFeature & BASICIDE_UI_FEATURE_SHOW_BROWSER) == BASICIDE_UI_FEATURE_SHOW_BROWSER ) if ( (nFeature & BASICIDE_UI_FEATURE_SHOW_BROWSER) == BASICIDE_UI_FEATURE_SHOW_BROWSER )
{ {
// fade out (in) property browser in module (dialog) windows // fade out (in) property browser in module (dialog) windows
if ( pCurWin && pCurWin->IsA( TYPE( DialogWindow ) ) && !pCurWin->IsReadOnly() ) if (dynamic_cast<DialogWindow*>(pCurWin) && !pCurWin->IsReadOnly())
bResult = true; bResult = true;
} }
@@ -1140,9 +1139,9 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, bool bUpdateTabBar, bo
pPrevCurWin->Hide(); pPrevCurWin->Hide();
pPrevCurWin->Deactivating(); pPrevCurWin->Deactivating();
// pPrevCurWin->GetLayoutWindow()->Hide(); // pPrevCurWin->GetLayoutWindow()->Hide();
if( pPrevCurWin->IsA( TYPE( DialogWindow ) ) ) if (DialogWindow* pDialogWin = dynamic_cast<DialogWindow*>(pPrevCurWin))
{ {
((DialogWindow*)pPrevCurWin)->DisableBrowser(); pDialogWin->DisableBrowser();
} }
else else
{ {
@@ -1152,11 +1151,11 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, bool bUpdateTabBar, bo
if ( pCurWin ) if ( pCurWin )
{ {
AdjustPosSizePixel( Point( 0, 0 ), GetViewFrame()->GetWindow().GetOutputSizePixel() ); AdjustPosSizePixel( Point( 0, 0 ), GetViewFrame()->GetWindow().GetOutputSizePixel() );
if( pCurWin->IsA( TYPE( ModulWindow ) ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
{ {
dynamic_cast<ModulWindow*>(pCurWin)->SetLineNumberDisplay(SourceLinesDisplayed()); pMCurWin->SetLineNumberDisplay(SourceLinesDisplayed());
GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW ); GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
pModulLayout->SetModulWindow( (ModulWindow*)pCurWin ); pModulLayout->SetModulWindow(pMCurWin);
pModulLayout->Show(); pModulLayout->Show();
} }
else else
@@ -1170,7 +1169,8 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, bool bUpdateTabBar, bo
BasicIDEData* pData = BasicIDEGlobals::GetExtraData(); BasicIDEData* pData = BasicIDEGlobals::GetExtraData();
if ( pData ) if ( pData )
{ {
sal_uInt16 nCurrentType = pCurWin->IsA( TYPE( ModulWindow ) ) ? BASICIDE_TYPE_MODULE : BASICIDE_TYPE_DIALOG; sal_uInt16 nCurrentType = dynamic_cast<ModulWindow*>(pCurWin) ?
BASICIDE_TYPE_MODULE : BASICIDE_TYPE_DIALOG;
LibInfoItem* pLibInfoItem = new LibInfoItem( pCurWin->GetDocument(), pCurWin->GetLibName(), pCurWin->GetName(), nCurrentType ); LibInfoItem* pLibInfoItem = new LibInfoItem( pCurWin->GetDocument(), pCurWin->GetLibName(), pCurWin->GetName(), nCurrentType );
pData->GetLibInfos().InsertInfo( pLibInfoItem ); pData->GetLibInfos().InsertInfo( pLibInfoItem );
} }
@@ -1190,8 +1190,8 @@ void BasicIDEShell::SetCurWindow( IDEBaseWindow* pNewWin, bool bUpdateTabBar, bo
if ( pFocusWindow ) // Focus in BasicIDE if ( pFocusWindow ) // Focus in BasicIDE
pNewWin->GrabFocus(); pNewWin->GrabFocus();
} }
if( pCurWin->IsA( TYPE( DialogWindow ) ) ) if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin))
((DialogWindow*)pCurWin)->UpdateBrowser(); pDCurWin->UpdateBrowser();
} }
if ( bUpdateTabBar ) if ( bUpdateTabBar )
{ {
@@ -1251,7 +1251,7 @@ void BasicIDEShell::ManageToolbars()
if ( xLayoutManager.is() ) if ( xLayoutManager.is() )
{ {
xLayoutManager->lock(); xLayoutManager->lock();
if( pCurWin->IsA( TYPE( DialogWindow ) ) ) if (dynamic_cast<DialogWindow*>(pCurWin))
{ {
xLayoutManager->destroyElement( aMacroBarResName ); xLayoutManager->destroyElement( aMacroBarResName );
@@ -1290,8 +1290,8 @@ IDEBaseWindow* BasicIDEShell::FindWindow( const ScriptDocument& rDocument, const
return pWin; return pWin;
} }
else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName && else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rName &&
( ( pWin->IsA( TYPE( ModulWindow ) ) && nType == BASICIDE_TYPE_MODULE ) || ( ( dynamic_cast<ModulWindow*>(pWin) && nType == BASICIDE_TYPE_MODULE ) ||
( pWin->IsA( TYPE( DialogWindow ) ) && nType == BASICIDE_TYPE_DIALOG ) ) ) ( dynamic_cast<DialogWindow*>(pWin) && nType == BASICIDE_TYPE_DIALOG ) ) )
{ {
return pWin; return pWin;
} }
@@ -1344,18 +1344,15 @@ ModulWindow* BasicIDEShell::ShowActiveModuleWindow( StarBASIC* pBasic )
SetCurLib( ScriptDocument::getApplicationScriptDocument(), ::rtl::OUString(), false ); SetCurLib( ScriptDocument::getApplicationScriptDocument(), ::rtl::OUString(), false );
SbModule* pActiveModule = StarBASIC::GetActiveModule(); SbModule* pActiveModule = StarBASIC::GetActiveModule();
SbClassModuleObject* pClassModuleObject = PTR_CAST(SbClassModuleObject,pActiveModule); if (SbClassModuleObject* pCMO = dynamic_cast<SbClassModuleObject*>(pActiveModule))
if( pClassModuleObject != NULL ) pActiveModule = pCMO->getClassModule();
pActiveModule = pClassModuleObject->getClassModule();
DBG_ASSERT( pActiveModule, "Kein aktives Modul im ErrorHdl?!" ); DBG_ASSERT( pActiveModule, "Kein aktives Modul im ErrorHdl?!" );
if ( pActiveModule ) if ( pActiveModule )
{ {
ModulWindow* pWin = 0; ModulWindow* pWin = 0;
SbxObject* pParent = pActiveModule->GetParent(); SbxObject* pParent = pActiveModule->GetParent();
DBG_ASSERT( pParent && pParent->ISA( StarBASIC ), "Kein BASIC!" ); if (StarBASIC* pLib = dynamic_cast<StarBASIC*>(pParent))
StarBASIC* pLib = static_cast< StarBASIC* >( pParent );
if ( pLib )
{ {
BasicManager* pBasMgr = BasicIDE::FindBasicManager( pLib ); BasicManager* pBasMgr = BasicIDE::FindBasicManager( pLib );
if ( pBasMgr ) if ( pBasMgr )
@@ -1368,6 +1365,8 @@ ModulWindow* BasicIDEShell::ShowActiveModuleWindow( StarBASIC* pBasic )
SetCurWindow( pWin, true ); SetCurWindow( pWin, true );
} }
} }
else
DBG_ASSERT(false, "Kein BASIC!");
BasicManager* pBasicMgr = BasicIDE::FindBasicManager( pBasic ); BasicManager* pBasicMgr = BasicIDE::FindBasicManager( pBasic );
if ( pBasicMgr ) if ( pBasicMgr )
StartListening( *pBasicMgr, true /* log on only once */ ); StartListening( *pBasicMgr, true /* log on only once */ );
@@ -1407,14 +1406,8 @@ void BasicIDEShell::AdjustPosSizePixel( const Point &rPos, const Size &rSize )
pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width()/2, aScrollBarBoxSz.Height() ) ); pTabBar->SetPosSizePixel( Point( rPos.X(), rPos.Y()+aSz.Height() ), Size( aSz.Width()/2, aScrollBarBoxSz.Height() ) );
} }
Window* pEdtWin = pCurWin ? pCurWin->GetLayoutWindow() : pModulLayout; if (Window* pEdtWin = pCurWin ? pCurWin->GetLayoutWindow() : pModulLayout)
if ( pEdtWin ) pEdtWin->SetPosSizePixel(rPos, dynamic_cast<DialogWindow*>(pCurWin) ? aSz : aOutSz);
{
if( pCurWin && pCurWin->IsA( TYPE( DialogWindow ) ) )
pEdtWin->SetPosSizePixel( rPos, aSz ); // without ScrollBar
else
pEdtWin->SetPosSizePixel( rPos, aOutSz );
}
} }
Reference< XModel > BasicIDEShell::GetCurrentDocument() const Reference< XModel > BasicIDEShell::GetCurrentDocument() const
@@ -1431,8 +1424,8 @@ void BasicIDEShell::Activate( sal_Bool bMDI )
if ( bMDI ) if ( bMDI )
{ {
if( pCurWin && pCurWin->IsA( TYPE( DialogWindow ) ) ) if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow>(pCurWin))
((DialogWindow*)pCurWin)->UpdateBrowser(); pDCurWin->UpdateBrowser();
} }
} }
@@ -1442,9 +1435,8 @@ void BasicIDEShell::Deactivate( sal_Bool bMDI )
// deactivate due to a MessageBox bMDI is false // deactivate due to a MessageBox bMDI is false
if ( bMDI ) if ( bMDI )
{ {
if( pCurWin && pCurWin->IsA( TYPE( DialogWindow ) ) ) if (DialogWindow* pXDlgWin = dynamic_cast<DialogWindow*>(pCurWin))
{ {
DialogWindow* pXDlgWin = (DialogWindow*)pCurWin;
pXDlgWin->DisableBrowser(); pXDlgWin->DisableBrowser();
if( pXDlgWin->IsModified() ) if( pXDlgWin->IsModified() )
BasicIDE::MarkDocumentModified( pXDlgWin->GetDocument() ); BasicIDE::MarkDocumentModified( pXDlgWin->GetDocument() );

View File

@@ -52,23 +52,21 @@ Reference< view::XRenderable > BasicIDEShell::GetRenderable()
sal_Bool BasicIDEShell::HasSelection( sal_Bool /* bText */ ) const sal_Bool BasicIDEShell::HasSelection( sal_Bool /* bText */ ) const
{ {
bool bSel = false; if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
if ( pCurWin && pCurWin->ISA( ModulWindow ) )
{ {
TextView* pEditView = ((ModulWindow*)pCurWin)->GetEditView(); TextView* pEditView = pMCurWin->GetEditView();
if ( pEditView && pEditView->HasSelection() ) if ( pEditView && pEditView->HasSelection() )
bSel = true; return true;
} }
return bSel; return false;
} }
String BasicIDEShell::GetSelectionText( sal_Bool bWholeWord ) String BasicIDEShell::GetSelectionText( sal_Bool bWholeWord )
{ {
String aText; String aText;
if ( pCurWin && pCurWin->ISA( ModulWindow ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
{ {
TextView* pEditView = ((ModulWindow*)pCurWin)->GetEditView(); if (TextView* pEditView = pMCurWin->GetEditView())
if ( pEditView )
{ {
if ( bWholeWord && !pEditView->HasSelection() ) if ( bWholeWord && !pEditView->HasSelection() )
{ {
@@ -87,7 +85,7 @@ String BasicIDEShell::GetSelectionText( sal_Bool bWholeWord )
SfxPrinter* BasicIDEShell::GetPrinter( sal_Bool bCreate ) SfxPrinter* BasicIDEShell::GetPrinter( sal_Bool bCreate )
{ {
if ( pCurWin ) // && pCurWin->ISA( ModulWindow ) ) if ( pCurWin )
{ {
BasicDocShell* pDocShell = (BasicDocShell*)GetViewFrame()->GetObjectShell(); BasicDocShell* pDocShell = (BasicDocShell*)GetViewFrame()->GetObjectShell();
DBG_ASSERT( pDocShell, "DocShell ?!" ); DBG_ASSERT( pDocShell, "DocShell ?!" );
@@ -242,41 +240,30 @@ ModulWindow* BasicIDEShell::CreateBasWin( const ScriptDocument& rDocument, const
ModulWindow* BasicIDEShell::FindBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName, bool bCreateIfNotExist, bool bFindSuspended ) ModulWindow* BasicIDEShell::FindBasWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rModName, bool bCreateIfNotExist, bool bFindSuspended )
{ {
ModulWindow* pModWin = 0;
for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin();
it != aIDEWindowTable.end(); ++it ) it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second; IDEBaseWindow* pWin = it->second;
if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( ModulWindow ) ) ) if (!pWin->IsSuspended() || bFindSuspended)
{ if (rLibName.isEmpty() || (pWin->IsDocument(rDocument) && pWin->GetLibName() == rLibName && pWin->GetName() == rModName))
if ( rLibName.isEmpty() )
{ {
pModWin = (ModulWindow*)pWin; if (ModulWindow* pModWin = dynamic_cast<ModulWindow*>(pWin))
break; return pModWin;
} }
else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rModName )
{
pModWin = (ModulWindow*)pWin;
break;
}
}
} }
if ( !pModWin && bCreateIfNotExist ) return bCreateIfNotExist ? CreateBasWin(rDocument, rLibName, rModName) : 0;
pModWin = CreateBasWin( rDocument, rLibName, rModName );
return pModWin;
} }
void BasicIDEShell::Move() void BasicIDEShell::Move()
{ {
if ( pCurWin && pCurWin->ISA( ModulWindow ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
((ModulWindow*)pCurWin)->FrameWindowMoved(); pMCurWin->FrameWindowMoved();
} }
void BasicIDEShell::ShowCursor( bool bOn ) void BasicIDEShell::ShowCursor( bool bOn )
{ {
if ( pCurWin && pCurWin->ISA( ModulWindow ) ) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
((ModulWindow*)pCurWin)->ShowCursor( bOn ); pMCurWin->ShowCursor(bOn);
} }
// Hack for #101048 // Hack for #101048
@@ -285,7 +272,7 @@ sal_Int32 getBasicIDEShellCount( void );
// only if basic window above: // only if basic window above:
void BasicIDEShell::ExecuteBasic( SfxRequest& rReq ) void BasicIDEShell::ExecuteBasic( SfxRequest& rReq )
{ {
if ( !pCurWin || !pCurWin->IsA( TYPE( ModulWindow ) ) ) if (!dynamic_cast<ModulWindow*>(pCurWin))
return; return;
pCurWin->ExecuteCommand( rReq ); pCurWin->ExecuteCommand( rReq );

View File

@@ -117,28 +117,15 @@ DialogWindow* BasicIDEShell::CreateDlgWin( const ScriptDocument& rDocument, cons
DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName, bool bCreateIfNotExist, bool bFindSuspended ) DialogWindow* BasicIDEShell::FindDlgWin( const ScriptDocument& rDocument, const ::rtl::OUString& rLibName, const ::rtl::OUString& rDlgName, bool bCreateIfNotExist, bool bFindSuspended )
{ {
DialogWindow* pDlgWin = 0;
for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it ) for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second; IDEBaseWindow* pWin = it->second;
if ( ( !pWin->IsSuspended() || bFindSuspended ) && pWin->IsA( TYPE( DialogWindow ) ) ) if (!pWin->IsSuspended() || bFindSuspended)
{ if (rLibName.isEmpty() || (pWin->IsDocument(rDocument) && pWin->GetLibName() == rLibName && pWin->GetName() == rDlgName))
if ( rLibName.isEmpty() ) if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(pWin))
{ return pDlgWin;
pDlgWin = (DialogWindow*)pWin;
break;
}
else if ( pWin->IsDocument( rDocument ) && pWin->GetLibName() == rLibName && pWin->GetName() == rDlgName )
{
pDlgWin = (DialogWindow*)pWin;
break;
}
}
} }
if ( !pDlgWin && bCreateIfNotExist ) return bCreateIfNotExist ? CreateDlgWin(rDocument, rLibName, rDlgName) : 0;
pDlgWin = CreateDlgWin( rDocument, rLibName, rDlgName );
return pDlgWin;
} }
sal_uInt16 BasicIDEShell::GetIDEWindowId(const IDEBaseWindow* pWin) const sal_uInt16 BasicIDEShell::GetIDEWindowId(const IDEBaseWindow* pWin) const
@@ -151,18 +138,17 @@ sal_uInt16 BasicIDEShell::GetIDEWindowId(const IDEBaseWindow* pWin) const
SdrView* BasicIDEShell::GetCurDlgView() const SdrView* BasicIDEShell::GetCurDlgView() const
{ {
if ( !pCurWin || !pCurWin->IsA( TYPE( DialogWindow ) ) ) if (DialogWindow* pDCurWin = dynamic_cast<DialogWindow*>(pCurWin))
return NULL; return pDCurWin->GetView();
else
DialogWindow* pWin = (DialogWindow*)pCurWin; return 0;
return pWin->GetView();
} }
// only if dialogue window above: // only if dialogue window above:
void BasicIDEShell::ExecuteDialog( SfxRequest& rReq ) void BasicIDEShell::ExecuteDialog( SfxRequest& rReq )
{ {
if ( pCurWin && ( pCurWin->IsA( TYPE( DialogWindow) ) || if (pCurWin && (dynamic_cast<DialogWindow*>(pCurWin) ||
(rReq.GetSlot() == SID_IMPORT_DIALOG &&pCurWin->IsA( TYPE( ModulWindow) ) ) ) ) (rReq.GetSlot() == SID_IMPORT_DIALOG && dynamic_cast<ModulWindow*>(pCurWin))))
{ {
pCurWin->ExecuteCommand( rReq ); pCurWin->ExecuteCommand( rReq );
} }

View File

@@ -251,19 +251,15 @@ BasicIDEShell::~BasicIDEShell()
void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ ) void BasicIDEShell::onDocumentCreated( const ScriptDocument& /*_rDocument*/ )
{ {
if(pCurWin && pCurWin->IsA( TYPE(ModulWindow))) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
{ pMCurWin->SetLineNumberDisplay(SourceLinesDisplayed());
dynamic_cast<ModulWindow*>(pCurWin)->SetLineNumberDisplay(SourceLinesDisplayed());
}
UpdateWindows(); UpdateWindows();
} }
void BasicIDEShell::onDocumentOpened( const ScriptDocument& /*_rDocument*/ ) void BasicIDEShell::onDocumentOpened( const ScriptDocument& /*_rDocument*/ )
{ {
if(pCurWin && pCurWin->IsA( TYPE(ModulWindow))) if (ModulWindow* pMCurWin = dynamic_cast<ModulWindow*>(pCurWin))
{ pMCurWin->SetLineNumberDisplay(SourceLinesDisplayed());
dynamic_cast<ModulWindow*>(pCurWin)->SetLineNumberDisplay(SourceLinesDisplayed());
}
UpdateWindows(); UpdateWindows();
} }
@@ -534,9 +530,9 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
{ {
if ( BasicIDEGlobals::GetShell() ) if ( BasicIDEGlobals::GetShell() )
{ {
if ( rHint.IsA( TYPE( SfxSimpleHint ) ) ) if (SfxSimpleHint* pSimpleHint = dynamic_cast<SfxSimpleHint*>(&rHint))
{ {
switch ( ((SfxSimpleHint&)rHint).GetId() ) switch (pSimpleHint->GetId())
{ {
case SFX_HINT_DYING: case SFX_HINT_DYING:
{ {
@@ -546,15 +542,13 @@ void BasicIDEShell::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId&,
break; break;
} }
if ( rHint.IsA( TYPE( SbxHint ) ) ) if (SbxHint* pSbxHint = dynamic_cast<SbxHint*>(&rHint))
{ {
SbxHint& rSbxHint = (SbxHint&)rHint; sal_uLong nHintId = pSbxHint->GetId();
sal_uLong nHintId = rSbxHint.GetId();
if ( ( nHintId == SBX_HINT_BASICSTART ) || if ( ( nHintId == SBX_HINT_BASICSTART ) ||
( nHintId == SBX_HINT_BASICSTOP ) ) ( nHintId == SBX_HINT_BASICSTOP ) )
{ {
SfxBindings* pBindings = BasicIDE::GetBindingsPtr(); if (SfxBindings* pBindings = BasicIDE::GetBindingsPtr())
if ( pBindings )
{ {
pBindings->Invalidate( SID_BASICRUN ); pBindings->Invalidate( SID_BASICRUN );
pBindings->Update( SID_BASICRUN ); pBindings->Update( SID_BASICRUN );

View File

@@ -130,8 +130,7 @@ SbMethod* CreateMacro( SbModule* pModule, const String& rMacroName )
// update module in library // update module in library
ScriptDocument aDocument( ScriptDocument::NoDocument ); ScriptDocument aDocument( ScriptDocument::NoDocument );
SbxObject* pParent = pModule->GetParent(); StarBASIC* pBasic = dynamic_cast<StarBASIC*>(pModule->GetParent());
StarBASIC* pBasic = PTR_CAST(StarBASIC,pParent);
DBG_ASSERT(pBasic, "BasicIDE::CreateMacro: No Basic found!"); DBG_ASSERT(pBasic, "BasicIDE::CreateMacro: No Basic found!");
if ( pBasic ) if ( pBasic )
{ {
@@ -246,11 +245,9 @@ bool RemoveDialog( const ScriptDocument& rDocument, const ::rtl::OUString& rLibN
StarBASIC* FindBasic( const SbxVariable* pVar ) StarBASIC* FindBasic( const SbxVariable* pVar )
{ {
const SbxVariable* pSbx = pVar; const SbxVariable* pSbx = pVar;
while ( pSbx && !pSbx->ISA( StarBASIC ) ) while (pSbx && !dynamic_cast<StarBASIC*>(pSbx))
pSbx = pSbx->GetParent(); pSbx = pSbx->GetParent();
return static_cast<StarBASIC*>(pSbx);
DBG_ASSERT( !pSbx || pSbx->ISA( StarBASIC ), "Find Basic: Kein Basic!" );
return (StarBASIC*)pSbx;
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@@ -486,7 +483,7 @@ SfxBindings* GetBindingsPtr()
while ( pView ) while ( pView )
{ {
SfxObjectShell* pObjShell = pView->GetObjectShell(); SfxObjectShell* pObjShell = pView->GetObjectShell();
if ( pObjShell && pObjShell->ISA( BasicDocShell ) ) if (dynamic_cast<BasicDocShell*>(pObjShell))
{ {
pFrame = pView; pFrame = pView;
break; break;

View File

@@ -183,7 +183,7 @@ SbxVariable* BasicTreeListBox::FindVariable( SvLBoxEntry* pEntry )
break; break;
case 0: case 0:
{ {
aDocument = ((BasicDocumentEntry*)pEntry->GetUserData())->GetDocument(); aDocument = static_cast<BasicDocumentEntry*>(pEntry->GetUserData())->GetDocument();
} }
break; break;
} }
@@ -198,7 +198,7 @@ SbxVariable* BasicTreeListBox::FindVariable( SvLBoxEntry* pEntry )
{ {
SvLBoxEntry* pLE = aEntries[n]; SvLBoxEntry* pLE = aEntries[n];
DBG_ASSERT( pLE, "Can not find entry in array" ); DBG_ASSERT( pLE, "Can not find entry in array" );
BasicEntry* pBE = (BasicEntry*)pLE->GetUserData(); BasicEntry* pBE = static_cast<BasicEntry*>(pLE->GetUserData());
DBG_ASSERT( pBE, "The data in the entry not found!" ); DBG_ASSERT( pBE, "The data in the entry not found!" );
String aName( GetEntryText( pLE ) ); String aName( GetEntryText( pLE ) );
@@ -206,27 +206,26 @@ SbxVariable* BasicTreeListBox::FindVariable( SvLBoxEntry* pEntry )
{ {
case OBJ_TYPE_LIBRARY: case OBJ_TYPE_LIBRARY:
{ {
BasicManager* pBasMgr = aDocument.getBasicManager(); if (BasicManager* pBasMgr = aDocument.getBasicManager())
if ( pBasMgr )
pVar = pBasMgr->GetLib( aName ); pVar = pBasMgr->GetLib( aName );
} }
break; break;
case OBJ_TYPE_MODULE: case OBJ_TYPE_MODULE:
{ {
DBG_ASSERT( pVar && pVar->IsA( TYPE(StarBASIC) ), "FindVariable: Ungueltiges Basic" ); DBG_ASSERT(dynamic_cast<StarBASIC*>(pVar), "FindVariable: invalid Basic");
// extract the module name from the string like "Sheet1 (Example1)" // extract the module name from the string like "Sheet1 (Example1)"
if( bDocumentObjects ) if( bDocumentObjects )
{ {
sal_uInt16 nIndex = 0; sal_uInt16 nIndex = 0;
aName = aName.GetToken( 0, ' ', nIndex ); aName = aName.GetToken( 0, ' ', nIndex );
} }
pVar = ((StarBASIC*)pVar)->FindModule( aName ); pVar = static_cast<StarBASIC*>(pVar)->FindModule( aName );
} }
break; break;
case OBJ_TYPE_METHOD: case OBJ_TYPE_METHOD:
{ {
DBG_ASSERT( pVar && ( (pVar->IsA( TYPE(SbModule) )) || (pVar->IsA( TYPE(SbxObject) )) ), "FindVariable: Ungueltiges Modul/Objekt" ); DBG_ASSERT(dynamic_cast<SbxObject*>(pVar), "FindVariable: invalid modul/object");
pVar = ((SbxObject*)pVar)->GetMethods()->Find( aName, SbxCLASS_METHOD ); pVar = static_cast<SbxObject*>(pVar)->GetMethods()->Find(aName, SbxCLASS_METHOD);
} }
break; break;
case OBJ_TYPE_DIALOG: case OBJ_TYPE_DIALOG:
@@ -288,8 +287,7 @@ BasicEntryDescriptor BasicTreeListBox::GetEntryDescriptor( SvLBoxEntry* pEntry )
break; break;
case 0: case 0:
{ {
BasicDocumentEntry* pBasicDocumentEntry = (BasicDocumentEntry*)pEntry->GetUserData(); if (BasicDocumentEntry* pBasicDocumentEntry = static_cast<BasicDocumentEntry*>(pEntry->GetUserData()))
if ( pBasicDocumentEntry )
{ {
aDocument = pBasicDocumentEntry->GetDocument(); aDocument = pBasicDocumentEntry->GetDocument();
eLocation = pBasicDocumentEntry->GetLocation(); eLocation = pBasicDocumentEntry->GetLocation();
@@ -307,7 +305,7 @@ BasicEntryDescriptor BasicTreeListBox::GetEntryDescriptor( SvLBoxEntry* pEntry )
{ {
SvLBoxEntry* pLE = aEntries[n]; SvLBoxEntry* pLE = aEntries[n];
DBG_ASSERT( pLE, "Entrie im Array nicht gefunden" ); DBG_ASSERT( pLE, "Entrie im Array nicht gefunden" );
BasicEntry* pBE = (BasicEntry*)pLE->GetUserData(); BasicEntry* pBE = static_cast<BasicEntry*>(pLE->GetUserData());
DBG_ASSERT( pBE, "Keine Daten im Eintrag gefunden!" ); DBG_ASSERT( pBE, "Keine Daten im Eintrag gefunden!" );
switch ( pBE->GetType() ) switch ( pBE->GetType() )
@@ -455,10 +453,7 @@ bool BasicTreeListBox::IsValidEntry( SvLBoxEntry* pEntry )
SbModule* BasicTreeListBox::FindModule( SvLBoxEntry* pEntry ) SbModule* BasicTreeListBox::FindModule( SvLBoxEntry* pEntry )
{ {
SbxVariable* pVar = FindVariable( pEntry ); return dynamic_cast<SbModule*>(FindVariable(pEntry));
if ( pVar && pVar->IsA( TYPE(SbModule ) ) )
return (SbModule*)pVar;
return 0;
} }
SvLBoxEntry* BasicTreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation ) SvLBoxEntry* BasicTreeListBox::FindRootEntry( const ScriptDocument& rDocument, LibraryLocation eLocation )
@@ -468,9 +463,9 @@ SvLBoxEntry* BasicTreeListBox::FindRootEntry( const ScriptDocument& rDocument, L
SvLBoxEntry* pRootEntry = GetEntry( nRootPos ); SvLBoxEntry* pRootEntry = GetEntry( nRootPos );
while ( pRootEntry ) while ( pRootEntry )
{ {
DBG_ASSERT( (((BasicEntry*)pRootEntry->GetUserData())->GetType() == OBJ_TYPE_DOCUMENT ), "Kein Shelleintrag?" ); DBG_ASSERT( static_cast<BasicEntry*>(pRootEntry->GetUserData())->GetType() == OBJ_TYPE_DOCUMENT, "Kein Shelleintrag?" );
BasicDocumentEntry* pBasicDocumentEntry = (BasicDocumentEntry*)pRootEntry->GetUserData(); BasicDocumentEntry* pBDEntry = static_cast<BasicDocEntry*>(pRootEntry->GetUserData());
if ( pBasicDocumentEntry && ( pBasicDocumentEntry->GetDocument() == rDocument ) && pBasicDocumentEntry->GetLocation() == eLocation ) if (pBDEntry && pBDEntry->GetDocument() == rDocument && pBDEntry->GetLocation() == eLocation)
return pRootEntry; return pRootEntry;
pRootEntry = GetEntry( ++nRootPos ); pRootEntry = GetEntry( ++nRootPos );
} }

View File

@@ -444,15 +444,13 @@ void BasicIDETabBar::Command( const CommandEvent& rCEvt )
if ( aDocument.isInVBAMode() ) if ( aDocument.isInVBAMode() )
{ {
// disable to delete or remove object modules in IDE // disable to delete or remove object modules in IDE
BasicManager* pBasMgr = aDocument.getBasicManager(); if (BasicManager* pBasMgr = aDocument.getBasicManager())
if ( pBasMgr )
{ {
StarBASIC* pBasic = pBasMgr->GetLib( aOULibName ); if (StarBASIC* pBasic = pBasMgr->GetLib(aOULibName))
if( pBasic )
{ {
IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable(); IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
IDEWindowTable::const_iterator it = aIDEWindowTable.find( GetCurPageId() ); IDEWindowTable::const_iterator it = aIDEWindowTable.find( GetCurPageId() );
if( it != aIDEWindowTable.end() && it->second->ISA( ModulWindow ) ) if (it != aIDEWindowTable.end() && dynamic_cast<ModulWindow*>(it->second))
{ {
SbModule* pActiveModule = (SbModule*)pBasic->FindModule( it->second->GetName() ); SbModule* pActiveModule = (SbModule*)pBasic->FindModule( it->second->GetName() );
if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) ) if( pActiveModule && ( pActiveModule->GetModuleType() == script::ModuleType::DOCUMENT ) )
@@ -467,10 +465,10 @@ void BasicIDETabBar::Command( const CommandEvent& rCEvt )
} }
SfxViewFrame* pViewFrame = pIDEShell ? pIDEShell->GetViewFrame() : NULL; if (pIDEShell)
SfxDispatcher* pDispatcher = pViewFrame ? pViewFrame->GetDispatcher() : NULL; if (SfxViewFrame* pViewFrame = pIDEShell->GetViewFrame())
if ( pDispatcher ) if (SfxDispatcher* pDispatcher = pViewFrame->GetDispatcher())
pDispatcher->Execute( aPopup.Execute( this, aPos ) ); pDispatcher->Execute(aPopup.Execute(this, aPos));
} }
} }
@@ -523,11 +521,11 @@ void BasicIDETabBar::Sort()
aTabBarSortHelper.aPageText = GetPageText( nId ); aTabBarSortHelper.aPageText = GetPageText( nId );
IDEBaseWindow* pWin = aIDEWindowTable[ nId ]; IDEBaseWindow* pWin = aIDEWindowTable[ nId ];
if ( pWin->IsA( TYPE( ModulWindow ) ) ) if (dynamic_cast<ModulWindow*>(pWin))
{ {
aModuleList.push_back( aTabBarSortHelper ); aModuleList.push_back( aTabBarSortHelper );
} }
else if ( pWin->IsA( TYPE( DialogWindow ) ) ) else if (dynamic_cast<DialogWindow*>(pWin))
{ {
aDialogList.push_back( aTabBarSortHelper ); aDialogList.push_back( aTabBarSortHelper );
} }

View File

@@ -135,9 +135,8 @@ void LocalizationMgr::implEnableDisableResourceForAllLibraryDialogs( HandleResou
{ {
String aDlgName = pDlgNames[ i ]; String aDlgName = pDlgNames[ i ];
DialogWindow* pWin = m_pIDEShell->FindDlgWin( m_aDocument, m_aLibName, aDlgName, false ); DialogWindow* pWin = m_pIDEShell->FindDlgWin( m_aDocument, m_aLibName, aDlgName, false );
if( pWin && pWin->IsA( TYPE( DialogWindow ) ) ) if (DialogWindow* pDialogWin = dynamic_cast<DialogWindow*>(pWin))
{ {
DialogWindow* pDialogWin = static_cast< DialogWindow* >( pWin );
Reference< container::XNameContainer > xDialog = pDialogWin->GetDialog(); Reference< container::XNameContainer > xDialog = pDialogWin->GetDialog();
if( xDialog.is() ) if( xDialog.is() )
{ {
@@ -778,14 +777,10 @@ void LocalizationMgr::handleSetCurrentLocale( ::com::sun::star::lang::Locale aLo
if ( pBindings ) if ( pBindings )
pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG ); pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
IDEBaseWindow* pCurWin = m_pIDEShell->GetCurWindow(); if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(m_pIDEShell->GetCurWindow()))
if ( pCurWin && !pCurWin->IsSuspended() && pCurWin->IsA( TYPE( DialogWindow ) ) ) if (!pDlgWin->IsSuspended())
{ if (DlgEditor* pWinEditor = pDlgWin->GetEditor())
DialogWindow* pDlgWin = (DialogWindow*)pCurWin; pWinEditor->UpdatePropertyBrowserDelayed();
DlgEditor* pWinEditor = pDlgWin->GetEditor();
if( pWinEditor )
pWinEditor->UpdatePropertyBrowserDelayed();
}
} }
} }
@@ -812,22 +807,18 @@ DialogWindow* FindDialogWindowForEditor( DlgEditor* pEditor )
{ {
BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell(); BasicIDEShell* pIDEShell = BasicIDEGlobals::GetShell();
IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable(); IDEWindowTable& aIDEWindowTable = pIDEShell->GetIDEWindowTable();
DialogWindow* pFoundDlgWin = NULL;
for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it ) for( IDEWindowTable::const_iterator it = aIDEWindowTable.begin(); it != aIDEWindowTable.end(); ++it )
{ {
IDEBaseWindow* pWin = it->second; IDEBaseWindow* pWin = it->second;
if ( !pWin->IsSuspended() && pWin->IsA( TYPE( DialogWindow ) ) ) if (!pWin->IsSuspended())
{ if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(pWin))
DialogWindow* pDlgWin = (DialogWindow*)pWin;
DlgEditor* pWinEditor = pDlgWin->GetEditor();
if( pWinEditor == pEditor )
{ {
pFoundDlgWin = pDlgWin; DlgEditor* pWinEditor = pDlgWin->GetEditor();
break; if( pWinEditor == pEditor )
return pFoundDlgWin;
} }
}
} }
return pFoundDlgWin; return 0;
} }

View File

@@ -55,13 +55,15 @@ SfxPoolItem *SbxItem::Clone(SfxItemPool*) const
int SbxItem::operator==(const SfxPoolItem& rCmp) const int SbxItem::operator==(const SfxPoolItem& rCmp) const
{ {
DBG_ASSERT( rCmp.ISA( SbxItem ), "==: Kein SbxItem!" ); SbxItem const* pSbxItem = dynamic_cast<SbxItem const*>(&rCmp);
return (SfxPoolItem::operator==(rCmp) && DBG_ASSERT(pSbxItem, "==: no SbxItem!" );
m_aDocument == ((const SbxItem&)rCmp).m_aDocument && return
m_aLibName == ((const SbxItem&)rCmp).m_aLibName && SfxPoolItem::operator==(rCmp) &&
m_aName == ((const SbxItem&)rCmp).m_aName && m_aDocument == pSbxItem->m_aDocument &&
m_aMethodName == ((const SbxItem&)rCmp).m_aMethodName && m_aLibName == pSbxItem->m_aLibName &&
m_nType == ((const SbxItem&)rCmp).m_nType); m_aName == pSbxItem->m_aName &&
m_aMethodName == pSbxItem->m_aMethodName &&
m_nType == pSbxItem->m_nType;
} }
const ScriptDocument& SbxItem::GetDocument() const const ScriptDocument& SbxItem::GetDocument() const

View File

@@ -67,12 +67,10 @@ void TbxControls::StateChanged( sal_uInt16 nSID, SfxItemState eState,
{ {
if( pState ) if( pState )
{ {
SfxAllEnumItem* pItem = PTR_CAST(SfxAllEnumItem, pState); if (SfxAllEnumItem* pItem = dynamic_cast<SfxAllEnumItem*>(pState))
if( pItem )
{ {
sal_uInt16 nLastEnum = pItem->GetValue();
sal_uInt16 nTemp = 0; sal_uInt16 nTemp = 0;
switch( nLastEnum ) switch (sal_uInt16 nLastEnum = pItem->GetValue())
{ {
case SVX_SNAP_PUSHBUTTON: nTemp = SID_INSERT_PUSHBUTTON; break; case SVX_SNAP_PUSHBUTTON: nTemp = SID_INSERT_PUSHBUTTON; break;
case SVX_SNAP_CHECKBOX: nTemp = SID_INSERT_CHECKBOX; break; case SVX_SNAP_CHECKBOX: nTemp = SID_INSERT_CHECKBOX; break;

View File

@@ -561,12 +561,9 @@ IMPL_LINK_NOARG(DlgEditor, PaintTimeout)
if ( pDlgEdPage && ( ( nObjCount = pDlgEdPage->GetObjCount() ) > 0 ) ) if ( pDlgEdPage && ( ( nObjCount = pDlgEdPage->GetObjCount() ) > 0 ) )
{ {
for ( sal_uLong i = 0 ; i < nObjCount ; i++ ) for ( sal_uLong i = 0 ; i < nObjCount ; i++ )
{ if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pDlgEdPage->GetObj(i)))
SdrObject* pObj = pDlgEdPage->GetObj(i); if (!dynamic_cast<DlgEdForm*>(pDlgEdObj))
DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj); pDlgEdObj->SetRectFromProps();
if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
pDlgEdObj->SetRectFromProps();
}
} }
} }
} }
@@ -668,8 +665,7 @@ void DlgEditor::CreateDefaultObject()
// create object by factory // create object by factory
SdrObject* pObj = SdrObjFactory::MakeNewObject( pDlgEdView->GetCurrentObjInventor(), pDlgEdView->GetCurrentObjIdentifier(), pDlgEdPage ); SdrObject* pObj = SdrObjFactory::MakeNewObject( pDlgEdView->GetCurrentObjInventor(), pDlgEdView->GetCurrentObjIdentifier(), pDlgEdPage );
DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, pObj ); if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj))
if ( pDlgEdObj )
{ {
// set position and size // set position and size
Size aSize = pWindow->PixelToLogic( Size( 96, 24 ) ); Size aSize = pWindow->PixelToLogic( Size( 96, 24 ) );
@@ -746,9 +742,9 @@ void DlgEditor::Copy()
for( sal_uLong i = 0; i < nMark; i++ ) for( sal_uLong i = 0; i < nMark; i++ )
{ {
SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj(); SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj); DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj);
if (pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) ) if (pDlgEdObj && !dynamic_cast<DlgEdForm*>(pDlgEdObj))
{ {
::rtl::OUString aName; ::rtl::OUString aName;
Reference< beans::XPropertySet > xMarkPSet(pDlgEdObj->GetUnoControlModel(), uno::UNO_QUERY); Reference< beans::XPropertySet > xMarkPSet(pDlgEdObj->GetUnoControlModel(), uno::UNO_QUERY);
@@ -1070,9 +1066,9 @@ void DlgEditor::Delete()
for( sal_uLong i = 0; i < nMark; i++ ) for( sal_uLong i = 0; i < nMark; i++ )
{ {
SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj(); SdrObject* pObj = pDlgEdView->GetMarkedObjectList().GetMark(i)->GetMarkedSdrObj();
DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj); DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj);
if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) ) if ( pDlgEdObj && !dynamic_cast<DlgEdForm*>(pDlgEdObj) )
{ {
// get name from property // get name from property
::rtl::OUString aName; ::rtl::OUString aName;

View File

@@ -509,7 +509,7 @@ bool DlgEdFuncSelect::MouseButtonDown( const MouseEvent& rMEvt )
{ {
if( pView->PickObj( aMDPos, nHitLog, pObj, pPV ) ) if( pView->PickObj( aMDPos, nHitLog, pObj, pPV ) )
{ {
//if( pObj->ISA( DlgEdForm ) ) //if (dynamic_cast<DlgEdForm*>(pObj))
// pView->UnmarkAll(); // pView->UnmarkAll();
//else //else
// pParent->UnmarkDialog(); // pParent->UnmarkDialog();

View File

@@ -51,6 +51,14 @@ using ::rtl::OUString;
TYPEINIT1(DlgEdObj, SdrUnoObj); TYPEINIT1(DlgEdObj, SdrUnoObj);
DBG_NAME(DlgEdObj); DBG_NAME(DlgEdObj);
DlgEditor* DlgEdObj::GetDialogEditor ()
{
if (DlgEdForm* pFormThis = dynamic_cast<DlgEdForm*>(this))
return pFormThis->GetDlgEditor();
else
return pDlgEdForm->GetDlgEditor();
}
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
DlgEdObj::DlgEdObj() DlgEdObj::DlgEdObj()
@@ -512,12 +520,9 @@ void SAL_CALL DlgEdObj::NameChange( const ::com::sun::star::beans::PropertyChan
xCont->removeByName( aOldName ); xCont->removeByName( aOldName );
xCont->insertByName( aNewName , aAny ); xCont->insertByName( aNewName , aAny );
DlgEditor* pEditor; LocalizationMgr::renameControlResourceIDsForEditorObject(
if ( ISA(DlgEdForm) ) GetDialogEditor(), aAny, aNewName
pEditor = ((DlgEdForm*)this)->GetDlgEditor(); );
else
pEditor = GetDlgEdForm()->GetDlgEditor();
LocalizationMgr::renameControlResourceIDsForEditorObject( pEditor, aAny, aNewName );
} }
} }
else else
@@ -1104,12 +1109,9 @@ void DlgEdObj::SetDefaults()
aAny <<= xCtrl; aAny <<= xCtrl;
xCont->insertByName( aOUniqueName , aAny ); xCont->insertByName( aOUniqueName , aAny );
DlgEditor* pEditor; LocalizationMgr::setControlResourceIDsForNewEditorObject(
if ( ISA(DlgEdForm) ) GetDialogEditor(), aAny, aOUniqueName
pEditor = ((DlgEdForm*)this)->GetDlgEditor(); );
else
pEditor = GetDlgEdForm()->GetDlgEditor();
LocalizationMgr::setControlResourceIDsForNewEditorObject( pEditor, aAny, aOUniqueName );
// #110559# // #110559#
pDlgEdForm->UpdateTabOrderAndGroups(); pDlgEdForm->UpdateTabOrderAndGroups();
@@ -1222,20 +1224,13 @@ void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::Propert
PositionAndSizeChange( evt ); PositionAndSizeChange( evt );
if ( evt.PropertyName == DLGED_PROP_DECORATION ) if ( evt.PropertyName == DLGED_PROP_DECORATION )
{ GetDialogEditor()->ResetDialog();
if ( ISA(DlgEdForm) )
((DlgEdForm*)this)->GetDlgEditor()->ResetDialog();
else
GetDlgEdForm()->GetDlgEditor()->ResetDialog();
}
} }
// change name of control in dialog model // change name of control in dialog model
else if ( evt.PropertyName == DLGED_PROP_NAME ) else if ( evt.PropertyName == DLGED_PROP_NAME )
{ {
if ( !ISA(DlgEdForm) ) if (!dynamic_cast<DlgEdForm*>(this))
{
NameChange(evt); NameChange(evt);
}
} }
// update step // update step
else if ( evt.PropertyName == DLGED_PROP_STEP ) else if ( evt.PropertyName == DLGED_PROP_STEP )
@@ -1245,10 +1240,8 @@ void SAL_CALL DlgEdObj::_propertyChange( const ::com::sun::star::beans::Propert
// change tabindex // change tabindex
else if ( evt.PropertyName == DLGED_PROP_TABINDEX ) else if ( evt.PropertyName == DLGED_PROP_TABINDEX )
{ {
if ( !ISA(DlgEdForm) ) if (!dynamic_cast<DlgEdForm>(this))
{
TabIndexChange(evt); TabIndexChange(evt);
}
} }
} }
} }
@@ -1260,14 +1253,7 @@ void SAL_CALL DlgEdObj::_elementInserted(const ::com::sun::star::container::Cont
if (isListening()) if (isListening())
{ {
// dialog model changed // dialog model changed
if ( ISA(DlgEdForm) ) GetDialogEditor()->SetDialogModelChanged(true);
{
((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(true);
}
else
{
GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(true);
}
} }
} }
@@ -1278,14 +1264,7 @@ void SAL_CALL DlgEdObj::_elementReplaced(const ::com::sun::star::container::Cont
if (isListening()) if (isListening())
{ {
// dialog model changed // dialog model changed
if ( ISA(DlgEdForm) ) GetDialogEditor()->SetDialogModelChanged(true);
{
((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(true);
}
else
{
GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(true);
}
} }
} }
@@ -1296,14 +1275,7 @@ void SAL_CALL DlgEdObj::_elementRemoved(const ::com::sun::star::container::Conta
if (isListening()) if (isListening())
{ {
// dialog model changed // dialog model changed
if ( ISA(DlgEdForm) ) GetDialogEditor()->SetDialogModelChanged(true);
{
((DlgEdForm*)this)->GetDlgEditor()->SetDialogModelChanged(true);
}
else
{
GetDlgEdForm()->GetDlgEditor()->SetDialogModelChanged(true);
}
} }
} }
@@ -1567,9 +1539,8 @@ void DlgEdForm::UpdateStep()
{ {
for ( sal_uLong i = 0 ; i < nObjCount ; i++ ) for ( sal_uLong i = 0 ; i < nObjCount ; i++ )
{ {
SdrObject* pObj = pSdrPage->GetObj(i); DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pSdrPage->GetObj(i));
DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pObj); if (pDlgEdObj && !dynamic_cast<DlgEdForm*>(pDlgEdObj))
if ( pDlgEdObj && !pDlgEdObj->ISA(DlgEdForm) )
pDlgEdObj->UpdateStep(); pDlgEdObj->UpdateStep();
} }
} }

View File

@@ -281,8 +281,7 @@ Sequence< Reference< XInterface > >
while (pCurrent) while (pCurrent)
{ {
DlgEdObj* pDlgEdObj = PTR_CAST(DlgEdObj, pCurrent); if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pCurrent))
if (pDlgEdObj)
{ {
Reference< XInterface > xControlInterface(pDlgEdObj->GetUnoControlModel(), UNO_QUERY); Reference< XInterface > xControlInterface(pDlgEdObj->GetUnoControlModel(), UNO_QUERY);
if (xControlInterface.is()) if (xControlInterface.is())
@@ -525,8 +524,7 @@ void PropBrw::ImplUpdate( const Reference< XModel >& _rxContextDocument, SdrView
Sequence< Reference< XInterface > > aNewObjects; Sequence< Reference< XInterface > > aNewObjects;
if ( nMarkCount == 1 ) if ( nMarkCount == 1 )
{ {
DlgEdObj* pDlgEdObj = PTR_CAST( DlgEdObj, rMarkList.GetMark(0)->GetMarkedSdrObj() ); if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rMarkList.GetMark(0)->GetMarkedSdrObj()))
if ( pDlgEdObj )
{ {
if ( pDlgEdObj->IsGroupObject() ) // group object if ( pDlgEdObj->IsGroupObject() ) // group object
aNewObjects = CreateMultiSelectionSequence( rMarkList ); aNewObjects = CreateMultiSelectionSequence( rMarkList );

View File

@@ -51,6 +51,9 @@ private:
::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener; ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener> m_xPropertyChangeListener;
::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener> m_xContainerListener; ::com::sun::star::uno::Reference< ::com::sun::star::container::XContainerListener> m_xContainerListener;
private:
DlgEditor* GetDialogEditor ();
protected: protected:
DlgEdObj(); DlgEdObj();
DlgEdObj(const ::rtl::OUString& rModelName, DlgEdObj(const ::rtl::OUString& rModelName,