LCOV - code coverage report
Current view: top level - libreoffice/basctl/source/basicide - baside2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 803 0.0 %
Date: 2012-12-17 Functions: 0 87 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "baside2.hxx"
      21             : #include "brkdlg.hxx"
      22             : #include "iderdll.hxx"
      23             : #include "iderdll2.hxx"
      24             : #include "objdlg.hxx"
      25             : #include "moduldlg.hxx"
      26             : #include "docsignature.hxx"
      27             : 
      28             : #include "helpid.hrc"
      29             : #include "baside2.hrc"
      30             : 
      31             : #include <basic/basmgr.hxx>
      32             : #include <basic/basrdll.hxx>
      33             : #include <basic/sbmeth.hxx>
      34             : #include <com/sun/star/script/ModuleType.hpp>
      35             : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      36             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      37             : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      38             : #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
      39             : #include <comphelper/processfactory.hxx>
      40             : #include <comphelper/string.hxx>
      41             : #include <sfx2/dinfdlg.hxx>
      42             : #include <sfx2/dispatch.hxx>
      43             : #include <sfx2/docfile.hxx>
      44             : #include <sfx2/printer.hxx>
      45             : #include <sfx2/request.hxx>
      46             : #include <svl/aeitem.hxx>
      47             : #include <svl/srchitem.hxx>
      48             : #include <svl/visitem.hxx>
      49             : #include <svl/whiter.hxx>
      50             : #include <vcl/xtextedt.hxx>
      51             : #include <toolkit/helper/vclunohelper.hxx>
      52             : #include <vcl/msgbox.hxx>
      53             : #include <cassert>
      54             : 
      55             : namespace basctl
      56             : {
      57             : 
      58             : namespace
      59             : {
      60             : 
      61             : namespace Print
      62             : {
      63             :     long const nLeftMargin = 1700;
      64             :     long const nRightMargin = 900;
      65             :     long const nTopMargin = 2000;
      66             :     long const nBottomMargin = 1000;
      67             :     long const nBorder = 300;
      68             : }
      69             : 
      70             : short const ValidWindow = 0x1234;
      71             : 
      72             : #if defined(OW) || defined(MTF)
      73             : char const FilterMask_All[] = "*";
      74             : #else
      75             : char const FilterMask_All[] = "*.*";
      76             : #endif
      77             : 
      78             : } // namespace
      79             : 
      80             : using namespace ::com::sun::star;
      81             : using namespace ::com::sun::star::uno;
      82             : using namespace ::com::sun::star::ui::dialogs;
      83             : using namespace utl;
      84             : using namespace comphelper;
      85             : 
      86             : 
      87             : DBG_NAME( ModulWindow )
      88             : 
      89           0 : TYPEINIT1( ModulWindow , BaseWindow );
      90             : 
      91             : namespace
      92             : {
      93             : 
      94           0 : void lcl_PrintHeader( Printer* pPrinter, sal_uInt16 nPages, sal_uInt16 nCurPage, const OUString& rTitle, bool bOutput )
      95             : {
      96           0 :     Size const aSz = pPrinter->GetOutputSize();
      97             : 
      98           0 :     const Color aOldLineColor( pPrinter->GetLineColor() );
      99           0 :     const Color aOldFillColor( pPrinter->GetFillColor() );
     100           0 :     const Font  aOldFont( pPrinter->GetFont() );
     101             : 
     102           0 :     pPrinter->SetLineColor( Color( COL_BLACK ) );
     103           0 :     pPrinter->SetFillColor();
     104             : 
     105           0 :     Font aFont( aOldFont );
     106           0 :     aFont.SetWeight( WEIGHT_BOLD );
     107           0 :     aFont.SetAlign( ALIGN_BOTTOM );
     108           0 :     pPrinter->SetFont( aFont );
     109             : 
     110           0 :     long nFontHeight = pPrinter->GetTextHeight();
     111             : 
     112             :     // 1st Border => line, 2+3 Border = free space
     113           0 :     long nYTop = Print::nTopMargin - 3*Print::nBorder - nFontHeight;
     114             : 
     115           0 :     long nXLeft = Print::nLeftMargin - Print::nBorder;
     116           0 :     long nXRight = aSz.Width() - Print::nRightMargin + Print::nBorder;
     117             : 
     118           0 :     if( bOutput )
     119             :         pPrinter->DrawRect(Rectangle(
     120             :             Point(nXLeft, nYTop),
     121           0 :             Size(nXRight - nXLeft, aSz.Height() - nYTop - Print::nBottomMargin + Print::nBorder)
     122           0 :         ));
     123             : 
     124             : 
     125           0 :     long nY = Print::nTopMargin - 2*Print::nBorder;
     126           0 :     Point aPos(Print::nLeftMargin, nY);
     127           0 :     if( bOutput )
     128           0 :         pPrinter->DrawText( aPos, rTitle );
     129           0 :     if ( nPages != 1 )
     130             :     {
     131           0 :         aFont.SetWeight( WEIGHT_NORMAL );
     132           0 :         pPrinter->SetFont( aFont );
     133           0 :         aPos.X() += pPrinter->GetTextWidth( rTitle );
     134             : 
     135           0 :         if( bOutput )
     136             :         {
     137           0 :             OUStringBuffer aPageStr;
     138           0 :             aPageStr.appendAscii( " [" );
     139           0 :             aPageStr.append(IDE_RESSTR(RID_STR_PAGE));
     140           0 :             aPageStr.append(' ');
     141           0 :             aPageStr.append( nCurPage );
     142           0 :             aPageStr.append(']');
     143           0 :             pPrinter->DrawText( aPos, aPageStr.makeStringAndClear() );
     144             :         }
     145             :     }
     146             : 
     147           0 :     nY = Print::nTopMargin - Print::nBorder;
     148             : 
     149           0 :     if( bOutput )
     150           0 :         pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
     151             : 
     152           0 :     pPrinter->SetFont( aOldFont );
     153           0 :     pPrinter->SetFillColor( aOldFillColor );
     154           0 :     pPrinter->SetLineColor( aOldLineColor );
     155           0 : }
     156             : 
     157           0 : void lcl_ConvertTabsToSpaces( String& rLine )
     158             : {
     159           0 :     if ( rLine.Len() )
     160             :     {
     161           0 :         sal_uInt16 nPos = 0;
     162           0 :         sal_uInt16 nMax = rLine.Len();
     163           0 :         while ( nPos < nMax )
     164             :         {
     165           0 :             if ( rLine.GetChar( nPos ) == '\t' )
     166             :             {
     167             :                 // not 4 Blanks, but at 4 TabPos:
     168           0 :                 rtl::OUStringBuffer aBlanker;
     169           0 :                 string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' ');
     170           0 :                 rLine.Erase( nPos, 1 );
     171           0 :                 rLine.Insert( aBlanker.makeStringAndClear(), nPos );
     172           0 :                 nMax = rLine.Len();
     173             :             }
     174           0 :             ++nPos;
     175             :         }
     176             :     }
     177           0 : }
     178             : 
     179             : // until we have some configuration lets just keep
     180             : // persist this value for the process lifetime
     181             : bool bSourceLinesEnabled = false;
     182             : 
     183             : } // namespace
     184             : 
     185             : 
     186             : //
     187             : // ModulWindow
     188             : // ===========
     189             : //
     190             : 
     191           0 : ModulWindow::ModulWindow (
     192             :     ModulWindowLayout* pParent,
     193             :     ScriptDocument const& rDocument,
     194             :     OUString aLibName, OUString aName, OUString& aModule
     195             : ) :
     196             :     BaseWindow(pParent, rDocument, aLibName, aName),
     197             :     rLayout(*pParent),
     198             :     nValid(ValidWindow),
     199             :     aXEditorWindow(this),
     200           0 :     m_aModule(aModule)
     201             : {
     202             :     DBG_CTOR( ModulWindow, 0 );
     203           0 :     aXEditorWindow.Show();
     204           0 :     SetBackground();
     205           0 : }
     206             : 
     207           0 : SbModuleRef ModulWindow::XModule()
     208             : {
     209             :     // ModuleWindows can now be created as a result of the
     210             :     // modules getting created via the api. This is a result of an
     211             :     // elementInserted event from the BasicLibrary container.
     212             :     // However the SbModule is also created from a different listener to
     213             :     // the same event ( in basmgr ) Therefore it is possible when we look
     214             :     // for xModule it may not yet be available, here we keep tring to access
     215             :     // the module until such time as it exists
     216             : 
     217           0 :     if ( !xModule.Is() )
     218             :     {
     219           0 :         BasicManager* pBasMgr = GetDocument().getBasicManager();
     220           0 :         if ( pBasMgr )
     221             :         {
     222           0 :             StarBASIC* pBasic = pBasMgr->GetLib( GetLibName() );
     223           0 :             if ( pBasic )
     224             :             {
     225           0 :                 xBasic = pBasic;
     226           0 :                 xModule = (SbModule*)pBasic->FindModule( GetName() );
     227             :             }
     228             :         }
     229             :     }
     230           0 :     return xModule;
     231             : }
     232             : 
     233           0 : ModulWindow::~ModulWindow()
     234             : {
     235             :     DBG_DTOR( ModulWindow, 0 );
     236           0 :     nValid = 0;
     237             : 
     238           0 :     StarBASIC::Stop();
     239           0 : }
     240             : 
     241             : 
     242           0 : void ModulWindow::GetFocus()
     243             : {
     244           0 :     if (nValid != ValidWindow)
     245           0 :         return;
     246             :     DBG_CHKTHIS( ModulWindow, 0 );
     247           0 :     aXEditorWindow.GetEdtWindow().GrabFocus();
     248             :     // don't call basic calls because focus is somewhere else...
     249             : }
     250             : 
     251           0 : void ModulWindow::DoInit()
     252             : {
     253             :     DBG_CHKTHIS( ModulWindow, 0 );
     254             : 
     255           0 :     if ( GetVScrollBar() )
     256           0 :         GetVScrollBar()->Hide();
     257           0 :     GetHScrollBar()->Show();
     258           0 :     GetEditorWindow().InitScrollBars();
     259           0 : }
     260             : 
     261             : 
     262           0 : void ModulWindow::Paint( const Rectangle& )
     263             : {
     264           0 : }
     265             : 
     266           0 : void ModulWindow::Resize()
     267             : {
     268             :     aXEditorWindow.SetPosSizePixel( Point( 0, 0 ),
     269           0 :                                     Size( GetOutputSizePixel() ) );
     270           0 : }
     271             : 
     272             : 
     273           0 : void ModulWindow::CheckCompileBasic()
     274             : {
     275             :     DBG_CHKTHIS( ModulWindow, 0 );
     276             : 
     277           0 :     if ( XModule().Is() )
     278             :     {
     279             :         // never compile while running!
     280           0 :         bool const bRunning = StarBASIC::IsRunning();
     281           0 :         bool const bModified = ( !xModule->IsCompiled() ||
     282           0 :             ( GetEditEngine() && GetEditEngine()->IsModified() ) );
     283             : 
     284           0 :         if ( !bRunning && bModified )
     285             :         {
     286           0 :             bool bDone = false;
     287             : 
     288           0 :             GetShell()->GetViewFrame()->GetWindow().EnterWait();
     289             : 
     290           0 :             if( bModified )
     291             :             {
     292           0 :                 AssertValidEditEngine();
     293           0 :                 GetEditorWindow().SetSourceInBasic();
     294             :             }
     295             : 
     296           0 :             bool bWasModified = GetBasic()->IsModified();
     297             : 
     298           0 :             bDone = GetBasic()->Compile( xModule );
     299           0 :             if ( !bWasModified )
     300           0 :                 GetBasic()->SetModified(false);
     301             : 
     302           0 :             if ( bDone )
     303             :             {
     304           0 :                 GetBreakPoints().SetBreakPointsInBasic( xModule );
     305             :             }
     306             : 
     307           0 :             GetShell()->GetViewFrame()->GetWindow().LeaveWait();
     308             : 
     309           0 :             aStatus.bError = !bDone;
     310           0 :             aStatus.bIsRunning = false;
     311             :         }
     312             :     }
     313           0 : }
     314             : 
     315           0 : bool ModulWindow::BasicExecute()
     316             : {
     317             :     DBG_CHKTHIS( ModulWindow, 0 );
     318             : 
     319             :     // #116444# check security settings before macro execution
     320           0 :     ScriptDocument aDocument( GetDocument() );
     321           0 :     if ( aDocument.isDocument() )
     322             :     {
     323           0 :         if ( !aDocument.allowMacros() )
     324             :         {
     325           0 :             WarningBox( this, WB_OK, IDE_RESSTR(RID_STR_CANNOTRUNMACRO)).Execute();
     326           0 :             return false;
     327             :         }
     328             :     }
     329             : 
     330           0 :     CheckCompileBasic();
     331             : 
     332           0 :     if ( XModule().Is() && xModule->IsCompiled() && !aStatus.bError )
     333             :     {
     334           0 :         if ( GetBreakPoints().size() )
     335           0 :             aStatus.nBasicFlags = aStatus.nBasicFlags | SbDEBUG_BREAK;
     336             : 
     337           0 :         if ( !aStatus.bIsRunning )
     338             :         {
     339             :             DBG_ASSERT( xModule.Is(), "Kein Modul!" );
     340           0 :             AddStatus( BASWIN_RUNNINGBASIC );
     341           0 :             sal_uInt16 nStart, nEnd, nCurMethodStart = 0;
     342           0 :             TextSelection aSel = GetEditView()->GetSelection();
     343             :             // Init cursor to top
     344           0 :             nCurMethodStart = ( aSel.GetStart().GetPara() + 1 );
     345           0 :             SbMethod* pMethod = 0;
     346             :             // first Macro, else blind "Main" (ExtSearch?)
     347           0 :             for ( sal_uInt16 nMacro = 0; nMacro < xModule->GetMethods()->Count(); nMacro++ )
     348             :             {
     349           0 :                 SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro );
     350             :                 DBG_ASSERT( pM, "Method?" );
     351           0 :                 pM->GetLineRange( nStart, nEnd );
     352           0 :                 if (  nCurMethodStart >= nStart && nCurMethodStart <= nEnd )
     353             :                 {
     354             :                     // matched a method to the cursor position
     355           0 :                     pMethod = pM;
     356           0 :                     break;
     357             :                 }
     358             :             }
     359           0 :             if ( !pMethod )
     360             :             {
     361             :                 // If not in a method then prompt the user
     362           0 :                 return ( !ChooseMacro( uno::Reference< frame::XModel >(), false, OUString() ).isEmpty() );
     363             :             }
     364           0 :             if ( pMethod )
     365             :             {
     366           0 :                 pMethod->SetDebugFlags( aStatus.nBasicFlags );
     367           0 :                 BasicDLL::SetDebugMode( true );
     368           0 :                 RunMethod( pMethod );
     369           0 :                 BasicDLL::SetDebugMode( false );
     370             :                 // if cancelled during Interactive=false
     371           0 :                 BasicDLL::EnableBreak( true );
     372             :             }
     373           0 :             ClearStatus( BASWIN_RUNNINGBASIC );
     374             :         }
     375             :         else
     376           0 :             aStatus.bIsRunning = false; // cancel of Reschedule()
     377             :     }
     378             : 
     379           0 :     bool bDone = !aStatus.bError;
     380             : 
     381           0 :     return bDone;
     382             : }
     383             : 
     384           0 : bool ModulWindow::CompileBasic()
     385             : {
     386             :     DBG_CHKTHIS( ModulWindow, 0 );
     387           0 :     CheckCompileBasic();
     388             : 
     389           0 :     return XModule().Is() && xModule->IsCompiled();
     390             : }
     391             : 
     392           0 : bool ModulWindow::BasicRun()
     393             : {
     394             :     DBG_CHKTHIS( ModulWindow, 0 );
     395             : 
     396           0 :     aStatus.nBasicFlags = 0;
     397           0 :     return BasicExecute();
     398             : }
     399             : 
     400           0 : bool ModulWindow::BasicStepOver()
     401             : {
     402             :     DBG_CHKTHIS( ModulWindow, 0 );
     403           0 :     aStatus.nBasicFlags = SbDEBUG_STEPINTO | SbDEBUG_STEPOVER;
     404           0 :     return BasicExecute();
     405             : }
     406             : 
     407             : 
     408           0 : bool ModulWindow::BasicStepInto()
     409             : {
     410             :     DBG_CHKTHIS( ModulWindow, 0 );
     411             : 
     412           0 :     aStatus.nBasicFlags = SbDEBUG_STEPINTO;
     413           0 :     return BasicExecute();
     414             : }
     415             : 
     416           0 : bool ModulWindow::BasicStepOut()
     417             : {
     418             :     DBG_CHKTHIS( ModulWindow, 0 );
     419             : 
     420           0 :     aStatus.nBasicFlags = SbDEBUG_STEPOUT;
     421           0 :     return BasicExecute();
     422             : }
     423             : 
     424             : 
     425             : 
     426           0 : void ModulWindow::BasicStop()
     427             : {
     428             :     DBG_CHKTHIS( ModulWindow, 0 );
     429             : 
     430           0 :     GetBasic()->Stop();
     431           0 :     aStatus.bIsRunning = false;
     432           0 : }
     433             : 
     434           0 : bool ModulWindow::LoadBasic()
     435             : {
     436             :     DBG_CHKTHIS( ModulWindow, 0 );
     437           0 :     bool bDone = false;
     438             : 
     439           0 :     Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
     440           0 :     Reference < XFilePicker > xFP;
     441           0 :     if( xMSF.is() )
     442             :     {
     443           0 :         Sequence <Any> aServiceType(1);
     444           0 :         aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
     445           0 :         xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
     446           0 :             "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY );
     447             :     }
     448             : 
     449           0 :     if ( !aCurPath.isEmpty() )
     450           0 :         xFP->setDisplayDirectory ( aCurPath );
     451             : 
     452           0 :     Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
     453           0 :     xFltMgr->appendFilter( "BASIC" , "*.bas" );
     454           0 :     xFltMgr->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), OUString( FilterMask_All ) );
     455           0 :     xFltMgr->setCurrentFilter( "BASIC" );
     456             : 
     457           0 :     if( xFP->execute() == RET_OK )
     458             :     {
     459           0 :         Sequence< OUString > aPaths = xFP->getFiles();
     460           0 :         aCurPath = aPaths[0];
     461           0 :         SfxMedium aMedium( aCurPath, STREAM_READ | STREAM_SHARE_DENYWRITE | STREAM_NOCREATE );
     462           0 :         SvStream* pStream = aMedium.GetInStream();
     463           0 :         if ( pStream )
     464             :         {
     465           0 :             AssertValidEditEngine();
     466           0 :             sal_uLong nLines = CalcLineCount( *pStream );
     467             :             // nLines*4: ReadText/Formatting/Highlighting/Formatting
     468           0 :             GetEditorWindow().CreateProgress( String( IDEResId( RID_STR_GENERATESOURCE ) ), nLines*4 );
     469           0 :             GetEditEngine()->SetUpdateMode( false );
     470           0 :             GetEditView()->Read( *pStream );
     471           0 :             GetEditEngine()->SetUpdateMode( true );
     472           0 :             GetEditorWindow().Update();
     473           0 :             GetEditorWindow().ForceSyntaxTimeout();
     474           0 :             GetEditorWindow().DestroyProgress();
     475           0 :             sal_uLong nError = aMedium.GetError();
     476           0 :             if ( nError )
     477           0 :                 ErrorHandler::HandleError( nError );
     478             :             else
     479           0 :                 bDone = true;
     480             :         }
     481             :         else
     482           0 :             ErrorBox( this, WB_OK | WB_DEF_OK, IDE_RESSTR(RID_STR_COULDNTREAD) ).Execute();
     483             :     }
     484           0 :     return bDone;
     485             : }
     486             : 
     487             : 
     488           0 : bool ModulWindow::SaveBasicSource()
     489             : {
     490             :     DBG_CHKTHIS( ModulWindow, 0 );
     491           0 :     bool bDone = false;
     492             : 
     493           0 :     Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
     494           0 :     Reference < XFilePicker > xFP;
     495           0 :     if( xMSF.is() )
     496             :     {
     497           0 :         Sequence <Any> aServiceType(1);
     498           0 :         aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
     499           0 :         xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
     500           0 :                     "com.sun.star.ui.dialogs.FilePicker", aServiceType ), UNO_QUERY );
     501             :     }
     502             : 
     503           0 :     Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
     504           0 :     xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, false);
     505           0 :     Any aValue;
     506           0 :     aValue <<= sal_True;
     507           0 :     xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
     508             : 
     509           0 :     if ( !aCurPath.isEmpty() )
     510           0 :         xFP->setDisplayDirectory ( aCurPath );
     511             : 
     512           0 :     Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
     513           0 :     xFltMgr->appendFilter( "BASIC", "*.bas" );
     514           0 :     xFltMgr->appendFilter( IDE_RESSTR(RID_STR_FILTER_ALLFILES), OUString( FilterMask_All ) );
     515           0 :     xFltMgr->setCurrentFilter( "BASIC" );
     516             : 
     517           0 :     if( xFP->execute() == RET_OK )
     518             :     {
     519           0 :         Sequence< OUString > aPaths = xFP->getFiles();
     520           0 :         aCurPath = aPaths[0];
     521           0 :         SfxMedium aMedium( aCurPath, STREAM_WRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC );
     522           0 :         SvStream* pStream = aMedium.GetOutStream();
     523           0 :         if ( pStream )
     524             :         {
     525           0 :             EnterWait();
     526           0 :             AssertValidEditEngine();
     527           0 :             GetEditEngine()->Write( *pStream );
     528           0 :             aMedium.Commit();
     529           0 :             LeaveWait();
     530           0 :             sal_uLong nError = aMedium.GetError();
     531           0 :             if ( nError )
     532           0 :                 ErrorHandler::HandleError( nError );
     533             :             else
     534           0 :                 bDone = true;
     535             :         }
     536             :         else
     537           0 :             ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_COULDNTWRITE) ) ).Execute();
     538             :     }
     539             : 
     540           0 :     return bDone;
     541             : }
     542             : 
     543             : extern bool implImportDialog( Window* pWin, const OUString& rCurPath, const ScriptDocument& rDocument, const OUString& aLibName ); // defined in baside3.cxx
     544             : 
     545           0 : bool ModulWindow::ImportDialog()
     546             : {
     547           0 :     const ScriptDocument& rDocument = GetDocument();
     548           0 :     OUString aLibName = GetLibName();
     549           0 :     return implImportDialog( this, aCurPath, rDocument, aLibName );
     550             : }
     551             : 
     552           0 : bool ModulWindow::ToggleBreakPoint( sal_uLong nLine )
     553             : {
     554             :     DBG_ASSERT( XModule().Is(), "Kein Modul!" );
     555             : 
     556           0 :     bool bNewBreakPoint = false;
     557             : 
     558           0 :     if ( XModule().Is() )
     559             :     {
     560           0 :         CheckCompileBasic();
     561           0 :         if ( aStatus.bError )
     562             :         {
     563           0 :             return false;
     564             :         }
     565             : 
     566           0 :         BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine );
     567           0 :         if ( pBrk ) // remove
     568             :         {
     569           0 :             xModule->ClearBP( (sal_uInt16)nLine );
     570           0 :             delete GetBreakPoints().remove( pBrk );
     571             :         }
     572             :         else // create one
     573             :         {
     574           0 :             if ( xModule->SetBP( (sal_uInt16)nLine) )
     575             :             {
     576           0 :                 GetBreakPoints().InsertSorted( new BreakPoint( nLine ) );
     577           0 :                 bNewBreakPoint = true;
     578           0 :                 if ( StarBASIC::IsRunning() )
     579             :                 {
     580           0 :                     for ( sal_uInt16 nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ )
     581             :                     {
     582           0 :                         SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod );
     583             :                         DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
     584           0 :                         pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
     585             :                     }
     586             :                 }
     587             :             }
     588             :         }
     589             :     }
     590             : 
     591           0 :     return bNewBreakPoint;
     592             : }
     593             : 
     594           0 : void ModulWindow::UpdateBreakPoint( const BreakPoint& rBrk )
     595             : {
     596             :     DBG_ASSERT( XModule().Is(), "Kein Modul!" );
     597             : 
     598           0 :     if ( XModule().Is() )
     599             :     {
     600           0 :         CheckCompileBasic();
     601             : 
     602           0 :         if ( rBrk.bEnabled )
     603           0 :             xModule->SetBP( (sal_uInt16)rBrk.nLine );
     604             :         else
     605           0 :             xModule->ClearBP( (sal_uInt16)rBrk.nLine );
     606             :     }
     607           0 : }
     608             : 
     609             : 
     610           0 : bool ModulWindow::BasicToggleBreakPoint()
     611             : {
     612             :     DBG_CHKTHIS( ModulWindow, 0 );
     613           0 :     AssertValidEditEngine();
     614             : 
     615           0 :     TextSelection aSel = GetEditView()->GetSelection();
     616           0 :     aSel.GetStart().GetPara()++;    // Basic lines start at 1!
     617           0 :     aSel.GetEnd().GetPara()++;
     618             : 
     619           0 :     bool bNewBreakPoint = false;
     620             : 
     621           0 :     for ( sal_uLong nLine = aSel.GetStart().GetPara(); nLine <= aSel.GetEnd().GetPara(); nLine++ )
     622             :     {
     623           0 :         if ( ToggleBreakPoint( nLine ) )
     624           0 :             bNewBreakPoint = true;
     625             :     }
     626             : 
     627           0 :     aXEditorWindow.GetBrkWindow().Invalidate();
     628           0 :     return bNewBreakPoint;
     629             : }
     630             : 
     631             : 
     632           0 : void ModulWindow::BasicToggleBreakPointEnabled()
     633             : {
     634             :     DBG_CHKTHIS( ModulWindow, 0 );
     635           0 :     AssertValidEditEngine();
     636             : 
     637           0 :     ExtTextView* pView = GetEditView();
     638           0 :     if ( pView )
     639             :     {
     640           0 :         TextSelection aSel = pView->GetSelection();
     641           0 :         BreakPointList& rList = GetBreakPoints();
     642             : 
     643           0 :         for ( sal_uLong nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine )
     644             :         {
     645           0 :             BreakPoint* pBrk = rList.FindBreakPoint( nLine );
     646           0 :             if ( pBrk )
     647             :             {
     648           0 :                 pBrk->bEnabled = !pBrk->bEnabled;
     649           0 :                 UpdateBreakPoint( *pBrk );
     650             :             }
     651             :         }
     652             : 
     653           0 :         GetBreakPointWindow().Invalidate();
     654             :     }
     655           0 : }
     656             : 
     657             : 
     658           0 : void ModulWindow::ManageBreakPoints()
     659             : {
     660           0 :     BreakPointWindow& rBrkWin = GetBreakPointWindow();
     661           0 :     BreakPointDialog aBrkDlg( &rBrkWin, GetBreakPoints() );
     662           0 :     aBrkDlg.Execute();
     663           0 :     rBrkWin.Invalidate();
     664           0 : }
     665             : 
     666             : 
     667           0 : long ModulWindow::BasicErrorHdl( StarBASIC * pBasic )
     668             : {
     669             :     DBG_CHKTHIS( ModulWindow, 0 );
     670           0 :     GoOnTop();
     671             : 
     672             :     // ReturnWert: BOOL
     673             :     //  FALSE:  cancel
     674             :     //  TRUE:   go on....
     675           0 :     OUString aErrorText( pBasic->GetErrorText() );
     676           0 :     sal_uInt16 nErrorLine = pBasic->GetLine() - 1;
     677           0 :     sal_uInt16 nErrCol1 = pBasic->GetCol1();
     678           0 :     sal_uInt16 nErrCol2 = pBasic->GetCol2();
     679           0 :     if ( nErrCol2 != 0xFFFF )
     680           0 :         nErrCol2++;
     681             : 
     682           0 :     AssertValidEditEngine();
     683           0 :     GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, nErrCol1 ), TextPaM( nErrorLine, nErrCol2 ) ) );
     684             : 
     685           0 :     OUStringBuffer aErrorTextPrefixBuf;
     686           0 :     if( pBasic->IsCompilerError() )
     687           0 :         aErrorTextPrefixBuf.append(IDE_RESSTR(RID_STR_COMPILEERROR));
     688             :     else
     689             :     {
     690           0 :         aErrorTextPrefixBuf.append(IDE_RESSTR(RID_STR_RUNTIMEERROR));
     691           0 :         aErrorTextPrefixBuf.append(StarBASIC::GetVBErrorCode(pBasic->GetErrorCode()));
     692           0 :         aErrorTextPrefixBuf.append(' ');
     693           0 :         rLayout.UpdateDebug(false);
     694             :     }
     695           0 :     OUString aErrorTextPrefix(aErrorTextPrefixBuf.makeStringAndClear());
     696             :     // if other basic, the IDE should try to display the correct module
     697           0 :     bool const bMarkError = pBasic == GetBasic();
     698           0 :     if ( bMarkError )
     699           0 :         aXEditorWindow.GetBrkWindow().SetMarkerPos(nErrorLine, true);
     700             : 
     701             :     // #i47002#
     702           0 :     Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( this );
     703             : 
     704           0 :     ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
     705             : 
     706             :     // #i47002#
     707           0 :     Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
     708           0 :     if ( !pWindow )
     709           0 :         return false;
     710             : 
     711           0 :     if ( bMarkError )
     712           0 :         aXEditorWindow.GetBrkWindow().SetNoMarker();
     713           0 :     return false;
     714             : }
     715             : 
     716           0 : long ModulWindow::BasicBreakHdl( StarBASIC* pBasic )
     717             : {
     718             :     DBG_CHKTHIS( ModulWindow, 0 );
     719             : 
     720             :     // #i69280 Required in Window despite normal usage in next command!
     721             :     (void)pBasic;
     722             : 
     723             :     // Return value: sal_uInt16 => see SB-Debug-Flags
     724           0 :     sal_uInt16 nErrorLine = pBasic->GetLine();
     725             : 
     726             : 
     727           0 :     BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nErrorLine );
     728           0 :     if ( pBrk )
     729             :     {
     730           0 :         pBrk->nHitCount++;
     731           0 :         if ( pBrk->nHitCount <= pBrk->nStopAfter && GetBasic()->IsBreak() )
     732           0 :             return aStatus.nBasicFlags; // go on...
     733             :     }
     734             : 
     735           0 :     nErrorLine--;   // EditEngine starts at 0, Basic at 1
     736             : 
     737           0 :     AssertValidEditEngine();
     738           0 :     GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, 0 ), TextPaM( nErrorLine, 0 ) ) );
     739           0 :     aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine );
     740             : 
     741           0 :     rLayout.UpdateDebug(false);
     742             : 
     743           0 :     aStatus.bIsInReschedule = true;
     744           0 :     aStatus.bIsRunning = true;
     745             : 
     746           0 :     AddStatus( BASWIN_INRESCHEDULE );
     747             : 
     748           0 :     InvalidateDebuggerSlots();
     749             : 
     750           0 :     while( aStatus.bIsRunning )
     751           0 :         Application::Yield();
     752             : 
     753           0 :     aStatus.bIsInReschedule = false;
     754           0 :     aXEditorWindow.GetBrkWindow().SetNoMarker();
     755             : 
     756           0 :     ClearStatus( BASWIN_INRESCHEDULE );
     757             : 
     758           0 :     return aStatus.nBasicFlags;
     759             : }
     760             : 
     761           0 : void ModulWindow::BasicAddWatch()
     762             : {
     763             :     DBG_CHKTHIS( ModulWindow, 0 );
     764           0 :     String aWatchStr;
     765           0 :     AssertValidEditEngine();
     766           0 :     bool bAdd = true;
     767           0 :     if ( !GetEditView()->HasSelection() )
     768             :     {
     769           0 :         TextPaM aWordStart;
     770           0 :         OUString aWord = GetEditEngine()->GetWord( GetEditView()->GetSelection().GetEnd(), &aWordStart );
     771           0 :         if ( !aWord.isEmpty() )
     772             :         {
     773           0 :             TextSelection aSel( aWordStart );
     774           0 :             sal_uInt16& rIndex = aSel.GetEnd().GetIndex();
     775           0 :             rIndex = rIndex + aWord.getLength();
     776           0 :             GetEditView()->SetSelection( aSel );
     777           0 :             bAdd = true;
     778           0 :         }
     779             :     }
     780           0 :     if ( bAdd )
     781             :     {
     782           0 :         TextSelection aSel = GetEditView()->GetSelection();
     783           0 :         if ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() ) // single line selection
     784           0 :             rLayout.BasicAddWatch(GetEditView()->GetSelected());
     785           0 :     }
     786           0 : }
     787             : 
     788             : 
     789             : 
     790           0 : void ModulWindow::EditMacro( const String& rMacroName )
     791             : {
     792             :     DBG_CHKTHIS( ModulWindow, 0 );
     793             :     DBG_ASSERT( XModule().Is(), "Kein Modul!" );
     794             : 
     795           0 :     if ( XModule().Is() )
     796             :     {
     797           0 :         CheckCompileBasic();
     798             : 
     799           0 :         if ( !aStatus.bError )
     800             :         {
     801             :             sal_uInt16 nStart, nEnd;
     802           0 :             SbMethod* pMethod = (SbMethod*)xModule->Find( rMacroName, SbxCLASS_METHOD );
     803           0 :             if ( pMethod )
     804             :             {
     805           0 :                 pMethod->GetLineRange( nStart, nEnd );
     806           0 :                 if ( nStart )
     807             :                 {
     808           0 :                     nStart--;
     809           0 :                     nEnd--;
     810             :                 }
     811           0 :                 TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) );
     812           0 :                 AssertValidEditEngine();
     813           0 :                 TextView * pView = GetEditView();
     814             :                 // scroll if applicabel so that first line is at the top
     815           0 :                 long nVisHeight = GetOutputSizePixel().Height();
     816           0 :                 if ( (long)pView->GetTextEngine()->GetTextHeight() > nVisHeight )
     817             :                 {
     818           0 :                     long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight;
     819           0 :                     long nOldStartY = pView->GetStartDocPos().Y();
     820           0 :                     long nNewStartY = nStart * pView->GetTextEngine()->GetCharHeight();
     821           0 :                     nNewStartY = Min( nNewStartY, nMaxY );
     822           0 :                     pView->Scroll( 0, -(nNewStartY-nOldStartY) );
     823           0 :                     pView->ShowCursor( false, true );
     824           0 :                     GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() );
     825             :                 }
     826           0 :                 pView->SetSelection( aSel );
     827           0 :                 pView->ShowCursor();
     828           0 :                 pView->GetWindow()->GrabFocus();
     829             :             }
     830             :         }
     831             :     }
     832           0 : }
     833             : 
     834             : 
     835           0 : void ModulWindow::StoreData()
     836             : {
     837             :     DBG_CHKTHIS( ModulWindow, 0 );
     838             :     // StoreData is called when the BasicManager is destroyed or
     839             :     // this window is closed.
     840             :     // => interrupts undesired!
     841           0 :     GetEditorWindow().SetSourceInBasic();
     842           0 : }
     843             : 
     844           0 : bool ModulWindow::CanClose()
     845             : {
     846             :     DBG_CHKTHIS( ModulWindow, 0 );
     847           0 :     return true;
     848             : }
     849             : 
     850             : 
     851           0 : bool ModulWindow::AllowUndo()
     852             : {
     853           0 :     return GetEditorWindow().CanModify();
     854             : }
     855             : 
     856             : 
     857           0 : void ModulWindow::UpdateData()
     858             : {
     859             :     DBG_CHKTHIS( ModulWindow, 0 );
     860             :     DBG_ASSERT( XModule().Is(), "Kein Modul!" );
     861             :     // UpdateData is called when the source has changed from outside
     862             :     // => interrupts undesired!
     863             : 
     864           0 :     if ( XModule().Is() )
     865             :     {
     866           0 :         SetModule( xModule->GetSource32() );
     867             : 
     868           0 :         if ( GetEditView() )
     869             :         {
     870           0 :             TextSelection aSel = GetEditView()->GetSelection();
     871           0 :             setTextEngineText(*GetEditEngine(), xModule->GetSource32());
     872           0 :             GetEditView()->SetSelection( aSel );
     873           0 :             GetEditEngine()->SetModified( false );
     874           0 :             MarkDocumentModified( GetDocument() );
     875             :         }
     876             :     }
     877           0 : }
     878             : 
     879           0 : sal_Int32 ModulWindow::countPages( Printer* pPrinter )
     880             : {
     881           0 :     return FormatAndPrint( pPrinter, -1 );
     882             : }
     883             : 
     884           0 : void ModulWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
     885             : {
     886           0 :     FormatAndPrint( pPrinter, nPage );
     887           0 : }
     888             : 
     889             : /* implementation note: this is totally inefficient for the XRenderable interface
     890             :    usage since the whole "document" will be format for every page. Should this ever
     891             :    become a problem we should
     892             :    - format only once for every new printer
     893             :    - keep an index list for each page which is the starting paragraph
     894             : */
     895           0 : sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
     896             : {
     897             :     DBG_CHKTHIS( ModulWindow, 0 );
     898             : 
     899           0 :     AssertValidEditEngine();
     900             : 
     901           0 :     MapMode eOldMapMode( pPrinter->GetMapMode() );
     902           0 :     Font aOldFont( pPrinter->GetFont() );
     903             : 
     904           0 :     Font aFont( GetEditEngine()->GetFont() );
     905           0 :     aFont.SetAlign( ALIGN_BOTTOM );
     906           0 :     aFont.SetTransparent( true );
     907           0 :     aFont.SetSize( Size( 0, 360 ) );
     908           0 :     pPrinter->SetFont( aFont );
     909           0 :     pPrinter->SetMapMode( MAP_100TH_MM );
     910             : 
     911           0 :     String aTitle( CreateQualifiedName() );
     912             : 
     913           0 :     sal_uInt16 nLineHeight = (sal_uInt16) pPrinter->GetTextHeight(); // etwas mehr.
     914           0 :     sal_uInt16 nParaSpace = 10;
     915             : 
     916           0 :     Size aPaperSz = pPrinter->GetOutputSize();
     917           0 :     aPaperSz.Width() -= (Print::nLeftMargin + Print::nRightMargin);
     918           0 :     aPaperSz.Height() -= (Print::nTopMargin + Print::nBottomMargin);
     919             : 
     920             :     // nLinepPage is not correct if there's a line break
     921           0 :     sal_uInt16 nLinespPage = (sal_uInt16) (aPaperSz.Height()/nLineHeight);
     922           0 :     sal_uInt16 nCharspLine = (sal_uInt16) (aPaperSz.Width() / pPrinter->GetTextWidth( 'X' ) );
     923           0 :     sal_uLong nParas = GetEditEngine()->GetParagraphCount();
     924             : 
     925           0 :     sal_uInt16 nPages = (sal_uInt16) (nParas/nLinespPage+1 );
     926           0 :     sal_uInt16 nCurPage = 1;
     927             : 
     928           0 :     lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 );
     929           0 :     Point aPos( Print::nLeftMargin, Print::nTopMargin );
     930           0 :     for ( sal_uLong nPara = 0; nPara < nParas; nPara++ )
     931             :     {
     932           0 :         String aLine( GetEditEngine()->GetText( nPara ) );
     933           0 :         lcl_ConvertTabsToSpaces( aLine );
     934           0 :         sal_uInt16 nLines = aLine.Len()/nCharspLine+1;
     935           0 :         for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ )
     936             :         {
     937           0 :             String aTmpLine( aLine, nLine*nCharspLine, nCharspLine );
     938           0 :             aPos.Y() += nLineHeight;
     939           0 :             if ( aPos.Y() > ( aPaperSz.Height() + Print::nTopMargin ) )
     940             :             {
     941           0 :                 nCurPage++;
     942           0 :                 lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nCurPage-1 == nPrintPage );
     943           0 :                 aPos = Point(Print::nLeftMargin, Print::nTopMargin + nLineHeight);
     944             :             }
     945           0 :             if( nCurPage-1 == nPrintPage )
     946           0 :                 pPrinter->DrawText( aPos, aTmpLine );
     947           0 :         }
     948           0 :         aPos.Y() += nParaSpace;
     949           0 :     }
     950             : 
     951           0 :     pPrinter->SetFont( aOldFont );
     952           0 :     pPrinter->SetMapMode( eOldMapMode );
     953             : 
     954           0 :     return sal_Int32(nCurPage);
     955             : }
     956             : 
     957             : 
     958           0 : void ModulWindow::ExecuteCommand (SfxRequest& rReq)
     959             : {
     960             :     DBG_CHKTHIS( ModulWindow, 0 );
     961           0 :     AssertValidEditEngine();
     962           0 :     switch (rReq.GetSlot())
     963             :     {
     964             :         case SID_DELETE:
     965             :         {
     966           0 :             KeyEvent aFakeDelete( 0, KEY_DELETE );
     967           0 :             GetEditView()->KeyInput( aFakeDelete );
     968             :             break;
     969             :         }
     970             :         case SID_SELECTALL:
     971           0 :             GetEditView()->SetSelection( TextSelection( TextPaM( 0, 0 ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
     972           0 :             break;
     973             :         case SID_BASICRUN:
     974             :         {
     975           0 :             BasicRun();
     976             :         }
     977           0 :         break;
     978             :         case SID_BASICCOMPILE:
     979             :         {
     980           0 :             CompileBasic();
     981             :         }
     982           0 :         break;
     983             :         case SID_BASICSTEPOVER:
     984             :         {
     985           0 :             BasicStepOver();
     986             :         }
     987           0 :         break;
     988             :         case SID_BASICSTEPINTO:
     989             :         {
     990           0 :             BasicStepInto();
     991             :         }
     992           0 :         break;
     993             :         case SID_BASICSTEPOUT:
     994             :         {
     995           0 :             BasicStepOut();
     996             :         }
     997           0 :         break;
     998             :         case SID_BASICLOAD:
     999             :         {
    1000           0 :             LoadBasic();
    1001             :         }
    1002           0 :         break;
    1003             :         case SID_BASICSAVEAS:
    1004             :         {
    1005           0 :             SaveBasicSource();
    1006             :         }
    1007           0 :         break;
    1008             :         case SID_IMPORT_DIALOG:
    1009             :         {
    1010           0 :             ImportDialog();
    1011             :         }
    1012           0 :         break;
    1013             :         case SID_BASICIDE_MATCHGROUP:
    1014             :         {
    1015           0 :             GetEditView()->MatchGroup();
    1016             :         }
    1017           0 :         break;
    1018             :         case SID_BASICIDE_TOGGLEBRKPNT:
    1019             :         {
    1020           0 :             BasicToggleBreakPoint();
    1021             :         }
    1022           0 :         break;
    1023             :         case SID_BASICIDE_MANAGEBRKPNTS:
    1024             :         {
    1025           0 :             ManageBreakPoints();
    1026             :         }
    1027           0 :         break;
    1028             :         case SID_BASICIDE_TOGGLEBRKPNTENABLED:
    1029             :         {
    1030           0 :             BasicToggleBreakPointEnabled();
    1031             :         }
    1032           0 :         break;
    1033             :         case SID_BASICIDE_ADDWATCH:
    1034             :         {
    1035           0 :             BasicAddWatch();
    1036             :         }
    1037           0 :         break;
    1038             :         case SID_BASICIDE_REMOVEWATCH:
    1039             :         {
    1040           0 :             rLayout.BasicRemoveWatch();
    1041             :         }
    1042           0 :         break;
    1043             :         case SID_CUT:
    1044             :         {
    1045           0 :             if ( !IsReadOnly() )
    1046             :             {
    1047           0 :                 GetEditView()->Cut();
    1048           0 :                 if (SfxBindings* pBindings = GetBindingsPtr())
    1049           0 :                     pBindings->Invalidate( SID_DOC_MODIFIED );
    1050             :             }
    1051             :         }
    1052           0 :         break;
    1053             :         case SID_COPY:
    1054             :         {
    1055           0 :             GetEditView()->Copy();
    1056             :         }
    1057           0 :         break;
    1058             :         case SID_PASTE:
    1059             :         {
    1060           0 :             if ( !IsReadOnly() )
    1061             :             {
    1062           0 :                 GetEditView()->Paste();
    1063           0 :                 if (SfxBindings* pBindings = GetBindingsPtr())
    1064           0 :                     pBindings->Invalidate( SID_DOC_MODIFIED );
    1065             :             }
    1066             :         }
    1067           0 :         break;
    1068             :         case SID_BASICIDE_BRKPNTSCHANGED:
    1069             :         {
    1070           0 :             GetBreakPointWindow().Invalidate();
    1071             :         }
    1072           0 :         break;
    1073             :         case SID_SHOWLINES:
    1074             :         {
    1075           0 :             SFX_REQUEST_ARG(rReq, pItem, SfxBoolItem, rReq.GetSlot(), false);
    1076           0 :             bSourceLinesEnabled = pItem && pItem->GetValue();
    1077           0 :             aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled);
    1078             :         }
    1079           0 :         break;
    1080             :         case SID_BASICIDE_DELETECURRENT:
    1081             :         {
    1082           0 :             if (QueryDelModule(m_aName, this))
    1083           0 :                 if (m_aDocument.removeModule(m_aLibName, m_aName))
    1084           0 :                     MarkDocumentModified(m_aDocument);
    1085             :         }
    1086           0 :         break;
    1087             :         case FID_SEARCH_OFF:
    1088           0 :             GrabFocus();
    1089           0 :             break;
    1090             :         case SID_GOTOLINE:
    1091             :         {
    1092           0 :             GotoLineDialog aGotoDlg(this);
    1093           0 :             if (aGotoDlg.Execute())
    1094           0 :                 if (sal_Int32 const nLine = aGotoDlg.GetLineNumber())
    1095             :                 {
    1096           0 :                     TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0));
    1097           0 :                     GetEditView()->SetSelection(aSel);
    1098             :                 }
    1099           0 :             break;
    1100             :         }
    1101             :     }
    1102           0 : }
    1103             : 
    1104           0 : void ModulWindow::ExecuteGlobal (SfxRequest& rReq)
    1105             : {
    1106           0 :     switch (rReq.GetSlot())
    1107             :     {
    1108             :         case SID_SIGNATURE:
    1109             :         {
    1110           0 :             DocumentSignature aSignature(m_aDocument);
    1111           0 :             if (aSignature.supportsSignatures())
    1112             :             {
    1113           0 :                 aSignature.signScriptingContent();
    1114           0 :                 if (SfxBindings* pBindings = GetBindingsPtr())
    1115           0 :                     pBindings->Invalidate(SID_SIGNATURE);
    1116           0 :             }
    1117             :         }
    1118           0 :         break;
    1119             :     }
    1120           0 : }
    1121             : 
    1122             : 
    1123             : 
    1124           0 : void ModulWindow::GetState( SfxItemSet &rSet )
    1125             : {
    1126             :     DBG_CHKTHIS( ModulWindow, 0 );
    1127           0 :     SfxWhichIter aIter(rSet);
    1128           0 :     for ( sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
    1129             :     {
    1130           0 :         switch ( nWh )
    1131             :         {
    1132             :             case SID_CUT:
    1133             :             {
    1134           0 :                 if ( !GetEditView() || !GetEditView()->HasSelection() )
    1135           0 :                     rSet.DisableItem( nWh );
    1136             : 
    1137           0 :                 if ( IsReadOnly() )
    1138           0 :                     rSet.DisableItem( nWh );
    1139             :             }
    1140           0 :             break;
    1141             :             case SID_COPY:
    1142             :             {
    1143           0 :                 if ( !GetEditView() || !GetEditView()->HasSelection() )
    1144           0 :                     rSet.DisableItem( nWh );
    1145             :             }
    1146           0 :             break;
    1147             :             case SID_PASTE:
    1148             :             {
    1149           0 :                 if ( !IsPasteAllowed() )
    1150           0 :                     rSet.DisableItem( nWh );
    1151             : 
    1152           0 :                 if ( IsReadOnly() )
    1153           0 :                     rSet.DisableItem( nWh );
    1154             :             }
    1155           0 :             break;
    1156             :             case SID_BASICIDE_STAT_POS:
    1157             :             {
    1158           0 :                 TextView* pView = GetEditView();
    1159           0 :                 if ( pView )
    1160             :                 {
    1161           0 :                     TextSelection aSel = pView->GetSelection();
    1162           0 :                     String aPos( IDEResId( RID_STR_LINE ) );
    1163           0 :                     aPos += ' ';
    1164           0 :                     aPos += String::CreateFromInt32( aSel.GetEnd().GetPara()+1 );
    1165           0 :                     aPos += String( ", " );
    1166           0 :                     aPos += String( IDEResId( RID_STR_COLUMN ) );
    1167           0 :                     aPos += ' ';
    1168           0 :                     aPos += String::CreateFromInt32( aSel.GetEnd().GetIndex()+1 );
    1169           0 :                     SfxStringItem aItem( SID_BASICIDE_STAT_POS, aPos );
    1170           0 :                     rSet.Put( aItem );
    1171             :                 }
    1172             :             }
    1173           0 :             break;
    1174             :             case SID_ATTR_INSERT:
    1175             :             {
    1176           0 :                 TextView* pView = GetEditView();
    1177           0 :                 if ( pView )
    1178             :                 {
    1179           0 :                     SfxBoolItem aItem( SID_ATTR_INSERT, pView->IsInsertMode() );
    1180           0 :                     rSet.Put( aItem );
    1181             :                 }
    1182             :             }
    1183           0 :             break;
    1184             :             case SID_SHOWLINES:
    1185             :             {
    1186           0 :                 rSet.Put(SfxBoolItem(nWh, bSourceLinesEnabled));
    1187           0 :                 break;
    1188             :             }
    1189             :         }
    1190           0 :     }
    1191           0 : }
    1192             : 
    1193             : 
    1194           0 : void ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
    1195             : {
    1196             :     DBG_CHKTHIS( ModulWindow, 0 );
    1197           0 :     if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
    1198             :     {
    1199             :         // don't scroll with the value but rather use the Thumb-Pos for the VisArea:
    1200           0 :         long nDiff = GetEditView()->GetStartDocPos().X() - pCurScrollBar->GetThumbPos();
    1201           0 :         GetEditView()->Scroll( nDiff, 0 );
    1202           0 :         GetEditView()->ShowCursor( false, true );
    1203           0 :         pCurScrollBar->SetThumbPos( GetEditView()->GetStartDocPos().X() );
    1204             : 
    1205             :     }
    1206           0 : }
    1207             : 
    1208             : 
    1209           0 : bool ModulWindow::IsModified()
    1210             : {
    1211           0 :     return GetEditEngine() && GetEditEngine()->IsModified();
    1212             : }
    1213             : 
    1214             : 
    1215             : 
    1216           0 : void ModulWindow::GoOnTop()
    1217             : {
    1218           0 :     GetShell()->GetViewFrame()->ToTop();
    1219           0 : }
    1220             : 
    1221           0 : OUString ModulWindow::GetSbModuleName()
    1222             : {
    1223           0 :     OUString aModuleName;
    1224           0 :     if ( XModule().Is() )
    1225           0 :         aModuleName = xModule->GetName();
    1226           0 :     return aModuleName;
    1227             : }
    1228             : 
    1229           0 : OUString ModulWindow::GetTitle()
    1230             : {
    1231           0 :     return GetSbModuleName();
    1232             : }
    1233             : 
    1234           0 : void ModulWindow::FrameWindowMoved()
    1235             : {
    1236           0 : }
    1237             : 
    1238             : 
    1239             : 
    1240           0 : void ModulWindow::ShowCursor( bool bOn )
    1241             : {
    1242           0 :     if ( GetEditEngine() )
    1243             :     {
    1244           0 :         TextView* pView = GetEditEngine()->GetActiveView();
    1245           0 :         if ( pView )
    1246             :         {
    1247           0 :             if ( bOn )
    1248           0 :                 pView->ShowCursor();
    1249             :             else
    1250           0 :                 pView->HideCursor();
    1251             :         }
    1252             :     }
    1253           0 : }
    1254             : 
    1255             : 
    1256           0 : void ModulWindow::AssertValidEditEngine()
    1257             : {
    1258           0 :     if ( !GetEditEngine() )
    1259           0 :         GetEditorWindow().CreateEditEngine();
    1260           0 : }
    1261             : 
    1262           0 : void ModulWindow::Activating ()
    1263             : {
    1264           0 :     aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled);
    1265           0 :     Show();
    1266           0 : }
    1267             : 
    1268           0 : void ModulWindow::Deactivating()
    1269             : {
    1270           0 :     Hide();
    1271           0 :     if ( GetEditView() )
    1272           0 :         GetEditView()->EraseVirtualDevice();
    1273           0 : }
    1274             : 
    1275           0 : sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem, bool bFromStart )
    1276             : {
    1277           0 :     if (IsSuspended())
    1278           0 :         return 0;
    1279             : 
    1280             :     // one could also relinquish syntaxhighlighting/formatting instead of the stupid replace-everything...
    1281           0 :     AssertValidEditEngine();
    1282           0 :     ExtTextView* pView = GetEditView();
    1283           0 :     TextSelection aSel;
    1284           0 :     if ( bFromStart )
    1285             :     {
    1286           0 :         aSel = pView->GetSelection();
    1287           0 :         if ( !rSearchItem.GetBackward() )
    1288           0 :             pView->SetSelection( TextSelection() );
    1289             :         else
    1290           0 :             pView->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
    1291             :     }
    1292             : 
    1293           0 :     bool const bForward = !rSearchItem.GetBackward();
    1294           0 :     sal_uInt16 nFound = 0;
    1295           0 :     if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND ) ||
    1296           0 :          ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND_ALL ) )
    1297             :     {
    1298           0 :         nFound = pView->Search( rSearchItem.GetSearchOptions() , bForward );
    1299             :     }
    1300           0 :     else if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE ) ||
    1301           0 :               ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL ) )
    1302             :     {
    1303           0 :         if ( !IsReadOnly() )
    1304             :         {
    1305           0 :             bool const bAll = rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;
    1306           0 :             nFound = pView->Replace( rSearchItem.GetSearchOptions() , bAll , bForward );
    1307             :         }
    1308             :     }
    1309             : 
    1310           0 :     if ( bFromStart && !nFound )
    1311           0 :         pView->SetSelection( aSel );
    1312             : 
    1313           0 :     return nFound;
    1314             : }
    1315             : 
    1316           0 : ::svl::IUndoManager* ModulWindow::GetUndoManager()
    1317             : {
    1318           0 :     if ( GetEditEngine() )
    1319           0 :         return &GetEditEngine()->GetUndoManager();
    1320           0 :     return NULL;
    1321             : }
    1322             : 
    1323           0 : sal_uInt16 ModulWindow::GetSearchOptions()
    1324             : {
    1325             :     sal_uInt16 nOptions = SEARCH_OPTIONS_SEARCH |
    1326             :                       SEARCH_OPTIONS_WHOLE_WORDS |
    1327             :                       SEARCH_OPTIONS_BACKWARDS |
    1328             :                       SEARCH_OPTIONS_REG_EXP |
    1329             :                       SEARCH_OPTIONS_EXACT |
    1330             :                       SEARCH_OPTIONS_SELECTION |
    1331           0 :                       SEARCH_OPTIONS_SIMILARITY;
    1332             : 
    1333           0 :     if ( !IsReadOnly() )
    1334             :     {
    1335           0 :         nOptions |= SEARCH_OPTIONS_REPLACE;
    1336           0 :         nOptions |= SEARCH_OPTIONS_REPLACE_ALL;
    1337             :     }
    1338             : 
    1339           0 :     return nOptions;
    1340             : }
    1341             : 
    1342           0 : void ModulWindow::BasicStarted()
    1343             : {
    1344           0 :     if ( XModule().Is() )
    1345             :     {
    1346           0 :         aStatus.bIsRunning = true;
    1347           0 :         BreakPointList& rList = GetBreakPoints();
    1348           0 :         if ( rList.size() )
    1349             :         {
    1350           0 :             rList.ResetHitCount();
    1351           0 :             rList.SetBreakPointsInBasic( xModule );
    1352           0 :             for ( sal_uInt16 nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ )
    1353             :             {
    1354           0 :                 SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod );
    1355             :                 DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
    1356           0 :                 pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
    1357             :             }
    1358             :         }
    1359             :     }
    1360           0 : }
    1361             : 
    1362           0 : void ModulWindow::BasicStopped()
    1363             : {
    1364           0 :     aStatus.bIsRunning = false;
    1365           0 :     GetBreakPointWindow().SetNoMarker();
    1366           0 : }
    1367             : 
    1368           0 : EntryDescriptor ModulWindow::CreateEntryDescriptor()
    1369             : {
    1370           0 :     ScriptDocument aDocument( GetDocument() );
    1371           0 :     String aLibName( GetLibName() );
    1372           0 :     LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
    1373           0 :     String aModName( GetName() );
    1374           0 :     String aLibSubName;
    1375           0 :     if( xBasic.Is() && aDocument.isInVBAMode() && XModule().Is() )
    1376             :     {
    1377           0 :         switch( xModule->GetModuleType() )
    1378             :         {
    1379             :             case script::ModuleType::DOCUMENT:
    1380             :             {
    1381           0 :                 aLibSubName = String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) );
    1382           0 :                 uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
    1383           0 :                 if( xLib.is() )
    1384             :                 {
    1385           0 :                     OUString sObjName;
    1386           0 :                     ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
    1387           0 :                     if( !sObjName.isEmpty() )
    1388             :                     {
    1389           0 :                         aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
    1390           0 :                     }
    1391             :                 }
    1392           0 :                 break;
    1393             :             }
    1394             :             case script::ModuleType::FORM:
    1395           0 :                 aLibSubName = String( IDEResId( RID_STR_USERFORMS ) );
    1396           0 :                 break;
    1397             :             case script::ModuleType::NORMAL:
    1398           0 :                 aLibSubName = String( IDEResId( RID_STR_NORMAL_MODULES ) );
    1399           0 :                 break;
    1400             :             case script::ModuleType::CLASS:
    1401           0 :                 aLibSubName = String( IDEResId( RID_STR_CLASS_MODULES ) );
    1402           0 :                 break;
    1403             :         }
    1404             :     }
    1405           0 :     return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE );
    1406             : }
    1407             : 
    1408           0 : void ModulWindow::SetReadOnly (bool b)
    1409             : {
    1410           0 :     if ( GetEditView() )
    1411           0 :         GetEditView()->SetReadOnly( b );
    1412           0 : }
    1413             : 
    1414           0 : bool ModulWindow::IsReadOnly()
    1415             : {
    1416           0 :     return GetEditView() && GetEditView()->IsReadOnly();
    1417             : }
    1418             : 
    1419           0 : bool ModulWindow::IsPasteAllowed()
    1420             : {
    1421           0 :     bool bPaste = false;
    1422             : 
    1423             :     // get clipboard
    1424           0 :     Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
    1425           0 :     if ( xClipboard.is() )
    1426             :     {
    1427             :         // get clipboard content
    1428           0 :         const sal_uInt32 nRef = Application::ReleaseSolarMutex();
    1429           0 :         Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
    1430           0 :         Application::AcquireSolarMutex( nRef );
    1431           0 :         if ( xTransf.is() )
    1432             :         {
    1433           0 :             datatransfer::DataFlavor aFlavor;
    1434           0 :             SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
    1435           0 :             if ( xTransf->isDataFlavorSupported( aFlavor ) )
    1436           0 :                 bPaste = true;
    1437           0 :         }
    1438             :     }
    1439             : 
    1440           0 :     return bPaste;
    1441             : }
    1442             : 
    1443           0 : void ModulWindow::OnNewDocument ()
    1444             : {
    1445           0 :     aXEditorWindow.SetLineNumberDisplay(bSourceLinesEnabled);
    1446           0 : }
    1447             : 
    1448           0 : char const* ModulWindow::GetHid () const
    1449             : {
    1450           0 :     return HID_BASICIDE_MODULWINDOW;
    1451             : }
    1452           0 : ItemType ModulWindow::GetType () const
    1453             : {
    1454           0 :     return TYPE_MODULE;
    1455             : }
    1456             : 
    1457           0 : bool ModulWindow::HasActiveEditor () const
    1458             : {
    1459           0 :     return !IsSuspended();
    1460             : }
    1461             : 
    1462             : 
    1463           0 : void ModulWindow::UpdateModule ()
    1464             : {
    1465           0 :     OUString const aModule = getTextEngineText(*GetEditEngine());
    1466             : 
    1467             :     // update module in basic
    1468             :     assert(xModule);
    1469             : 
    1470             :     // update module in module window
    1471           0 :     SetModule(aModule);
    1472             : 
    1473             :     // update module in library
    1474           0 :     OSL_VERIFY(m_aDocument.updateModule(m_aLibName, m_aName, aModule));
    1475             : 
    1476           0 :     GetEditEngine()->SetModified(false);
    1477           0 :     MarkDocumentModified(m_aDocument);
    1478           0 : }
    1479             : 
    1480             : 
    1481             : //
    1482             : // ModulWindowLayout
    1483             : // =================
    1484             : //
    1485             : 
    1486           0 : ModulWindowLayout::ModulWindowLayout (Window* pParent, ObjectCatalog& rObjectCatalog_) :
    1487             :     Layout(pParent),
    1488             :     pChild(0),
    1489             :     aWatchWindow(this),
    1490             :     aStackWindow(this),
    1491           0 :     rObjectCatalog(rObjectCatalog_)
    1492           0 : { }
    1493             : 
    1494           0 : void ModulWindowLayout::UpdateDebug (bool bBasicStopped)
    1495             : {
    1496           0 :     aWatchWindow.UpdateWatches(bBasicStopped);
    1497           0 :     aStackWindow.UpdateCalls();
    1498           0 : }
    1499             : 
    1500           0 : void ModulWindowLayout::Paint (Rectangle const&)
    1501             : {
    1502           0 :     DrawText(Point(), String(IDEResId(RID_STR_NOMODULE)));
    1503           0 : }
    1504             : 
    1505             : // virtual
    1506           0 : void ModulWindowLayout::DataChanged (DataChangedEvent const& rDCEvt)
    1507             : {
    1508           0 :     Layout::DataChanged(rDCEvt);
    1509           0 :     if (rDCEvt.GetType() == DATACHANGED_SETTINGS && (rDCEvt.GetFlags() & SETTINGS_STYLE))
    1510           0 :         aSyntaxColors.SettingsChanged();
    1511           0 : }
    1512             : 
    1513             : 
    1514           0 : void ModulWindowLayout::Activating (BaseWindow& rChild)
    1515             : {
    1516             :     assert(dynamic_cast<ModulWindow*>(&rChild));
    1517           0 :     pChild = &static_cast<ModulWindow&>(rChild);
    1518           0 :     aWatchWindow.Show();
    1519           0 :     aStackWindow.Show();
    1520           0 :     rObjectCatalog.Show();
    1521           0 :     rObjectCatalog.SetLayoutWindow(this);
    1522           0 :     rObjectCatalog.UpdateEntries();
    1523           0 :     Layout::Activating(rChild);
    1524           0 :     aSyntaxColors.SetActiveEditor(&pChild->GetEditorWindow());
    1525           0 : }
    1526             : 
    1527           0 : void ModulWindowLayout::Deactivating ()
    1528             : {
    1529           0 :     aSyntaxColors.SetActiveEditor(0);
    1530           0 :     Layout::Deactivating();
    1531           0 :     aWatchWindow.Hide();
    1532           0 :     aStackWindow.Hide();
    1533           0 :     rObjectCatalog.Hide();
    1534           0 :     pChild = 0;
    1535           0 : }
    1536             : 
    1537           0 : void ModulWindowLayout::GetState (SfxItemSet &rSet, unsigned nWhich)
    1538             : {
    1539           0 :     switch (nWhich)
    1540             :     {
    1541             :         case SID_SHOW_PROPERTYBROWSER:
    1542           0 :             rSet.Put(SfxVisibilityItem(nWhich, false));
    1543           0 :             break;
    1544             : 
    1545             :         case SID_BASICIDE_CHOOSEMACRO:
    1546           0 :             rSet.Put(SfxVisibilityItem(nWhich, true));
    1547           0 :             break;
    1548             :     }
    1549           0 : }
    1550             : 
    1551           0 : void ModulWindowLayout::BasicAddWatch (String const& rWatchStr)
    1552             : {
    1553           0 :     aWatchWindow.AddWatch(rWatchStr);
    1554           0 : }
    1555             : 
    1556           0 : void ModulWindowLayout::BasicRemoveWatch ()
    1557             : {
    1558             :     DBG_CHKTHIS( ModulWindow, 0 );
    1559           0 :     aWatchWindow.RemoveSelectedWatch();
    1560           0 : }
    1561             : 
    1562           0 : void ModulWindowLayout::OnFirstSize (long const nWidth, long const nHeight)
    1563             : {
    1564           0 :     AddToLeft(&rObjectCatalog, Size(nWidth * 0.20, nHeight * 0.75));
    1565           0 :     AddToBottom(&aWatchWindow, Size(nWidth * 0.67, nHeight * 0.25));
    1566           0 :     AddToBottom(&aStackWindow, Size(nWidth * 0.33, nHeight * 0.25));
    1567           0 : }
    1568             : 
    1569             : 
    1570             : //
    1571             : // SyntaxColors
    1572             : // ============
    1573             : //
    1574             : 
    1575           0 : ModulWindowLayout::SyntaxColors::SyntaxColors () :
    1576           0 :     pEditor(0)
    1577             : {
    1578           0 :     aConfig.AddListener(this);
    1579             : 
    1580             :     aColors[TT_UNKNOWN] =
    1581             :     aColors[TT_WHITESPACE] =
    1582             :     aColors[TT_EOL] =
    1583           0 :         Application::GetSettings().GetStyleSettings().GetFieldTextColor();
    1584             : 
    1585           0 :     NewConfig(true);
    1586           0 : }
    1587             : 
    1588           0 : ModulWindowLayout::SyntaxColors::~SyntaxColors ()
    1589             : {
    1590           0 :     aConfig.RemoveListener(this);
    1591           0 : }
    1592             : 
    1593           0 : void ModulWindowLayout::SyntaxColors::SettingsChanged ()
    1594             : {
    1595           0 :     Color const aColor = Application::GetSettings().GetStyleSettings().GetFieldTextColor();
    1596           0 :     if (aColor != aColors[TT_UNKNOWN])
    1597             :     {
    1598             :         aColors[TT_UNKNOWN] =
    1599             :         aColors[TT_WHITESPACE] =
    1600             :         aColors[TT_EOL] =
    1601           0 :             aColor;
    1602           0 :         if (pEditor)
    1603           0 :             pEditor->UpdateSyntaxHighlighting();
    1604             :     }
    1605           0 : }
    1606             : 
    1607             : // virtual
    1608           0 : void ModulWindowLayout::SyntaxColors::ConfigurationChanged (utl::ConfigurationBroadcaster*, sal_uInt32)
    1609             : {
    1610           0 :     NewConfig(false);
    1611           0 : }
    1612             : 
    1613             : // when a new configuration has to be set
    1614           0 : void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst)
    1615             : {
    1616             :     static struct
    1617             :     {
    1618             :         TokenTypes eTokenType;
    1619             :         svtools::ColorConfigEntry eEntry;
    1620             :     }
    1621             :     const vIds[] =
    1622             :     {
    1623             :         { TT_IDENTIFIER,  svtools::BASICIDENTIFIER },
    1624             :         { TT_NUMBER,      svtools::BASICNUMBER },
    1625             :         { TT_STRING,      svtools::BASICSTRING },
    1626             :         { TT_COMMENT,     svtools::BASICCOMMENT },
    1627             :         { TT_ERROR,       svtools::BASICERROR },
    1628             :         { TT_OPERATOR,    svtools::BASICOPERATOR },
    1629             :         { TT_KEYWORDS,    svtools::BASICKEYWORD },
    1630             :     };
    1631             : 
    1632           0 :     bool bChanged = false;
    1633           0 :     for (unsigned i = 0; i != sizeof vIds / sizeof vIds[0]; ++i)
    1634             :     {
    1635           0 :         Color const aColor = aConfig.GetColorValue(vIds[i].eEntry).nColor;
    1636           0 :         Color& rMyColor = aColors[vIds[i].eTokenType];
    1637           0 :         if (bFirst || aColor != rMyColor)
    1638             :         {
    1639           0 :             rMyColor = aColor;
    1640           0 :             bChanged = true;
    1641             :         }
    1642             :     }
    1643           0 :     if (bChanged && !bFirst && pEditor)
    1644           0 :         pEditor->UpdateSyntaxHighlighting();
    1645           0 : }
    1646             : 
    1647             : 
    1648           0 : } // namespace basctl
    1649             : 
    1650             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10