summaryrefslogtreecommitdiff
path: root/basctl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-04-18 15:04:58 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-04-18 21:48:16 +0200
commitcd0ab2cf5063242ef3bff3c6899cea4d4bd53485 (patch)
tree2631f9c128209d178cf2f6b946f5882a5c49e6b2 /basctl
parenteab4993eab9a2a9e0660a827ed60f0125cf20d53 (diff)
loplugin:flatten in basctl
Change-Id: I66e3f46fcaae4e15d230a5a7c98c1b20cfb4dbda Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92485 Tested-by: Jenkins Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basctl')
-rw-r--r--basctl/source/accessibility/accessibledialogwindow.cxx150
-rw-r--r--basctl/source/basicide/basicrenderable.cxx44
-rw-r--r--basctl/source/basicide/baside2.cxx448
-rw-r--r--basctl/source/basicide/baside2b.cxx451
-rw-r--r--basctl/source/basicide/baside3.cxx246
-rw-r--r--basctl/source/basicide/basides1.cxx170
-rw-r--r--basctl/source/basicide/basides2.cxx24
-rw-r--r--basctl/source/basicide/basidesh.cxx323
-rw-r--r--basctl/source/basicide/basobj3.cxx43
-rw-r--r--basctl/source/basicide/bastype2.cxx50
-rw-r--r--basctl/source/basicide/bastypes.cxx77
-rw-r--r--basctl/source/basicide/docsignature.cxx22
-rw-r--r--basctl/source/basicide/layout.cxx93
-rw-r--r--basctl/source/basicide/localizationmgr.cxx116
-rw-r--r--basctl/source/basicide/macrodlg.cxx68
-rw-r--r--basctl/source/basicide/moduldl2.cxx492
-rw-r--r--basctl/source/basicide/moduldlg.cxx180
-rw-r--r--basctl/source/dlged/dlged.cxx445
-rw-r--r--basctl/source/dlged/dlgedobj.cxx710
-rw-r--r--basctl/source/dlged/dlgedview.cxx82
-rw-r--r--basctl/source/dlged/managelang.cxx46
21 files changed, 2145 insertions, 2135 deletions
diff --git a/basctl/source/accessibility/accessibledialogwindow.cxx b/basctl/source/accessibility/accessibledialogwindow.cxx
index ade28c57f738..eeb43b4f0c8b 100644
--- a/basctl/source/accessibility/accessibledialogwindow.cxx
+++ b/basctl/source/accessibility/accessibledialogwindow.cxx
@@ -80,28 +80,28 @@ AccessibleDialogWindow::AccessibleDialogWindow (basctl::DialogWindow* pDialogWin
: m_pDialogWindow(pDialogWindow)
, m_pDlgEdModel(nullptr)
{
- if ( m_pDialogWindow )
- {
- SdrPage& rPage = m_pDialogWindow->GetPage();
- const size_t nCount = rPage.GetObjCount();
+ if ( !m_pDialogWindow )
+ return;
- for ( size_t i = 0; i < nCount; ++i )
+ SdrPage& rPage = m_pDialogWindow->GetPage();
+ const size_t nCount = rPage.GetObjCount();
+
+ for ( size_t i = 0; i < nCount; ++i )
+ {
+ if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
{
- if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(rPage.GetObj(i)))
- {
- ChildDescriptor aDesc( pDlgEdObj );
- if ( IsChildVisible( aDesc ) )
- m_aAccessibleChildren.push_back( aDesc );
- }
+ ChildDescriptor aDesc( pDlgEdObj );
+ if ( IsChildVisible( aDesc ) )
+ m_aAccessibleChildren.push_back( aDesc );
}
+ }
- m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
+ m_pDialogWindow->AddEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
- StartListening(m_pDialogWindow->GetEditor());
+ StartListening(m_pDialogWindow->GetEditor());
- m_pDlgEdModel = &m_pDialogWindow->GetModel();
- StartListening(*m_pDlgEdModel);
- }
+ m_pDlgEdModel = &m_pDialogWindow->GetModel();
+ StartListening(*m_pDlgEdModel);
}
@@ -211,24 +211,24 @@ void AccessibleDialogWindow::InsertChild( const ChildDescriptor& rDesc )
AccessibleChildren::iterator aIter = std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
// if not found, insert in child list
- if ( aIter == m_aAccessibleChildren.end() )
- {
- // insert entry in child list
- m_aAccessibleChildren.push_back( rDesc );
+ if ( aIter != m_aAccessibleChildren.end() )
+ return;
- // get the accessible of the inserted child
- Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
+ // insert entry in child list
+ m_aAccessibleChildren.push_back( rDesc );
- // sort child list
- SortChildren();
+ // get the accessible of the inserted child
+ Reference< XAccessible > xChild( getAccessibleChild( m_aAccessibleChildren.size() - 1 ) );
- // send accessible child event
- if ( xChild.is() )
- {
- Any aOldValue, aNewValue;
- aNewValue <<= xChild;
- NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
- }
+ // sort child list
+ SortChildren();
+
+ // send accessible child event
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aNewValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
}
}
@@ -239,25 +239,25 @@ void AccessibleDialogWindow::RemoveChild( const ChildDescriptor& rDesc )
AccessibleChildren::iterator aIter = std::find( m_aAccessibleChildren.begin(), m_aAccessibleChildren.end(), rDesc );
// if found, remove from child list
- if ( aIter != m_aAccessibleChildren.end() )
- {
- // get the accessible of the removed child
- Reference< XAccessible > xChild( aIter->rxAccessible );
+ if ( aIter == m_aAccessibleChildren.end() )
+ return;
- // remove entry from child list
- m_aAccessibleChildren.erase( aIter );
+ // get the accessible of the removed child
+ Reference< XAccessible > xChild( aIter->rxAccessible );
- // send accessible child event
- if ( xChild.is() )
- {
- Any aOldValue, aNewValue;
- aOldValue <<= xChild;
- NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+ // remove entry from child list
+ m_aAccessibleChildren.erase( aIter );
- Reference< XComponent > xComponent( xChild, UNO_QUERY );
- if ( xComponent.is() )
- xComponent->dispose();
- }
+ // send accessible child event
+ if ( xChild.is() )
+ {
+ Any aOldValue, aNewValue;
+ aOldValue <<= xChild;
+ NotifyAccessibleEvent( AccessibleEventId::CHILD, aOldValue, aNewValue );
+
+ Reference< XComponent > xComponent( xChild, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
}
}
@@ -397,25 +397,25 @@ void AccessibleDialogWindow::ProcessWindowEvent( const VclWindowEvent& rVclWindo
void AccessibleDialogWindow::FillAccessibleStateSet( utl::AccessibleStateSetHelper& rStateSet )
{
- if ( m_pDialogWindow )
- {
- if ( m_pDialogWindow->IsEnabled() )
- rStateSet.AddState( AccessibleStateType::ENABLED );
+ if ( !m_pDialogWindow )
+ return;
- rStateSet.AddState( AccessibleStateType::FOCUSABLE );
+ if ( m_pDialogWindow->IsEnabled() )
+ rStateSet.AddState( AccessibleStateType::ENABLED );
- if ( m_pDialogWindow->HasFocus() )
- rStateSet.AddState( AccessibleStateType::FOCUSED );
+ rStateSet.AddState( AccessibleStateType::FOCUSABLE );
- rStateSet.AddState( AccessibleStateType::VISIBLE );
+ if ( m_pDialogWindow->HasFocus() )
+ rStateSet.AddState( AccessibleStateType::FOCUSED );
- if ( m_pDialogWindow->IsVisible() )
- rStateSet.AddState( AccessibleStateType::SHOWING );
+ rStateSet.AddState( AccessibleStateType::VISIBLE );
- rStateSet.AddState( AccessibleStateType::OPAQUE );
+ if ( m_pDialogWindow->IsVisible() )
+ rStateSet.AddState( AccessibleStateType::SHOWING );
- rStateSet.AddState( AccessibleStateType::RESIZABLE );
- }
+ rStateSet.AddState( AccessibleStateType::OPAQUE );
+
+ rStateSet.AddState( AccessibleStateType::RESIZABLE );
}
@@ -512,24 +512,24 @@ void AccessibleDialogWindow::disposing()
{
OAccessibleExtendedComponentHelper::disposing();
- if ( m_pDialogWindow )
- {
- m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
- m_pDialogWindow = nullptr;
+ if ( !m_pDialogWindow )
+ return;
- if ( m_pDlgEdModel )
- EndListening( *m_pDlgEdModel );
- m_pDlgEdModel = nullptr;
+ m_pDialogWindow->RemoveEventListener( LINK( this, AccessibleDialogWindow, WindowEventListener ) );
+ m_pDialogWindow = nullptr;
- // dispose all children
- for (const ChildDescriptor & i : m_aAccessibleChildren)
- {
- Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY );
- if ( xComponent.is() )
- xComponent->dispose();
- }
- m_aAccessibleChildren.clear();
+ if ( m_pDlgEdModel )
+ EndListening( *m_pDlgEdModel );
+ m_pDlgEdModel = nullptr;
+
+ // dispose all children
+ for (const ChildDescriptor & i : m_aAccessibleChildren)
+ {
+ Reference< XComponent > xComponent( i.rxAccessible, UNO_QUERY );
+ if ( xComponent.is() )
+ xComponent->dispose();
}
+ m_aAccessibleChildren.clear();
}
// XServiceInfo
diff --git a/basctl/source/basicide/basicrenderable.cxx b/basctl/source/basicide/basicrenderable.cxx
index e74f455f91df..eae8b5c81c93 100644
--- a/basctl/source/basicide/basicrenderable.cxx
+++ b/basctl/source/basicide/basicrenderable.cxx
@@ -182,33 +182,33 @@ void SAL_CALL Renderable::render (
{
processProperties( i_xOptions );
- if( mpWindow )
- {
- VclPtr<Printer> pPrinter = getPrinter();
- if (!pPrinter)
- throw lang::IllegalArgumentException();
+ if( !mpWindow )
+ return;
- sal_Int64 nContent = getIntValue( "PrintContent", -1 );
- if( nContent == 1 )
+ VclPtr<Printer> pPrinter = getPrinter();
+ if (!pPrinter)
+ throw lang::IllegalArgumentException();
+
+ sal_Int64 nContent = getIntValue( "PrintContent", -1 );
+ if( nContent == 1 )
+ {
+ OUString aPageRange( getStringValue( "PageRange" ) );
+ if( !aPageRange.isEmpty() )
{
- OUString aPageRange( getStringValue( "PageRange" ) );
- if( !aPageRange.isEmpty() )
- {
- sal_Int32 nPageCount = mpWindow->countPages( pPrinter );
- StringRangeEnumerator aRangeEnum( aPageRange, 0, nPageCount-1 );
- StringRangeEnumerator::Iterator it = aRangeEnum.begin();
- for( ; it != aRangeEnum.end() && nRenderer; --nRenderer )
- ++it;
-
- sal_Int32 nPage = ( it != aRangeEnum.end() ) ? *it : nRenderer;
- mpWindow->printPage( nPage, pPrinter );
- }
- else
- mpWindow->printPage( nRenderer, pPrinter );
+ sal_Int32 nPageCount = mpWindow->countPages( pPrinter );
+ StringRangeEnumerator aRangeEnum( aPageRange, 0, nPageCount-1 );
+ StringRangeEnumerator::Iterator it = aRangeEnum.begin();
+ for( ; it != aRangeEnum.end() && nRenderer; --nRenderer )
+ ++it;
+
+ sal_Int32 nPage = ( it != aRangeEnum.end() ) ? *it : nRenderer;
+ mpWindow->printPage( nPage, pPrinter );
}
else
- mpWindow->printPage( maValidPages.at( nRenderer ), pPrinter );
+ mpWindow->printPage( nRenderer, pPrinter );
}
+ else
+ mpWindow->printPage( maValidPages.at( nRenderer ), pPrinter );
}
} // namespace basctl
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index 2aa29d74df71..46014b5e32db 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -167,26 +167,26 @@ void lcl_PrintHeader( Printer* pPrinter, sal_uInt16 nPages, sal_uInt16 nCurPage,
void lcl_ConvertTabsToSpaces( OUString& rLine )
{
- if ( !rLine.isEmpty() )
+ if ( rLine.isEmpty() )
+ return;
+
+ OUStringBuffer aResult( rLine );
+ sal_Int32 nPos = 0;
+ sal_Int32 nMax = aResult.getLength();
+ while ( nPos < nMax )
{
- OUStringBuffer aResult( rLine );
- sal_Int32 nPos = 0;
- sal_Int32 nMax = aResult.getLength();
- while ( nPos < nMax )
+ if ( aResult[nPos] == '\t' )
{
- if ( aResult[nPos] == '\t' )
- {
- // not 4 Blanks, but at 4 TabPos:
- OUStringBuffer aBlanker;
- string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' ');
- aResult.remove( nPos, 1 );
- aResult.insert( nPos, aBlanker.makeStringAndClear() );
- nMax = aResult.getLength();
- }
- ++nPos;
+ // not 4 Blanks, but at 4 TabPos:
+ OUStringBuffer aBlanker;
+ string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' ');
+ aResult.remove( nPos, 1 );
+ aResult.insert( nPos, aBlanker.makeStringAndClear() );
+ nMax = aResult.getLength();
}
- rLine = aResult.makeStringAndClear();
+ ++nPos;
}
+ rLine = aResult.makeStringAndClear();
}
} // namespace
@@ -270,43 +270,43 @@ void ModulWindow::Resize()
void ModulWindow::CheckCompileBasic()
{
- if ( XModule().is() )
- {
- // never compile while running!
- bool const bRunning = StarBASIC::IsRunning();
- bool const bModified = ( !m_xModule->IsCompiled() ||
- ( GetEditEngine() && GetEditEngine()->IsModified() ) );
+ if ( !XModule().is() )
+ return;
- if ( !bRunning && bModified )
- {
- bool bDone = false;
+ // never compile while running!
+ bool const bRunning = StarBASIC::IsRunning();
+ bool const bModified = ( !m_xModule->IsCompiled() ||
+ ( GetEditEngine() && GetEditEngine()->IsModified() ) );
- GetShell()->GetViewFrame()->GetWindow().EnterWait();
+ if ( !(!bRunning && bModified) )
+ return;
- AssertValidEditEngine();
- GetEditorWindow().SetSourceInBasic();
+ bool bDone = false;
- bool bWasModified = GetBasic()->IsModified();
+ GetShell()->GetViewFrame()->GetWindow().EnterWait();
- {
- // tdf#106529: only use strict compilation mode when compiling from the IDE
- css::uno::ContextLayer layer(comphelper::NewFlagContext("BasicStrict"));
- bDone = m_xModule->Compile();
- }
- if ( !bWasModified )
- GetBasic()->SetModified(false);
+ AssertValidEditEngine();
+ GetEditorWindow().SetSourceInBasic();
- if ( bDone )
- {
- GetBreakPoints().SetBreakPointsInBasic( m_xModule.get() );
- }
+ bool bWasModified = GetBasic()->IsModified();
- GetShell()->GetViewFrame()->GetWindow().LeaveWait();
+ {
+ // tdf#106529: only use strict compilation mode when compiling from the IDE
+ css::uno::ContextLayer layer(comphelper::NewFlagContext("BasicStrict"));
+ bDone = m_xModule->Compile();
+ }
+ if ( !bWasModified )
+ GetBasic()->SetModified(false);
- m_aStatus.bError = !bDone;
- m_aStatus.bIsRunning = false;
- }
+ if ( bDone )
+ {
+ GetBreakPoints().SetBreakPointsInBasic( m_xModule.get() );
}
+
+ GetShell()->GetViewFrame()->GetWindow().LeaveWait();
+
+ m_aStatus.bError = !bDone;
+ m_aStatus.bIsRunning = false;
}
void ModulWindow::BasicExecute()
@@ -325,50 +325,50 @@ void ModulWindow::BasicExecute()
CheckCompileBasic();
- if ( XModule().is() && m_xModule->IsCompiled() && !m_aStatus.bError )
- {
- if ( GetBreakPoints().size() )
- m_aStatus.nBasicFlags = m_aStatus.nBasicFlags | BasicDebugFlags::Break;
+ if ( !(XModule().is() && m_xModule->IsCompiled() && !m_aStatus.bError) )
+ return;
+
+ if ( GetBreakPoints().size() )
+ m_aStatus.nBasicFlags = m_aStatus.nBasicFlags | BasicDebugFlags::Break;
- if ( !m_aStatus.bIsRunning )
+ if ( !m_aStatus.bIsRunning )
+ {
+ DBG_ASSERT( m_xModule.is(), "No Module!" );
+ AddStatus( BASWIN_RUNNINGBASIC );
+ sal_uInt16 nStart, nEnd;
+ TextSelection aSel = GetEditView()->GetSelection();
+ // Init cursor to top
+ const sal_uInt32 nCurMethodStart = aSel.GetStart().GetPara() + 1;
+ SbMethod* pMethod = nullptr;
+ // first Macro, else blind "Main" (ExtSearch?)
+ for ( sal_uInt32 nMacro = 0; nMacro < m_xModule->GetMethods()->Count32(); nMacro++ )
{
- DBG_ASSERT( m_xModule.is(), "No Module!" );
- AddStatus( BASWIN_RUNNINGBASIC );
- sal_uInt16 nStart, nEnd;
- TextSelection aSel = GetEditView()->GetSelection();
- // Init cursor to top
- const sal_uInt32 nCurMethodStart = aSel.GetStart().GetPara() + 1;
- SbMethod* pMethod = nullptr;
- // first Macro, else blind "Main" (ExtSearch?)
- for ( sal_uInt32 nMacro = 0; nMacro < m_xModule->GetMethods()->Count32(); nMacro++ )
- {
- SbMethod* pM = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMacro ));
- assert(pM && "Method?");
- pM->GetLineRange( nStart, nEnd );
- if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd )
- {
- // matched a method to the cursor position
- pMethod = pM;
- break;
- }
- }
- if ( !pMethod )
+ SbMethod* pM = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMacro ));
+ assert(pM && "Method?");
+ pM->GetLineRange( nStart, nEnd );
+ if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd )
{
- // If not in a method then prompt the user
- ChooseMacro(GetFrameWeld(), uno::Reference<frame::XModel>());
- return;
+ // matched a method to the cursor position
+ pMethod = pM;
+ break;
}
- pMethod->SetDebugFlags(m_aStatus.nBasicFlags);
- BasicDLL::SetDebugMode(true);
- RunMethod(pMethod);
- BasicDLL::SetDebugMode(false);
- // if cancelled during Interactive=false
- BasicDLL::EnableBreak(true);
- ClearStatus( BASWIN_RUNNINGBASIC );
}
- else
- m_aStatus.bIsRunning = false; // cancel of Reschedule()
+ if ( !pMethod )
+ {
+ // If not in a method then prompt the user
+ ChooseMacro(GetFrameWeld(), uno::Reference<frame::XModel>());
+ return;
+ }
+ pMethod->SetDebugFlags(m_aStatus.nBasicFlags);
+ BasicDLL::SetDebugMode(true);
+ RunMethod(pMethod);
+ BasicDLL::SetDebugMode(false);
+ // if cancelled during Interactive=false
+ BasicDLL::EnableBreak(true);
+ ClearStatus( BASWIN_RUNNINGBASIC );
}
+ else
+ m_aStatus.bIsRunning = false; // cancel of Reschedule()
}
void ModulWindow::CompileBasic()
@@ -422,34 +422,34 @@ void ModulWindow::LoadBasic()
xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
xFP->setCurrentFilter( "BASIC" );
- if( xFP->execute() == RET_OK )
+ if( xFP->execute() != RET_OK )
+ return;
+
+ Sequence< OUString > aPaths = xFP->getSelectedFiles();
+ m_sCurPath = aPaths[0];
+ SfxMedium aMedium( m_sCurPath, StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE );
+ SvStream* pStream = aMedium.GetInStream();
+ if ( pStream )
{
- Sequence< OUString > aPaths = xFP->getSelectedFiles();
- m_sCurPath = aPaths[0];
- SfxMedium aMedium( m_sCurPath, StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE );
- SvStream* pStream = aMedium.GetInStream();
- if ( pStream )
- {
- AssertValidEditEngine();
- sal_uInt32 nLines = CalcLineCount( *pStream );
- // nLines*4: ReadText/Formatting/Highlighting/Formatting
- GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE), nLines*4 );
- GetEditEngine()->SetUpdateMode( false );
- GetEditView()->Read( *pStream );
- GetEditEngine()->SetUpdateMode( true );
- GetEditorWindow().PaintImmediately();
- GetEditorWindow().ForceSyntaxTimeout();
- GetEditorWindow().DestroyProgress();
- ErrCode nError = aMedium.GetError();
- if ( nError )
- ErrorHandler::HandleError( nError );
- }
- else
- {
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
- VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTREAD)));
- xBox->run();
- }
+ AssertValidEditEngine();
+ sal_uInt32 nLines = CalcLineCount( *pStream );
+ // nLines*4: ReadText/Formatting/Highlighting/Formatting
+ GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE), nLines*4 );
+ GetEditEngine()->SetUpdateMode( false );
+ GetEditView()->Read( *pStream );
+ GetEditEngine()->SetUpdateMode( true );
+ GetEditorWindow().PaintImmediately();
+ GetEditorWindow().ForceSyntaxTimeout();
+ GetEditorWindow().DestroyProgress();
+ ErrCode nError = aMedium.GetError();
+ if ( nError )
+ ErrorHandler::HandleError( nError );
+ }
+ else
+ {
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTREAD)));
+ xBox->run();
}
}
@@ -472,29 +472,29 @@ void ModulWindow::SaveBasicSource()
xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
xFP->setCurrentFilter( "BASIC" );
- if( xFP->execute() == RET_OK )
+ if( xFP->execute() != RET_OK )
+ return;
+
+ Sequence< OUString > aPaths = xFP->getSelectedFiles();
+ m_sCurPath = aPaths[0];
+ SfxMedium aMedium( m_sCurPath, StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC );
+ SvStream* pStream = aMedium.GetOutStream();
+ if ( pStream )
{
- Sequence< OUString > aPaths = xFP->getSelectedFiles();
- m_sCurPath = aPaths[0];
- SfxMedium aMedium( m_sCurPath, StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC );
- SvStream* pStream = aMedium.GetOutStream();
- if ( pStream )
- {
- EnterWait();
- AssertValidEditEngine();
- GetEditEngine()->Write( *pStream );
- aMedium.Commit();
- LeaveWait();
- ErrCode nError = aMedium.GetError();
- if ( nError )
- ErrorHandler::HandleError( nError );
- }
- else
- {
- std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
- VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE)));
- xErrorBox->run();
- }
+ EnterWait();
+ AssertValidEditEngine();
+ GetEditEngine()->Write( *pStream );
+ aMedium.Commit();
+ LeaveWait();
+ ErrCode nError = aMedium.GetError();
+ if ( nError )
+ ErrorHandler::HandleError( nError );
+ }
+ else
+ {
+ std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE)));
+ xErrorBox->run();
}
}
@@ -509,33 +509,33 @@ void ModulWindow::ToggleBreakPoint( sal_uInt16 nLine )
{
DBG_ASSERT( XModule().is(), "No Module!" );
- if ( XModule().is() )
+ if ( !XModule().is() )
+ return;
+
+ CheckCompileBasic();
+ if ( m_aStatus.bError )
{
- CheckCompileBasic();
- if ( m_aStatus.bError )
- {
- return;
- }
+ return;
+ }
- BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine );
- if ( pBrk ) // remove
- {
- m_xModule->ClearBP( nLine );
- GetBreakPoints().remove( pBrk );
- }
- else // create one
+ BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine );
+ if ( pBrk ) // remove
+ {
+ m_xModule->ClearBP( nLine );
+ GetBreakPoints().remove( pBrk );
+ }
+ else // create one
+ {
+ if ( m_xModule->SetBP( nLine ))
{
- if ( m_xModule->SetBP( nLine ))
+ GetBreakPoints().InsertSorted( BreakPoint( nLine ) );
+ if ( StarBASIC::IsRunning() )
{
- GetBreakPoints().InsertSorted( BreakPoint( nLine ) );
- if ( StarBASIC::IsRunning() )
+ for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ )
{
- for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ )
- {
- SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod ));
- assert(pMethod && "Method not found! (NULL)");
- pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break );
- }
+ SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod ));
+ assert(pMethod && "Method not found! (NULL)");
+ pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break );
}
}
}
@@ -580,23 +580,23 @@ void ModulWindow::BasicToggleBreakPointEnabled()
AssertValidEditEngine();
TextView* pView = GetEditView();
- if ( pView )
- {
- TextSelection aSel = pView->GetSelection();
- BreakPointList& rList = GetBreakPoints();
+ if ( !pView )
+ return;
+
+ TextSelection aSel = pView->GetSelection();
+ BreakPointList& rList = GetBreakPoints();
- for ( sal_uInt32 nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine )
+ for ( sal_uInt32 nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine )
+ {
+ BreakPoint* pBrk = rList.FindBreakPoint( nLine );
+ if ( pBrk )
{
- BreakPoint* pBrk = rList.FindBreakPoint( nLine );
- if ( pBrk )
- {
- pBrk->bEnabled = !pBrk->bEnabled;
- UpdateBreakPoint( *pBrk );
- }
+ pBrk->bEnabled = !pBrk->bEnabled;
+ UpdateBreakPoint( *pBrk );
}
-
- GetBreakPointWindow().Invalidate();
}
+
+ GetBreakPointWindow().Invalidate();
}
void ModulWindow::ManageBreakPoints()
@@ -717,43 +717,43 @@ void ModulWindow::EditMacro( const OUString& rMacroName )
{
DBG_ASSERT( XModule().is(), "No Module!" );
- if ( XModule().is() )
- {
- CheckCompileBasic();
+ if ( !XModule().is() )
+ return;
- if ( !m_aStatus.bError )
- {
- sal_uInt16 nStart, nEnd;
- SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->Find( rMacroName, SbxClassType::Method ));
- if ( pMethod )
- {
- pMethod->GetLineRange( nStart, nEnd );
- if ( nStart )
- {
- nStart--;
- nEnd--;
- }
- TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) );
- AssertValidEditEngine();
- TextView * pView = GetEditView();
- // scroll if applicable so that first line is at the top
- long nVisHeight = GetOutputSizePixel().Height();
- if ( pView->GetTextEngine()->GetTextHeight() > nVisHeight )
- {
- long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight;
- long nOldStartY = pView->GetStartDocPos().Y();
- long nNewStartY = static_cast<long>(nStart) * pView->GetTextEngine()->GetCharHeight();
- nNewStartY = std::min( nNewStartY, nMaxY );
- pView->Scroll( 0, -(nNewStartY-nOldStartY) );
- pView->ShowCursor( false );
- GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() );
- }
- pView->SetSelection( aSel );
- pView->ShowCursor();
- pView->GetWindow()->GrabFocus();
- }
- }
+ CheckCompileBasic();
+
+ if ( m_aStatus.bError )
+ return;
+
+ sal_uInt16 nStart, nEnd;
+ SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->Find( rMacroName, SbxClassType::Method ));
+ if ( !pMethod )
+ return;
+
+ pMethod->GetLineRange( nStart, nEnd );
+ if ( nStart )
+ {
+ nStart--;
+ nEnd--;
}
+ TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) );
+ AssertValidEditEngine();
+ TextView * pView = GetEditView();
+ // scroll if applicable so that first line is at the top
+ long nVisHeight = GetOutputSizePixel().Height();
+ if ( pView->GetTextEngine()->GetTextHeight() > nVisHeight )
+ {
+ long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight;
+ long nOldStartY = pView->GetStartDocPos().Y();
+ long nNewStartY = static_cast<long>(nStart) * pView->GetTextEngine()->GetCharHeight();
+ nNewStartY = std::min( nNewStartY, nMaxY );
+ pView->Scroll( 0, -(nNewStartY-nOldStartY) );
+ pView->ShowCursor( false );
+ GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() );
+ }
+ pView->SetSelection( aSel );
+ pView->ShowCursor();
+ pView->GetWindow()->GrabFocus();
}
void ModulWindow::StoreData()
@@ -775,18 +775,18 @@ void ModulWindow::UpdateData()
// UpdateData is called when the source has changed from outside
// => interrupts undesired!
- if ( XModule().is() )
- {
- SetModule( m_xModule->GetSource32() );
+ if ( !XModule().is() )
+ return;
- if ( GetEditView() )
- {
- TextSelection aSel = GetEditView()->GetSelection();
- setTextEngineText(*GetEditEngine(), m_xModule->GetSource32());
- GetEditView()->SetSelection( aSel );
- GetEditEngine()->SetModified( false );
- MarkDocumentModified( GetDocument() );
- }
+ SetModule( m_xModule->GetSource32() );
+
+ if ( GetEditView() )
+ {
+ TextSelection aSel = GetEditView()->GetSelection();
+ setTextEngineText(*GetEditEngine(), m_xModule->GetSource32());
+ GetEditView()->SetSelection( aSel );
+ GetEditEngine()->SetModified( false );
+ MarkDocumentModified( GetDocument() );
}
}
@@ -1287,20 +1287,20 @@ SearchOptionFlags ModulWindow::GetSearchOptions()
void ModulWindow::BasicStarted()
{
- if ( XModule().is() )
+ if ( !XModule().is() )
+ return;
+
+ m_aStatus.bIsRunning = true;
+ BreakPointList& rList = GetBreakPoints();
+ if ( rList.size() )
{
- m_aStatus.bIsRunning = true;
- BreakPointList& rList = GetBreakPoints();
- if ( rList.size() )
+ rList.ResetHitCount();
+ rList.SetBreakPointsInBasic( m_xModule.get() );
+ for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ )
{
- rList.ResetHitCount();
- rList.SetBreakPointsInBasic( m_xModule.get() );
- for ( sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count32(); nMethod++ )
- {
- SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod ));
- assert(pMethod && "Method not found! (NULL)");
- pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break );
- }
+ SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get32( nMethod ));
+ assert(pMethod && "Method not found! (NULL)");
+ pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break );
}
}
}
diff --git a/basctl/source/basicide/baside2b.cxx b/basctl/source/basicide/baside2b.cxx
index 83f09d64297e..270c6cfc5b12 100644
--- a/basctl/source/basicide/baside2b.cxx
+++ b/basctl/source/basicide/baside2b.cxx
@@ -406,28 +406,28 @@ void EditorWindow::RequestHelp( const HelpEvent& rHEvt )
void EditorWindow::Resize()
{
// ScrollBars, etc. happens in Adjust...
- if ( pEditView )
- {
- long nVisY = pEditView->GetStartDocPos().Y();
+ if ( !pEditView )
+ return;
+
+ long nVisY = pEditView->GetStartDocPos().Y();
+ pEditView->ShowCursor();
+ Size aOutSz( GetOutputSizePixel() );
+ long nMaxVisAreaStart = pEditView->GetTextEngine()->GetTextHeight() - aOutSz.Height();
+ if ( nMaxVisAreaStart < 0 )
+ nMaxVisAreaStart = 0;
+ if ( pEditView->GetStartDocPos().Y() > nMaxVisAreaStart )
+ {
+ Point aStartDocPos( pEditView->GetStartDocPos() );
+ aStartDocPos.setY( nMaxVisAreaStart );
+ pEditView->SetStartDocPos( aStartDocPos );
pEditView->ShowCursor();
- Size aOutSz( GetOutputSizePixel() );
- long nMaxVisAreaStart = pEditView->GetTextEngine()->GetTextHeight() - aOutSz.Height();
- if ( nMaxVisAreaStart < 0 )
- nMaxVisAreaStart = 0;
- if ( pEditView->GetStartDocPos().Y() > nMaxVisAreaStart )
- {
- Point aStartDocPos( pEditView->GetStartDocPos() );
- aStartDocPos.setY( nMaxVisAreaStart );
- pEditView->SetStartDocPos( aStartDocPos );
- pEditView->ShowCursor();
- rModulWindow.GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y();
- rModulWindow.GetLineNumberWindow().GetCurYOffset() = aStartDocPos.Y();
- }
- InitScrollBars();
- if ( nVisY != pEditView->GetStartDocPos().Y() )
- Invalidate();
+ rModulWindow.GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y();
+ rModulWindow.GetLineNumberWindow().GetCurYOffset() = aStartDocPos.Y();
}
+ InitScrollBars();
+ if ( nVisY != pEditView->GetStartDocPos().Y() )
+ Invalidate();
}
@@ -468,23 +468,23 @@ void EditorWindow::MouseButtonDown( const MouseEvent &rEvt )
void EditorWindow::Command( const CommandEvent& rCEvt )
{
- if ( pEditView )
+ if ( !pEditView )
+ return;
+
+ pEditView->Command( rCEvt );
+ if ( ( rCEvt.GetCommand() == CommandEventId::Wheel ) ||
+ ( rCEvt.GetCommand() == CommandEventId::StartAutoScroll ) ||
+ ( rCEvt.GetCommand() == CommandEventId::AutoScroll ) )
{
- pEditView->Command( rCEvt );
- if ( ( rCEvt.GetCommand() == CommandEventId::Wheel ) ||
- ( rCEvt.GetCommand() == CommandEventId::StartAutoScroll ) ||
- ( rCEvt.GetCommand() == CommandEventId::AutoScroll ) )
+ HandleScrollCommand( rCEvt, rModulWindow.GetHScrollBar(), &rModulWindow.GetEditVScrollBar() );
+ } else if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) {
+ SfxDispatcher* pDispatcher = GetDispatcher();
+ if ( pDispatcher )
{
- HandleScrollCommand( rCEvt, rModulWindow.GetHScrollBar(), &rModulWindow.GetEditVScrollBar() );
- } else if ( rCEvt.GetCommand() == CommandEventId::ContextMenu ) {
- SfxDispatcher* pDispatcher = GetDispatcher();
- if ( pDispatcher )
- {
- SfxDispatcher::ExecutePopup();
- }
- if( pCodeCompleteWnd->IsVisible() ) // hide the code complete window
- pCodeCompleteWnd->ClearAndHide();
+ SfxDispatcher::ExecutePopup();
}
+ if( pCodeCompleteWnd->IsVisible() ) // hide the code complete window
+ pCodeCompleteWnd->ClearAndHide();
}
}
@@ -649,27 +649,28 @@ void EditorWindow::HandleAutoCorrect()
pEditEngine->ReplaceText( sTextSelection, sStr );
pEditView->SetSelection( aSel );
}
- if( r.tokenType == TokenType::Identifier )
- {// correct variables
- if( !aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName ).isEmpty() )
- {
- sStr = aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName );
- pEditEngine->ReplaceText( sTextSelection, sStr );
- pEditView->SetSelection( aSel );
- }
- else
+ if( r.tokenType != TokenType::Identifier )
+ return;
+
+// correct variables
+ if( !aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName ).isEmpty() )
+ {
+ sStr = aCodeCompleteCache.GetCorrectCaseVarName( sStr, sActSubName );
+ pEditEngine->ReplaceText( sTextSelection, sStr );
+ pEditView->SetSelection( aSel );
+ }
+ else
+ {
+ //autocorrect procedures
+ SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods().get();
+ for( sal_uInt32 i=0; i < pArr->Count32(); ++i )
{
- //autocorrect procedures
- SbxArray* pArr = rModulWindow.GetSbModule()->GetMethods().get();
- for( sal_uInt32 i=0; i < pArr->Count32(); ++i )
+ if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sStr ) )
{
- if( pArr->Get32(i)->GetName().equalsIgnoreAsciiCase( sStr ) )
- {
- sStr = pArr->Get32(i)->GetName(); //if found, get the correct case
- pEditEngine->ReplaceText( sTextSelection, sStr );
- pEditView->SetSelection( aSel );
- return;
- }
+ sStr = pArr->Get32(i)->GetName(); //if found, get the correct case
+ pEditEngine->ReplaceText( sTextSelection, sStr );
+ pEditView->SetSelection( aSel );
+ return;
}
}
}
@@ -844,55 +845,56 @@ void EditorWindow::HandleCodeCompletion()
std::vector<HighlightPortion> aPortions;
aLine = aLine.copy(0, aSel.GetEnd().GetIndex());
aHighlighter.getHighlightPortions( aLine, aPortions );
- if( !aPortions.empty() )
- {//use the syntax highlighter to grab out nested reflection calls, eg. aVar.aMethod("aa").aOtherMethod ..
- for( std::vector<HighlightPortion>::reverse_iterator i(
- aPortions.rbegin());
- i != aPortions.rend(); ++i)
- {
- if( i->tokenType == TokenType::Whitespace ) // a whitespace: stop; if there is no ws, it goes to the beginning of the line
- break;
- if( i->tokenType == TokenType::Identifier || i->tokenType == TokenType::Keywords ) // extract the identifiers(methods, base variable)
- /* an example: Dim aLocVar2 as com.sun.star.beans.PropertyValue
- * here, aLocVar2.Name, and PropertyValue's Name field is treated as a keyword(?!)
- * */
- aVect.insert( aVect.begin(), aLine.copy(i->nBegin, i->nEnd - i->nBegin) );
- }
-
- if( aVect.empty() )//nothing to do
- return;
+ if( aPortions.empty() )
+ return;
- OUString sBaseName = aVect[aVect.size()-1];//variable name
- OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName );
+ //use the syntax highlighter to grab out nested reflection calls, eg. aVar.aMethod("aa").aOtherMethod ..
+ for( std::vector<HighlightPortion>::reverse_iterator i(
+ aPortions.rbegin());
+ i != aPortions.rend(); ++i)
+ {
+ if( i->tokenType == TokenType::Whitespace ) // a whitespace: stop; if there is no ws, it goes to the beginning of the line
+ break;
+ if( i->tokenType == TokenType::Identifier || i->tokenType == TokenType::Keywords ) // extract the identifiers(methods, base variable)
+ /* an example: Dim aLocVar2 as com.sun.star.beans.PropertyValue
+ * here, aLocVar2.Name, and PropertyValue's Name field is treated as a keyword(?!)
+ * */
+ aVect.insert( aVect.begin(), aLine.copy(i->nBegin, i->nEnd - i->nBegin) );
+ }
- if( !sVarType.isEmpty() && CodeCompleteOptions::IsAutoCorrectOn() )
- {//correct variable name, if autocorrection on
- const OUString& sStr = aCodeCompleteCache.GetCorrectCaseVarName( sBaseName, GetActualSubName(nLine) );
- if( !sStr.isEmpty() )
- {
- TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() );
- TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex()));
- pEditEngine->ReplaceText( sTextSelection, sStr );
- pEditView->SetSelection( aSel );
- }
- }
+ if( aVect.empty() )//nothing to do
+ return;
- UnoTypeCodeCompletetor aTypeCompletor( aVect, sVarType );
+ OUString sBaseName = aVect[aVect.size()-1];//variable name
+ OUString sVarType = aCodeCompleteCache.GetVarType( sBaseName );
- if( aTypeCompletor.CanCodeComplete() )
+ if( !sVarType.isEmpty() && CodeCompleteOptions::IsAutoCorrectOn() )
+ {//correct variable name, if autocorrection on
+ const OUString& sStr = aCodeCompleteCache.GetCorrectCaseVarName( sBaseName, GetActualSubName(nLine) );
+ if( !sStr.isEmpty() )
{
- std::vector< OUString > aEntryVect;//entries to be inserted into the list
- std::vector< OUString > aFieldVect = aTypeCompletor.GetXIdlClassFields();//fields
- aEntryVect.insert(aEntryVect.end(), aFieldVect.begin(), aFieldVect.end() );
- if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
- {// if extended types on, reflect classes, else just the structs (XIdlClass without methods)
- std::vector< OUString > aMethVect = aTypeCompletor.GetXIdlClassMethods();//methods
- aEntryVect.insert(aEntryVect.end(), aMethVect.begin(), aMethVect.end() );
- }
- if( !aEntryVect.empty() )
- SetupAndShowCodeCompleteWnd( aEntryVect, aSel );
+ TextPaM aStart(nLine, aSel.GetStart().GetIndex() - sStr.getLength() );
+ TextSelection sTextSelection(aStart, TextPaM(nLine, aSel.GetStart().GetIndex()));
+ pEditEngine->ReplaceText( sTextSelection, sStr );
+ pEditView->SetSelection( aSel );
}
}
+
+ UnoTypeCodeCompletetor aTypeCompletor( aVect, sVarType );
+
+ if( !aTypeCompletor.CanCodeComplete() )
+ return;
+
+ std::vector< OUString > aEntryVect;//entries to be inserted into the list
+ std::vector< OUString > aFieldVect = aTypeCompletor.GetXIdlClassFields();//fields
+ aEntryVect.insert(aEntryVect.end(), aFieldVect.begin(), aFieldVect.end() );
+ if( CodeCompleteOptions::IsExtendedTypeDeclaration() )
+ {// if extended types on, reflect classes, else just the structs (XIdlClass without methods)
+ std::vector< OUString > aMethVect = aTypeCompletor.GetXIdlClassMethods();//methods
+ aEntryVect.insert(aEntryVect.end(), aMethVect.begin(), aMethVect.end() );
+ }
+ if( !aEntryVect.empty() )
+ SetupAndShowCodeCompleteWnd( aEntryVect, aSel );
}
void EditorWindow::SetupAndShowCodeCompleteWnd( const std::vector< OUString >& aEntryVect, TextSelection aSel )
@@ -1047,70 +1049,71 @@ void EditorWindow::CreateEditEngine()
void EditorWindow::Notify( SfxBroadcaster& /*rBC*/, const SfxHint& rHint )
{
- if (TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint))
+ TextHint const* pTextHint = dynamic_cast<TextHint const*>(&rHint);
+ if (!pTextHint)
+ return;
+
+ TextHint const& rTextHint = *pTextHint;
+ if( rTextHint.GetId() == SfxHintId::TextViewScrolled )
{
- TextHint const& rTextHint = *pTextHint;
- if( rTextHint.GetId() == SfxHintId::TextViewScrolled )
- {
- if ( rModulWindow.GetHScrollBar() )
- rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
- rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
- rModulWindow.GetBreakPointWindow().DoScroll
- ( rModulWindow.GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
- rModulWindow.GetLineNumberWindow().DoScroll
- ( rModulWindow.GetLineNumberWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
- }
- else if( rTextHint.GetId() == SfxHintId::TextHeightChanged )
+ if ( rModulWindow.GetHScrollBar() )
+ rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
+ rModulWindow.GetEditVScrollBar().SetThumbPos( pEditView->GetStartDocPos().Y() );
+ rModulWindow.GetBreakPointWindow().DoScroll
+ ( rModulWindow.GetBreakPointWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
+ rModulWindow.GetLineNumberWindow().DoScroll
+ ( rModulWindow.GetLineNumberWindow().GetCurYOffset() - pEditView->GetStartDocPos().Y() );
+ }
+ else if( rTextHint.GetId() == SfxHintId::TextHeightChanged )
+ {
+ if ( pEditView->GetStartDocPos().Y() )
{
- if ( pEditView->GetStartDocPos().Y() )
- {
- long nOutHeight = GetOutputSizePixel().Height();
- long nTextHeight = pEditEngine->GetTextHeight();
- if ( nTextHeight < nOutHeight )
- pEditView->Scroll( 0, pEditView->GetStartDocPos().Y() );
+ long nOutHeight = GetOutputSizePixel().Height();
+ long nTextHeight = pEditEngine->GetTextHeight();
+ if ( nTextHeight < nOutHeight )
+ pEditView->Scroll( 0, pEditView->GetStartDocPos().Y() );
- rModulWindow.GetLineNumberWindow().Invalidate();
- }
-
- SetScrollBarRanges();
+ rModulWindow.GetLineNumberWindow().Invalidate();
}
- else if( rTextHint.GetId() == SfxHintId::TextFormatted )
+
+ SetScrollBarRanges();
+ }
+ else if( rTextHint.GetId() == SfxHintId::TextFormatted )
+ {
+ if ( rModulWindow.GetHScrollBar() )
{
- if ( rModulWindow.GetHScrollBar() )
+ const long nWidth = pEditEngine->CalcTextWidth();
+ if ( nWidth != nCurTextWidth )
{
- const long nWidth = pEditEngine->CalcTextWidth();
- if ( nWidth != nCurTextWidth )
- {
- nCurTextWidth = nWidth;
- rModulWindow.GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1) );
- rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
- }
+ nCurTextWidth = nWidth;
+ rModulWindow.GetHScrollBar()->SetRange( Range( 0, nCurTextWidth-1) );
+ rModulWindow.GetHScrollBar()->SetThumbPos( pEditView->GetStartDocPos().X() );
}
- long nPrevTextWidth = nCurTextWidth;
- nCurTextWidth = pEditEngine->CalcTextWidth();
- if ( nCurTextWidth != nPrevTextWidth )
- SetScrollBarRanges();
}
- else if( rTextHint.GetId() == SfxHintId::TextParaInserted )
- {
- ParagraphInsertedDeleted( rTextHint.GetValue(), true );
- DoDelayedSyntaxHighlight( rTextHint.GetValue() );
- }
- else if( rTextHint.GetId() == SfxHintId::TextParaRemoved )
- {
- ParagraphInsertedDeleted( rTextHint.GetValue(), false );
- }
- else if( rTextHint.GetId() == SfxHintId::TextParaContentChanged )
- {
- DoDelayedSyntaxHighlight( rTextHint.GetValue() );
- }
- else if( rTextHint.GetId() == SfxHintId::TextViewSelectionChanged )
+ long nPrevTextWidth = nCurTextWidth;
+ nCurTextWidth = pEditEngine->CalcTextWidth();
+ if ( nCurTextWidth != nPrevTextWidth )
+ SetScrollBarRanges();
+ }
+ else if( rTextHint.GetId() == SfxHintId::TextParaInserted )
+ {
+ ParagraphInsertedDeleted( rTextHint.GetValue(), true );
+ DoDelayedSyntaxHighlight( rTextHint.GetValue() );
+ }
+ else if( rTextHint.GetId() == SfxHintId::TextParaRemoved )
+ {
+ ParagraphInsertedDeleted( rTextHint.GetValue(), false );
+ }
+ else if( rTextHint.GetId() == SfxHintId::TextParaContentChanged )
+ {
+ DoDelayedSyntaxHighlight( rTextHint.GetValue() );
+ }
+ else if( rTextHint.GetId() == SfxHintId::TextViewSelectionChanged )
+ {
+ if (SfxBindings* pBindings = GetBindingsPtr())
{
- if (SfxBindings* pBindings = GetBindingsPtr())
- {
- pBindings->Invalidate( SID_CUT );
- pBindings->Invalidate( SID_COPY );
- }
+ pBindings->Invalidate( SID_CUT );
+ pBindings->Invalidate( SID_COPY );
}
}
}
@@ -1171,22 +1174,22 @@ void EditorWindow::InitScrollBars()
void EditorWindow::ImpDoHighlight( sal_uLong nLine )
{
- if ( bDoSyntaxHighlight )
- {
- OUString aLine( pEditEngine->GetText( nLine ) );
- bool const bWasModified = pEditEngine->IsModified();
- pEditEngine->RemoveAttribs( nLine );
- std::vector<HighlightPortion> aPortions;
- aHighlighter.getHighlightPortions( aLine, aPortions );
+ if ( !bDoSyntaxHighlight )
+ return;
- for (auto const& portion : aPortions)
- {
- Color const aColor = rModulWindow.GetLayout().GetSyntaxColor(portion.tokenType);
- pEditEngine->SetAttrib(TextAttribFontColor(aColor), nLine, portion.nBegin, portion.nEnd);
- }
+ OUString aLine( pEditEngine->GetText( nLine ) );
+ bool const bWasModified = pEditEngine->IsModified();
+ pEditEngine->RemoveAttribs( nLine );
+ std::vector<HighlightPortion> aPortions;
+ aHighlighter.getHighlightPortions( aLine, aPortions );
- pEditEngine->SetModified(bWasModified);
+ for (auto const& portion : aPortions)
+ {
+ Color const aColor = rModulWindow.GetLayout().GetSyntaxColor(portion.tokenType);
+ pEditEngine->SetAttrib(TextAttribFontColor(aColor), nLine, portion.nBegin, portion.nEnd);
}
+
+ pEditEngine->SetModified(bWasModified);
}
void EditorWindow::ChangeFontColor( Color aColor )
@@ -1459,44 +1462,44 @@ void BreakPointWindow::MouseButtonDown( const MouseEvent& rMEvt )
void BreakPointWindow::Command( const CommandEvent& rCEvt )
{
- if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
- {
- if (!mpUIBuilder)
- mpUIBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/BasicIDE/ui/breakpointmenus.ui", ""));
+ if ( rCEvt.GetCommand() != CommandEventId::ContextMenu )
+ return;
- Point aPos( rCEvt.IsMouseEvent() ? rCEvt.GetMousePosPixel() : Point(1,1) );
- Point aEventPos( PixelToLogic( aPos ) );
- BreakPoint* pBrk = rCEvt.IsMouseEvent() ? FindBreakPoint( aEventPos ) : nullptr;
- if ( pBrk )
+ if (!mpUIBuilder)
+ mpUIBuilder.reset(new VclBuilder(nullptr, VclBuilderContainer::getUIRootDir(), "modules/BasicIDE/ui/breakpointmenus.ui", ""));
+
+ Point aPos( rCEvt.IsMouseEvent() ? rCEvt.GetMousePosPixel() : Point(1,1) );
+ Point aEventPos( PixelToLogic( aPos ) );
+ BreakPoint* pBrk = rCEvt.IsMouseEvent() ? FindBreakPoint( aEventPos ) : nullptr;
+ if ( pBrk )
+ {
+ // test if break point is enabled...
+ VclPtr<PopupMenu> xBrkPropMenu = mpUIBuilder->get_menu("breakmenu");
+ xBrkPropMenu->CheckItem("active", pBrk->bEnabled);
+ OString sCommand = xBrkPropMenu->GetItemIdent(xBrkPropMenu->Execute(this, aPos));
+ if (sCommand == "active")
{
- // test if break point is enabled...
- VclPtr<PopupMenu> xBrkPropMenu = mpUIBuilder->get_menu("breakmenu");
- xBrkPropMenu->CheckItem("active", pBrk->bEnabled);
- OString sCommand = xBrkPropMenu->GetItemIdent(xBrkPropMenu->Execute(this, aPos));
- if (sCommand == "active")
- {
- pBrk->bEnabled = !pBrk->bEnabled;
- rModulWindow.UpdateBreakPoint( *pBrk );
- Invalidate();
- }
- else if (sCommand == "properties")
- {
- BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints());
- aBrkDlg.SetCurrentBreakPoint( *pBrk );
- aBrkDlg.run();
- Invalidate();
- }
+ pBrk->bEnabled = !pBrk->bEnabled;
+ rModulWindow.UpdateBreakPoint( *pBrk );
+ Invalidate();
}
- else
+ else if (sCommand == "properties")
{
- VclPtr<PopupMenu> xBrkListMenu = mpUIBuilder->get_menu("breaklistmenu");
- OString sCommand = xBrkListMenu->GetItemIdent(xBrkListMenu->Execute(this, aPos));
- if (sCommand == "manage")
- {
- BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints());
- aBrkDlg.run();
- Invalidate();
- }
+ BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints());
+ aBrkDlg.SetCurrentBreakPoint( *pBrk );
+ aBrkDlg.run();
+ Invalidate();
+ }
+ }
+ else
+ {
+ VclPtr<PopupMenu> xBrkListMenu = mpUIBuilder->get_menu("breaklistmenu");
+ OString sCommand = xBrkListMenu->GetItemIdent(xBrkListMenu->Execute(this, aPos));
+ if (sCommand == "manage")
+ {
+ BreakPointDialog aBrkDlg(GetFrameWeld(), GetBreakPoints());
+ aBrkDlg.run();
+ Invalidate();
}
}
}
@@ -2751,41 +2754,41 @@ void CodeCompleteWindow::SetTextSelection( const TextSelection& aSel )
void CodeCompleteWindow::ResizeAndPositionListBox()
{
- if (m_xListBox->n_children() >= 1)
- {
- // if there is at least one element inside
- // calculate basic position: under the current line
- tools::Rectangle aRect = static_cast<TextEngine*>(pParent->GetEditEngine())->PaMtoEditCursor( pParent->GetEditView()->GetSelection().GetEnd() );
- long nViewYOffset = pParent->GetEditView()->GetStartDocPos().Y();
- Point aPos = aRect.BottomRight();// this variable will be used later (if needed)
- aPos.setY( (aPos.Y() - nViewYOffset) + nBasePad );
+ if (m_xListBox->n_children() < 1)
+ return;
- // get line count
- const sal_uInt16 nLines = static_cast<sal_uInt16>(std::min(6, m_xListBox->n_children()));
+ // if there is at least one element inside
+ // calculate basic position: under the current line
+ tools::Rectangle aRect = static_cast<TextEngine*>(pParent->GetEditEngine())->PaMtoEditCursor( pParent->GetEditView()->GetSelection().GetEnd() );
+ long nViewYOffset = pParent->GetEditView()->GetStartDocPos().Y();
+ Point aPos = aRect.BottomRight();// this variable will be used later (if needed)
+ aPos.setY( (aPos.Y() - nViewYOffset) + nBasePad );
- m_xListBox->set_size_request(-1, m_xListBox->get_height_rows(nLines));
+ // get line count
+ const sal_uInt16 nLines = static_cast<sal_uInt16>(std::min(6, m_xListBox->n_children()));
- Size aSize = m_xContainer->get_preferred_size();
- //set the size
- SetSizePixel( aSize );
+ m_xListBox->set_size_request(-1, m_xListBox->get_height_rows(nLines));
- //calculate position
- const tools::Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() ); //the visible area
- const Point& aBottomPoint = aVisArea.BottomRight();
+ Size aSize = m_xContainer->get_preferred_size();
+ //set the size
+ SetSizePixel( aSize );
- if( aVisArea.TopRight().getY() + aPos.getY() + aSize.getHeight() > aBottomPoint.getY() )
- {//clipped at the bottom: move it up
- const long& nParentFontHeight = pParent->GetEditEngine()->GetFont().GetFontHeight(); //parent's font (in the IDE): needed for height
- aPos.AdjustY( -(aSize.getHeight() + nParentFontHeight + nCursorPad) );
- }
+ //calculate position
+ const tools::Rectangle aVisArea( pParent->GetEditView()->GetStartDocPos(), pParent->GetOutputSizePixel() ); //the visible area
+ const Point& aBottomPoint = aVisArea.BottomRight();
- if( aVisArea.TopLeft().getX() + aPos.getX() + aSize.getWidth() > aBottomPoint.getX() )
- {//clipped at the right side, move it a bit left
- aPos.AdjustX( -(aSize.getWidth() + aVisArea.TopLeft().getX()) );
- }
- //set the position
- SetPosPixel( aPos );
+ if( aVisArea.TopRight().getY() + aPos.getY() + aSize.getHeight() > aBottomPoint.getY() )
+ {//clipped at the bottom: move it up
+ const long& nParentFontHeight = pParent->GetEditEngine()->GetFont().GetFontHeight(); //parent's font (in the IDE): needed for height
+ aPos.AdjustY( -(aSize.getHeight() + nParentFontHeight + nCursorPad) );
+ }
+
+ if( aVisArea.TopLeft().getX() + aPos.getX() + aSize.getWidth() > aBottomPoint.getX() )
+ {//clipped at the right side, move it a bit left
+ aPos.AdjustX( -(aSize.getWidth() + aVisArea.TopLeft().getX()) );
}
+ //set the position
+ SetPosPixel( aPos );
}
void CodeCompleteWindow::SelectFirstEntry()
diff --git a/basctl/source/basicide/baside3.cxx b/basctl/source/basicide/baside3.cxx
index ece79057fc58..eab48715882b 100644
--- a/basctl/source/basicide/baside3.cxx
+++ b/basctl/source/basicide/baside3.cxx
@@ -621,138 +621,138 @@ void DialogWindow::SaveDialog()
xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
xFP->setCurrentFilter( aDialogStr );
- if( xFP->execute() == RET_OK )
- {
- Sequence< OUString > aPaths = xFP->getSelectedFiles();
- m_sCurPath = aPaths[0];
+ if( xFP->execute() != RET_OK )
+ return;
- // export dialog model to xml
- Reference< container::XNameContainer > xDialogModel = GetDialog();
- Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
- Reference< XInputStream > xInput( xISP->createInputStream() );
+ Sequence< OUString > aPaths = xFP->getSelectedFiles();
+ m_sCurPath = aPaths[0];
- Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) );
+ // export dialog model to xml
+ Reference< container::XNameContainer > xDialogModel = GetDialog();
+ Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
+ Reference< XInputStream > xInput( xISP->createInputStream() );
- Reference< XOutputStream > xOutput;
- try
+ Reference< XSimpleFileAccess3 > xSFI( SimpleFileAccess::create(xContext) );
+
+ Reference< XOutputStream > xOutput;
+ try
+ {
+ if( xSFI->exists( m_sCurPath ) )
+ xSFI->kill( m_sCurPath );
+ xOutput = xSFI->openFileWrite( m_sCurPath );
+ }
+ catch(const Exception& )
+ {}
+
+ if( xOutput.is() )
+ {
+ Sequence< sal_Int8 > bytes;
+ sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() );
+ for (;;)
{
- if( xSFI->exists( m_sCurPath ) )
- xSFI->kill( m_sCurPath );
- xOutput = xSFI->openFileWrite( m_sCurPath );
+ if( nRead )
+ xOutput->writeBytes( bytes );
+
+ nRead = xInput->readBytes( bytes, 1024 );
+ if (! nRead)
+ break;
}
- catch(const Exception& )
- {}
- if( xOutput.is() )
+ // With resource?
+ Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
+ Reference< resource::XStringResourceResolver > xStringResourceResolver;
+ if( xDialogModelPropSet.is() )
{
- Sequence< sal_Int8 > bytes;
- sal_Int32 nRead = xInput->readBytes( bytes, xInput->available() );
- for (;;)
+ try
{
- if( nRead )
- xOutput->writeBytes( bytes );
-
- nRead = xInput->readBytes( bytes, 1024 );
- if (! nRead)
- break;
+ Any aResourceResolver = xDialogModelPropSet->getPropertyValue( "ResourceResolver" );
+ aResourceResolver >>= xStringResourceResolver;
}
+ catch(const beans::UnknownPropertyException& )
+ {}
+ }
- // With resource?
- Reference< beans::XPropertySet > xDialogModelPropSet( xDialogModel, UNO_QUERY );
- Reference< resource::XStringResourceResolver > xStringResourceResolver;
- if( xDialogModelPropSet.is() )
- {
- try
- {
- Any aResourceResolver = xDialogModelPropSet->getPropertyValue( "ResourceResolver" );
- aResourceResolver >>= xStringResourceResolver;
- }
- catch(const beans::UnknownPropertyException& )
- {}
- }
+ bool bResource = false;
+ if( xStringResourceResolver.is() )
+ {
+ Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
+ if( aLocaleSeq.hasElements() )
+ bResource = true;
+ }
- bool bResource = false;
- if( xStringResourceResolver.is() )
- {
- Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
- if( aLocaleSeq.hasElements() )
- bResource = true;
- }
+ if( bResource )
+ {
+ INetURLObject aURLObj( m_sCurPath );
+ aURLObj.removeExtension();
+ OUString aDialogName( aURLObj.getName() );
+ aURLObj.removeSegment();
+ OUString aURL( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ OUString aComment = "# " + aDialogName + " strings" ;
+ Reference< task::XInteractionHandler > xDummyHandler;
- if( bResource )
+ // Remove old properties files in case of overwriting Dialog files
+ if( xSFI->isFolder( aURL ) )
{
- INetURLObject aURLObj( m_sCurPath );
- aURLObj.removeExtension();
- OUString aDialogName( aURLObj.getName() );
- aURLObj.removeSegment();
- OUString aURL( aURLObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
- OUString aComment = "# " + aDialogName + " strings" ;
- Reference< task::XInteractionHandler > xDummyHandler;
-
- // Remove old properties files in case of overwriting Dialog files
- if( xSFI->isFolder( aURL ) )
- {
- Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false );
+ Sequence< OUString > aContentSeq = xSFI->getFolderContents( aURL, false );
- OUString aDialogName_ = aDialogName + "_" ;
- sal_Int32 nCount = aContentSeq.getLength();
- const OUString* pFiles = aContentSeq.getConstArray();
- for( int i = 0 ; i < nCount ; i++ )
+ OUString aDialogName_ = aDialogName + "_" ;
+ sal_Int32 nCount = aContentSeq.getLength();
+ const OUString* pFiles = aContentSeq.getConstArray();
+ for( int i = 0 ; i < nCount ; i++ )
+ {
+ OUString aCompleteName = pFiles[i];
+ OUString aPureName;
+ OUString aExtension;
+ sal_Int32 iDot = aCompleteName.lastIndexOf( '.' );
+ sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' );
+ if( iDot != -1 )
{
- OUString aCompleteName = pFiles[i];
- OUString aPureName;
- OUString aExtension;
- sal_Int32 iDot = aCompleteName.lastIndexOf( '.' );
- sal_Int32 iSlash = aCompleteName.lastIndexOf( '/' );
- if( iDot != -1 )
- {
- sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0;
- aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom );
- aExtension = aCompleteName.copy( iDot + 1 );
- }
+ sal_Int32 iCopyFrom = (iSlash != -1) ? iSlash + 1 : 0;
+ aPureName = aCompleteName.copy( iCopyFrom, iDot-iCopyFrom );
+ aExtension = aCompleteName.copy( iDot + 1 );
+ }
- if( aExtension == "properties" || aExtension == "default" )
+ if( aExtension == "properties" || aExtension == "default" )
+ {
+ if( aPureName.startsWith( aDialogName_ ) )
{
- if( aPureName.startsWith( aDialogName_ ) )
+ try
{
- try
- {
- xSFI->kill( aCompleteName );
- }
- catch(const uno::Exception& )
- {}
+ xSFI->kill( aCompleteName );
}
+ catch(const uno::Exception& )
+ {}
}
}
}
+ }
- Reference< XStringResourceWithLocation > xStringResourceWithLocation =
- StringResourceWithLocation::create( xContext, aURL, false/*bReadOnly*/,
- xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler );
+ Reference< XStringResourceWithLocation > xStringResourceWithLocation =
+ StringResourceWithLocation::create( xContext, aURL, false/*bReadOnly*/,
+ xStringResourceResolver->getDefaultLocale(), aDialogName, aComment, xDummyHandler );
- // Add locales
- Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
- const lang::Locale* pLocales = aLocaleSeq.getConstArray();
- sal_Int32 nLocaleCount = aLocaleSeq.getLength();
- for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
- {
- const lang::Locale& rLocale = pLocales[ iLocale ];
- xStringResourceWithLocation->newLocale( rLocale );
- }
+ // Add locales
+ Sequence< lang::Locale > aLocaleSeq = xStringResourceResolver->getLocales();
+ const lang::Locale* pLocales = aLocaleSeq.getConstArray();
+ sal_Int32 nLocaleCount = aLocaleSeq.getLength();
+ for( sal_Int32 iLocale = 0 ; iLocale < nLocaleCount ; iLocale++ )
+ {
+ const lang::Locale& rLocale = pLocales[ iLocale ];
+ xStringResourceWithLocation->newLocale( rLocale );
+ }
- LocalizationMgr::copyResourceForDialog( xDialogModel,
- xStringResourceResolver, xStringResourceWithLocation );
+ LocalizationMgr::copyResourceForDialog( xDialogModel,
+ xStringResourceResolver, xStringResourceWithLocation );
- xStringResourceWithLocation->store();
- }
- }
- else
- {
- std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
- VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE)));
- xBox->run();
+ xStringResourceWithLocation->store();
}
}
+ else
+ {
+ std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE)));
+ xBox->run();
+ }
}
static std::vector< lang::Locale > implGetLanguagesOnlyContainedInFirstSeq
@@ -1166,32 +1166,32 @@ bool DialogWindow::IsPasteAllowed()
void DialogWindow::StoreData()
{
- if ( IsModified() )
+ if ( !IsModified() )
+ return;
+
+ try
{
- try
+ Reference< container::XNameContainer > xLib = GetDocument().getLibrary( E_DIALOGS, GetLibName(), true );
+
+ if( xLib.is() )
{
- Reference< container::XNameContainer > xLib = GetDocument().getLibrary( E_DIALOGS, GetLibName(), true );
+ Reference< container::XNameContainer > xDialogModel = m_pEditor->GetDialog();
- if( xLib.is() )
+ if( xDialogModel.is() )
{
- Reference< container::XNameContainer > xDialogModel = m_pEditor->GetDialog();
-
- if( xDialogModel.is() )
- {
- Reference< XComponentContext > xContext(
- comphelper::getProcessComponentContext() );
- Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
- xLib->replaceByName( GetName(), Any( xISP ) );
- }
+ Reference< XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ Reference< XInputStreamProvider > xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, GetDocument().isDocument() ? GetDocument().getDocument() : Reference< frame::XModel >() );
+ xLib->replaceByName( GetName(), Any( xISP ) );
}
}
- catch (const uno::Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
- }
- MarkDocumentModified( GetDocument() );
- m_pEditor->ClearModifyFlag();
}
+ catch (const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ }
+ MarkDocumentModified( GetDocument() );
+ m_pEditor->ClearModifyFlag();
}
void DialogWindow::Activating ()
diff --git a/basctl/source/basicide/basides1.cxx b/basctl/source/basicide/basides1.cxx
index ff7224ac6cb0..12399e823019 100644
--- a/basctl/source/basicide/basides1.cxx
+++ b/basctl/source/basicide/basides1.cxx
@@ -1120,75 +1120,75 @@ bool Shell::HasUIFeature(SfxShellFeature nFeature) const
void Shell::SetCurWindow( BaseWindow* pNewWin, bool bUpdateTabBar, bool bRememberAsCurrent )
{
- if ( pNewWin != pCurWin )
+ if ( pNewWin == pCurWin )
+ return;
+
+ pCurWin = pNewWin;
+ if (pLayout)
+ pLayout->Deactivating();
+ if (pCurWin)
{
- pCurWin = pNewWin;
- if (pLayout)
- pLayout->Deactivating();
- if (pCurWin)
- {
- if (pCurWin->GetType() == TYPE_MODULE)
- pLayout = pModulLayout.get();
- else
- pLayout = pDialogLayout.get();
- AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel());
- pLayout->Activating(*pCurWin);
- GetViewFrame()->GetWindow().SetHelpId(pCurWin->GetHid());
- if (bRememberAsCurrent)
- pCurWin->InsertLibInfo();
- if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise
- pCurWin->Show();
- pCurWin->Init();
- if (!GetExtraData()->ShellInCriticalSection())
- {
- vcl::Window* pFrameWindow = &GetViewFrame()->GetWindow();
- vcl::Window* pFocusWindow = Application::GetFocusWindow();
- while ( pFocusWindow && ( pFocusWindow != pFrameWindow ) )
- pFocusWindow = pFocusWindow->GetParent();
- if ( pFocusWindow ) // Focus in BasicIDE
- pCurWin->GrabFocus();
- }
- }
+ if (pCurWin->GetType() == TYPE_MODULE)
+ pLayout = pModulLayout.get();
else
+ pLayout = pDialogLayout.get();
+ AdjustPosSizePixel(Point(0, 0), GetViewFrame()->GetWindow().GetOutputSizePixel());
+ pLayout->Activating(*pCurWin);
+ GetViewFrame()->GetWindow().SetHelpId(pCurWin->GetHid());
+ if (bRememberAsCurrent)
+ pCurWin->InsertLibInfo();
+ if (GetViewFrame()->GetWindow().IsVisible()) // SFX will do it later otherwise
+ pCurWin->Show();
+ pCurWin->Init();
+ if (!GetExtraData()->ShellInCriticalSection())
{
- SetWindow(pLayout);
- pLayout = nullptr;
- }
- if ( bUpdateTabBar )
- {
- sal_uInt16 nKey = GetWindowId( pCurWin );
- if ( pCurWin && ( pTabBar->GetPagePos( nKey ) == TabBar::PAGE_NOT_FOUND ) )
- pTabBar->InsertPage( nKey, pCurWin->GetTitle() ); // has just been faded in
- pTabBar->SetCurPageId( nKey );
+ vcl::Window* pFrameWindow = &GetViewFrame()->GetWindow();
+ vcl::Window* pFocusWindow = Application::GetFocusWindow();
+ while ( pFocusWindow && ( pFocusWindow != pFrameWindow ) )
+ pFocusWindow = pFocusWindow->GetParent();
+ if ( pFocusWindow ) // Focus in BasicIDE
+ pCurWin->GrabFocus();
}
- if ( pCurWin && pCurWin->IsSuspended() ) // if the window is shown in the case of an error...
- pCurWin->SetStatus( pCurWin->GetStatus() & ~BASWIN_SUSPENDED );
- if ( pCurWin )
- {
- SetWindow( pCurWin );
- if ( pCurWin->GetDocument().isDocument() )
- SfxObjectShell::SetCurrentComponent( pCurWin->GetDocument().getDocument() );
- }
- else if (pLayout)
- {
- SetWindow(pLayout);
- GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
- SfxObjectShell::SetCurrentComponent(nullptr);
- }
- aObjectCatalog->SetCurrentEntry(pCurWin);
- SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : nullptr );
- InvalidateBasicIDESlots();
- InvalidateControlSlots();
- EnableScrollbars(pCurWin != nullptr);
+ }
+ else
+ {
+ SetWindow(pLayout);
+ pLayout = nullptr;
+ }
+ if ( bUpdateTabBar )
+ {
+ sal_uInt16 nKey = GetWindowId( pCurWin );
+ if ( pCurWin && ( pTabBar->GetPagePos( nKey ) == TabBar::PAGE_NOT_FOUND ) )
+ pTabBar->InsertPage( nKey, pCurWin->GetTitle() ); // has just been faded in
+ pTabBar->SetCurPageId( nKey );
+ }
+ if ( pCurWin && pCurWin->IsSuspended() ) // if the window is shown in the case of an error...
+ pCurWin->SetStatus( pCurWin->GetStatus() & ~BASWIN_SUSPENDED );
+ if ( pCurWin )
+ {
+ SetWindow( pCurWin );
+ if ( pCurWin->GetDocument().isDocument() )
+ SfxObjectShell::SetCurrentComponent( pCurWin->GetDocument().getDocument() );
+ }
+ else if (pLayout)
+ {
+ SetWindow(pLayout);
+ GetViewFrame()->GetWindow().SetHelpId( HID_BASICIDE_MODULWINDOW );
+ SfxObjectShell::SetCurrentComponent(nullptr);
+ }
+ aObjectCatalog->SetCurrentEntry(pCurWin);
+ SetUndoManager( pCurWin ? pCurWin->GetUndoManager() : nullptr );
+ InvalidateBasicIDESlots();
+ InvalidateControlSlots();
+ EnableScrollbars(pCurWin != nullptr);
- if ( m_pCurLocalizationMgr )
- m_pCurLocalizationMgr->handleTranslationbar();
+ if ( m_pCurLocalizationMgr )
+ m_pCurLocalizationMgr->handleTranslationbar();
- ManageToolbars();
+ ManageToolbars();
- // fade out (in) property browser in module (dialog) windows
- UIFeatureChanged();
- }
+ // fade out (in) property browser in module (dialog) windows
+ UIFeatureChanged();
}
void Shell::ManageToolbars()
@@ -1203,33 +1203,33 @@ void Shell::ManageToolbars()
Reference< beans::XPropertySet > xFrameProps
( GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
- if ( xFrameProps.is() )
+ if ( !xFrameProps.is() )
+ return;
+
+ Reference< css::frame::XLayoutManager > xLayoutManager;
+ uno::Any a = xFrameProps->getPropertyValue( "LayoutManager" );
+ a >>= xLayoutManager;
+ if ( !xLayoutManager.is() )
+ return;
+
+ xLayoutManager->lock();
+ if (dynamic_cast<DialogWindow*>(pCurWin.get()))
{
- Reference< css::frame::XLayoutManager > xLayoutManager;
- uno::Any a = xFrameProps->getPropertyValue( "LayoutManager" );
- a >>= xLayoutManager;
- if ( xLayoutManager.is() )
- {
- xLayoutManager->lock();
- if (dynamic_cast<DialogWindow*>(pCurWin.get()))
- {
- xLayoutManager->destroyElement( aMacroBarResName );
+ xLayoutManager->destroyElement( aMacroBarResName );
- xLayoutManager->requestElement( aDialogBarResName );
- xLayoutManager->requestElement( aInsertControlsBarResName );
- xLayoutManager->requestElement( aFormControlsBarResName );
- }
- else
- {
- xLayoutManager->destroyElement( aDialogBarResName );
- xLayoutManager->destroyElement( aInsertControlsBarResName );
- xLayoutManager->destroyElement( aFormControlsBarResName );
+ xLayoutManager->requestElement( aDialogBarResName );
+ xLayoutManager->requestElement( aInsertControlsBarResName );
+ xLayoutManager->requestElement( aFormControlsBarResName );
+ }
+ else
+ {
+ xLayoutManager->destroyElement( aDialogBarResName );
+ xLayoutManager->destroyElement( aInsertControlsBarResName );
+ xLayoutManager->destroyElement( aFormControlsBarResName );
- xLayoutManager->requestElement( aMacroBarResName );
- }
- xLayoutManager->unlock();
- }
+ xLayoutManager->requestElement( aMacroBarResName );
}
+ xLayoutManager->unlock();
}
VclPtr<BaseWindow> Shell::FindApplicationWindow()
diff --git a/basctl/source/basicide/basides2.cxx b/basctl/source/basicide/basides2.cxx
index ebf8245089c5..fedebcb1d98b 100644
--- a/basctl/source/basicide/basides2.cxx
+++ b/basctl/source/basicide/basides2.cxx
@@ -115,20 +115,20 @@ void Shell::SetMDITitle()
}
SfxViewFrame* pViewFrame = GetViewFrame();
- if ( pViewFrame )
- {
- SfxObjectShell* pShell = pViewFrame->GetObjectShell();
- if ( pShell && pShell->GetTitle( SFX_TITLE_CAPTION ) != aTitle )
- {
- pShell->SetTitle( aTitle );
- pShell->SetModified(false);
- }
+ if ( !pViewFrame )
+ return;
- css::uno::Reference< css::frame::XController > xController = GetController ();
- css::uno::Reference< css::frame::XTitle > xTitle (xController, css::uno::UNO_QUERY);
- if (xTitle.is ())
- xTitle->setTitle (aTitle);
+ SfxObjectShell* pShell = pViewFrame->GetObjectShell();
+ if ( pShell && pShell->GetTitle( SFX_TITLE_CAPTION ) != aTitle )
+ {
+ pShell->SetTitle( aTitle );
+ pShell->SetModified(false);
}
+
+ css::uno::Reference< css::frame::XController > xController = GetController ();
+ css::uno::Reference< css::frame::XTitle > xTitle (xController, css::uno::UNO_QUERY);
+ if (xTitle.is ())
+ xTitle->setTitle (aTitle);
}
VclPtr<ModulWindow> Shell::CreateBasWin( const ScriptDocument& rDocument, const OUString& rLibName, const OUString& rModName )
diff --git a/basctl/source/basicide/basidesh.cxx b/basctl/source/basicide/basidesh.cxx
index b2394690c08c..896b77f2f892 100644
--- a/basctl/source/basicide/basidesh.cxx
+++ b/basctl/source/basicide/basidesh.cxx
@@ -473,69 +473,70 @@ SfxUndoManager* Shell::GetUndoManager()
void Shell::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
- if (GetShell())
+ if (!GetShell())
+ return;
+
+ if (rHint.GetId() == SfxHintId::Dying)
{
- if (rHint.GetId() == SfxHintId::Dying)
- {
- EndListening( rBC, true /* log off all */ );
- aObjectCatalog->UpdateEntries();
- }
+ EndListening( rBC, true /* log off all */ );
+ aObjectCatalog->UpdateEntries();
+ }
- if (SbxHint const* pSbxHint = dynamic_cast<SbxHint const*>(&rHint))
- {
- const SfxHintId nHintId = pSbxHint->GetId();
- if ( ( nHintId == SfxHintId::BasicStart ) ||
- ( nHintId == SfxHintId::BasicStop ) )
- {
- if (SfxBindings* pBindings = GetBindingsPtr())
- {
- pBindings->Invalidate( SID_BASICRUN );
- pBindings->Update( SID_BASICRUN );
- pBindings->Invalidate( SID_BASICCOMPILE );
- pBindings->Update( SID_BASICCOMPILE );
- pBindings->Invalidate( SID_BASICSTEPOVER );
- pBindings->Update( SID_BASICSTEPOVER );
- pBindings->Invalidate( SID_BASICSTEPINTO );
- pBindings->Update( SID_BASICSTEPINTO );
- pBindings->Invalidate( SID_BASICSTEPOUT );
- pBindings->Update( SID_BASICSTEPOUT );
- pBindings->Invalidate( SID_BASICSTOP );
- pBindings->Update( SID_BASICSTOP );
- pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
- pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
- pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
- pBindings->Update( SID_BASICIDE_MANAGEBRKPNTS );
- pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
- pBindings->Update( SID_BASICIDE_MODULEDLG );
- pBindings->Invalidate( SID_BASICLOAD );
- pBindings->Update( SID_BASICLOAD );
- }
+ SbxHint const* pSbxHint = dynamic_cast<SbxHint const*>(&rHint);
+ if (!pSbxHint)
+ return;
- if ( nHintId == SfxHintId::BasicStop )
- {
- // not only at error/break or explicit stoppage,
- // if the update is turned off due to a programming bug
- BasicStopped();
- if (pLayout)
- pLayout->UpdateDebug(true); // clear...
- if( m_pCurLocalizationMgr )
- m_pCurLocalizationMgr->handleBasicStopped();
- }
- else if( m_pCurLocalizationMgr )
- {
- m_pCurLocalizationMgr->handleBasicStarted();
- }
+ const SfxHintId nHintId = pSbxHint->GetId();
+ if ( !(( nHintId == SfxHintId::BasicStart ) ||
+ ( nHintId == SfxHintId::BasicStop )) )
+ return;
- for (auto const& window : aWindowTable)
- {
- BaseWindow* pWin = window.second;
- if ( nHintId == SfxHintId::BasicStart )
- pWin->BasicStarted();
- else
- pWin->BasicStopped();
- }
- }
- }
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ {
+ pBindings->Invalidate( SID_BASICRUN );
+ pBindings->Update( SID_BASICRUN );
+ pBindings->Invalidate( SID_BASICCOMPILE );
+ pBindings->Update( SID_BASICCOMPILE );
+ pBindings->Invalidate( SID_BASICSTEPOVER );
+ pBindings->Update( SID_BASICSTEPOVER );
+ pBindings->Invalidate( SID_BASICSTEPINTO );
+ pBindings->Update( SID_BASICSTEPINTO );
+ pBindings->Invalidate( SID_BASICSTEPOUT );
+ pBindings->Update( SID_BASICSTEPOUT );
+ pBindings->Invalidate( SID_BASICSTOP );
+ pBindings->Update( SID_BASICSTOP );
+ pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
+ pBindings->Update( SID_BASICIDE_MANAGEBRKPNTS );
+ pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
+ pBindings->Update( SID_BASICIDE_MODULEDLG );
+ pBindings->Invalidate( SID_BASICLOAD );
+ pBindings->Update( SID_BASICLOAD );
+ }
+
+ if ( nHintId == SfxHintId::BasicStop )
+ {
+ // not only at error/break or explicit stoppage,
+ // if the update is turned off due to a programming bug
+ BasicStopped();
+ if (pLayout)
+ pLayout->UpdateDebug(true); // clear...
+ if( m_pCurLocalizationMgr )
+ m_pCurLocalizationMgr->handleBasicStopped();
+ }
+ else if( m_pCurLocalizationMgr )
+ {
+ m_pCurLocalizationMgr->handleBasicStarted();
+ }
+
+ for (auto const& window : aWindowTable)
+ {
+ BaseWindow* pWin = window.second;
+ if ( nHintId == SfxHintId::BasicStart )
+ pWin->BasicStarted();
+ else
+ pWin->BasicStopped();
}
}
@@ -802,91 +803,93 @@ void Shell::InvalidateBasicIDESlots()
{
// only those that have an optic effect...
- if (GetShell())
- {
- if (SfxBindings* pBindings = GetBindingsPtr())
- {
- pBindings->Invalidate( SID_COPY );
- pBindings->Invalidate( SID_CUT );
- pBindings->Invalidate( SID_PASTE );
- pBindings->Invalidate( SID_UNDO );
- pBindings->Invalidate( SID_REDO );
- pBindings->Invalidate( SID_SAVEDOC );
- pBindings->Invalidate( SID_SIGNATURE );
- pBindings->Invalidate( SID_BASICIDE_CHOOSEMACRO );
- pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
- pBindings->Invalidate( SID_BASICIDE_OBJCAT );
- pBindings->Invalidate( SID_BASICSTOP );
- pBindings->Invalidate( SID_BASICRUN );
- pBindings->Invalidate( SID_BASICCOMPILE );
- pBindings->Invalidate( SID_BASICLOAD );
- pBindings->Invalidate( SID_BASICSAVEAS );
- pBindings->Invalidate( SID_BASICIDE_MATCHGROUP );
- pBindings->Invalidate( SID_BASICSTEPINTO );
- pBindings->Invalidate( SID_BASICSTEPOVER );
- pBindings->Invalidate( SID_BASICSTEPOUT );
- pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
- pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
- pBindings->Invalidate( SID_BASICIDE_ADDWATCH );
- pBindings->Invalidate( SID_BASICIDE_REMOVEWATCH );
-
- pBindings->Invalidate( SID_PRINTDOC );
- pBindings->Invalidate( SID_PRINTDOCDIRECT );
- pBindings->Invalidate( SID_SETUPPRINTER );
- pBindings->Invalidate( SID_DIALOG_TESTMODE );
-
- pBindings->Invalidate( SID_DOC_MODIFIED );
- pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
- pBindings->Invalidate( SID_BASICIDE_STAT_POS );
- pBindings->Invalidate( SID_ATTR_INSERT );
- pBindings->Invalidate( SID_ATTR_SIZE );
- }
- }
+ if (!GetShell())
+ return;
+
+ SfxBindings* pBindings = GetBindingsPtr();
+ if (!pBindings)
+ return;
+
+ pBindings->Invalidate( SID_COPY );
+ pBindings->Invalidate( SID_CUT );
+ pBindings->Invalidate( SID_PASTE );
+ pBindings->Invalidate( SID_UNDO );
+ pBindings->Invalidate( SID_REDO );
+ pBindings->Invalidate( SID_SAVEDOC );
+ pBindings->Invalidate( SID_SIGNATURE );
+ pBindings->Invalidate( SID_BASICIDE_CHOOSEMACRO );
+ pBindings->Invalidate( SID_BASICIDE_MODULEDLG );
+ pBindings->Invalidate( SID_BASICIDE_OBJCAT );
+ pBindings->Invalidate( SID_BASICSTOP );
+ pBindings->Invalidate( SID_BASICRUN );
+ pBindings->Invalidate( SID_BASICCOMPILE );
+ pBindings->Invalidate( SID_BASICLOAD );
+ pBindings->Invalidate( SID_BASICSAVEAS );
+ pBindings->Invalidate( SID_BASICIDE_MATCHGROUP );
+ pBindings->Invalidate( SID_BASICSTEPINTO );
+ pBindings->Invalidate( SID_BASICSTEPOVER );
+ pBindings->Invalidate( SID_BASICSTEPOUT );
+ pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Invalidate( SID_BASICIDE_MANAGEBRKPNTS );
+ pBindings->Invalidate( SID_BASICIDE_ADDWATCH );
+ pBindings->Invalidate( SID_BASICIDE_REMOVEWATCH );
+
+ pBindings->Invalidate( SID_PRINTDOC );
+ pBindings->Invalidate( SID_PRINTDOCDIRECT );
+ pBindings->Invalidate( SID_SETUPPRINTER );
+ pBindings->Invalidate( SID_DIALOG_TESTMODE );
+
+ pBindings->Invalidate( SID_DOC_MODIFIED );
+ pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
+ pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+ pBindings->Invalidate( SID_ATTR_INSERT );
+ pBindings->Invalidate( SID_ATTR_SIZE );
}
void Shell::InvalidateControlSlots()
{
- if (GetShell())
- {
- if (SfxBindings* pBindings = GetBindingsPtr())
- {
- pBindings->Invalidate( SID_INSERT_FORM_RADIO );
- pBindings->Invalidate( SID_INSERT_FORM_CHECK );
- pBindings->Invalidate( SID_INSERT_FORM_LIST );
- pBindings->Invalidate( SID_INSERT_FORM_COMBO );
- pBindings->Invalidate( SID_INSERT_FORM_VSCROLL );
- pBindings->Invalidate( SID_INSERT_FORM_HSCROLL );
- pBindings->Invalidate( SID_INSERT_FORM_SPIN );
-
- pBindings->Invalidate( SID_INSERT_SELECT );
- pBindings->Invalidate( SID_INSERT_PUSHBUTTON );
- pBindings->Invalidate( SID_INSERT_RADIOBUTTON );
- pBindings->Invalidate( SID_INSERT_CHECKBOX );
- pBindings->Invalidate( SID_INSERT_LISTBOX );
- pBindings->Invalidate( SID_INSERT_COMBOBOX );
- pBindings->Invalidate( SID_INSERT_GROUPBOX );
- pBindings->Invalidate( SID_INSERT_EDIT );
- pBindings->Invalidate( SID_INSERT_FIXEDTEXT );
- pBindings->Invalidate( SID_INSERT_IMAGECONTROL );
- pBindings->Invalidate( SID_INSERT_PROGRESSBAR );
- pBindings->Invalidate( SID_INSERT_HSCROLLBAR );
- pBindings->Invalidate( SID_INSERT_VSCROLLBAR );
- pBindings->Invalidate( SID_INSERT_HFIXEDLINE );
- pBindings->Invalidate( SID_INSERT_VFIXEDLINE );
- pBindings->Invalidate( SID_INSERT_DATEFIELD );
- pBindings->Invalidate( SID_INSERT_TIMEFIELD );
- pBindings->Invalidate( SID_INSERT_NUMERICFIELD );
- pBindings->Invalidate( SID_INSERT_CURRENCYFIELD );
- pBindings->Invalidate( SID_INSERT_FORMATTEDFIELD );
- pBindings->Invalidate( SID_INSERT_PATTERNFIELD );
- pBindings->Invalidate( SID_INSERT_FILECONTROL );
- pBindings->Invalidate( SID_INSERT_SPINBUTTON );
- pBindings->Invalidate( SID_INSERT_GRIDCONTROL );
- pBindings->Invalidate( SID_INSERT_HYPERLINKCONTROL );
- pBindings->Invalidate( SID_INSERT_TREECONTROL );
- pBindings->Invalidate( SID_CHOOSE_CONTROLS );
- }
- }
+ if (!GetShell())
+ return;
+
+ SfxBindings* pBindings = GetBindingsPtr();
+ if (!pBindings)
+ return;
+
+ pBindings->Invalidate( SID_INSERT_FORM_RADIO );
+ pBindings->Invalidate( SID_INSERT_FORM_CHECK );
+ pBindings->Invalidate( SID_INSERT_FORM_LIST );
+ pBindings->Invalidate( SID_INSERT_FORM_COMBO );
+ pBindings->Invalidate( SID_INSERT_FORM_VSCROLL );
+ pBindings->Invalidate( SID_INSERT_FORM_HSCROLL );
+ pBindings->Invalidate( SID_INSERT_FORM_SPIN );
+
+ pBindings->Invalidate( SID_INSERT_SELECT );
+ pBindings->Invalidate( SID_INSERT_PUSHBUTTON );
+ pBindings->Invalidate( SID_INSERT_RADIOBUTTON );
+ pBindings->Invalidate( SID_INSERT_CHECKBOX );
+ pBindings->Invalidate( SID_INSERT_LISTBOX );
+ pBindings->Invalidate( SID_INSERT_COMBOBOX );
+ pBindings->Invalidate( SID_INSERT_GROUPBOX );
+ pBindings->Invalidate( SID_INSERT_EDIT );
+ pBindings->Invalidate( SID_INSERT_FIXEDTEXT );
+ pBindings->Invalidate( SID_INSERT_IMAGECONTROL );
+ pBindings->Invalidate( SID_INSERT_PROGRESSBAR );
+ pBindings->Invalidate( SID_INSERT_HSCROLLBAR );
+ pBindings->Invalidate( SID_INSERT_VSCROLLBAR );
+ pBindings->Invalidate( SID_INSERT_HFIXEDLINE );
+ pBindings->Invalidate( SID_INSERT_VFIXEDLINE );
+ pBindings->Invalidate( SID_INSERT_DATEFIELD );
+ pBindings->Invalidate( SID_INSERT_TIMEFIELD );
+ pBindings->Invalidate( SID_INSERT_NUMERICFIELD );
+ pBindings->Invalidate( SID_INSERT_CURRENCYFIELD );
+ pBindings->Invalidate( SID_INSERT_FORMATTEDFIELD );
+ pBindings->Invalidate( SID_INSERT_PATTERNFIELD );
+ pBindings->Invalidate( SID_INSERT_FILECONTROL );
+ pBindings->Invalidate( SID_INSERT_SPINBUTTON );
+ pBindings->Invalidate( SID_INSERT_GRIDCONTROL );
+ pBindings->Invalidate( SID_INSERT_HYPERLINKCONTROL );
+ pBindings->Invalidate( SID_INSERT_TREECONTROL );
+ pBindings->Invalidate( SID_CHOOSE_CONTROLS );
}
void Shell::EnableScrollbars( bool bEnable )
@@ -897,32 +900,32 @@ void Shell::EnableScrollbars( bool bEnable )
void Shell::SetCurLib( const ScriptDocument& rDocument, const OUString& aLibName, bool bUpdateWindows, bool bCheck )
{
- if ( !bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName ) )
- {
- ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
+ if ( !(!bCheck || ( rDocument != m_aCurDocument || aLibName != m_aCurLibName )) )
+ return;
- m_aCurDocument = rDocument;
- m_aCurLibName = aLibName;
+ ContainerListenerImpl* pListener = static_cast< ContainerListenerImpl* >( m_xLibListener.get() );
- if ( pListener )
- {
- pListener->removeContainerListener( m_aCurDocument, m_aCurLibName );
- pListener->addContainerListener( m_aCurDocument, aLibName );
- }
+ m_aCurDocument = rDocument;
+ m_aCurLibName = aLibName;
+
+ if ( pListener )
+ {
+ pListener->removeContainerListener( m_aCurDocument, m_aCurLibName );
+ pListener->addContainerListener( m_aCurDocument, aLibName );
+ }
- if ( bUpdateWindows )
- UpdateWindows();
+ if ( bUpdateWindows )
+ UpdateWindows();
- SetMDITitle();
+ SetMDITitle();
- SetCurLibForLocalization( rDocument, aLibName );
+ SetCurLibForLocalization( rDocument, aLibName );
- if (SfxBindings* pBindings = GetBindingsPtr())
- {
- pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
- pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
- pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG );
- }
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ {
+ pBindings->Invalidate( SID_BASICIDE_LIBSELECTOR );
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+ pBindings->Invalidate( SID_BASICIDE_MANAGE_LANG );
}
}
diff --git a/basctl/source/basicide/basobj3.cxx b/basctl/source/basicide/basobj3.cxx
index 41c4f52052a4..64255fc1162a 100644
--- a/basctl/source/basicide/basobj3.cxx
+++ b/basctl/source/basicide/basobj3.cxx
@@ -344,27 +344,28 @@ void BasicStopped(
void InvalidateDebuggerSlots()
{
- if (SfxBindings* pBindings = GetBindingsPtr())
- {
- pBindings->Invalidate( SID_BASICSTOP );
- pBindings->Update( SID_BASICSTOP );
- pBindings->Invalidate( SID_BASICRUN );
- pBindings->Update( SID_BASICRUN );
- pBindings->Invalidate( SID_BASICCOMPILE );
- pBindings->Update( SID_BASICCOMPILE );
- pBindings->Invalidate( SID_BASICSTEPOVER );
- pBindings->Update( SID_BASICSTEPOVER );
- pBindings->Invalidate( SID_BASICSTEPINTO );
- pBindings->Update( SID_BASICSTEPINTO );
- pBindings->Invalidate( SID_BASICSTEPOUT );
- pBindings->Update( SID_BASICSTEPOUT );
- pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
- pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
- pBindings->Invalidate( SID_BASICIDE_STAT_POS );
- pBindings->Update( SID_BASICIDE_STAT_POS );
- pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
- pBindings->Update( SID_BASICIDE_STAT_TITLE );
- }
+ SfxBindings* pBindings = GetBindingsPtr();
+ if (!pBindings)
+ return;
+
+ pBindings->Invalidate( SID_BASICSTOP );
+ pBindings->Update( SID_BASICSTOP );
+ pBindings->Invalidate( SID_BASICRUN );
+ pBindings->Update( SID_BASICRUN );
+ pBindings->Invalidate( SID_BASICCOMPILE );
+ pBindings->Update( SID_BASICCOMPILE );
+ pBindings->Invalidate( SID_BASICSTEPOVER );
+ pBindings->Update( SID_BASICSTEPOVER );
+ pBindings->Invalidate( SID_BASICSTEPINTO );
+ pBindings->Update( SID_BASICSTEPINTO );
+ pBindings->Invalidate( SID_BASICSTEPOUT );
+ pBindings->Update( SID_BASICSTEPOUT );
+ pBindings->Invalidate( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Update( SID_BASICIDE_TOGGLEBRKPNT );
+ pBindings->Invalidate( SID_BASICIDE_STAT_POS );
+ pBindings->Update( SID_BASICIDE_STAT_POS );
+ pBindings->Invalidate( SID_BASICIDE_STAT_TITLE );
+ pBindings->Update( SID_BASICIDE_STAT_TITLE );
}
long HandleBasicError( StarBASIC const * pBasic )
diff --git a/basctl/source/basicide/bastype2.cxx b/basctl/source/basicide/bastype2.cxx
index 4efdb2c1be41..f120f41e0577 100644
--- a/basctl/source/basicide/bastype2.cxx
+++ b/basctl/source/basicide/bastype2.cxx
@@ -330,38 +330,38 @@ void SbTreeListBox::ImpCreateLibSubEntries(const weld::TreeIter& rLibRootEntry,
}
// dialogs
- if ( nMode & BrowseMode::Dialogs )
- {
- Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
+ if ( !(nMode & BrowseMode::Dialogs) )
+ return;
- if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( rLibName ) && xDlgLibContainer->isLibraryLoaded( rLibName ) )
- {
- try
- {
- // get a sorted list of dialog names
- Sequence< OUString > aDlgNames( rDocument.getObjectNames( E_DIALOGS, rLibName ) );
- sal_Int32 nDlgCount = aDlgNames.getLength();
- const OUString* pDlgNames = aDlgNames.getConstArray();
+ Reference< script::XLibraryContainer > xDlgLibContainer( rDocument.getLibraryContainer( E_DIALOGS ) );
- auto xTreeIter = m_xControl->make_iterator();
+ if ( !(xDlgLibContainer.is() && xDlgLibContainer->hasByName( rLibName ) && xDlgLibContainer->isLibraryLoaded( rLibName )) )
+ return;
- for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
- {
- OUString aDlgName = pDlgNames[ i ];
- m_xControl->copy_iterator(rLibRootEntry, *xTreeIter);
- bool bDialogEntry = FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xTreeIter);
- if (!bDialogEntry)
- {
- AddEntry(aDlgName, RID_BMP_DIALOG, &rLibRootEntry, false, std::make_unique<Entry>(OBJ_TYPE_DIALOG));
- }
- }
- }
- catch (const container::NoSuchElementException& )
+ try
+ {
+ // get a sorted list of dialog names
+ Sequence< OUString > aDlgNames( rDocument.getObjectNames( E_DIALOGS, rLibName ) );
+ sal_Int32 nDlgCount = aDlgNames.getLength();
+ const OUString* pDlgNames = aDlgNames.getConstArray();
+
+ auto xTreeIter = m_xControl->make_iterator();
+
+ for ( sal_Int32 i = 0 ; i < nDlgCount ; i++ )
+ {
+ OUString aDlgName = pDlgNames[ i ];
+ m_xControl->copy_iterator(rLibRootEntry, *xTreeIter);
+ bool bDialogEntry = FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xTreeIter);
+ if (!bDialogEntry)
{
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ AddEntry(aDlgName, RID_BMP_DIALOG, &rLibRootEntry, false, std::make_unique<Entry>(OBJ_TYPE_DIALOG));
}
}
}
+ catch (const container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
+ }
}
void SbTreeListBox::ImpCreateLibSubEntriesInVBAMode(const weld::TreeIter& rLibRootEntry, const ScriptDocument& rDocument, const OUString& rLibName )
diff --git a/basctl/source/basicide/bastypes.cxx b/basctl/source/basicide/bastypes.cxx
index 5120e456342a..8430c9444dbf 100644
--- a/basctl/source/basicide/bastypes.cxx
+++ b/basctl/source/basicide/bastypes.cxx
@@ -505,52 +505,53 @@ struct TabBarSortHelper
void TabBar::Sort()
{
- if (Shell* pShell = GetShell())
+ Shell* pShell = GetShell();
+ if (!pShell)
+ return;
+
+ Shell::WindowTable& aWindowTable = pShell->GetWindowTable();
+ TabBarSortHelper aTabBarSortHelper;
+ std::vector<TabBarSortHelper> aModuleList;
+ std::vector<TabBarSortHelper> aDialogList;
+ sal_uInt16 nPageCount = GetPageCount();
+ sal_uInt16 i;
+
+ // create module and dialog lists for sorting
+ for ( i = 0; i < nPageCount; i++)
{
- Shell::WindowTable& aWindowTable = pShell->GetWindowTable();
- TabBarSortHelper aTabBarSortHelper;
- std::vector<TabBarSortHelper> aModuleList;
- std::vector<TabBarSortHelper> aDialogList;
- sal_uInt16 nPageCount = GetPageCount();
- sal_uInt16 i;
-
- // create module and dialog lists for sorting
- for ( i = 0; i < nPageCount; i++)
- {
- sal_uInt16 nId = GetPageId( i );
- aTabBarSortHelper.nPageId = nId;
- aTabBarSortHelper.aPageText = GetPageText( nId );
- BaseWindow* pWin = aWindowTable[ nId ].get();
+ sal_uInt16 nId = GetPageId( i );
+ aTabBarSortHelper.nPageId = nId;
+ aTabBarSortHelper.aPageText = GetPageText( nId );
+ BaseWindow* pWin = aWindowTable[ nId ].get();
- if (dynamic_cast<ModulWindow*>(pWin))
- {
- aModuleList.push_back( aTabBarSortHelper );
- }
- else if (dynamic_cast<DialogWindow*>(pWin))
- {
- aDialogList.push_back( aTabBarSortHelper );
- }
+ if (dynamic_cast<ModulWindow*>(pWin))
+ {
+ aModuleList.push_back( aTabBarSortHelper );
}
+ else if (dynamic_cast<DialogWindow*>(pWin))
+ {
+ aDialogList.push_back( aTabBarSortHelper );
+ }
+ }
- // sort module and dialog lists by page text
- std::sort( aModuleList.begin() , aModuleList.end() );
- std::sort( aDialogList.begin() , aDialogList.end() );
+ // sort module and dialog lists by page text
+ std::sort( aModuleList.begin() , aModuleList.end() );
+ std::sort( aDialogList.begin() , aDialogList.end() );
- sal_uInt16 nModules = sal::static_int_cast<sal_uInt16>( aModuleList.size() );
- sal_uInt16 nDialogs = sal::static_int_cast<sal_uInt16>( aDialogList.size() );
+ sal_uInt16 nModules = sal::static_int_cast<sal_uInt16>( aModuleList.size() );
+ sal_uInt16 nDialogs = sal::static_int_cast<sal_uInt16>( aDialogList.size() );
- // move module pages to new positions
- for (i = 0; i < nModules; i++)
- {
- MovePage( aModuleList[i].nPageId , i );
- }
+ // move module pages to new positions
+ for (i = 0; i < nModules; i++)
+ {
+ MovePage( aModuleList[i].nPageId , i );
+ }
- // move dialog pages to new positions
- for (i = 0; i < nDialogs; i++)
- {
- MovePage( aDialogList[i].nPageId , nModules + i );
- }
+ // move dialog pages to new positions
+ for (i = 0; i < nDialogs; i++)
+ {
+ MovePage( aDialogList[i].nPageId , nModules + i );
}
}
diff --git a/basctl/source/basicide/docsignature.cxx b/basctl/source/basicide/docsignature.cxx
index 251e0eb06508..9f2dd6f150e6 100644
--- a/basctl/source/basicide/docsignature.cxx
+++ b/basctl/source/basicide/docsignature.cxx
@@ -45,19 +45,19 @@ namespace basctl
DocumentSignature::DocumentSignature (ScriptDocument const& rDocument) :
m_pImpl(new Impl)
{
- if (rDocument.isDocument())
+ if (!rDocument.isDocument())
+ return;
+
+ Reference<XModel> xDocument(rDocument.getDocument());
+ // find object shell for document
+ SfxObjectShell* pShell = SfxObjectShell::GetFirst();
+ while ( pShell )
{
- Reference<XModel> xDocument(rDocument.getDocument());
- // find object shell for document
- SfxObjectShell* pShell = SfxObjectShell::GetFirst();
- while ( pShell )
- {
- if ( pShell->GetModel() == xDocument )
- break;
- pShell = SfxObjectShell::GetNext( *pShell );
- }
- m_pImpl->pShell = pShell;
+ if ( pShell->GetModel() == xDocument )
+ break;
+ pShell = SfxObjectShell::GetNext( *pShell );
}
+ m_pImpl->pShell = pShell;
}
DocumentSignature::~DocumentSignature()
diff --git a/basctl/source/basicide/layout.cxx b/basctl/source/basicide/layout.cxx
index 3fd4f98a6d57..eb81e7964b2a 100644
--- a/basctl/source/basicide/layout.cxx
+++ b/basctl/source/basicide/layout.cxx
@@ -135,27 +135,27 @@ void Layout::Deactivating ()
void Layout::DataChanged (DataChangedEvent const& rDCEvt)
{
Window::DataChanged(rDCEvt);
- if (rDCEvt.GetType() == DataChangedEventType::SETTINGS && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE))
+ if (!(rDCEvt.GetType() == DataChangedEventType::SETTINGS && (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)))
+ return;
+
+ bool bInvalidate = false;
+ Color aColor = GetSettings().GetStyleSettings().GetWindowColor();
+ const AllSettings* pOldSettings = rDCEvt.GetOldSettings();
+ if (!pOldSettings || aColor != pOldSettings->GetStyleSettings().GetWindowColor())
{
- bool bInvalidate = false;
- Color aColor = GetSettings().GetStyleSettings().GetWindowColor();
- const AllSettings* pOldSettings = rDCEvt.GetOldSettings();
- if (!pOldSettings || aColor != pOldSettings->GetStyleSettings().GetWindowColor())
- {
- SetBackground(Wallpaper(aColor));
- bInvalidate = true;
- }
- aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
- if (!pOldSettings || aColor != pOldSettings->GetStyleSettings().GetWindowTextColor())
- {
- vcl::Font aFont(GetFont());
- aFont.SetColor(aColor);
- SetFont(aFont);
- bInvalidate = true;
- }
- if (bInvalidate)
- Invalidate();
+ SetBackground(Wallpaper(aColor));
+ bInvalidate = true;
+ }
+ aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
+ if (!pOldSettings || aColor != pOldSettings->GetStyleSettings().GetWindowTextColor())
+ {
+ vcl::Font aFont(GetFont());
+ aFont.SetColor(aColor);
+ SetFont(aFont);
+ bInvalidate = true;
}
+ if (bInvalidate)
+ Invalidate();
}
@@ -346,19 +346,19 @@ void Layout::SplittedSide::ArrangeIn (tools::Rectangle const& rRect)
}
// filling the remaining space with the last docking window
- if (!bEmpty && vItems[iLastWin].nEndPos != nLength)
- {
- Item& rItem = vItems[iLastWin];
- Size aSize = rItem.pWin->GetDockingSize();
- if (bVertical)
- aSize.AdjustHeight( nLength - rItem.nEndPos );
- else
- aSize.AdjustWidth( nLength - rItem.nEndPos );
- rItem.pWin->ResizeIfDocking(aSize);
- // and hiding the split line after the window
- if (iLastWin < vItems.size() - 1)
- vItems[iLastWin + 1].pSplit->Hide();
- }
+ if (bEmpty || vItems[iLastWin].nEndPos == nLength)
+ return;
+
+ Item& rItem = vItems[iLastWin];
+ Size aSize = rItem.pWin->GetDockingSize();
+ if (bVertical)
+ aSize.AdjustHeight( nLength - rItem.nEndPos );
+ else
+ aSize.AdjustWidth( nLength - rItem.nEndPos );
+ rItem.pWin->ResizeIfDocking(aSize);
+ // and hiding the split line after the window
+ if (iLastWin < vItems.size() - 1)
+ vItems[iLastWin + 1].pSplit->Hide();
}
IMPL_LINK(Layout::SplittedSide, SplitHdl, Splitter*, pSplitter, void)
@@ -397,20 +397,21 @@ void Layout::SplittedSide::CheckMarginsFor (Splitter* pSplitter)
// The splitter line cannot be closer to the edges than nMargin pixels.
static long const nMargin = 16;
// Checking margins:
- if (long const nLength = pSplitter->IsHorizontal() ?
- aRect.GetWidth() : aRect.GetHeight()
- ) {
- // bounds
- long const nLower = (pSplitter->IsHorizontal() ? aRect.Left() : aRect.Top()) + nMargin;
- long const nUpper = nLower + nLength - 2*nMargin;
- // split position
- long const nPos = pSplitter->GetSplitPosPixel();
- // checking bounds
- if (nPos < nLower)
- pSplitter->SetSplitPosPixel(nLower);
- if (nPos > nUpper)
- pSplitter->SetSplitPosPixel(nUpper);
- }
+ long const nLength = pSplitter->IsHorizontal() ?
+ aRect.GetWidth() : aRect.GetHeight();
+ if (!nLength)
+ return;
+
+ // bounds
+ long const nLower = (pSplitter->IsHorizontal() ? aRect.Left() : aRect.Top()) + nMargin;
+ long const nUpper = nLower + nLength - 2*nMargin;
+ // split position
+ long const nPos = pSplitter->GetSplitPosPixel();
+ // checking bounds
+ if (nPos < nLower)
+ pSplitter->SetSplitPosPixel(nLower);
+ if (nPos > nUpper)
+ pSplitter->SetSplitPosPixel(nUpper);
}
void Layout::SplittedSide::InitSplitter (Splitter& rSplitter)
diff --git a/basctl/source/basicide/localizationmgr.cxx b/basctl/source/basicide/localizationmgr.cxx
index 718682cb232b..5825e59f0b87 100644
--- a/basctl/source/basicide/localizationmgr.cxx
+++ b/basctl/source/basicide/localizationmgr.cxx
@@ -78,22 +78,22 @@ void LocalizationMgr::handleTranslationbar ()
Reference< beans::XPropertySet > xFrameProps
( m_pShell->GetViewFrame()->GetFrame().GetFrameInterface(), uno::UNO_QUERY );
- if ( xFrameProps.is() )
+ if ( !xFrameProps.is() )
+ return;
+
+ Reference< css::frame::XLayoutManager > xLayoutManager;
+ uno::Any a = xFrameProps->getPropertyValue( "LayoutManager" );
+ a >>= xLayoutManager;
+ if ( xLayoutManager.is() )
{
- Reference< css::frame::XLayoutManager > xLayoutManager;
- uno::Any a = xFrameProps->getPropertyValue( "LayoutManager" );
- a >>= xLayoutManager;
- if ( xLayoutManager.is() )
+ if ( !isLibraryLocalized() )
{
- if ( !isLibraryLocalized() )
- {
- xLayoutManager->destroyElement( aToolBarResName );
- }
- else
- {
- xLayoutManager->createElement( aToolBarResName );
- xLayoutManager->requestElement( aToolBarResName );
- }
+ xLayoutManager->destroyElement( aToolBarResName );
+ }
+ else
+ {
+ xLayoutManager->createElement( aToolBarResName );
+ xLayoutManager->requestElement( aToolBarResName );
}
}
}
@@ -716,44 +716,44 @@ void LocalizationMgr::handleRemoveLocales( const Sequence< Locale >& aLocaleSeq
void LocalizationMgr::handleSetDefaultLocale(const Locale& rLocale)
{
- if( m_xStringResourceManager.is() )
- {
- try
- {
- m_xStringResourceManager->setDefaultLocale(rLocale);
- }
- catch(const IllegalArgumentException&)
- {
- OSL_FAIL( "LocalizationMgr::handleSetDefaultLocale: Invalid locale" );
- }
+ if( !m_xStringResourceManager.is() )
+ return;
- // update locale toolbar
- if (SfxBindings* pBindings = GetBindingsPtr())
- pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+ try
+ {
+ m_xStringResourceManager->setDefaultLocale(rLocale);
}
+ catch(const IllegalArgumentException&)
+ {
+ OSL_FAIL( "LocalizationMgr::handleSetDefaultLocale: Invalid locale" );
+ }
+
+ // update locale toolbar
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
}
void LocalizationMgr::handleSetCurrentLocale(const css::lang::Locale& rLocale)
{
- if( m_xStringResourceManager.is() )
+ if( !m_xStringResourceManager.is() )
+ return;
+
+ try
{
- try
- {
- m_xStringResourceManager->setCurrentLocale(rLocale, false);
- }
- catch(const IllegalArgumentException&)
- {
- OSL_FAIL( "LocalizationMgr::handleSetCurrentLocale: Invalid locale" );
- }
+ m_xStringResourceManager->setCurrentLocale(rLocale, false);
+ }
+ catch(const IllegalArgumentException&)
+ {
+ OSL_FAIL( "LocalizationMgr::handleSetCurrentLocale: Invalid locale" );
+ }
- // update locale toolbar
- if (SfxBindings* pBindings = GetBindingsPtr())
- pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
+ // update locale toolbar
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ pBindings->Invalidate( SID_BASICIDE_CURRENT_LANG );
- if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(m_pShell->GetCurWindow()))
- if (!pDlgWin->IsSuspended())
- pDlgWin->GetEditor().UpdatePropertyBrowserDelayed();
- }
+ if (DialogWindow* pDlgWin = dynamic_cast<DialogWindow*>(m_pShell->GetCurWindow()))
+ if (!pDlgWin->IsSuspended())
+ pDlgWin->GetEditor().UpdatePropertyBrowserDelayed();
}
void LocalizationMgr::handleBasicStarted()
@@ -885,23 +885,23 @@ void LocalizationMgr::setStringResourceAtDialog( const ScriptDocument& rDocument
LocalizationMgr::getStringResourceFromDialogLibrary( xDialogLib );
// Set resource property
- if( xStringResourceManager.is() )
- {
- // Not very elegant as dialog may or may not be localized yet
- // TODO: Find better place, where dialog is created
- if( xStringResourceManager->getLocales().hasElements() )
- {
- Any aDialogCtrl;
- aDialogCtrl <<= xDialogModel;
- Reference< XStringResourceResolver > xDummyStringResolver;
- implHandleControlResourceProperties( aDialogCtrl, aDlgName,
- OUString(), xStringResourceManager,
- xDummyStringResolver, SET_IDS );
- }
+ if( !xStringResourceManager.is() )
+ return;
- Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY );
- xDlgPSet->setPropertyValue( "ResourceResolver", Any(xStringResourceManager) );
+ // Not very elegant as dialog may or may not be localized yet
+ // TODO: Find better place, where dialog is created
+ if( xStringResourceManager->getLocales().hasElements() )
+ {
+ Any aDialogCtrl;
+ aDialogCtrl <<= xDialogModel;
+ Reference< XStringResourceResolver > xDummyStringResolver;
+ implHandleControlResourceProperties( aDialogCtrl, aDlgName,
+ OUString(), xStringResourceManager,
+ xDummyStringResolver, SET_IDS );
}
+
+ Reference< beans::XPropertySet > xDlgPSet( xDialogModel, UNO_QUERY );
+ xDlgPSet->setPropertyValue( "ResourceResolver", Any(xStringResourceManager) );
}
void LocalizationMgr::renameStringResourceIDs( const ScriptDocument& rDocument, const OUString& aLibName,
diff --git a/basctl/source/basicide/macrodlg.cxx b/basctl/source/basicide/macrodlg.cxx
index 2101a22efb5a..0ee787b970bf 100644
--- a/basctl/source/basicide/macrodlg.cxx
+++ b/basctl/source/basicide/macrodlg.cxx
@@ -249,43 +249,43 @@ void MacroChooser::DeleteMacro()
{
SbMethod* pMethod = GetMacro();
DBG_ASSERT( pMethod, "DeleteMacro: No Macro !" );
- if (pMethod && QueryDelMacro(pMethod->GetName(), m_xDialog.get()))
- {
- if (SfxDispatcher* pDispatcher = GetDispatcher())
- pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
+ if (!(pMethod && QueryDelMacro(pMethod->GetName(), m_xDialog.get())))
+ return;
- // mark current doc as modified:
- StarBASIC* pBasic = FindBasic(pMethod);
- assert(pBasic && "Basic?!");
- BasicManager* pBasMgr = FindBasicManager( pBasic );
- DBG_ASSERT( pBasMgr, "BasMgr?" );
- ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
- if ( aDocument.isDocument() )
- {
- aDocument.setDocumentModified();
- if (SfxBindings* pBindings = GetBindingsPtr())
- pBindings->Invalidate( SID_SAVEDOC );
- }
+ if (SfxDispatcher* pDispatcher = GetDispatcher())
+ pDispatcher->Execute( SID_BASICIDE_STOREALLMODULESOURCES );
- SbModule* pModule = pMethod->GetModule();
- assert(pModule && "DeleteMacro: No Module?!");
- OUString aSource( pModule->GetSource32() );
- sal_uInt16 nStart, nEnd;
- pMethod->GetLineRange( nStart, nEnd );
- pModule->GetMethods()->Remove( pMethod );
- CutLines( aSource, nStart-1, nEnd-nStart+1 );
- pModule->SetSource32( aSource );
-
- // update module in library
- OUString aLibName = pBasic->GetName();
- OUString aModName = pModule->GetName();
- OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aSource ) );
-
- bool bSelected = m_xMacroBox->get_selected(m_xMacroBoxIter.get());
- DBG_ASSERT(bSelected, "DeleteMacro: Entry ?!");
- m_xMacroBox->remove(*m_xMacroBoxIter);
- bForceStoreBasic = true;
+ // mark current doc as modified:
+ StarBASIC* pBasic = FindBasic(pMethod);
+ assert(pBasic && "Basic?!");
+ BasicManager* pBasMgr = FindBasicManager( pBasic );
+ DBG_ASSERT( pBasMgr, "BasMgr?" );
+ ScriptDocument aDocument( ScriptDocument::getDocumentForBasicManager( pBasMgr ) );
+ if ( aDocument.isDocument() )
+ {
+ aDocument.setDocumentModified();
+ if (SfxBindings* pBindings = GetBindingsPtr())
+ pBindings->Invalidate( SID_SAVEDOC );
}
+
+ SbModule* pModule = pMethod->GetModule();
+ assert(pModule && "DeleteMacro: No Module?!");
+ OUString aSource( pModule->GetSource32() );
+ sal_uInt16 nStart, nEnd;
+ pMethod->GetLineRange( nStart, nEnd );
+ pModule->GetMethods()->Remove( pMethod );
+ CutLines( aSource, nStart-1, nEnd-nStart+1 );
+ pModule->SetSource32( aSource );
+
+ // update module in library
+ OUString aLibName = pBasic->GetName();
+ OUString aModName = pModule->GetName();
+ OSL_VERIFY( aDocument.updateModule( aLibName, aModName, aSource ) );
+
+ bool bSelected = m_xMacroBox->get_selected(m_xMacroBoxIter.get());
+ DBG_ASSERT(bSelected, "DeleteMacro: Entry ?!");
+ m_xMacroBox->remove(*m_xMacroBoxIter);
+ bForceStoreBasic = true;
}
SbMethod* MacroChooser::CreateMacro()
diff --git a/basctl/source/basicide/moduldl2.cxx b/basctl/source/basicide/moduldl2.cxx
index ae7f57786614..c4402089979a 100644
--- a/basctl/source/basicide/moduldl2.cxx
+++ b/basctl/source/basicide/moduldl2.cxx
@@ -354,51 +354,51 @@ LibPage::~LibPage()
void LibPage::CheckButtons()
{
std::unique_ptr<weld::TreeIter> xCur(m_xLibBox->make_iterator());
- if (m_xLibBox->get_cursor(xCur.get()))
- {
- OUString aLibName = m_xLibBox->get_text(*xCur, 0);
- Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
- Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+ if (!m_xLibBox->get_cursor(xCur.get()))
+ return;
- if ( m_eCurLocation == LIBRARY_LOCATION_SHARE )
- {
- m_xPasswordButton->set_sensitive(false);
- m_xNewLibButton->set_sensitive(false);
- m_xInsertLibButton->set_sensitive(false);
- m_xDelButton->set_sensitive(false);
- }
- else if ( aLibName.equalsIgnoreAsciiCase( "Standard" ) )
- {
- m_xPasswordButton->set_sensitive(false);
- m_xNewLibButton->set_sensitive(true);
- m_xInsertLibButton->set_sensitive(true);
- m_xExportButton->set_sensitive(false);
+ OUString aLibName = m_xLibBox->get_text(*xCur, 0);
+ Reference< script::XLibraryContainer2 > xModLibContainer( m_aCurDocument.getLibraryContainer( E_SCRIPTS ), UNO_QUERY );
+ Reference< script::XLibraryContainer2 > xDlgLibContainer( m_aCurDocument.getLibraryContainer( E_DIALOGS ), UNO_QUERY );
+
+ if ( m_eCurLocation == LIBRARY_LOCATION_SHARE )
+ {
+ m_xPasswordButton->set_sensitive(false);
+ m_xNewLibButton->set_sensitive(false);
+ m_xInsertLibButton->set_sensitive(false);
+ m_xDelButton->set_sensitive(false);
+ }
+ else if ( aLibName.equalsIgnoreAsciiCase( "Standard" ) )
+ {
+ m_xPasswordButton->set_sensitive(false);
+ m_xNewLibButton->set_sensitive(true);
+ m_xInsertLibButton->set_sensitive(true);
+ m_xExportButton->set_sensitive(false);
+ m_xDelButton->set_sensitive(false);
+ }
+ else if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) )
+ {
+ m_xPasswordButton->set_sensitive(false);
+ m_xNewLibButton->set_sensitive(true);
+ m_xInsertLibButton->set_sensitive(true);
+ if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) ||
+ ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) )
m_xDelButton->set_sensitive(false);
- }
- else if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) ) ||
- ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) ) )
- {
- m_xPasswordButton->set_sensitive(false);
- m_xNewLibButton->set_sensitive(true);
- m_xInsertLibButton->set_sensitive(true);
- if ( ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) && xModLibContainer->isLibraryReadOnly( aLibName ) && !xModLibContainer->isLibraryLink( aLibName ) ) ||
- ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) && xDlgLibContainer->isLibraryReadOnly( aLibName ) && !xDlgLibContainer->isLibraryLink( aLibName ) ) )
- m_xDelButton->set_sensitive(false);
- else
- m_xDelButton->set_sensitive(true);
- }
else
- {
- if ( xModLibContainer.is() && !xModLibContainer->hasByName( aLibName ) )
- m_xPasswordButton->set_sensitive(false);
- else
- m_xPasswordButton->set_sensitive(true);
-
- m_xNewLibButton->set_sensitive(true);
- m_xInsertLibButton->set_sensitive(true);
- m_xExportButton->set_sensitive(true);
m_xDelButton->set_sensitive(true);
- }
+ }
+ else
+ {
+ if ( xModLibContainer.is() && !xModLibContainer->hasByName( aLibName ) )
+ m_xPasswordButton->set_sensitive(false);
+ else
+ m_xPasswordButton->set_sensitive(true);
+
+ m_xNewLibButton->set_sensitive(true);
+ m_xInsertLibButton->set_sensitive(true);
+ m_xExportButton->set_sensitive(true);
+ m_xDelButton->set_sensitive(true);
}
}
@@ -931,22 +931,22 @@ void LibPage::Export()
}
std::unique_ptr<ExportDialog> xNewDlg(new ExportDialog(m_pDialog->getDialog()));
- if (xNewDlg->run() == RET_OK)
+ if (xNewDlg->run() != RET_OK)
+ return;
+
+ try
+ {
+ bool bExportAsPackage = xNewDlg->isExportAsPackage();
+ //tdf#112063 ensure closing xNewDlg is not selected as
+ //parent of file dialog from ExportAs...
+ xNewDlg.reset();
+ if (bExportAsPackage)
+ ExportAsPackage( aLibName );
+ else
+ ExportAsBasic( aLibName );
+ }
+ catch(const util::VetoException& ) // user canceled operation
{
- try
- {
- bool bExportAsPackage = xNewDlg->isExportAsPackage();
- //tdf#112063 ensure closing xNewDlg is not selected as
- //parent of file dialog from ExportAs...
- xNewDlg.reset();
- if (bExportAsPackage)
- ExportAsPackage( aLibName );
- else
- ExportAsBasic( aLibName );
- }
- catch(const util::VetoException& ) // user canceled operation
- {
- }
}
}
@@ -1031,90 +1031,90 @@ void LibPage::ExportAsPackage( const OUString& aLibName )
}
xFP->setCurrentFilter( aTitle );
- if ( xFP->execute() == RET_OK )
- {
- GetExtraData()->SetAddLibPath(xFP->getDisplayDirectory());
-
- Sequence< OUString > aFiles = xFP->getSelectedFiles();
- INetURLObject aURL( aFiles[0] );
- if( aURL.getExtension().isEmpty() )
- aURL.setExtension( "oxt" );
+ if ( xFP->execute() != RET_OK )
+ return;
- OUString aPackageURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+ GetExtraData()->SetAddLibPath(xFP->getDisplayDirectory());
- OUString aTmpPath = SvtPathOptions().GetTempPath();
- INetURLObject aInetObj( aTmpPath );
- aInetObj.insertName( aLibName, true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
- OUString aSourcePath = aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( xSFA->exists( aSourcePath ) )
- xSFA->kill( aSourcePath );
- Reference< task::XInteractionHandler > xDummyHandler( new DummyInteractionHandler( xHandler ) );
- implExportLib( aLibName, aTmpPath, xDummyHandler );
-
- Reference< XCommandEnvironment > xCmdEnv = new OLibCommandEnvironment(xHandler);
-
- ::ucbhelper::Content sourceContent( aSourcePath, xCmdEnv, comphelper::getProcessComponentContext() );
-
- OUString destFolder = "vnd.sun.star.zip://" +
- ::rtl::Uri::encode( aPackageURL,
- rtl_UriCharClassRegName,
- rtl_UriEncodeIgnoreEscapes,
- RTL_TEXTENCODING_UTF8 ) +
- "/";
-
- if( xSFA->exists( aPackageURL ) )
- xSFA->kill( aPackageURL );
-
- ::ucbhelper::Content destFolderContent( destFolder, xCmdEnv, comphelper::getProcessComponentContext() );
- destFolderContent.transferContent(
- sourceContent, ::ucbhelper::InsertOperation::Copy,
- OUString(), NameClash::OVERWRITE );
-
- INetURLObject aMetaInfInetObj( aTmpPath );
- aMetaInfInetObj.insertName( "META-INF",
- true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
- OUString aMetaInfFolder = aMetaInfInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
- if( xSFA->exists( aMetaInfFolder ) )
- xSFA->kill( aMetaInfFolder );
- xSFA->createFolder( aMetaInfFolder );
-
- std::vector< Sequence<beans::PropertyValue> > manifest;
- const OUString strMediaType = "MediaType" ;
- const OUString strFullPath = "FullPath" ;
- const OUString strBasicMediaType = "application/vnd.sun.star.basic-library" ;
-
- OUString fullPath = aLibName
- + "/" ;
- auto attribs(::comphelper::InitPropertySequence({
- { strFullPath, Any(fullPath) },
- { strMediaType, Any(strBasicMediaType) }
- }));
- manifest.push_back( attribs );
-
- // write into pipe:
- Reference<packages::manifest::XManifestWriter> xManifestWriter = packages::manifest::ManifestWriter::create( xContext );
- Reference<io::XOutputStream> xPipe( io::Pipe::create( xContext ), UNO_QUERY_THROW );
- xManifestWriter->writeManifestSequence(
- xPipe, Sequence< Sequence<beans::PropertyValue> >(
- manifest.data(), manifest.size() ) );
-
- aMetaInfInetObj.insertName( "manifest.xml",
- true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
-
- // write buffered pipe data to content:
- ::ucbhelper::Content manifestContent( aMetaInfInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xCmdEnv, comphelper::getProcessComponentContext() );
- manifestContent.writeStream( Reference<io::XInputStream>( xPipe, UNO_QUERY_THROW ), true );
-
- ::ucbhelper::Content MetaInfContent( aMetaInfFolder, xCmdEnv, comphelper::getProcessComponentContext() );
- destFolderContent.transferContent(
- MetaInfContent, ::ucbhelper::InsertOperation::Copy,
- OUString(), NameClash::OVERWRITE );
-
- if( xSFA->exists( aSourcePath ) )
- xSFA->kill( aSourcePath );
- if( xSFA->exists( aMetaInfFolder ) )
- xSFA->kill( aMetaInfFolder );
- }
+ Sequence< OUString > aFiles = xFP->getSelectedFiles();
+ INetURLObject aURL( aFiles[0] );
+ if( aURL.getExtension().isEmpty() )
+ aURL.setExtension( "oxt" );
+
+ OUString aPackageURL( aURL.GetMainURL( INetURLObject::DecodeMechanism::NONE ) );
+
+ OUString aTmpPath = SvtPathOptions().GetTempPath();
+ INetURLObject aInetObj( aTmpPath );
+ aInetObj.insertName( aLibName, true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
+ OUString aSourcePath = aInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( xSFA->exists( aSourcePath ) )
+ xSFA->kill( aSourcePath );
+ Reference< task::XInteractionHandler > xDummyHandler( new DummyInteractionHandler( xHandler ) );
+ implExportLib( aLibName, aTmpPath, xDummyHandler );
+
+ Reference< XCommandEnvironment > xCmdEnv = new OLibCommandEnvironment(xHandler);
+
+ ::ucbhelper::Content sourceContent( aSourcePath, xCmdEnv, comphelper::getProcessComponentContext() );
+
+ OUString destFolder = "vnd.sun.star.zip://" +
+ ::rtl::Uri::encode( aPackageURL,
+ rtl_UriCharClassRegName,
+ rtl_UriEncodeIgnoreEscapes,
+ RTL_TEXTENCODING_UTF8 ) +
+ "/";
+
+ if( xSFA->exists( aPackageURL ) )
+ xSFA->kill( aPackageURL );
+
+ ::ucbhelper::Content destFolderContent( destFolder, xCmdEnv, comphelper::getProcessComponentContext() );
+ destFolderContent.transferContent(
+ sourceContent, ::ucbhelper::InsertOperation::Copy,
+ OUString(), NameClash::OVERWRITE );
+
+ INetURLObject aMetaInfInetObj( aTmpPath );
+ aMetaInfInetObj.insertName( "META-INF",
+ true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
+ OUString aMetaInfFolder = aMetaInfInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE );
+ if( xSFA->exists( aMetaInfFolder ) )
+ xSFA->kill( aMetaInfFolder );
+ xSFA->createFolder( aMetaInfFolder );
+
+ std::vector< Sequence<beans::PropertyValue> > manifest;
+ const OUString strMediaType = "MediaType" ;
+ const OUString strFullPath = "FullPath" ;
+ const OUString strBasicMediaType = "application/vnd.sun.star.basic-library" ;
+
+ OUString fullPath = aLibName
+ + "/" ;
+ auto attribs(::comphelper::InitPropertySequence({
+ { strFullPath, Any(fullPath) },
+ { strMediaType, Any(strBasicMediaType) }
+ }));
+ manifest.push_back( attribs );
+
+ // write into pipe:
+ Reference<packages::manifest::XManifestWriter> xManifestWriter = packages::manifest::ManifestWriter::create( xContext );
+ Reference<io::XOutputStream> xPipe( io::Pipe::create( xContext ), UNO_QUERY_THROW );
+ xManifestWriter->writeManifestSequence(
+ xPipe, Sequence< Sequence<beans::PropertyValue> >(
+ manifest.data(), manifest.size() ) );
+
+ aMetaInfInetObj.insertName( "manifest.xml",
+ true, INetURLObject::LAST_SEGMENT, INetURLObject::EncodeMechanism::All );
+
+ // write buffered pipe data to content:
+ ::ucbhelper::Content manifestContent( aMetaInfInetObj.GetMainURL( INetURLObject::DecodeMechanism::NONE ), xCmdEnv, comphelper::getProcessComponentContext() );
+ manifestContent.writeStream( Reference<io::XInputStream>( xPipe, UNO_QUERY_THROW ), true );
+
+ ::ucbhelper::Content MetaInfContent( aMetaInfFolder, xCmdEnv, comphelper::getProcessComponentContext() );
+ destFolderContent.transferContent(
+ MetaInfContent, ::ucbhelper::InsertOperation::Copy,
+ OUString(), NameClash::OVERWRITE );
+
+ if( xSFA->exists( aSourcePath ) )
+ xSFA->kill( aSourcePath );
+ if( xSFA->exists( aMetaInfFolder ) )
+ xSFA->kill( aMetaInfFolder );
}
void LibPage::ExportAsBasic( const OUString& aLibName )
@@ -1161,24 +1161,24 @@ void LibPage::DeleteCurrent()
bIsLibraryLink = true;
}
- if (QueryDelLib(aLibName, bIsLibraryLink, m_pDialog->getDialog()))
- {
- // inform BasicIDE
- SfxUnoAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, Any( m_aCurDocument.getDocumentOrNull() ) );
- SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
- if (SfxDispatcher* pDispatcher = GetDispatcher())
- pDispatcher->ExecuteList(SID_BASICIDE_LIBREMOVED,
- SfxCallMode::SYNCHRON, { &aDocItem, &aLibNameItem });
-
- // remove library from module and dialog library containers
- if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
- xModLibContainer->removeLibrary( aLibName );
- if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
- xDlgLibContainer->removeLibrary( aLibName );
+ if (!QueryDelLib(aLibName, bIsLibraryLink, m_pDialog->getDialog()))
+ return;
- m_xLibBox->remove(*xCurEntry);
- MarkDocumentModified( m_aCurDocument );
- }
+ // inform BasicIDE
+ SfxUnoAnyItem aDocItem( SID_BASICIDE_ARG_DOCUMENT_MODEL, Any( m_aCurDocument.getDocumentOrNull() ) );
+ SfxStringItem aLibNameItem( SID_BASICIDE_ARG_LIBNAME, aLibName );
+ if (SfxDispatcher* pDispatcher = GetDispatcher())
+ pDispatcher->ExecuteList(SID_BASICIDE_LIBREMOVED,
+ SfxCallMode::SYNCHRON, { &aDocItem, &aLibNameItem });
+
+ // remove library from module and dialog library containers
+ if ( xModLibContainer.is() && xModLibContainer->hasByName( aLibName ) )
+ xModLibContainer->removeLibrary( aLibName );
+ if ( xDlgLibContainer.is() && xDlgLibContainer->hasByName( aLibName ) )
+ xDlgLibContainer->removeLibrary( aLibName );
+
+ m_xLibBox->remove(*xCurEntry);
+ MarkDocumentModified( m_aCurDocument );
}
void LibPage::EndTabDialog()
@@ -1208,38 +1208,38 @@ void LibPage::InsertListBoxEntry( const ScriptDocument& rDocument, LibraryLocati
void LibPage::SetCurLib()
{
DocumentEntry* pEntry = reinterpret_cast<DocumentEntry*>(m_xBasicsBox->get_active_id().toInt64());
- if (pEntry)
- {
- const ScriptDocument& aDocument( pEntry->GetDocument() );
- DBG_ASSERT( aDocument.isAlive(), "LibPage::SetCurLib: no document, or document is dead!" );
- if ( !aDocument.isAlive() )
- return;
- LibraryLocation eLocation = pEntry->GetLocation();
- if ( aDocument != m_aCurDocument || eLocation != m_eCurLocation )
- {
- m_aCurDocument = aDocument;
- m_eCurLocation = eLocation;
- m_xLibBox->clear();
+ if (!pEntry)
+ return;
- // get a sorted list of library names
- Sequence< OUString > aLibNames = aDocument.getLibraryNames();
- sal_Int32 nLibCount = aLibNames.getLength();
- const OUString* pLibNames = aLibNames.getConstArray();
+ const ScriptDocument& aDocument( pEntry->GetDocument() );
+ DBG_ASSERT( aDocument.isAlive(), "LibPage::SetCurLib: no document, or document is dead!" );
+ if ( !aDocument.isAlive() )
+ return;
+ LibraryLocation eLocation = pEntry->GetLocation();
+ if ( aDocument == m_aCurDocument && eLocation == m_eCurLocation )
+ return;
- int nEntry = 0;
- for (int i = 0 ; i < nLibCount; ++i)
- {
- OUString aLibName(pLibNames[i]);
- if (eLocation == aDocument.getLibraryLocation(aLibName))
- ImpInsertLibEntry(aLibName, nEntry++);
- }
+ m_aCurDocument = aDocument;
+ m_eCurLocation = eLocation;
+ m_xLibBox->clear();
- int nEntry_ = FindEntry(*m_xLibBox, "Standard");
- if (nEntry_ == -1 && m_xLibBox->n_children())
- nEntry_ = 0;
- m_xLibBox->set_cursor(nEntry_);
- }
+ // get a sorted list of library names
+ Sequence< OUString > aLibNames = aDocument.getLibraryNames();
+ sal_Int32 nLibCount = aLibNames.getLength();
+ const OUString* pLibNames = aLibNames.getConstArray();
+
+ int nEntry = 0;
+ for (int i = 0 ; i < nLibCount; ++i)
+ {
+ OUString aLibName(pLibNames[i]);
+ if (eLocation == aDocument.getLibraryLocation(aLibName))
+ ImpInsertLibEntry(aLibName, nEntry++);
}
+
+ int nEntry_ = FindEntry(*m_xLibBox, "Standard");
+ if (nEntry_ == -1 && m_xLibBox->n_children())
+ nEntry_ = 0;
+ m_xLibBox->set_cursor(nEntry_);
}
void LibPage::ImpInsertLibEntry( const OUString& rLibName, sal_uLong nPos )
@@ -1292,78 +1292,78 @@ void createLibImpl(weld::Window* pWin, const ScriptDocument& rDocument,
NewObjectDialog aNewDlg(pWin, ObjectMode::Library);
aNewDlg.SetObjectName(aLibName);
- if (aNewDlg.run())
- {
- if (!aNewDlg.GetObjectName().isEmpty())
- aLibName = aNewDlg.GetObjectName();
+ if (!aNewDlg.run())
+ return;
- if ( aLibName.getLength() > 30 )
- {
- std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
- VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_LIBNAMETOLONG)));
- xErrorBox->run();
- }
- else if ( !IsValidSbxName( aLibName ) )
- {
- std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
- VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
- xErrorBox->run();
- }
- else if ( rDocument.hasLibrary( E_SCRIPTS, aLibName ) || rDocument.hasLibrary( E_DIALOGS, aLibName ) )
- {
- std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
- VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
- xErrorBox->run();
- }
- else
+ if (!aNewDlg.GetObjectName().isEmpty())
+ aLibName = aNewDlg.GetObjectName();
+
+ if ( aLibName.getLength() > 30 )
+ {
+ std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_LIBNAMETOLONG)));
+ xErrorBox->run();
+ }
+ else if ( !IsValidSbxName( aLibName ) )
+ {
+ std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_BADSBXNAME)));
+ xErrorBox->run();
+ }
+ else if ( rDocument.hasLibrary( E_SCRIPTS, aLibName ) || rDocument.hasLibrary( E_DIALOGS, aLibName ) )
+ {
+ std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(pWin,
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
+ xErrorBox->run();
+ }
+ else
+ {
+ try
{
- try
- {
- // create module and dialog library
- rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
- rDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
+ // create module and dialog library
+ rDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
+ rDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
- if( pLibBox )
- {
- pLibBox->append_text(aLibName);
- pLibBox->set_cursor(pLibBox->find_text(aLibName));
- }
+ if( pLibBox )
+ {
+ pLibBox->append_text(aLibName);
+ pLibBox->set_cursor(pLibBox->find_text(aLibName));
+ }
- // create a module
- OUString aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
- OUString sModuleCode;
- if ( !rDocument.createModule( aLibName, aModName, true, sModuleCode ) )
- throw Exception("could not create module " + aModName, nullptr);
+ // create a module
+ OUString aModName = rDocument.createObjectName( E_SCRIPTS, aLibName );
+ OUString sModuleCode;
+ if ( !rDocument.createModule( aLibName, aModName, true, sModuleCode ) )
+ throw Exception("could not create module " + aModName, nullptr);
- SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE );
- if (SfxDispatcher* pDispatcher = GetDispatcher())
- pDispatcher->ExecuteList(SID_BASICIDE_SBXINSERTED,
- SfxCallMode::SYNCHRON, { &aSbxItem });
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, rDocument, aLibName, aModName, TYPE_MODULE );
+ if (SfxDispatcher* pDispatcher = GetDispatcher())
+ pDispatcher->ExecuteList(SID_BASICIDE_SBXINSERTED,
+ SfxCallMode::SYNCHRON, { &aSbxItem });
- if( pBasicBox )
+ if( pBasicBox )
+ {
+ std::unique_ptr<weld::TreeIter> xIter(pBasicBox->make_iterator(nullptr));
+ bool bValidIter = pBasicBox->get_cursor(xIter.get());
+ std::unique_ptr<weld::TreeIter> xRootEntry(pBasicBox->make_iterator(xIter.get()));
+ while (bValidIter)
{
- std::unique_ptr<weld::TreeIter> xIter(pBasicBox->make_iterator(nullptr));
- bool bValidIter = pBasicBox->get_cursor(xIter.get());
- std::unique_ptr<weld::TreeIter> xRootEntry(pBasicBox->make_iterator(xIter.get()));
- while (bValidIter)
- {
- pBasicBox->copy_iterator(*xIter, *xRootEntry);
- bValidIter = pBasicBox->iter_parent(*xIter);
- }
-
- BrowseMode nMode = pBasicBox->GetMode();
- bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules );
- const OUString sId = bDlgMode ? OUStringLiteral(RID_BMP_DLGLIB) : OUStringLiteral(RID_BMP_MODLIB);
- pBasicBox->AddEntry(aLibName, sId, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_LIBRARY));
- pBasicBox->AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_MODULE));
- pBasicBox->set_cursor(*xRootEntry);
- pBasicBox->select(*xRootEntry);
+ pBasicBox->copy_iterator(*xIter, *xRootEntry);
+ bValidIter = pBasicBox->iter_parent(*xIter);
}
+
+ BrowseMode nMode = pBasicBox->GetMode();
+ bool bDlgMode = ( nMode & BrowseMode::Dialogs ) && !( nMode & BrowseMode::Modules );
+ const OUString sId = bDlgMode ? OUStringLiteral(RID_BMP_DLGLIB) : OUStringLiteral(RID_BMP_MODLIB);
+ pBasicBox->AddEntry(aLibName, sId, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_LIBRARY));
+ pBasicBox->AddEntry(aModName, RID_BMP_MODULE, xRootEntry.get(), false, std::make_unique<Entry>(OBJ_TYPE_MODULE));
+ pBasicBox->set_cursor(*xRootEntry);
+ pBasicBox->select(*xRootEntry);
}
- catch (const uno::Exception& )
- {
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
- }
+ }
+ catch (const uno::Exception& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
}
}
}
diff --git a/basctl/source/basicide/moduldlg.cxx b/basctl/source/basicide/moduldlg.cxx
index 2cd8bd8009b3..a4ab2f3fb112 100644
--- a/basctl/source/basicide/moduldlg.cxx
+++ b/basctl/source/basicide/moduldlg.cxx
@@ -164,22 +164,22 @@ void Shell::CopyDialogResources(
Reference< io::XInputStream > xInput( io_xISP->createInputStream() );
::xmlscript::importDialogModel( xInput, xDialogModel, xContext, rSourceDoc.isDocument() ? rSourceDoc.getDocument() : Reference< frame::XModel >() );
- if( xDialogModel.is() )
+ if( !xDialogModel.is() )
+ return;
+
+ if( bSourceLocalized && bDestLocalized )
{
- if( bSourceLocalized && bDestLocalized )
- {
- LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceMgr );
- }
- else if( bSourceLocalized )
- {
- LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr );
- }
- else if( bDestLocalized )
- {
- LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr );
- }
- io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() );
+ LocalizationMgr::copyResourceForDroppedDialog( xDialogModel, rDlgName, xDestMgr, xSourceMgr );
}
+ else if( bSourceLocalized )
+ {
+ LocalizationMgr::resetResourceForDialog( xDialogModel, xSourceMgr );
+ }
+ else if( bDestLocalized )
+ {
+ LocalizationMgr::setResourceIDsForDialog( xDialogModel, xDestMgr );
+ }
+ io_xISP = ::xmlscript::exportDialogModel( xDialogModel, xContext, rDestDoc.isDocument() ? rDestDoc.getDocument() : Reference< frame::XModel >() );
}
// OrganizeDialog
@@ -776,62 +776,62 @@ void ObjectPage::NewDialog()
ScriptDocument aDocument( ScriptDocument::getApplicationScriptDocument() );
OUString aLibName;
- if ( GetSelection( aDocument, aLibName ) )
- {
- aDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
+ if ( !GetSelection( aDocument, aLibName ) )
+ return;
- NewObjectDialog aNewDlg(m_pDialog->getDialog(), ObjectMode::Dialog, true);
- aNewDlg.SetObjectName(aDocument.createObjectName(E_DIALOGS, aLibName));
+ aDocument.getOrCreateLibrary( E_DIALOGS, aLibName );
- if (aNewDlg.run() != RET_CANCEL)
- {
- OUString aDlgName = aNewDlg.GetObjectName();
- if (aDlgName.isEmpty())
- aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName);
+ NewObjectDialog aNewDlg(m_pDialog->getDialog(), ObjectMode::Dialog, true);
+ aNewDlg.SetObjectName(aDocument.createObjectName(E_DIALOGS, aLibName));
- if ( aDocument.hasDialog( aLibName, aDlgName ) )
- {
- std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_pDialog->getDialog(),
- VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
- xError->run();
- }
- else
- {
- Reference< io::XInputStreamProvider > xISP;
- if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) )
- return;
+ if (aNewDlg.run() == RET_CANCEL)
+ return;
- SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, TYPE_DIALOG );
- if (SfxDispatcher* pDispatcher = GetDispatcher())
- {
- pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED,
- SfxCallMode::SYNCHRON, { &aSbxItem });
- }
- LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
- std::unique_ptr<weld::TreeIter> xIter(m_xBasicBox->make_iterator());
- bool bRootEntry = m_xBasicBox->FindRootEntry(aDocument, eLocation, *xIter);
- if (bRootEntry)
+ OUString aDlgName = aNewDlg.GetObjectName();
+ if (aDlgName.isEmpty())
+ aDlgName = aDocument.createObjectName( E_DIALOGS, aLibName);
+
+ if ( aDocument.hasDialog( aLibName, aDlgName ) )
+ {
+ std::unique_ptr<weld::MessageDialog> xError(Application::CreateMessageDialog(m_pDialog->getDialog(),
+ VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_SBXNAMEALLREADYUSED2)));
+ xError->run();
+ }
+ else
+ {
+ Reference< io::XInputStreamProvider > xISP;
+ if ( !aDocument.createDialog( aLibName, aDlgName, xISP ) )
+ return;
+
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aDlgName, TYPE_DIALOG );
+ if (SfxDispatcher* pDispatcher = GetDispatcher())
+ {
+ pDispatcher->ExecuteList( SID_BASICIDE_SBXINSERTED,
+ SfxCallMode::SYNCHRON, { &aSbxItem });
+ }
+ LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
+ std::unique_ptr<weld::TreeIter> xIter(m_xBasicBox->make_iterator());
+ bool bRootEntry = m_xBasicBox->FindRootEntry(aDocument, eLocation, *xIter);
+ if (bRootEntry)
+ {
+ if (!m_xBasicBox->get_row_expanded(*xIter))
+ m_xBasicBox->expand_row(*xIter);
+ bool bLibEntry = m_xBasicBox->FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter);
+ DBG_ASSERT( bLibEntry, "LibEntry not found!" );
+ if (bLibEntry)
+ {
+ if (!m_xBasicBox->get_row_expanded(*xIter))
+ m_xBasicBox->expand_row(*xIter);
+ std::unique_ptr<weld::TreeIter> xSubRootEntry(m_xBasicBox->make_iterator(xIter.get()));
+ bool bDlgEntry = m_xBasicBox->FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xIter);
+ if (!bDlgEntry)
{
- if (!m_xBasicBox->get_row_expanded(*xIter))
- m_xBasicBox->expand_row(*xIter);
- bool bLibEntry = m_xBasicBox->FindEntry(aLibName, OBJ_TYPE_LIBRARY, *xIter);
- DBG_ASSERT( bLibEntry, "LibEntry not found!" );
- if (bLibEntry)
- {
- if (!m_xBasicBox->get_row_expanded(*xIter))
- m_xBasicBox->expand_row(*xIter);
- std::unique_ptr<weld::TreeIter> xSubRootEntry(m_xBasicBox->make_iterator(xIter.get()));
- bool bDlgEntry = m_xBasicBox->FindEntry(aDlgName, OBJ_TYPE_DIALOG, *xIter);
- if (!bDlgEntry)
- {
- m_xBasicBox->AddEntry(aDlgName, RID_BMP_DIALOG, xSubRootEntry.get(), false,
- std::make_unique<Entry>(OBJ_TYPE_DIALOG), xIter.get());
- assert(xIter.get() && "Insert entry failed!");
- }
- m_xBasicBox->set_cursor(*xIter);
- m_xBasicBox->select(*xIter);
- }
+ m_xBasicBox->AddEntry(aDlgName, RID_BMP_DIALOG, xSubRootEntry.get(), false,
+ std::make_unique<Entry>(OBJ_TYPE_DIALOG), xIter.get());
+ assert(xIter.get() && "Insert entry failed!");
}
+ m_xBasicBox->set_cursor(*xIter);
+ m_xBasicBox->select(*xIter);
}
}
}
@@ -852,34 +852,34 @@ void ObjectPage::DeleteCurrent()
const OUString& aName( aDesc.GetName() );
EntryType eType = aDesc.GetType();
- if ( ( eType == OBJ_TYPE_MODULE && QueryDelModule(aName, m_pDialog->getDialog()) ) ||
- ( eType == OBJ_TYPE_DIALOG && QueryDelDialog(aName, m_pDialog->getDialog()) ) )
+ if ( !(( eType == OBJ_TYPE_MODULE && QueryDelModule(aName, m_pDialog->getDialog()) ) ||
+ ( eType == OBJ_TYPE_DIALOG && QueryDelDialog(aName, m_pDialog->getDialog()) )) )
+ return;
+
+ m_xBasicBox->remove(*xCurEntry);
+ if (m_xBasicBox->get_cursor(xCurEntry.get()))
+ m_xBasicBox->select(*xCurEntry);
+ if (SfxDispatcher* pDispatcher = GetDispatcher())
{
- m_xBasicBox->remove(*xCurEntry);
- if (m_xBasicBox->get_cursor(xCurEntry.get()))
- m_xBasicBox->select(*xCurEntry);
- if (SfxDispatcher* pDispatcher = GetDispatcher())
- {
- SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aName, SbTreeListBox::ConvertType( eType ) );
- pDispatcher->ExecuteList( SID_BASICIDE_SBXDELETED,
- SfxCallMode::SYNCHRON, { &aSbxItem });
- }
+ SbxItem aSbxItem( SID_BASICIDE_ARG_SBX, aDocument, aLibName, aName, SbTreeListBox::ConvertType( eType ) );
+ pDispatcher->ExecuteList( SID_BASICIDE_SBXDELETED,
+ SfxCallMode::SYNCHRON, { &aSbxItem });
+ }
- try
- {
- bool bSuccess = false;
- if ( eType == OBJ_TYPE_MODULE )
- bSuccess = aDocument.removeModule( aLibName, aName );
- else if ( eType == OBJ_TYPE_DIALOG )
- bSuccess = RemoveDialog( aDocument, aLibName, aName );
-
- if ( bSuccess )
- MarkDocumentModified( aDocument );
- }
- catch (const container::NoSuchElementException& )
- {
- DBG_UNHANDLED_EXCEPTION("basctl.basicide");
- }
+ try
+ {
+ bool bSuccess = false;
+ if ( eType == OBJ_TYPE_MODULE )
+ bSuccess = aDocument.removeModule( aLibName, aName );
+ else if ( eType == OBJ_TYPE_DIALOG )
+ bSuccess = RemoveDialog( aDocument, aLibName, aName );
+
+ if ( bSuccess )
+ MarkDocumentModified( aDocument );
+ }
+ catch (const container::NoSuchElementException& )
+ {
+ DBG_UNHANDLED_EXCEPTION("basctl.basicide");
}
}
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 26f5446227ad..3f6fd34b106e 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -616,25 +616,26 @@ void DlgEditor::CreateDefaultObject()
pDlgEdView->GetCurrentObjInventor(),
pDlgEdView->GetCurrentObjIdentifier());
- if (DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj))
- {
- // set position and size
- Size aSize = rWindow.PixelToLogic( Size( 96, 24 ) );
- Point aPoint = pDlgEdForm->GetSnapRect().Center();
- aPoint.AdjustX( -(aSize.Width() / 2) );
- aPoint.AdjustY( -(aSize.Height() / 2) );
- pDlgEdObj->SetSnapRect( tools::Rectangle( aPoint, aSize ) );
+ DlgEdObj* pDlgEdObj = dynamic_cast<DlgEdObj*>(pObj);
+ if (!pDlgEdObj)
+ return;
- // set default property values
- pDlgEdObj->SetDefaults();
+ // set position and size
+ Size aSize = rWindow.PixelToLogic( Size( 96, 24 ) );
+ Point aPoint = pDlgEdForm->GetSnapRect().Center();
+ aPoint.AdjustX( -(aSize.Width() / 2) );
+ aPoint.AdjustY( -(aSize.Height() / 2) );
+ pDlgEdObj->SetSnapRect( tools::Rectangle( aPoint, aSize ) );
- // insert object into drawing page
- SdrPageView* pPageView = pDlgEdView->GetSdrPageView();
- if (pDlgEdView->InsertObjectAtView(pDlgEdObj, *pPageView))
- {
- // start listening
- pDlgEdObj->StartListening();
- }
+ // set default property values
+ pDlgEdObj->SetDefaults();
+
+ // insert object into drawing page
+ SdrPageView* pPageView = pDlgEdView->GetSdrPageView();
+ if (pDlgEdView->InsertObjectAtView(pDlgEdObj, *pPageView))
+ {
+ // start listening
+ pDlgEdObj->StartListening();
}
}
@@ -730,81 +731,81 @@ void DlgEditor::Copy()
// set clipboard content
Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow().GetClipboard();
- if ( xClipboard.is() )
+ if ( !xClipboard.is() )
+ return;
+
+ // With resource?
+ uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
+ if( xDialogModelPropSet.is() )
{
- // With resource?
- uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
- uno::Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
- if( xDialogModelPropSet.is() )
+ try
{
- try
- {
- Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
- aResourceResolver >>= xStringResourcePersistence;
- }
- catch(const UnknownPropertyException& )
- {}
+ Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
+ aResourceResolver >>= xStringResourcePersistence;
}
+ catch(const UnknownPropertyException& )
+ {}
+ }
- DlgEdTransferableImpl* pTrans = nullptr;
- if( xStringResourcePersistence.is() )
+ DlgEdTransferableImpl* pTrans = nullptr;
+ if( xStringResourcePersistence.is() )
+ {
+ // With resource, support old and new format
+
+ // Export xClipDialogModel another time with ids replaced by current language string
+ LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourcePersistence );
+ Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
+ Reference< XInputStream > xStream2( xISP2->createInputStream() );
+ Sequence< sal_Int8 > NoResourceDialogModelBytes;
+ implCopyStreamToByteSequence( xStream2, NoResourceDialogModelBytes );
+ xStream2->closeInput();
+
+ // Old format contains dialog with replaced ids
+ Sequence< Any > aSeqData(2);
+ Any aNoResourceDialogModelBytesAny;
+ aNoResourceDialogModelBytesAny <<= NoResourceDialogModelBytes;
+ aSeqData[0] = aNoResourceDialogModelBytesAny;
+
+ // New format contains dialog and resource
+ Sequence< sal_Int8 > aResData = xStringResourcePersistence->exportBinary();
+
+ // Create sequence for combined dialog and resource
+ sal_Int32 nDialogDataLen = DialogModelBytes.getLength();
+ sal_Int32 nResDataLen = aResData.getLength();
+
+ // Combined data = 4 Bytes 32Bit Offset to begin of resource data, lowest byte first
+ // + nDialogDataLen bytes dialog data + nResDataLen resource data
+ sal_Int32 nTotalLen = 4 + nDialogDataLen + nResDataLen;
+ sal_Int32 nResOffset = 4 + nDialogDataLen;
+ Sequence< sal_Int8 > aCombinedData( nTotalLen );
+ sal_Int8* pCombinedData = aCombinedData.getArray();
+
+ // Write offset
+ sal_Int32 n = nResOffset;
+ for( sal_Int16 i = 0 ; i < 4 ; i++ )
{
- // With resource, support old and new format
-
- // Export xClipDialogModel another time with ids replaced by current language string
- LocalizationMgr::resetResourceForDialog( xClipDialogModel, xStringResourcePersistence );
- Reference< XInputStreamProvider > xISP2 = ::xmlscript::exportDialogModel( xClipDialogModel, xContext, m_xDocument );
- Reference< XInputStream > xStream2( xISP2->createInputStream() );
- Sequence< sal_Int8 > NoResourceDialogModelBytes;
- implCopyStreamToByteSequence( xStream2, NoResourceDialogModelBytes );
- xStream2->closeInput();
-
- // Old format contains dialog with replaced ids
- Sequence< Any > aSeqData(2);
- Any aNoResourceDialogModelBytesAny;
- aNoResourceDialogModelBytesAny <<= NoResourceDialogModelBytes;
- aSeqData[0] = aNoResourceDialogModelBytesAny;
-
- // New format contains dialog and resource
- Sequence< sal_Int8 > aResData = xStringResourcePersistence->exportBinary();
-
- // Create sequence for combined dialog and resource
- sal_Int32 nDialogDataLen = DialogModelBytes.getLength();
- sal_Int32 nResDataLen = aResData.getLength();
-
- // Combined data = 4 Bytes 32Bit Offset to begin of resource data, lowest byte first
- // + nDialogDataLen bytes dialog data + nResDataLen resource data
- sal_Int32 nTotalLen = 4 + nDialogDataLen + nResDataLen;
- sal_Int32 nResOffset = 4 + nDialogDataLen;
- Sequence< sal_Int8 > aCombinedData( nTotalLen );
- sal_Int8* pCombinedData = aCombinedData.getArray();
-
- // Write offset
- sal_Int32 n = nResOffset;
- for( sal_Int16 i = 0 ; i < 4 ; i++ )
- {
- pCombinedData[i] = sal_Int8( n & 0xff );
- n >>= 8;
- }
- memcpy( pCombinedData + 4, DialogModelBytes.getConstArray(), nDialogDataLen );
- memcpy( pCombinedData + nResOffset, aResData.getConstArray(), nResDataLen );
+ pCombinedData[i] = sal_Int8( n & 0xff );
+ n >>= 8;
+ }
+ memcpy( pCombinedData + 4, DialogModelBytes.getConstArray(), nDialogDataLen );
+ memcpy( pCombinedData + nResOffset, aResData.getConstArray(), nResDataLen );
- aSeqData[1] <<= aCombinedData;
+ aSeqData[1] <<= aCombinedData;
- pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavorsResource, aSeqData );
- }
- else
- {
- // No resource, support only old format
- Sequence< Any > aSeqData(1);
- Any aDialogModelBytesAny;
- aDialogModelBytesAny <<= DialogModelBytes;
- aSeqData[0] = aDialogModelBytesAny;
- pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , aSeqData );
- }
- SolarMutexReleaser aReleaser;
- xClipboard->setContents( pTrans , pTrans );
+ pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavorsResource, aSeqData );
+ }
+ else
+ {
+ // No resource, support only old format
+ Sequence< Any > aSeqData(1);
+ Any aDialogModelBytesAny;
+ aDialogModelBytesAny <<= DialogModelBytes;
+ aSeqData[0] = aDialogModelBytesAny;
+ pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , aSeqData );
}
+ SolarMutexReleaser aReleaser;
+ xClipboard->setContents( pTrans , pTrans );
}
@@ -818,168 +819,168 @@ void DlgEditor::Paste()
// get clipboard
Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow().GetClipboard();
- if ( xClipboard.is() )
+ if ( !xClipboard.is() )
+ return;
+
+ Reference< datatransfer::XTransferable > xTransf;
{
- Reference< datatransfer::XTransferable > xTransf;
+ SolarMutexReleaser aReleaser;
+ // get clipboard content
+ xTransf = xClipboard->getContents();
+ }
+ if ( !xTransf.is() )
+ return;
+
+ // Is target dialog (library) localized?
+ uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
+ uno::Reference< resource::XStringResourceManager > xStringResourceManager;
+ if( xDialogModelPropSet.is() )
+ {
+ try
{
- SolarMutexReleaser aReleaser;
- // get clipboard content
- xTransf = xClipboard->getContents();
+ Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
+ aResourceResolver >>= xStringResourceManager;
}
- if ( xTransf.is() )
- {
- // Is target dialog (library) localized?
- uno::Reference< beans::XPropertySet > xDialogModelPropSet( m_xUnoControlDialogModel, uno::UNO_QUERY );
- uno::Reference< resource::XStringResourceManager > xStringResourceManager;
- if( xDialogModelPropSet.is() )
- {
- try
- {
- Any aResourceResolver = xDialogModelPropSet->getPropertyValue( aResourceResolverPropName );
- aResourceResolver >>= xStringResourceManager;
- }
- catch(const UnknownPropertyException& )
- {}
- }
- bool bLocalized = false;
- if( xStringResourceManager.is() )
- bLocalized = xStringResourceManager->getLocales().hasElements();
+ catch(const UnknownPropertyException& )
+ {}
+ }
+ bool bLocalized = false;
+ if( xStringResourceManager.is() )
+ bLocalized = xStringResourceManager->getLocales().hasElements();
- if ( xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) )
- {
- // create clipboard dialog model from xml
- Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
- Reference< container::XNameContainer > xClipDialogModel( xContext->getServiceManager()->createInstanceWithContext(
- "com.sun.star.awt.UnoControlDialogModel", xContext ), uno::UNO_QUERY );
-
- bool bSourceIsLocalized = false;
- Sequence< sal_Int8 > DialogModelBytes;
- Sequence< sal_Int8 > aResData;
- if( bLocalized && xTransf->isDataFlavorSupported( m_ClipboardDataFlavorsResource[1] ) )
- {
- bSourceIsLocalized = true;
+ if ( !xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] ) )
+ return;
- Any aCombinedDataAny = xTransf->getTransferData( m_ClipboardDataFlavorsResource[1] );
- Sequence< sal_Int8 > aCombinedData;
- aCombinedDataAny >>= aCombinedData;
- const sal_Int8* pCombinedData = aCombinedData.getConstArray();
+ // create clipboard dialog model from xml
+ Reference< XComponentContext > xContext = comphelper::getProcessComponentContext();
+ Reference< container::XNameContainer > xClipDialogModel( xContext->getServiceManager()->createInstanceWithContext(
+ "com.sun.star.awt.UnoControlDialogModel", xContext ), uno::UNO_QUERY );
- sal_Int32 nTotalLen = aCombinedData.getLength();
+ bool bSourceIsLocalized = false;
+ Sequence< sal_Int8 > DialogModelBytes;
+ Sequence< sal_Int8 > aResData;
+ if( bLocalized && xTransf->isDataFlavorSupported( m_ClipboardDataFlavorsResource[1] ) )
+ {
+ bSourceIsLocalized = true;
- // Reading offset
- sal_Int32 nResOffset = 0;
- sal_Int32 nFactor = 1;
- for( sal_Int16 i = 0; i < 4; i++ )
- {
- nResOffset += nFactor * sal_uInt8( pCombinedData[i] );
- nFactor *= 256;
- }
+ Any aCombinedDataAny = xTransf->getTransferData( m_ClipboardDataFlavorsResource[1] );
+ Sequence< sal_Int8 > aCombinedData;
+ aCombinedDataAny >>= aCombinedData;
+ const sal_Int8* pCombinedData = aCombinedData.getConstArray();
- sal_Int32 nResDataLen = nTotalLen - nResOffset;
- sal_Int32 nDialogDataLen = nTotalLen - nResDataLen - 4;
+ sal_Int32 nTotalLen = aCombinedData.getLength();
- DialogModelBytes.realloc( nDialogDataLen );
- memcpy( DialogModelBytes.getArray(), pCombinedData + 4, nDialogDataLen );
+ // Reading offset
+ sal_Int32 nResOffset = 0;
+ sal_Int32 nFactor = 1;
+ for( sal_Int16 i = 0; i < 4; i++ )
+ {
+ nResOffset += nFactor * sal_uInt8( pCombinedData[i] );
+ nFactor *= 256;
+ }
- aResData.realloc( nResDataLen );
- memcpy( aResData.getArray(), pCombinedData + nResOffset, nResDataLen );
- }
- else
- {
- Any aAny = xTransf->getTransferData( m_ClipboardDataFlavors[0] );
- aAny >>= DialogModelBytes;
- }
+ sal_Int32 nResDataLen = nTotalLen - nResOffset;
+ sal_Int32 nDialogDataLen = nTotalLen - nResDataLen - 4;
- if ( xClipDialogModel.is() )
- {
- Reference<XInputStream> xIn = ::xmlscript::createInputStream( DialogModelBytes.getConstArray(), DialogModelBytes.getLength() );
- ::xmlscript::importDialogModel( xIn , xClipDialogModel, xContext, m_xDocument );
- }
+ DialogModelBytes.realloc( nDialogDataLen );
+ memcpy( DialogModelBytes.getArray(), pCombinedData + 4, nDialogDataLen );
- // get control models from clipboard dialog model
- if ( xClipDialogModel.is() )
- {
- Sequence< OUString > aNames = xClipDialogModel->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_uInt32 nCtrls = aNames.getLength();
+ aResData.realloc( nResDataLen );
+ memcpy( aResData.getArray(), pCombinedData + nResOffset, nResDataLen );
+ }
+ else
+ {
+ Any aAny = xTransf->getTransferData( m_ClipboardDataFlavors[0] );
+ aAny >>= DialogModelBytes;
+ }
- Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
- if( nCtrls > 0 && bSourceIsLocalized )
- {
- xStringResourcePersistence = css::resource::StringResource::create( getProcessComponentContext() );
- xStringResourcePersistence->importBinary( aResData );
- }
- for( sal_uInt32 n = 0; n < nCtrls; n++ )
- {
- Any aA = xClipDialogModel->getByName( pNames[n] );
- Reference< css::awt::XControlModel > xCM;
- aA >>= xCM;
+ if ( xClipDialogModel.is() )
+ {
+ Reference<XInputStream> xIn = ::xmlscript::createInputStream( DialogModelBytes.getConstArray(), DialogModelBytes.getLength() );
+ ::xmlscript::importDialogModel( xIn , xClipDialogModel, xContext, m_xDocument );
+ }
- // clone the control model
- Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY );
- Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY );
+ // get control models from clipboard dialog model
+ if ( !xClipDialogModel.is() )
+ return;
- DlgEdObj* pCtrlObj = new DlgEdObj(*pDlgEdModel);
- pCtrlObj->SetDlgEdForm(pDlgEdForm); // set parent form
- pDlgEdForm->AddChild(pCtrlObj); // add child to parent form
- pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model
+ Sequence< OUString > aNames = xClipDialogModel->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_uInt32 nCtrls = aNames.getLength();
- // set new name
- OUString aOUniqueName( pCtrlObj->GetUniqueName() );
- Reference< beans::XPropertySet > xPSet( xCtrlModel , UNO_QUERY );
- xPSet->setPropertyValue( DLGED_PROP_NAME, Any(aOUniqueName) );
+ Reference< resource::XStringResourcePersistence > xStringResourcePersistence;
+ if( nCtrls > 0 && bSourceIsLocalized )
+ {
+ xStringResourcePersistence = css::resource::StringResource::create( getProcessComponentContext() );
+ xStringResourcePersistence->importBinary( aResData );
+ }
+ for( sal_uInt32 n = 0; n < nCtrls; n++ )
+ {
+ Any aA = xClipDialogModel->getByName( pNames[n] );
+ Reference< css::awt::XControlModel > xCM;
+ aA >>= xCM;
- // set tabindex
- Sequence< OUString > aNames_ = m_xUnoControlDialogModel->getElementNames();
- xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(aNames_.getLength())) );
+ // clone the control model
+ Reference< util::XCloneable > xClone( xCM, uno::UNO_QUERY );
+ Reference< awt::XControlModel > xCtrlModel( xClone->createClone(), uno::UNO_QUERY );
- if( bLocalized )
- {
- Any aControlAny;
- aControlAny <<= xCtrlModel;
- if( bSourceIsLocalized && xStringResourcePersistence.is() )
- {
- LocalizationMgr::copyResourcesForPastedEditorObject( this,
- aControlAny, aOUniqueName, xStringResourcePersistence );
- }
- else
- {
- LocalizationMgr::setControlResourceIDsForNewEditorObject
- ( this, aControlAny, aOUniqueName );
- }
- }
+ DlgEdObj* pCtrlObj = new DlgEdObj(*pDlgEdModel);
+ pCtrlObj->SetDlgEdForm(pDlgEdForm); // set parent form
+ pDlgEdForm->AddChild(pCtrlObj); // add child to parent form
+ pCtrlObj->SetUnoControlModel( xCtrlModel ); // set control model
- // insert control model in editor dialog model
- Any aCtrlModel;
- aCtrlModel <<= xCtrlModel;
- m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel );
-
- // insert object into drawing page
- pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
- pCtrlObj->SetRectFromProps();
- pCtrlObj->UpdateStep();
- pDlgEdForm->UpdateTabOrderAndGroups();
- pCtrlObj->StartListening(); // start listening
-
- // mark object
- SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
- pDlgEdView->MarkObj( pCtrlObj, pPgView, false, true);
- }
+ // set new name
+ OUString aOUniqueName( pCtrlObj->GetUniqueName() );
+ Reference< beans::XPropertySet > xPSet( xCtrlModel , UNO_QUERY );
+ xPSet->setPropertyValue( DLGED_PROP_NAME, Any(aOUniqueName) );
- // center marked objects in dialog editor form
- Point aMarkCenter = pDlgEdView->GetMarkedObjRect().Center();
- Point aFormCenter = pDlgEdForm->GetSnapRect().Center();
- Point aPoint = aFormCenter - aMarkCenter;
- Size aSize( aPoint.X() , aPoint.Y() );
- pDlgEdView->MoveMarkedObj( aSize ); // update of control model properties (position + size) in NbcMove
- pDlgEdView->MarkListHasChanged();
+ // set tabindex
+ Sequence< OUString > aNames_ = m_xUnoControlDialogModel->getElementNames();
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(aNames_.getLength())) );
- // dialog model changed
- SetDialogModelChanged();
- }
+ if( bLocalized )
+ {
+ Any aControlAny;
+ aControlAny <<= xCtrlModel;
+ if( bSourceIsLocalized && xStringResourcePersistence.is() )
+ {
+ LocalizationMgr::copyResourcesForPastedEditorObject( this,
+ aControlAny, aOUniqueName, xStringResourcePersistence );
+ }
+ else
+ {
+ LocalizationMgr::setControlResourceIDsForNewEditorObject
+ ( this, aControlAny, aOUniqueName );
}
}
+
+ // insert control model in editor dialog model
+ Any aCtrlModel;
+ aCtrlModel <<= xCtrlModel;
+ m_xUnoControlDialogModel->insertByName( aOUniqueName , aCtrlModel );
+
+ // insert object into drawing page
+ pDlgEdModel->GetPage(0)->InsertObject( pCtrlObj );
+ pCtrlObj->SetRectFromProps();
+ pCtrlObj->UpdateStep();
+ pDlgEdForm->UpdateTabOrderAndGroups();
+ pCtrlObj->StartListening(); // start listening
+
+ // mark object
+ SdrPageView* pPgView = pDlgEdView->GetSdrPageView();
+ pDlgEdView->MarkObj( pCtrlObj, pPgView, false, true);
}
+
+ // center marked objects in dialog editor form
+ Point aMarkCenter = pDlgEdView->GetMarkedObjRect().Center();
+ Point aFormCenter = pDlgEdForm->GetSnapRect().Center();
+ Point aPoint = aFormCenter - aMarkCenter;
+ Size aSize( aPoint.X() , aPoint.Y() );
+ pDlgEdView->MoveMarkedObj( aSize ); // update of control model properties (position + size) in NbcMove
+ pDlgEdView->MarkListHasChanged();
+
+ // dialog model changed
+ SetDialogModelChanged();
}
diff --git a/basctl/source/dlged/dlgedobj.cxx b/basctl/source/dlged/dlgedobj.cxx
index f635c0057505..360c5b4d2d58 100644
--- a/basctl/source/dlged/dlgedobj.cxx
+++ b/basctl/source/dlged/dlgedobj.cxx
@@ -332,23 +332,23 @@ void DlgEdObj::SetRectFromProps()
{
// get control position and size from properties
Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
- if ( xPSet.is() )
- {
- sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
- xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
- xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
- xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
- xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
+ if ( !xPSet.is() )
+ return;
- // transform coordinates
- sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
- if ( TransformControlToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
- {
- // set rectangle position and size
- Point aPoint( nXOut, nYOut );
- Size aSize( nWidthOut, nHeightOut );
- SetSnapRect( tools::Rectangle( aPoint, aSize ) );
- }
+ sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformControlToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set rectangle position and size
+ Point aPoint( nXOut, nYOut );
+ Size aSize( nWidthOut, nHeightOut );
+ SetSnapRect( tools::Rectangle( aPoint, aSize ) );
}
}
@@ -453,38 +453,38 @@ void DlgEdObj::NameChange( const css::beans::PropertyChangeEvent& evt )
OUString aNewName;
evt.NewValue >>= aNewName;
- if ( aNewName != aOldName )
+ if ( aNewName == aOldName )
+ return;
+
+ Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), UNO_QUERY);
+ if ( !(xNameAcc.is() && xNameAcc->hasByName(aOldName)) )
+ return;
+
+ if (!xNameAcc->hasByName(aNewName) && !aNewName.isEmpty())
{
- Reference< container::XNameAccess > xNameAcc((GetDlgEdForm()->GetUnoControlModel()), UNO_QUERY);
- if ( xNameAcc.is() && xNameAcc->hasByName(aOldName) )
+ // remove the control by the old name and insert the control by the new name in the container
+ Reference< container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
+ if ( xCont.is() )
{
- if (!xNameAcc->hasByName(aNewName) && !aNewName.isEmpty())
- {
- // remove the control by the old name and insert the control by the new name in the container
- Reference< container::XNameContainer > xCont(xNameAcc, UNO_QUERY );
- if ( xCont.is() )
- {
- Reference< awt::XControlModel > xCtrl = GetUnoControlModel();
- Any aAny;
- aAny <<= xCtrl;
- xCont->removeByName( aOldName );
- xCont->insertByName( aNewName , aAny );
-
- LocalizationMgr::renameControlResourceIDsForEditorObject(
- &GetDialogEditor(), aAny, aNewName
- );
- }
- }
- else
- {
- // set old name property
- EndListening(false);
- Reference< beans::XPropertySet > xPSet(GetUnoControlModel(), UNO_QUERY);
- xPSet->setPropertyValue( DLGED_PROP_NAME, Any(aOldName) );
- StartListening();
- }
+ Reference< awt::XControlModel > xCtrl = GetUnoControlModel();
+ Any aAny;
+ aAny <<= xCtrl;
+ xCont->removeByName( aOldName );
+ xCont->insertByName( aNewName , aAny );
+
+ LocalizationMgr::renameControlResourceIDsForEditorObject(
+ &GetDialogEditor(), aAny, aNewName
+ );
}
}
+ else
+ {
+ // set old name property
+ EndListening(false);
+ Reference< beans::XPropertySet > xPSet(GetUnoControlModel(), UNO_QUERY);
+ xPSet->setPropertyValue( DLGED_PROP_NAME, Any(aOldName) );
+ StartListening();
+ }
}
sal_Int32 DlgEdObj::GetStep() const
@@ -528,96 +528,96 @@ void DlgEdObj::UpdateStep()
void DlgEdObj::TabIndexChange( const beans::PropertyChangeEvent& evt )
{
DlgEdForm* pForm = GetDlgEdForm();
- if ( pForm )
+ if ( !pForm )
+ return;
+
+ // stop listening with all children
+ std::vector<DlgEdObj*> aChildList = pForm->GetChildren();
+ for (auto const& child : aChildList)
+ {
+ child->EndListening( false );
+ }
+
+ Reference< container::XNameAccess > xNameAcc( pForm->GetUnoControlModel() , UNO_QUERY );
+ if ( xNameAcc.is() )
{
- // stop listening with all children
- std::vector<DlgEdObj*> aChildList = pForm->GetChildren();
- for (auto const& child : aChildList)
+ // get sequence of control names
+ Sequence< OUString > aNames = xNameAcc->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_Int32 nCtrls = aNames.getLength();
+
+ // create a map of tab indices and control names, sorted by tab index
+ IndexToNameMap aIndexToNameMap;
+ for ( sal_Int32 i = 0; i < nCtrls; ++i )
{
- child->EndListening( false );
+ // get control name
+ OUString aName( pNames[i] );
+
+ // get tab index
+ sal_Int16 nTabIndex = -1;
+ Any aCtrl = xNameAcc->getByName( aName );
+ Reference< beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() && xPSet == Reference< beans::XPropertySet >( evt.Source, UNO_QUERY ) )
+ evt.OldValue >>= nTabIndex;
+ else if ( xPSet.is() )
+ xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
+
+ // insert into map
+ aIndexToNameMap.emplace( nTabIndex, aName );
}
- Reference< container::XNameAccess > xNameAcc( pForm->GetUnoControlModel() , UNO_QUERY );
- if ( xNameAcc.is() )
- {
- // get sequence of control names
- Sequence< OUString > aNames = xNameAcc->getElementNames();
- const OUString* pNames = aNames.getConstArray();
- sal_Int32 nCtrls = aNames.getLength();
-
- // create a map of tab indices and control names, sorted by tab index
- IndexToNameMap aIndexToNameMap;
- for ( sal_Int32 i = 0; i < nCtrls; ++i )
- {
- // get control name
- OUString aName( pNames[i] );
-
- // get tab index
- sal_Int16 nTabIndex = -1;
- Any aCtrl = xNameAcc->getByName( aName );
- Reference< beans::XPropertySet > xPSet;
- aCtrl >>= xPSet;
- if ( xPSet.is() && xPSet == Reference< beans::XPropertySet >( evt.Source, UNO_QUERY ) )
- evt.OldValue >>= nTabIndex;
- else if ( xPSet.is() )
- xPSet->getPropertyValue( DLGED_PROP_TABINDEX ) >>= nTabIndex;
-
- // insert into map
- aIndexToNameMap.emplace( nTabIndex, aName );
- }
+ // create a helper list of control names, sorted by tab index
+ std::vector< OUString > aNameList( aIndexToNameMap.size() );
+ std::transform(
+ aIndexToNameMap.begin(), aIndexToNameMap.end(),
+ aNameList.begin(),
+ ::o3tl::select2nd< IndexToNameMap::value_type >( )
+ );
+
+ // check tab index
+ sal_Int16 nOldTabIndex = 0;
+ evt.OldValue >>= nOldTabIndex;
+ sal_Int16 nNewTabIndex = 0;
+ evt.NewValue >>= nNewTabIndex;
+ if ( nNewTabIndex < 0 )
+ nNewTabIndex = 0;
+ else if ( nNewTabIndex > nCtrls - 1 )
+ nNewTabIndex = sal::static_int_cast<sal_Int16>( nCtrls - 1 );
+
+ // reorder helper list
+ OUString aCtrlName = aNameList[nOldTabIndex];
+ aNameList.erase( aNameList.begin() + nOldTabIndex );
+ aNameList.insert( aNameList.begin() + nNewTabIndex , aCtrlName );
- // create a helper list of control names, sorted by tab index
- std::vector< OUString > aNameList( aIndexToNameMap.size() );
- std::transform(
- aIndexToNameMap.begin(), aIndexToNameMap.end(),
- aNameList.begin(),
- ::o3tl::select2nd< IndexToNameMap::value_type >( )
- );
-
- // check tab index
- sal_Int16 nOldTabIndex = 0;
- evt.OldValue >>= nOldTabIndex;
- sal_Int16 nNewTabIndex = 0;
- evt.NewValue >>= nNewTabIndex;
- if ( nNewTabIndex < 0 )
- nNewTabIndex = 0;
- else if ( nNewTabIndex > nCtrls - 1 )
- nNewTabIndex = sal::static_int_cast<sal_Int16>( nCtrls - 1 );
-
- // reorder helper list
- OUString aCtrlName = aNameList[nOldTabIndex];
- aNameList.erase( aNameList.begin() + nOldTabIndex );
- aNameList.insert( aNameList.begin() + nNewTabIndex , aCtrlName );
-
- // set new tab indices
- for ( sal_Int32 i = 0; i < nCtrls; ++i )
+ // set new tab indices
+ for ( sal_Int32 i = 0; i < nCtrls; ++i )
+ {
+ Any aCtrl = xNameAcc->getByName( aNameList[i] );
+ Reference< beans::XPropertySet > xPSet;
+ aCtrl >>= xPSet;
+ if ( xPSet.is() )
{
- Any aCtrl = xNameAcc->getByName( aNameList[i] );
- Reference< beans::XPropertySet > xPSet;
- aCtrl >>= xPSet;
- if ( xPSet.is() )
+ assert(i >= SAL_MIN_INT16);
+ if (i > SAL_MAX_INT16)
{
- assert(i >= SAL_MIN_INT16);
- if (i > SAL_MAX_INT16)
- {
- SAL_WARN("basctl", "tab " << i << " > SAL_MAX_INT16");
- continue;
- }
- xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(i)) );
+ SAL_WARN("basctl", "tab " << i << " > SAL_MAX_INT16");
+ continue;
}
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, Any(static_cast<sal_Int16>(i)) );
}
+ }
- // reorder objects in drawing page
- getSdrModelFromSdrObject().GetPage(0)->SetObjectOrdNum( nOldTabIndex + 1, nNewTabIndex + 1 );
+ // reorder objects in drawing page
+ getSdrModelFromSdrObject().GetPage(0)->SetObjectOrdNum( nOldTabIndex + 1, nNewTabIndex + 1 );
- pForm->UpdateTabOrderAndGroups();
- }
+ pForm->UpdateTabOrderAndGroups();
+ }
- // start listening with all children
- for (auto const& child : aChildList)
- {
- child->StartListening();
- }
+ // start listening with all children
+ for (auto const& child : aChildList)
+ {
+ child->StartListening();
}
}
@@ -988,112 +988,112 @@ bool DlgEdObj::EndCreate(SdrDragStat& rStat, SdrCreateCmd eCmd)
void DlgEdObj::SetDefaults()
{
- if ( pDlgEdForm )
+ if ( !pDlgEdForm )
+ return;
+
+ // add child to parent form
+ pDlgEdForm->AddChild( this );
+
+ Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
+ if ( xPSet.is() )
{
- // add child to parent form
- pDlgEdForm->AddChild( this );
+ // get unique name
+ OUString aOUniqueName( GetUniqueName() );
- Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
- if ( xPSet.is() )
+ // set name property
+ xPSet->setPropertyValue( DLGED_PROP_NAME, Any(aOUniqueName) );
+
+ // set labels
+ if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) ||
+ supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
{
- // get unique name
- OUString aOUniqueName( GetUniqueName() );
-
- // set name property
- xPSet->setPropertyValue( DLGED_PROP_NAME, Any(aOUniqueName) );
-
- // set labels
- if ( supportsService( "com.sun.star.awt.UnoControlButtonModel" ) ||
- supportsService( "com.sun.star.awt.UnoControlRadioButtonModel" ) ||
- supportsService( "com.sun.star.awt.UnoControlCheckBoxModel" ) ||
- supportsService( "com.sun.star.awt.UnoControlGroupBoxModel" ) ||
- supportsService( "com.sun.star.awt.UnoControlFixedTextModel" ) )
- {
- xPSet->setPropertyValue( DLGED_PROP_LABEL, Any(aOUniqueName) );
- }
+ xPSet->setPropertyValue( DLGED_PROP_LABEL, Any(aOUniqueName) );
+ }
- // set number formats supplier for formatted field
- if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ) )
+ // set number formats supplier for formatted field
+ if ( supportsService( "com.sun.star.awt.UnoControlFormattedFieldModel" ) )
+ {
+ Reference< util::XNumberFormatsSupplier > xSupplier = GetDlgEdForm()->GetDlgEditor().GetNumberFormatsSupplier();
+ if ( xSupplier.is() )
{
- Reference< util::XNumberFormatsSupplier > xSupplier = GetDlgEdForm()->GetDlgEditor().GetNumberFormatsSupplier();
- if ( xSupplier.is() )
- {
- xPSet->setPropertyValue( DLGED_PROP_FORMATSSUPPLIER, Any(xSupplier) );
- }
+ xPSet->setPropertyValue( DLGED_PROP_FORMATSSUPPLIER, Any(xSupplier) );
}
+ }
- // set geometry properties
- SetPropsFromRect();
+ // set geometry properties
+ SetPropsFromRect();
- Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
- if ( xCont.is() )
+ Reference< container::XNameContainer > xCont( GetDlgEdForm()->GetUnoControlModel() , UNO_QUERY );
+ if ( xCont.is() )
+ {
+ // set tabindex
+ Sequence< OUString > aNames = xCont->getElementNames();
+ uno::Any aTabIndex;
+ aTabIndex <<= static_cast<sal_Int16>(aNames.getLength());
+ xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
+
+ // set step
+ Reference< beans::XPropertySet > xPSetForm( xCont, UNO_QUERY );
+ if ( xPSetForm.is() )
{
- // set tabindex
- Sequence< OUString > aNames = xCont->getElementNames();
- uno::Any aTabIndex;
- aTabIndex <<= static_cast<sal_Int16>(aNames.getLength());
- xPSet->setPropertyValue( DLGED_PROP_TABINDEX, aTabIndex );
-
- // set step
- Reference< beans::XPropertySet > xPSetForm( xCont, UNO_QUERY );
- if ( xPSetForm.is() )
- {
- Any aStep = xPSetForm->getPropertyValue( DLGED_PROP_STEP );
- xPSet->setPropertyValue( DLGED_PROP_STEP, aStep );
- }
+ Any aStep = xPSetForm->getPropertyValue( DLGED_PROP_STEP );
+ xPSet->setPropertyValue( DLGED_PROP_STEP, aStep );
+ }
- // insert control model in dialog model
- Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
- Any aAny;
- aAny <<= xCtrl;
- xCont->insertByName( aOUniqueName , aAny );
+ // insert control model in dialog model
+ Reference< awt::XControlModel > xCtrl( xPSet , UNO_QUERY );
+ Any aAny;
+ aAny <<= xCtrl;
+ xCont->insertByName( aOUniqueName , aAny );
- LocalizationMgr::setControlResourceIDsForNewEditorObject(
- &GetDialogEditor(), aAny, aOUniqueName
- );
+ LocalizationMgr::setControlResourceIDsForNewEditorObject(
+ &GetDialogEditor(), aAny, aOUniqueName
+ );
- pDlgEdForm->UpdateTabOrderAndGroups();
- }
+ pDlgEdForm->UpdateTabOrderAndGroups();
}
-
- // dialog model changed
- pDlgEdForm->GetDlgEditor().SetDialogModelChanged();
}
+
+ // dialog model changed
+ pDlgEdForm->GetDlgEditor().SetDialogModelChanged();
}
void DlgEdObj::StartListening()
{
DBG_ASSERT(!isListening(), "DlgEdObj::StartListening: already listening!");
- if (!isListening())
+ if (isListening())
+ return;
+
+ bIsListening = true;
+
+ // XPropertyChangeListener
+ Reference< XPropertySet > xControlModel( GetUnoControlModel() , UNO_QUERY );
+ if (!m_xPropertyChangeListener.is() && xControlModel.is())
{
- bIsListening = true;
+ // create listener
+ m_xPropertyChangeListener = new DlgEdPropListenerImpl(*this);
- // XPropertyChangeListener
- Reference< XPropertySet > xControlModel( GetUnoControlModel() , UNO_QUERY );
- if (!m_xPropertyChangeListener.is() && xControlModel.is())
- {
- // create listener
- m_xPropertyChangeListener = new DlgEdPropListenerImpl(*this);
+ // register listener to properties
+ xControlModel->addPropertyChangeListener( OUString() , m_xPropertyChangeListener );
+ }
- // register listener to properties
- xControlModel->addPropertyChangeListener( OUString() , m_xPropertyChangeListener );
- }
+ // XContainerListener
+ Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
+ if( !m_xContainerListener.is() && xEventsSupplier.is() )
+ {
+ // create listener
+ m_xContainerListener = new DlgEdEvtContListenerImpl(*this);
- // XContainerListener
- Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
- if( !m_xContainerListener.is() && xEventsSupplier.is() )
- {
- // create listener
- m_xContainerListener = new DlgEdEvtContListenerImpl(*this);
-
- // register listener to script event container
- Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
- DBG_ASSERT(xEventCont.is(), "DlgEdObj::StartListening: control model has no script event container!");
- Reference< XContainer > xCont( xEventCont , UNO_QUERY );
- if (xCont.is())
- xCont->addContainerListener( m_xContainerListener );
- }
+ // register listener to script event container
+ Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
+ DBG_ASSERT(xEventCont.is(), "DlgEdObj::StartListening: control model has no script event container!");
+ Reference< XContainer > xCont( xEventCont , UNO_QUERY );
+ if (xCont.is())
+ xCont->addContainerListener( m_xContainerListener );
}
}
@@ -1101,92 +1101,92 @@ void DlgEdObj::EndListening(bool bRemoveListener)
{
DBG_ASSERT(isListening(), "DlgEdObj::EndListening: not listening currently!");
- if (isListening())
- {
- bIsListening = false;
+ if (!isListening())
+ return;
- if (bRemoveListener)
- {
- // XPropertyChangeListener
- Reference< XPropertySet > xControlModel(GetUnoControlModel(), UNO_QUERY);
- if ( m_xPropertyChangeListener.is() && xControlModel.is() )
- {
- // remove listener
- xControlModel->removePropertyChangeListener( OUString() , m_xPropertyChangeListener );
- }
- m_xPropertyChangeListener.clear();
+ bIsListening = false;
- // XContainerListener
- Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
- if( m_xContainerListener.is() && xEventsSupplier.is() )
- {
- // remove listener
- Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
- DBG_ASSERT(xEventCont.is(), "DlgEdObj::EndListening: control model has no script event container!");
- Reference< XContainer > xCont( xEventCont , UNO_QUERY );
- if (xCont.is())
- xCont->removeContainerListener( m_xContainerListener );
- }
- m_xContainerListener.clear();
- }
+ if (!bRemoveListener)
+ return;
+
+ // XPropertyChangeListener
+ Reference< XPropertySet > xControlModel(GetUnoControlModel(), UNO_QUERY);
+ if ( m_xPropertyChangeListener.is() && xControlModel.is() )
+ {
+ // remove listener
+ xControlModel->removePropertyChangeListener( OUString() , m_xPropertyChangeListener );
}
+ m_xPropertyChangeListener.clear();
+
+ // XContainerListener
+ Reference< XScriptEventsSupplier > xEventsSupplier( GetUnoControlModel() , UNO_QUERY );
+ if( m_xContainerListener.is() && xEventsSupplier.is() )
+ {
+ // remove listener
+ Reference< XNameContainer > xEventCont = xEventsSupplier->getEvents();
+ DBG_ASSERT(xEventCont.is(), "DlgEdObj::EndListening: control model has no script event container!");
+ Reference< XContainer > xCont( xEventCont , UNO_QUERY );
+ if (xCont.is())
+ xCont->removeContainerListener( m_xContainerListener );
+ }
+ m_xContainerListener.clear();
}
void DlgEdObj::_propertyChange( const css::beans::PropertyChangeEvent& evt )
{
- if (isListening())
- {
- DlgEdForm* pRealDlgEdForm = dynamic_cast<DlgEdForm*>(this);
- if (!pRealDlgEdForm)
- pRealDlgEdForm = GetDlgEdForm();
- if (!pRealDlgEdForm)
- return;
- DlgEditor& rDlgEditor = pRealDlgEdForm->GetDlgEditor();
- if (rDlgEditor.isInPaint())
- return;
+ if (!isListening())
+ return;
- // dialog model changed
- rDlgEditor.SetDialogModelChanged();
+ DlgEdForm* pRealDlgEdForm = dynamic_cast<DlgEdForm*>(this);
+ if (!pRealDlgEdForm)
+ pRealDlgEdForm = GetDlgEdForm();
+ if (!pRealDlgEdForm)
+ return;
+ DlgEditor& rDlgEditor = pRealDlgEdForm->GetDlgEditor();
+ if (rDlgEditor.isInPaint())
+ return;
- // update position and size
- if ( evt.PropertyName == DLGED_PROP_POSITIONX || evt.PropertyName == DLGED_PROP_POSITIONY ||
- evt.PropertyName == DLGED_PROP_WIDTH || evt.PropertyName == DLGED_PROP_HEIGHT ||
- evt.PropertyName == DLGED_PROP_DECORATION )
- {
- PositionAndSizeChange( evt );
+ // dialog model changed
+ rDlgEditor.SetDialogModelChanged();
- if ( evt.PropertyName == DLGED_PROP_DECORATION )
- GetDialogEditor().ResetDialog();
- }
- // change name of control in dialog model
- else if ( evt.PropertyName == DLGED_PROP_NAME )
+ // update position and size
+ if ( evt.PropertyName == DLGED_PROP_POSITIONX || evt.PropertyName == DLGED_PROP_POSITIONY ||
+ evt.PropertyName == DLGED_PROP_WIDTH || evt.PropertyName == DLGED_PROP_HEIGHT ||
+ evt.PropertyName == DLGED_PROP_DECORATION )
+ {
+ PositionAndSizeChange( evt );
+
+ if ( evt.PropertyName == DLGED_PROP_DECORATION )
+ GetDialogEditor().ResetDialog();
+ }
+ // change name of control in dialog model
+ else if ( evt.PropertyName == DLGED_PROP_NAME )
+ {
+ if (!dynamic_cast<DlgEdForm*>(this))
{
- if (!dynamic_cast<DlgEdForm*>(this))
+ try
{
- try
- {
- NameChange(evt);
- }
- catch (container::NoSuchElementException const&)
- {
- css::uno::Any anyEx = cppu::getCaughtException();
- throw lang::WrappedTargetRuntimeException("", nullptr,
- anyEx);
- }
+ NameChange(evt);
+ }
+ catch (container::NoSuchElementException const&)
+ {
+ css::uno::Any anyEx = cppu::getCaughtException();
+ throw lang::WrappedTargetRuntimeException("", nullptr,
+ anyEx);
}
- }
- // update step
- else if ( evt.PropertyName == DLGED_PROP_STEP )
- {
- UpdateStep();
- }
- // change tabindex
- else if ( evt.PropertyName == DLGED_PROP_TABINDEX )
- {
- if (!dynamic_cast<DlgEdForm*>(this))
- TabIndexChange(evt);
}
}
+ // update step
+ else if ( evt.PropertyName == DLGED_PROP_STEP )
+ {
+ UpdateStep();
+ }
+ // change tabindex
+ else if ( evt.PropertyName == DLGED_PROP_TABINDEX )
+ {
+ if (!dynamic_cast<DlgEdForm*>(this))
+ TabIndexChange(evt);
+ }
}
void DlgEdObj::_elementInserted()
@@ -1245,23 +1245,23 @@ void DlgEdForm::SetRectFromProps()
{
// get form position and size from properties
Reference< beans::XPropertySet > xPSet( GetUnoControlModel(), UNO_QUERY );
- if ( xPSet.is() )
- {
- sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
- xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
- xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
- xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
- xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
+ if ( !xPSet.is() )
+ return;
- // transform coordinates
- sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
- if ( TransformFormToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
- {
- // set rectangle position and size
- Point aPoint( nXOut, nYOut );
- Size aSize( nWidthOut, nHeightOut );
- SetSnapRect( tools::Rectangle( aPoint, aSize ) );
- }
+ sal_Int32 nXIn = 0, nYIn = 0, nWidthIn = 0, nHeightIn = 0;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONX ) >>= nXIn;
+ xPSet->getPropertyValue( DLGED_PROP_POSITIONY ) >>= nYIn;
+ xPSet->getPropertyValue( DLGED_PROP_WIDTH ) >>= nWidthIn;
+ xPSet->getPropertyValue( DLGED_PROP_HEIGHT ) >>= nHeightIn;
+
+ // transform coordinates
+ sal_Int32 nXOut, nYOut, nWidthOut, nHeightOut;
+ if ( TransformFormToSdrCoordinates( nXIn, nYIn, nWidthIn, nHeightIn, nXOut, nYOut, nWidthOut, nHeightOut ) )
+ {
+ // set rectangle position and size
+ Point aPoint( nXOut, nYOut );
+ Size aSize( nWidthOut, nHeightOut );
+ SetSnapRect( tools::Rectangle( aPoint, aSize ) );
}
}
@@ -1514,56 +1514,56 @@ void DlgEdForm::UpdateGroups()
// drawing layer has to be done here.
Reference< awt::XTabControllerModel > xTabModel( GetUnoControlModel() , UNO_QUERY );
- if ( xTabModel.is() )
- {
- // create a global list of controls that belong to the dialog
- std::vector<DlgEdObj*> aChildList = GetChildren();
- sal_uInt32 nSize = aChildList.size();
- Sequence< Reference< awt::XControl > > aSeqControls( nSize );
- for ( sal_uInt32 i = 0; i < nSize; ++i )
- aSeqControls.getArray()[i] = aChildList[i]->GetControl();
-
- sal_Int32 nGroupCount = xTabModel->getGroupCount();
- for ( sal_Int32 nGroup = 0; nGroup < nGroupCount; ++nGroup )
+ if ( !xTabModel.is() )
+ return;
+
+ // create a global list of controls that belong to the dialog
+ std::vector<DlgEdObj*> aChildList = GetChildren();
+ sal_uInt32 nSize = aChildList.size();
+ Sequence< Reference< awt::XControl > > aSeqControls( nSize );
+ for ( sal_uInt32 i = 0; i < nSize; ++i )
+ aSeqControls.getArray()[i] = aChildList[i]->GetControl();
+
+ sal_Int32 nGroupCount = xTabModel->getGroupCount();
+ for ( sal_Int32 nGroup = 0; nGroup < nGroupCount; ++nGroup )
+ {
+ // get a list of control models that belong to this group
+ OUString aName;
+ Sequence< Reference< awt::XControlModel > > aSeqModels;
+ xTabModel->getGroup( nGroup, aSeqModels, aName );
+ const Reference< awt::XControlModel >* pModels = aSeqModels.getConstArray();
+ sal_Int32 nModelCount = aSeqModels.getLength();
+
+ // create a list of peers that belong to this group
+ Sequence< Reference< awt::XWindow > > aSeqPeers( nModelCount );
+ for ( sal_Int32 nModel = 0; nModel < nModelCount; ++nModel )
{
- // get a list of control models that belong to this group
- OUString aName;
- Sequence< Reference< awt::XControlModel > > aSeqModels;
- xTabModel->getGroup( nGroup, aSeqModels, aName );
- const Reference< awt::XControlModel >* pModels = aSeqModels.getConstArray();
- sal_Int32 nModelCount = aSeqModels.getLength();
-
- // create a list of peers that belong to this group
- Sequence< Reference< awt::XWindow > > aSeqPeers( nModelCount );
- for ( sal_Int32 nModel = 0; nModel < nModelCount; ++nModel )
+ // for each control model find the corresponding control in the global list
+ const Reference< awt::XControl >* pControls = aSeqControls.getConstArray();
+ sal_Int32 nControlCount = aSeqControls.getLength();
+ for ( sal_Int32 nControl = 0; nControl < nControlCount; ++nControl )
{
- // for each control model find the corresponding control in the global list
- const Reference< awt::XControl >* pControls = aSeqControls.getConstArray();
- sal_Int32 nControlCount = aSeqControls.getLength();
- for ( sal_Int32 nControl = 0; nControl < nControlCount; ++nControl )
+ const Reference< awt::XControl > xCtrl( pControls[nControl] );
+ if ( xCtrl.is() )
{
- const Reference< awt::XControl > xCtrl( pControls[nControl] );
- if ( xCtrl.is() )
+ Reference< awt::XControlModel > xCtrlModel( xCtrl->getModel() );
+ if ( xCtrlModel.get() == pModels[nModel].get() )
{
- Reference< awt::XControlModel > xCtrlModel( xCtrl->getModel() );
- if ( xCtrlModel.get() == pModels[nModel].get() )
- {
- // get the control peer and insert into the list of peers
- aSeqPeers.getArray()[ nModel ].set( xCtrl->getPeer(), UNO_QUERY );
- break;
- }
+ // get the control peer and insert into the list of peers
+ aSeqPeers.getArray()[ nModel ].set( xCtrl->getPeer(), UNO_QUERY );
+ break;
}
}
}
+ }
- // set the group at the dialog peer
- Reference< awt::XControl > xDlg = GetControl();
- if ( xDlg.is() )
- {
- Reference< awt::XVclContainerPeer > xDlgPeer( xDlg->getPeer(), UNO_QUERY );
- if ( xDlgPeer.is() )
- xDlgPeer->setGroup( aSeqPeers );
- }
+ // set the group at the dialog peer
+ Reference< awt::XControl > xDlg = GetControl();
+ if ( xDlg.is() )
+ {
+ Reference< awt::XVclContainerPeer > xDlgPeer( xDlg->getPeer(), UNO_QUERY );
+ if ( xDlgPeer.is() )
+ xDlgPeer->setGroup( aSeqPeers );
}
}
}
@@ -1680,31 +1680,31 @@ void DlgEdObj::MakeDataAware( const Reference< frame::XModel >& xModel )
Reference< lang::XMultiServiceFactory > xFac( xModel, UNO_QUERY );
Reference< form::binding::XBindableValue > xBindable( GetUnoControlModel(), UNO_QUERY );
Reference< form::binding::XListEntrySink > xListEntrySink( GetUnoControlModel(), UNO_QUERY );
- if ( xFac.is() )
- {
- css::table::CellAddress aApiAddress;
+ if ( !xFac.is() )
+ return;
- //tdf#90361 CellValueBinding and CellRangeListSource are unusable
- //without being initialized, so use createInstanceWithArguments with a
- //dummy BoundCell instead of createInstance. This at least results in
- //the dialog editor not falling.
- css::beans::NamedValue aValue;
- aValue.Name = "BoundCell";
- aValue.Value <<= aApiAddress;
+ css::table::CellAddress aApiAddress;
- Sequence< Any > aArgs( 1 );
- aArgs[ 0 ] <<= aValue;
+ //tdf#90361 CellValueBinding and CellRangeListSource are unusable
+ //without being initialized, so use createInstanceWithArguments with a
+ //dummy BoundCell instead of createInstance. This at least results in
+ //the dialog editor not falling.
+ css::beans::NamedValue aValue;
+ aValue.Name = "BoundCell";
+ aValue.Value <<= aApiAddress;
- if ( xBindable.is() )
- {
- Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs ), UNO_QUERY );
- xBindable->setValueBinding( xBinding );
- }
- if ( xListEntrySink.is() )
- {
- Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( "com.sun.star.table.CellRangeListSource", aArgs ), UNO_QUERY );
- xListEntrySink->setListEntrySource( xSource );
- }
+ Sequence< Any > aArgs( 1 );
+ aArgs[ 0 ] <<= aValue;
+
+ if ( xBindable.is() )
+ {
+ Reference< form::binding::XValueBinding > xBinding( xFac->createInstanceWithArguments( "com.sun.star.table.CellValueBinding", aArgs ), UNO_QUERY );
+ xBindable->setValueBinding( xBinding );
+ }
+ if ( xListEntrySink.is() )
+ {
+ Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( "com.sun.star.table.CellRangeListSource", aArgs ), UNO_QUERY );
+ xListEntrySink->setListEntrySource( xSource );
}
}
} // namespace basctl
diff --git a/basctl/source/dlged/dlgedview.cxx b/basctl/source/dlged/dlgedview.cxx
index 754ef71a7cc3..f9371b10bac3 100644
--- a/basctl/source/dlged/dlgedview.cxx
+++ b/basctl/source/dlged/dlgedview.cxx
@@ -63,61 +63,61 @@ void DlgEdView::MakeVisible( const tools::Rectangle& rRect, vcl::Window& rWin )
tools::Rectangle aVisRect( RectTmp );
// check, if rectangle is inside visible area
- if ( !aVisRect.IsInside( rRect ) )
- {
- // calculate scroll distance; the rectangle must be inside the visible area
- sal_Int32 nScrollX = 0, nScrollY = 0;
+ if ( aVisRect.IsInside( rRect ) )
+ return;
- sal_Int32 nVisLeft = aVisRect.Left();
- sal_Int32 nVisRight = aVisRect.Right();
- sal_Int32 nVisTop = aVisRect.Top();
- sal_Int32 nVisBottom = aVisRect.Bottom();
+ // calculate scroll distance; the rectangle must be inside the visible area
+ sal_Int32 nScrollX = 0, nScrollY = 0;
- sal_Int32 nDeltaX = rDlgEditor.GetHScroll()->GetLineSize();
- sal_Int32 nDeltaY = rDlgEditor.GetVScroll()->GetLineSize();
+ sal_Int32 nVisLeft = aVisRect.Left();
+ sal_Int32 nVisRight = aVisRect.Right();
+ sal_Int32 nVisTop = aVisRect.Top();
+ sal_Int32 nVisBottom = aVisRect.Bottom();
- while ( rRect.Right() > nVisRight + nScrollX )
- nScrollX += nDeltaX;
+ sal_Int32 nDeltaX = rDlgEditor.GetHScroll()->GetLineSize();
+ sal_Int32 nDeltaY = rDlgEditor.GetVScroll()->GetLineSize();
- while ( rRect.Left() < nVisLeft + nScrollX )
- nScrollX -= nDeltaX;
+ while ( rRect.Right() > nVisRight + nScrollX )
+ nScrollX += nDeltaX;
- while ( rRect.Bottom() > nVisBottom + nScrollY )
- nScrollY += nDeltaY;
+ while ( rRect.Left() < nVisLeft + nScrollX )
+ nScrollX -= nDeltaX;
- while ( rRect.Top() < nVisTop + nScrollY )
- nScrollY -= nDeltaY;
+ while ( rRect.Bottom() > nVisBottom + nScrollY )
+ nScrollY += nDeltaY;
- // don't scroll beyond the page size
- Size aPageSize = rDlgEditor.GetPage().GetSize();
- sal_Int32 nPageWidth = aPageSize.Width();
- sal_Int32 nPageHeight = aPageSize.Height();
+ while ( rRect.Top() < nVisTop + nScrollY )
+ nScrollY -= nDeltaY;
- if ( nVisRight + nScrollX > nPageWidth )
- nScrollX = nPageWidth - nVisRight;
+ // don't scroll beyond the page size
+ Size aPageSize = rDlgEditor.GetPage().GetSize();
+ sal_Int32 nPageWidth = aPageSize.Width();
+ sal_Int32 nPageHeight = aPageSize.Height();
- if ( nVisLeft + nScrollX < 0 )
- nScrollX = -nVisLeft;
+ if ( nVisRight + nScrollX > nPageWidth )
+ nScrollX = nPageWidth - nVisRight;
- if ( nVisBottom + nScrollY > nPageHeight )
- nScrollY = nPageHeight - nVisBottom;
+ if ( nVisLeft + nScrollX < 0 )
+ nScrollX = -nVisLeft;
- if ( nVisTop + nScrollY < 0 )
- nScrollY = -nVisTop;
+ if ( nVisBottom + nScrollY > nPageHeight )
+ nScrollY = nPageHeight - nVisBottom;
- // scroll window
- rWin.PaintImmediately();
- rWin.Scroll( -nScrollX, -nScrollY );
- aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
- rWin.SetMapMode( aMap );
- rWin.Invalidate();
+ if ( nVisTop + nScrollY < 0 )
+ nScrollY = -nVisTop;
- // update scroll bars
- rDlgEditor.UpdateScrollBars();
+ // scroll window
+ rWin.PaintImmediately();
+ rWin.Scroll( -nScrollX, -nScrollY );
+ aMap.SetOrigin( Point( aOrg.X() - nScrollX, aOrg.Y() - nScrollY ) );
+ rWin.SetMapMode( aMap );
+ rWin.Invalidate();
- DlgEdHint aHint( DlgEdHint::WINDOWSCROLLED );
- rDlgEditor.Broadcast( aHint );
- }
+ // update scroll bars
+ rDlgEditor.UpdateScrollBars();
+
+ DlgEdHint aHint( DlgEdHint::WINDOWSCROLLED );
+ rDlgEditor.Broadcast( aHint );
}
static SdrObject* impLocalHitCorrection(SdrObject* pRetval, const Point& rPnt, sal_uInt16 nTol)
diff --git a/basctl/source/dlged/managelang.cxx b/basctl/source/dlged/managelang.cxx
index 1c2e1093ad56..01ce70421b24 100644
--- a/basctl/source/dlged/managelang.cxx
+++ b/basctl/source/dlged/managelang.cxx
@@ -154,31 +154,31 @@ IMPL_LINK_NOARG(ManageLanguageDialog, DeleteHdl, weld::Button&, void)
{
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(m_xDialog.get(), "modules/BasicIDE/ui/deletelangdialog.ui"));
std::unique_ptr<weld::MessageDialog> xQBox(xBuilder->weld_message_dialog("DeleteLangDialog"));
- if (xQBox->run() == RET_OK)
+ if (xQBox->run() != RET_OK)
+ return;
+
+ std::vector<int> aSelection = m_xLanguageLB->get_selected_rows();
+ int nCount = aSelection.size();
+ int nPos = m_xLanguageLB->get_selected_index();
+ // remove locales
+ Sequence< Locale > aLocaleSeq( nCount );
+ for (int i = 0; i < nCount; ++i)
{
- std::vector<int> aSelection = m_xLanguageLB->get_selected_rows();
- int nCount = aSelection.size();
- int nPos = m_xLanguageLB->get_selected_index();
- // remove locales
- Sequence< Locale > aLocaleSeq( nCount );
- for (int i = 0; i < nCount; ++i)
- {
- const sal_Int32 nSelPos = aSelection[i];
- LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos).toInt64());
- if ( pEntry )
- aLocaleSeq[i] = pEntry->m_aLocale;
- }
- m_xLocalizationMgr->handleRemoveLocales( aLocaleSeq );
- // update listbox
- ClearLanguageBox();
- FillLanguageBox();
- // reset selection
- nCount = m_xLanguageLB->n_children();
- if (nCount <= nPos)
- nPos = nCount - 1;
- m_xLanguageLB->select(nPos);
- SelectHdl( *m_xLanguageLB );
+ const sal_Int32 nSelPos = aSelection[i];
+ LanguageEntry* pEntry = reinterpret_cast<LanguageEntry*>(m_xLanguageLB->get_id(nSelPos).toInt64());
+ if ( pEntry )
+ aLocaleSeq[i] = pEntry->m_aLocale;
}
+ m_xLocalizationMgr->handleRemoveLocales( aLocaleSeq );
+ // update listbox
+ ClearLanguageBox();
+ FillLanguageBox();
+ // reset selection
+ nCount = m_xLanguageLB->n_children();
+ if (nCount <= nPos)
+ nPos = nCount - 1;
+ m_xLanguageLB->select(nPos);
+ SelectHdl( *m_xLanguageLB );
}
IMPL_LINK_NOARG(ManageLanguageDialog, MakeDefHdl, weld::Button&, void)