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