1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "baside2.hxx"
21 #include <baside3.hxx>
23 #include <basidesh.hxx>
25 #include <iderdll.hxx>
27 #include "moduldlg.hxx"
28 #include <docsignature.hxx>
29 #include <officecfg/Office/BasicIDE.hxx>
32 #include <strings.hrc>
34 #include <basic/basmgr.hxx>
35 #include <basic/basrdll.hxx>
36 #include <basic/sbmeth.hxx>
37 #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
38 #include <com/sun/star/script/ModuleType.hpp>
39 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
40 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
41 #include <com/sun/star/ui/dialogs/FilePicker.hpp>
42 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
43 #include <comphelper/SetFlagContextHelper.hxx>
44 #include <comphelper/string.hxx>
45 #include <svl/srchdefs.hxx>
46 #include <sfx2/bindings.hxx>
47 #include <sfx2/docfile.hxx>
48 #include <sfx2/request.hxx>
49 #include <sfx2/viewfrm.hxx>
50 #include <sot/exchange.hxx>
51 #include <svl/eitem.hxx>
52 #include <svl/srchitem.hxx>
53 #include <svl/stritem.hxx>
54 #include <svl/visitem.hxx>
55 #include <svl/whiter.hxx>
56 #include <svx/svxids.hrc>
57 #include <tools/debug.hxx>
58 #include <vcl/waitobj.hxx>
59 #include <vcl/errinf.hxx>
60 #include <vcl/event.hxx>
61 #include <vcl/print.hxx>
62 #include <vcl/svapp.hxx>
63 #include <vcl/textview.hxx>
64 #include <vcl/weld.hxx>
65 #include <vcl/xtextedt.hxx>
66 #include <toolkit/helper/vclunohelper.hxx>
68 #include <osl/diagnose.h>
69 #include <officecfg/Office/Common.hxx>
79 tools::Long
const nLeftMargin
= 1700;
80 tools::Long
const nRightMargin
= 900;
81 tools::Long
const nTopMargin
= 2000;
82 tools::Long
const nBottomMargin
= 1000;
83 tools::Long
const nBorder
= 300;
86 short const ValidWindow
= 0x1234;
88 // What (who) are OW and MTF? Compare to baside3.cxx where an
89 // identically named variable, used in the same way, has the value
90 // "*.*" on Windows, "*" otherwise. Is that what should be done here,
93 #if defined(OW) || defined(MTF)
94 char const FilterMask_All
[] = "*";
96 char const FilterMask_All
[] = "*.*";
99 } // end anonymous namespace
101 using namespace ::com::sun::star
;
102 using namespace ::com::sun::star::uno
;
103 using namespace ::com::sun::star::ui::dialogs
;
105 using namespace comphelper
;
110 void lcl_PrintHeader( Printer
* pPrinter
, sal_uInt16 nPages
, sal_uInt16 nCurPage
, const OUString
& rTitle
, bool bOutput
)
112 Size
const aSz
= pPrinter
->GetOutputSize();
114 const Color
aOldLineColor( pPrinter
->GetLineColor() );
115 const Color
aOldFillColor( pPrinter
->GetFillColor() );
116 const vcl::Font
aOldFont( pPrinter
->GetFont() );
118 pPrinter
->SetLineColor( COL_BLACK
);
119 pPrinter
->SetFillColor();
121 vcl::Font
aFont( aOldFont
);
122 aFont
.SetWeight( WEIGHT_BOLD
);
123 aFont
.SetAlignment( ALIGN_BOTTOM
);
124 pPrinter
->SetFont( aFont
);
126 tools::Long nFontHeight
= pPrinter
->GetTextHeight();
128 // 1st Border => line, 2+3 Border = free space
129 tools::Long nYTop
= Print::nTopMargin
- 3*Print::nBorder
- nFontHeight
;
131 tools::Long nXLeft
= Print::nLeftMargin
- Print::nBorder
;
132 tools::Long nXRight
= aSz
.Width() - Print::nRightMargin
+ Print::nBorder
;
135 pPrinter
->DrawRect(tools::Rectangle(
136 Point(nXLeft
, nYTop
),
137 Size(nXRight
- nXLeft
, aSz
.Height() - nYTop
- Print::nBottomMargin
+ Print::nBorder
)
141 tools::Long nY
= Print::nTopMargin
- 2*Print::nBorder
;
142 Point
aPos(Print::nLeftMargin
, nY
);
144 pPrinter
->DrawText( aPos
, rTitle
);
147 aFont
.SetWeight( WEIGHT_NORMAL
);
148 pPrinter
->SetFont( aFont
);
149 aPos
.AdjustX(pPrinter
->GetTextWidth( rTitle
) );
153 OUString aPageStr
= " [" + IDEResId(RID_STR_PAGE
) + " " + OUString::number( nCurPage
) + "]";
154 pPrinter
->DrawText( aPos
, aPageStr
);
158 nY
= Print::nTopMargin
- Print::nBorder
;
161 pPrinter
->DrawLine( Point( nXLeft
, nY
), Point( nXRight
, nY
) );
163 pPrinter
->SetFont( aOldFont
);
164 pPrinter
->SetFillColor( aOldFillColor
);
165 pPrinter
->SetLineColor( aOldLineColor
);
168 void lcl_ConvertTabsToSpaces( OUString
& rLine
)
170 if ( rLine
.isEmpty() )
173 OUStringBuffer
aResult( rLine
);
175 sal_Int32 nMax
= aResult
.getLength();
176 while ( nPos
< nMax
)
178 if ( aResult
[nPos
] == '\t' )
180 // not 4 Blanks, but at 4 TabPos:
181 OUStringBuffer aBlanker
;
182 string::padToLength(aBlanker
, ( 4 - ( nPos
% 4 ) ), ' ');
183 aResult
.remove( nPos
, 1 );
184 aResult
.insert( nPos
, aBlanker
.makeStringAndClear() );
185 nMax
= aResult
.getLength();
189 rLine
= aResult
.makeStringAndClear();
194 ModulWindow::ModulWindow (ModulWindowLayout
* pParent
, ScriptDocument
const& rDocument
,
195 const OUString
& aLibName
, const OUString
& aName
, OUString
const & aModule
)
196 : BaseWindow(pParent
, rDocument
, aLibName
, aName
)
197 , m_rLayout(*pParent
)
198 , m_nValid(ValidWindow
)
199 , m_aXEditorWindow(VclPtr
<ComplexEditorWindow
>::Create(this))
202 m_aXEditorWindow
->Show();
206 SbModuleRef
const & ModulWindow::XModule()
208 // ModuleWindows can now be created as a result of the
209 // modules getting created via the api. This is a result of an
210 // elementInserted event from the BasicLibrary container.
211 // However the SbModule is also created from a different listener to
212 // the same event ( in basmgr ) Therefore it is possible when we look
213 // for m_xModule it may not yet be available, here we keep trying to access
214 // the module until such time as it exists
216 if ( !m_xModule
.is() )
218 BasicManager
* pBasMgr
= GetDocument().getBasicManager();
221 StarBASIC
* pBasic
= pBasMgr
->GetLib( GetLibName() );
225 m_xModule
= pBasic
->FindModule( GetName() );
232 ModulWindow::~ModulWindow()
237 void ModulWindow::dispose()
241 m_aXEditorWindow
.disposeAndClear();
242 BaseWindow::dispose();
246 void ModulWindow::GetFocus()
248 if (m_nValid
!= ValidWindow
)
250 m_aXEditorWindow
->GetEdtWindow().GrabFocus();
251 // don't call basic calls because focus is somewhere else...
254 void ModulWindow::DoInit()
257 GetVScrollBar()->Hide();
258 GetHScrollBar()->Show();
259 GetEditorWindow().InitScrollBars();
262 void ModulWindow::Paint(vcl::RenderContext
& /*rRenderContext*/, const tools::Rectangle
&)
266 void ModulWindow::Resize()
268 m_aXEditorWindow
->SetPosSizePixel( Point( 0, 0 ), GetOutputSizePixel() );
271 void ModulWindow::CheckCompileBasic()
273 if ( !XModule().is() )
276 // never compile while running!
277 bool const bRunning
= StarBASIC::IsRunning();
278 bool const bModified
= ( !m_xModule
->IsCompiled() ||
279 ( GetEditEngine() && GetEditEngine()->IsModified() ) );
281 if ( bRunning
|| !bModified
)
286 GetShell()->GetViewFrame()->GetWindow().EnterWait();
288 AssertValidEditEngine();
289 GetEditorWindow().SetSourceInBasic();
291 bool bWasModified
= GetBasic()->IsModified();
294 // tdf#106529: only use strict compilation mode when compiling from the IDE
295 css::uno::ContextLayer
layer(comphelper::NewFlagContext("BasicStrict"));
296 bDone
= m_xModule
->Compile();
299 GetBasic()->SetModified(false);
303 GetBreakPoints().SetBreakPointsInBasic( m_xModule
.get() );
306 GetShell()->GetViewFrame()->GetWindow().LeaveWait();
308 m_aStatus
.bError
= !bDone
;
309 m_aStatus
.bIsRunning
= false;
312 void ModulWindow::BasicExecute()
314 // #116444# check security settings before macro execution
315 ScriptDocument
aDocument( GetDocument() );
316 bool bMacrosDisabled
= officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
317 if (bMacrosDisabled
|| (aDocument
.isDocument() && !aDocument
.allowMacros()))
319 std::unique_ptr
<weld::MessageDialog
> xBox(
320 Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning
,
321 VclButtonsType::Ok
, IDEResId(RID_STR_CANNOTRUNMACRO
)));
328 if ( !XModule().is() || !m_xModule
->IsCompiled() || m_aStatus
.bError
)
331 if ( GetBreakPoints().size() )
332 m_aStatus
.nBasicFlags
= m_aStatus
.nBasicFlags
| BasicDebugFlags::Break
;
334 if ( !m_aStatus
.bIsRunning
)
336 DBG_ASSERT( m_xModule
.is(), "No Module!" );
337 AddStatus( BASWIN_RUNNINGBASIC
);
338 sal_uInt16 nStart
, nEnd
;
339 TextSelection aSel
= GetEditView()->GetSelection();
340 // Init cursor to top
341 const sal_uInt32 nCurMethodStart
= aSel
.GetStart().GetPara() + 1;
342 SbMethod
* pMethod
= nullptr;
343 // first Macro, else blind "Main" (ExtSearch?)
344 for ( sal_uInt32 nMacro
= 0; nMacro
< m_xModule
->GetMethods()->Count32(); nMacro
++ )
346 SbMethod
* pM
= static_cast<SbMethod
*>(m_xModule
->GetMethods()->Get32( nMacro
));
347 assert(pM
&& "Method?");
348 pM
->GetLineRange( nStart
, nEnd
);
349 if ( nCurMethodStart
>= nStart
&& nCurMethodStart
<= nEnd
)
351 // matched a method to the cursor position
358 // If not in a method then prompt the user
359 ChooseMacro(GetFrameWeld(), uno::Reference
<frame::XModel
>());
362 pMethod
->SetDebugFlags(m_aStatus
.nBasicFlags
);
363 BasicDLL::SetDebugMode(true);
365 BasicDLL::SetDebugMode(false);
366 // if cancelled during Interactive=false
367 BasicDLL::EnableBreak(true);
368 ClearStatus( BASWIN_RUNNINGBASIC
);
371 m_aStatus
.bIsRunning
= false; // cancel of Reschedule()
374 void ModulWindow::CompileBasic()
378 XModule().is() && m_xModule
->IsCompiled();
381 void ModulWindow::BasicRun()
383 m_aStatus
.nBasicFlags
= BasicDebugFlags::NONE
;
387 void ModulWindow::BasicStepOver()
389 m_aStatus
.nBasicFlags
= BasicDebugFlags::StepInto
| BasicDebugFlags::StepOver
;
394 void ModulWindow::BasicStepInto()
396 m_aStatus
.nBasicFlags
= BasicDebugFlags::StepInto
;
400 void ModulWindow::BasicStepOut()
402 m_aStatus
.nBasicFlags
= BasicDebugFlags::StepOut
;
407 void ModulWindow::BasicStop()
410 m_aStatus
.bIsRunning
= false;
413 void ModulWindow::LoadBasic()
415 Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
416 Reference
< XFilePicker3
> xFP
= FilePicker::createWithMode(xContext
, TemplateDescription::FILEOPEN_SIMPLE
);
418 if ( !m_sCurPath
.isEmpty() )
419 xFP
->setDisplayDirectory ( m_sCurPath
);
421 xFP
->appendFilter( "BASIC" , "*.bas" );
422 xFP
->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES
), FilterMask_All
);
423 xFP
->setCurrentFilter( "BASIC" );
425 if( xFP
->execute() != RET_OK
)
428 Sequence
< OUString
> aPaths
= xFP
->getSelectedFiles();
429 m_sCurPath
= aPaths
[0];
430 SfxMedium
aMedium( m_sCurPath
, StreamMode::READ
| StreamMode::SHARE_DENYWRITE
| StreamMode::NOCREATE
);
431 SvStream
* pStream
= aMedium
.GetInStream();
434 AssertValidEditEngine();
435 sal_uInt32 nLines
= CalcLineCount( *pStream
);
436 // nLines*4: ReadText/Formatting/Highlighting/Formatting
437 GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE
), nLines
*4 );
438 GetEditEngine()->SetUpdateMode( false );
439 GetEditView()->Read( *pStream
);
440 GetEditEngine()->SetUpdateMode( true );
441 GetEditorWindow().PaintImmediately();
442 GetEditorWindow().ForceSyntaxTimeout();
443 GetEditorWindow().DestroyProgress();
444 ErrCode nError
= aMedium
.GetError();
446 ErrorHandler::HandleError( nError
);
450 std::unique_ptr
<weld::MessageDialog
> xBox(Application::CreateMessageDialog(GetFrameWeld(),
451 VclMessageType::Warning
, VclButtonsType::Ok
, IDEResId(RID_STR_COULDNTREAD
)));
457 void ModulWindow::SaveBasicSource()
459 Reference
< uno::XComponentContext
> xContext( ::comphelper::getProcessComponentContext() );
460 Reference
< XFilePicker3
> xFP
= FilePicker::createWithMode(xContext
, TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD
);
462 Reference
< XFilePickerControlAccess
> xFPControl(xFP
, UNO_QUERY
);
463 xFPControl
->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD
, false);
466 xFPControl
->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION
, 0, aValue
);
468 if ( !m_sCurPath
.isEmpty() )
469 xFP
->setDisplayDirectory ( m_sCurPath
);
471 xFP
->appendFilter( "BASIC", "*.bas" );
472 xFP
->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES
), FilterMask_All
);
473 xFP
->setCurrentFilter( "BASIC" );
475 if( xFP
->execute() != RET_OK
)
478 Sequence
< OUString
> aPaths
= xFP
->getSelectedFiles();
479 m_sCurPath
= aPaths
[0];
480 SfxMedium
aMedium( m_sCurPath
, StreamMode::WRITE
| StreamMode::SHARE_DENYWRITE
| StreamMode::TRUNC
);
481 SvStream
* pStream
= aMedium
.GetOutStream();
485 AssertValidEditEngine();
486 GetEditEngine()->Write( *pStream
);
489 ErrCode nError
= aMedium
.GetError();
491 ErrorHandler::HandleError( nError
);
495 std::unique_ptr
<weld::MessageDialog
> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
496 VclMessageType::Warning
, VclButtonsType::Ok
, IDEResId(RID_STR_COULDNTWRITE
)));
501 void ModulWindow::ImportDialog()
503 const ScriptDocument
& rDocument
= GetDocument();
504 OUString aLibName
= GetLibName();
505 implImportDialog(GetFrameWeld(), m_sCurPath
, rDocument
, aLibName
);
508 void ModulWindow::ToggleBreakPoint( sal_uInt16 nLine
)
510 DBG_ASSERT( XModule().is(), "No Module!" );
512 if ( !XModule().is() )
516 if ( m_aStatus
.bError
)
521 BreakPoint
* pBrk
= GetBreakPoints().FindBreakPoint( nLine
);
522 if ( pBrk
) // remove
524 m_xModule
->ClearBP( nLine
);
525 GetBreakPoints().remove( pBrk
);
529 if ( m_xModule
->SetBP( nLine
))
531 GetBreakPoints().InsertSorted( BreakPoint( nLine
) );
532 if ( StarBASIC::IsRunning() )
534 for ( sal_uInt32 nMethod
= 0; nMethod
< m_xModule
->GetMethods()->Count32(); nMethod
++ )
536 SbMethod
* pMethod
= static_cast<SbMethod
*>(m_xModule
->GetMethods()->Get32( nMethod
));
537 assert(pMethod
&& "Method not found! (NULL)");
538 pMethod
->SetDebugFlags( pMethod
->GetDebugFlags() | BasicDebugFlags::Break
);
545 void ModulWindow::UpdateBreakPoint( const BreakPoint
& rBrk
)
547 DBG_ASSERT( XModule().is(), "No Module!" );
549 if ( XModule().is() )
554 m_xModule
->SetBP( rBrk
.nLine
);
556 m_xModule
->ClearBP( rBrk
.nLine
);
561 void ModulWindow::BasicToggleBreakPoint()
563 AssertValidEditEngine();
565 TextSelection aSel
= GetEditView()->GetSelection();
566 aSel
.GetStart().GetPara()++; // Basic lines start at 1!
567 aSel
.GetEnd().GetPara()++;
569 for ( sal_uInt32 nLine
= aSel
.GetStart().GetPara(); nLine
<= aSel
.GetEnd().GetPara(); ++nLine
)
571 ToggleBreakPoint( nLine
);
574 m_aXEditorWindow
->GetBrkWindow().Invalidate();
578 void ModulWindow::BasicToggleBreakPointEnabled()
580 AssertValidEditEngine();
582 TextView
* pView
= GetEditView();
586 TextSelection aSel
= pView
->GetSelection();
587 BreakPointList
& rList
= GetBreakPoints();
589 for ( sal_uInt32 nLine
= ++aSel
.GetStart().GetPara(), nEnd
= ++aSel
.GetEnd().GetPara(); nLine
<= nEnd
; ++nLine
)
591 BreakPoint
* pBrk
= rList
.FindBreakPoint( nLine
);
594 pBrk
->bEnabled
= !pBrk
->bEnabled
;
595 UpdateBreakPoint( *pBrk
);
599 GetBreakPointWindow().Invalidate();
602 void ModulWindow::ManageBreakPoints()
604 BreakPointWindow
& rBrkWin
= GetBreakPointWindow();
605 BreakPointDialog
aBrkDlg(rBrkWin
.GetFrameWeld(), GetBreakPoints());
607 rBrkWin
.Invalidate();
610 void ModulWindow::BasicErrorHdl( StarBASIC
const * pBasic
)
612 GetShell()->GetViewFrame()->ToTop();
614 // Return value: BOOL
617 sal_uInt16 nErrorLine
= StarBASIC::GetLine() - 1;
618 sal_uInt16 nErrCol1
= StarBASIC::GetCol1();
619 sal_uInt16 nErrCol2
= StarBASIC::GetCol2();
620 if ( nErrCol2
!= 0xFFFF )
623 AssertValidEditEngine();
624 GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine
, nErrCol1
), TextPaM( nErrorLine
, nErrCol2
) ) );
626 // if other basic, the IDE should try to display the correct module
627 bool const bMarkError
= pBasic
== GetBasic();
629 m_aXEditorWindow
->GetBrkWindow().SetMarkerPos(nErrorLine
, true);
632 Reference
< awt::XWindow
> xWindow
= VCLUnoHelper::GetInterface( this );
634 // tdf#118572 make a currently running dialog, regardless of what its modal
635 // to, insensitive to user input until after this error dialog goes away.
636 TopLevelWindowLocker aBusy
;
637 aBusy
.incBusy(nullptr);
639 ErrorHandler::HandleError(StarBASIC::GetErrorCode(), GetFrameWeld());
644 VclPtr
<vcl::Window
> pWindow
= VCLUnoHelper::GetWindow( xWindow
);
649 m_aXEditorWindow
->GetBrkWindow().SetNoMarker();
653 BasicDebugFlags
ModulWindow::BasicBreakHdl()
655 // Return value: sal_uInt16 => see SB-Debug-Flags
656 sal_uInt16 nErrorLine
= StarBASIC::GetLine();
659 BreakPoint
* pBrk
= GetBreakPoints().FindBreakPoint( nErrorLine
);
663 if ( pBrk
->nHitCount
<= pBrk
->nStopAfter
&& GetBasic()->IsBreak() )
664 return m_aStatus
.nBasicFlags
; // go on...
667 nErrorLine
--; // EditEngine starts at 0, Basic at 1
669 AssertValidEditEngine();
670 GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine
, 0 ), TextPaM( nErrorLine
, 0 ) ) );
671 m_aXEditorWindow
->GetBrkWindow().SetMarkerPos( nErrorLine
);
673 m_rLayout
.UpdateDebug(false);
675 m_aStatus
.bIsInReschedule
= true;
676 m_aStatus
.bIsRunning
= true;
678 AddStatus( BASWIN_INRESCHEDULE
);
680 InvalidateDebuggerSlots();
682 while( m_aStatus
.bIsRunning
)
683 Application::Yield();
685 m_aStatus
.bIsInReschedule
= false;
686 m_aXEditorWindow
->GetBrkWindow().SetNoMarker();
688 ClearStatus( BASWIN_INRESCHEDULE
);
690 return m_aStatus
.nBasicFlags
;
693 void ModulWindow::BasicAddWatch()
695 AssertValidEditEngine();
697 if ( !GetEditView()->HasSelection() )
699 // tdf#57307 - expand selection to include connector punctuations
701 OUString aWord
= GetEditEngine()->GetWord( GetEditView()->GetSelection().GetEnd(), &aSel
.GetStart(), &aSel
.GetEnd() );
702 if ( !aWord
.isEmpty() )
703 GetEditView()->SetSelection( aSel
);
709 TextSelection aSel
= GetEditView()->GetSelection();
710 if ( aSel
.GetStart().GetPara() == aSel
.GetEnd().GetPara() ) // single line selection
711 m_rLayout
.BasicAddWatch(GetEditView()->GetSelected());
716 void ModulWindow::EditMacro( const OUString
& rMacroName
)
718 DBG_ASSERT( XModule().is(), "No Module!" );
720 if ( !XModule().is() )
725 if ( m_aStatus
.bError
)
728 sal_uInt16 nStart
, nEnd
;
729 SbMethod
* pMethod
= static_cast<SbMethod
*>(m_xModule
->Find( rMacroName
, SbxClassType::Method
));
733 pMethod
->GetLineRange( nStart
, nEnd
);
739 TextSelection
aSel( TextPaM( nStart
, 0 ), TextPaM( nStart
, 0 ) );
740 AssertValidEditEngine();
741 TextView
* pView
= GetEditView();
742 // scroll if applicable so that first line is at the top
743 tools::Long nVisHeight
= GetOutputSizePixel().Height();
744 if ( pView
->GetTextEngine()->GetTextHeight() > nVisHeight
)
746 tools::Long nMaxY
= pView
->GetTextEngine()->GetTextHeight() - nVisHeight
;
747 tools::Long nOldStartY
= pView
->GetStartDocPos().Y();
748 tools::Long nNewStartY
= static_cast<tools::Long
>(nStart
) * pView
->GetTextEngine()->GetCharHeight();
749 nNewStartY
= std::min( nNewStartY
, nMaxY
);
750 pView
->Scroll( 0, -(nNewStartY
-nOldStartY
) );
751 pView
->ShowCursor( false );
752 GetEditVScrollBar().SetThumbPos( pView
->GetStartDocPos().Y() );
754 pView
->SetSelection( aSel
);
756 pView
->GetWindow()->GrabFocus();
759 void ModulWindow::StoreData()
761 // StoreData is called when the BasicManager is destroyed or
762 // this window is closed.
763 // => interrupts undesired!
764 GetEditorWindow().SetSourceInBasic();
767 bool ModulWindow::AllowUndo()
769 return GetEditorWindow().CanModify();
772 void ModulWindow::UpdateData()
774 DBG_ASSERT( XModule().is(), "No Module!" );
775 // UpdateData is called when the source has changed from outside
776 // => interrupts undesired!
778 if ( !XModule().is() )
781 SetModule( m_xModule
->GetSource32() );
785 TextSelection aSel
= GetEditView()->GetSelection();
786 setTextEngineText(*GetEditEngine(), m_xModule
->GetSource32());
787 GetEditView()->SetSelection( aSel
);
788 GetEditEngine()->SetModified( false );
789 MarkDocumentModified( GetDocument() );
793 sal_Int32
ModulWindow::countPages( Printer
* pPrinter
)
795 return FormatAndPrint( pPrinter
, -1 );
798 void ModulWindow::printPage( sal_Int32 nPage
, Printer
* pPrinter
)
800 FormatAndPrint( pPrinter
, nPage
);
803 /* implementation note: this is totally inefficient for the XRenderable interface
804 usage since the whole "document" will be format for every page. Should this ever
805 become a problem we should
806 - format only once for every new printer
807 - keep an index list for each page which is the starting paragraph
809 sal_Int32
ModulWindow::FormatAndPrint( Printer
* pPrinter
, sal_Int32 nPrintPage
)
811 AssertValidEditEngine();
813 MapMode
eOldMapMode( pPrinter
->GetMapMode() );
814 vcl::Font
aOldFont( pPrinter
->GetFont() );
816 vcl::Font
aFont( GetEditEngine()->GetFont() );
817 aFont
.SetAlignment( ALIGN_BOTTOM
);
818 aFont
.SetTransparent( true );
819 aFont
.SetFontSize( Size( 0, 360 ) );
820 pPrinter
->SetFont( aFont
);
821 pPrinter
->SetMapMode(MapMode(MapUnit::Map100thMM
));
823 OUString
aTitle( CreateQualifiedName() );
825 sal_Int32 nLineHeight
= pPrinter
->GetTextHeight();
831 Size aPaperSz
= pPrinter
->GetOutputSize();
832 aPaperSz
.AdjustWidth( -(Print::nLeftMargin
+ Print::nRightMargin
) );
833 aPaperSz
.AdjustHeight( -(Print::nTopMargin
+ Print::nBottomMargin
) );
835 // nLinepPage is not correct if there's a line break
836 sal_Int32 nLinespPage
= aPaperSz
.Height()/nLineHeight
;
837 tools::Long nXTextWidth
= pPrinter
->approximate_digit_width();
839 sal_Int32 nCharspLine
= aPaperSz
.Width() / std::max
<tools::Long
>(nXTextWidth
, 1);
840 const sal_uInt32 nParas
= GetEditEngine()->GetParagraphCount();
842 sal_Int32 nPages
= nParas
/nLinespPage
+1;
843 sal_Int32 nCurPage
= 1;
845 lcl_PrintHeader( pPrinter
, nPages
, nCurPage
, aTitle
, nPrintPage
== 0 );
846 Point
aPos( Print::nLeftMargin
, Print::nTopMargin
);
847 for ( sal_uInt32 nPara
= 0; nPara
< nParas
; ++nPara
)
849 OUString
aLine( GetEditEngine()->GetText( nPara
) );
850 lcl_ConvertTabsToSpaces( aLine
);
851 sal_Int32 nLines
= aLine
.getLength()/nCharspLine
+1;
852 for (sal_Int32 nLine
= 0; nLine
< nLines
; ++nLine
)
854 sal_Int32 nBeginIndex
= nLine
*nCharspLine
;
855 sal_Int32 nCopyCount
= std::min
<sal_Int32
>(nCharspLine
, aLine
.getLength()-nBeginIndex
);
856 OUString aTmpLine
= aLine
.copy(nBeginIndex
, nCopyCount
);
857 aPos
.AdjustY(nLineHeight
);
858 if ( aPos
.Y() > ( aPaperSz
.Height() + Print::nTopMargin
) )
861 lcl_PrintHeader( pPrinter
, nPages
, nCurPage
, aTitle
, nCurPage
-1 == nPrintPage
);
862 aPos
= Point(Print::nLeftMargin
, Print::nTopMargin
+ nLineHeight
);
864 if( nCurPage
-1 == nPrintPage
)
865 pPrinter
->DrawText( aPos
, aTmpLine
);
867 aPos
.AdjustY(10 ); // nParaSpace
870 pPrinter
->SetFont( aOldFont
);
871 pPrinter
->SetMapMode( eOldMapMode
);
876 void ModulWindow::ExecuteCommand (SfxRequest
& rReq
)
878 AssertValidEditEngine();
879 switch (rReq
.GetSlot())
885 KeyEvent
aFakeDelete(0, KEY_DELETE
);
886 (void)GetEditView()->KeyInput(aFakeDelete
);
892 TextSelection
aSel( TextPaM( 0, 0 ), TextPaM( TEXT_PARA_ALL
, TEXT_INDEX_ALL
) );
893 TextView
* pView
= GetEditView();
894 pView
->SetSelection( aSel
);
895 pView
->GetWindow()->GrabFocus();
903 case SID_BASICCOMPILE
:
908 case SID_BASICSTEPOVER
:
913 case SID_BASICSTEPINTO
:
918 case SID_BASICSTEPOUT
:
928 case SID_BASICSAVEAS
:
933 case SID_IMPORT_DIALOG
:
938 case SID_BASICIDE_MATCHGROUP
:
940 GetEditView()->MatchGroup();
943 case SID_BASICIDE_TOGGLEBRKPNT
:
945 BasicToggleBreakPoint();
948 case SID_BASICIDE_MANAGEBRKPNTS
:
953 case SID_BASICIDE_TOGGLEBRKPNTENABLED
:
955 BasicToggleBreakPointEnabled();
958 case SID_BASICIDE_ADDWATCH
:
963 case SID_BASICIDE_REMOVEWATCH
:
965 m_rLayout
.BasicRemoveWatch();
972 GetEditView()->Cut();
973 if (SfxBindings
* pBindings
= GetBindingsPtr())
974 pBindings
->Invalidate( SID_DOC_MODIFIED
);
980 GetEditView()->Copy();
987 GetEditView()->Paste();
988 if (SfxBindings
* pBindings
= GetBindingsPtr())
989 pBindings
->Invalidate( SID_DOC_MODIFIED
);
993 case SID_BASICIDE_BRKPNTSCHANGED
:
995 GetBreakPointWindow().Invalidate();
1000 const SfxBoolItem
* pItem
= rReq
.GetArg
<SfxBoolItem
>(rReq
.GetSlot());
1001 bool bLineNumbers
= pItem
&& pItem
->GetValue();
1002 m_aXEditorWindow
->SetLineNumberDisplay(bLineNumbers
);
1004 std::shared_ptr
<comphelper::ConfigurationChanges
> batch(comphelper::ConfigurationChanges::create());
1005 officecfg::Office::BasicIDE::EditorSettings::LineNumbering::set(bLineNumbers
, batch
);
1009 case SID_BASICIDE_DELETECURRENT
:
1011 if (QueryDelModule(m_aName
, GetFrameWeld()))
1013 // tdf#134551 don't delete the window if last module is removed until this block
1015 VclPtr
<ModulWindow
> xKeepRef(this);
1016 if (m_aDocument
.removeModule(m_aLibName
, m_aName
))
1017 MarkDocumentModified(m_aDocument
);
1021 case FID_SEARCH_OFF
:
1026 GotoLineDialog
aGotoDlg(GetFrameWeld());
1027 if (aGotoDlg
.run() == RET_OK
)
1029 if (sal_Int32
const nLine
= aGotoDlg
.GetLineNumber())
1031 TextSelection
const aSel(TextPaM(nLine
- 1, 0), TextPaM(nLine
- 1, 0));
1032 GetEditView()->SetSelection(aSel
);
1040 void ModulWindow::ExecuteGlobal (SfxRequest
& rReq
)
1042 switch (rReq
.GetSlot())
1046 DocumentSignature
aSignature(m_aDocument
);
1047 if (aSignature
.supportsSignatures())
1049 aSignature
.signScriptingContent(rReq
.GetFrameWeld());
1050 if (SfxBindings
* pBindings
= GetBindingsPtr())
1051 pBindings
->Invalidate(SID_SIGNATURE
);
1058 void ModulWindow::GetState( SfxItemSet
&rSet
)
1060 SfxWhichIter
aIter(rSet
);
1061 for ( sal_uInt16 nWh
= aIter
.FirstWhich(); nWh
!= 0; nWh
= aIter
.NextWhich() )
1067 if ( !GetEditView() || !GetEditView()->HasSelection() )
1068 rSet
.DisableItem( nWh
);
1071 rSet
.DisableItem( nWh
);
1076 if ( !GetEditView() || !GetEditView()->HasSelection() )
1077 rSet
.DisableItem( nWh
);
1082 if ( !IsPasteAllowed() )
1083 rSet
.DisableItem( nWh
);
1086 rSet
.DisableItem( nWh
);
1089 case SID_BASICIDE_STAT_POS
:
1091 TextView
* pView
= GetEditView();
1094 TextSelection aSel
= pView
->GetSelection();
1095 OUString aPos
= IDEResId( RID_STR_LINE
) +
1097 OUString::number(aSel
.GetEnd().GetPara()+1) +
1099 IDEResId( RID_STR_COLUMN
) +
1101 OUString::number(aSel
.GetEnd().GetIndex()+1);
1102 SfxStringItem
aItem( SID_BASICIDE_STAT_POS
, aPos
);
1107 case SID_BASICIDE_STAT_TITLE
:
1109 // search for current procedure name (Sub or Function)
1110 TextView
* pView
= GetEditView();
1115 TextSelection aSel
= pView
->GetSelection();
1117 sal_uInt32 i
= aSel
.GetStart().GetPara();
1120 OUString aCurrLine
= GetEditEngine()->GetText( i
);
1122 if (GetEditorWindow().GetProcedureName(aCurrLine
, sProcType
, sProcName
))
1126 OUString aTitle
= CreateQualifiedName();
1127 if (!sProcName
.isEmpty())
1128 aTitle
+= "." + sProcName
;
1130 SfxStringItem
aTitleItem( SID_BASICIDE_STAT_TITLE
, aTitle
);
1131 rSet
.Put( aTitleItem
);
1135 case SID_ATTR_INSERT
:
1137 TextView
* pView
= GetEditView();
1140 SfxBoolItem
aItem( SID_ATTR_INSERT
, pView
->IsInsertMode() );
1147 bool bLineNumbers
= ::officecfg::Office::BasicIDE::EditorSettings::LineNumbering::get();
1148 rSet
.Put(SfxBoolItem(nWh
, bLineNumbers
));
1153 if ( !GetEditView() )
1154 rSet
.DisableItem( nWh
);
1161 void ModulWindow::DoScroll( ScrollBar
* pCurScrollBar
)
1163 if ( ( pCurScrollBar
== GetHScrollBar() ) && GetEditView() )
1165 // don't scroll with the value but rather use the Thumb-Pos for the VisArea:
1166 tools::Long nDiff
= GetEditView()->GetStartDocPos().X() - pCurScrollBar
->GetThumbPos();
1167 GetEditView()->Scroll( nDiff
, 0 );
1168 GetEditView()->ShowCursor( false );
1169 pCurScrollBar
->SetThumbPos( GetEditView()->GetStartDocPos().X() );
1174 bool ModulWindow::IsModified()
1176 return GetEditEngine() && GetEditEngine()->IsModified();
1179 OUString
ModulWindow::GetSbModuleName()
1181 OUString aModuleName
;
1182 if ( XModule().is() )
1183 aModuleName
= m_xModule
->GetName();
1187 OUString
ModulWindow::GetTitle()
1189 return GetSbModuleName();
1192 void ModulWindow::ShowCursor( bool bOn
)
1194 if ( GetEditEngine() )
1196 TextView
* pView
= GetEditEngine()->GetActiveView();
1200 pView
->ShowCursor();
1202 pView
->HideCursor();
1207 void ModulWindow::AssertValidEditEngine()
1209 if ( !GetEditEngine() )
1210 GetEditorWindow().CreateEditEngine();
1213 void ModulWindow::Activating ()
1215 bool bLineNumbers
= ::officecfg::Office::BasicIDE::EditorSettings::LineNumbering::get();
1216 m_aXEditorWindow
->SetLineNumberDisplay(bLineNumbers
);
1220 void ModulWindow::Deactivating()
1225 sal_uInt16
ModulWindow::StartSearchAndReplace( const SvxSearchItem
& rSearchItem
, bool bFromStart
)
1230 // one could also relinquish syntaxhighlighting/formatting instead of the stupid replace-everything...
1231 AssertValidEditEngine();
1232 TextView
* pView
= GetEditView();
1236 aSel
= pView
->GetSelection();
1237 if ( !rSearchItem
.GetBackward() )
1238 pView
->SetSelection( TextSelection() );
1240 pView
->SetSelection( TextSelection( TextPaM( TEXT_PARA_ALL
, TEXT_INDEX_ALL
), TextPaM( TEXT_PARA_ALL
, TEXT_INDEX_ALL
) ) );
1243 bool const bForward
= !rSearchItem
.GetBackward();
1244 sal_uInt16 nFound
= 0;
1245 if ( ( rSearchItem
.GetCommand() == SvxSearchCmd::FIND
) ||
1246 ( rSearchItem
.GetCommand() == SvxSearchCmd::FIND_ALL
) )
1248 nFound
= pView
->Search( rSearchItem
.GetSearchOptions() , bForward
) ? 1 : 0;
1250 else if ( ( rSearchItem
.GetCommand() == SvxSearchCmd::REPLACE
) ||
1251 ( rSearchItem
.GetCommand() == SvxSearchCmd::REPLACE_ALL
) )
1253 if ( !IsReadOnly() )
1255 bool const bAll
= rSearchItem
.GetCommand() == SvxSearchCmd::REPLACE_ALL
;
1256 nFound
= pView
->Replace( rSearchItem
.GetSearchOptions() , bAll
, bForward
);
1260 if ( bFromStart
&& !nFound
)
1261 pView
->SetSelection( aSel
);
1266 SfxUndoManager
* ModulWindow::GetUndoManager()
1268 if ( GetEditEngine() )
1269 return &GetEditEngine()->GetUndoManager();
1273 SearchOptionFlags
ModulWindow::GetSearchOptions()
1275 SearchOptionFlags nOptions
= SearchOptionFlags::SEARCH
|
1276 SearchOptionFlags::WHOLE_WORDS
|
1277 SearchOptionFlags::BACKWARDS
|
1278 SearchOptionFlags::REG_EXP
|
1279 SearchOptionFlags::EXACT
|
1280 SearchOptionFlags::SELECTION
|
1281 SearchOptionFlags::SIMILARITY
;
1283 if ( !IsReadOnly() )
1285 nOptions
|= SearchOptionFlags::REPLACE
;
1286 nOptions
|= SearchOptionFlags::REPLACE_ALL
;
1292 void ModulWindow::BasicStarted()
1294 if ( !XModule().is() )
1297 m_aStatus
.bIsRunning
= true;
1298 BreakPointList
& rList
= GetBreakPoints();
1301 rList
.ResetHitCount();
1302 rList
.SetBreakPointsInBasic( m_xModule
.get() );
1303 for ( sal_uInt32 nMethod
= 0; nMethod
< m_xModule
->GetMethods()->Count32(); nMethod
++ )
1305 SbMethod
* pMethod
= static_cast<SbMethod
*>(m_xModule
->GetMethods()->Get32( nMethod
));
1306 assert(pMethod
&& "Method not found! (NULL)");
1307 pMethod
->SetDebugFlags( pMethod
->GetDebugFlags() | BasicDebugFlags::Break
);
1312 void ModulWindow::BasicStopped()
1314 m_aStatus
.bIsRunning
= false;
1315 GetBreakPointWindow().SetNoMarker();
1318 EntryDescriptor
ModulWindow::CreateEntryDescriptor()
1320 ScriptDocument
aDocument( GetDocument() );
1321 OUString
aLibName( GetLibName() );
1322 LibraryLocation eLocation
= aDocument
.getLibraryLocation( aLibName
);
1323 OUString
aModName( GetName() );
1324 OUString aLibSubName
;
1325 if( m_xBasic
.is() && aDocument
.isInVBAMode() && XModule().is() )
1327 switch( m_xModule
->GetModuleType() )
1329 case script::ModuleType::DOCUMENT
:
1331 aLibSubName
= IDEResId( RID_STR_DOCUMENT_OBJECTS
);
1332 uno::Reference
< container::XNameContainer
> xLib
= aDocument
.getOrCreateLibrary( E_SCRIPTS
, aLibName
);
1336 ModuleInfoHelper::getObjectName( xLib
, aModName
, sObjName
);
1337 if( !sObjName
.isEmpty() )
1339 aModName
+= " (" + sObjName
+ ")";
1344 case script::ModuleType::FORM
:
1345 aLibSubName
= IDEResId( RID_STR_USERFORMS
);
1347 case script::ModuleType::NORMAL
:
1348 aLibSubName
= IDEResId( RID_STR_NORMAL_MODULES
);
1350 case script::ModuleType::CLASS
:
1351 aLibSubName
= IDEResId( RID_STR_CLASS_MODULES
);
1355 return EntryDescriptor( aDocument
, eLocation
, aLibName
, aLibSubName
, aModName
, OBJ_TYPE_MODULE
);
1358 void ModulWindow::SetReadOnly (bool b
)
1360 if ( GetEditView() )
1361 GetEditView()->SetReadOnly( b
);
1364 bool ModulWindow::IsReadOnly()
1366 return GetEditView() && GetEditView()->IsReadOnly();
1369 bool ModulWindow::IsPasteAllowed()
1371 bool bPaste
= false;
1374 Reference
< datatransfer::clipboard::XClipboard
> xClipboard
= GetClipboard();
1375 if ( xClipboard
.is() )
1378 Reference
< datatransfer::XTransferable
> xTransf
;
1380 SolarMutexReleaser aReleaser
;
1381 // get clipboard content
1382 xTransf
= xClipboard
->getContents();
1386 datatransfer::DataFlavor aFlavor
;
1387 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING
, aFlavor
);
1388 if ( xTransf
->isDataFlavorSupported( aFlavor
) )
1396 void ModulWindow::OnNewDocument ()
1398 bool bLineNumbers
= ::officecfg::Office::BasicIDE::EditorSettings::LineNumbering::get();
1399 m_aXEditorWindow
->SetLineNumberDisplay(bLineNumbers
);
1402 char const* ModulWindow::GetHid () const
1404 return HID_BASICIDE_MODULWINDOW
;
1406 ItemType
ModulWindow::GetType () const
1411 bool ModulWindow::HasActiveEditor () const
1413 return !IsSuspended();
1417 void ModulWindow::UpdateModule ()
1419 OUString
const aModule
= getTextEngineText(*GetEditEngine());
1421 // update module in basic
1422 assert(m_xModule
.is());
1424 // update module in module window
1427 // update module in library
1428 OSL_VERIFY(m_aDocument
.updateModule(m_aLibName
, m_aName
, aModule
));
1430 GetEditEngine()->SetModified(false);
1431 MarkDocumentModified(m_aDocument
);
1434 ModulWindowLayout::ModulWindowLayout (vcl::Window
* pParent
, ObjectCatalog
& rObjectCatalog_
) :
1437 aWatchWindow(VclPtr
<WatchWindow
>::Create(this)),
1438 aStackWindow(VclPtr
<StackWindow
>::Create(this)),
1439 rObjectCatalog(rObjectCatalog_
)
1442 ModulWindowLayout::~ModulWindowLayout()
1447 void ModulWindowLayout::dispose()
1449 aWatchWindow
.disposeAndClear();
1450 aStackWindow
.disposeAndClear();
1455 void ModulWindowLayout::UpdateDebug (bool bBasicStopped
)
1457 aWatchWindow
->UpdateWatches(bBasicStopped
);
1458 aStackWindow
->UpdateCalls();
1461 void ModulWindowLayout::Paint (vcl::RenderContext
& rRenderContext
, tools::Rectangle
const&)
1463 rRenderContext
.DrawText(Point(), IDEResId(RID_STR_NOMODULE
));
1466 void ModulWindowLayout::Activating (BaseWindow
& rChild
)
1468 assert(dynamic_cast<ModulWindow
*>(&rChild
));
1469 pChild
= &static_cast<ModulWindow
&>(rChild
);
1470 aWatchWindow
->Show();
1471 aStackWindow
->Show();
1472 rObjectCatalog
.Show();
1473 rObjectCatalog
.SetLayoutWindow(this);
1474 rObjectCatalog
.UpdateEntries();
1475 Layout::Activating(rChild
);
1476 aSyntaxColors
.SetActiveEditor(&pChild
->GetEditorWindow());
1479 void ModulWindowLayout::Deactivating ()
1481 aSyntaxColors
.SetActiveEditor(nullptr);
1482 Layout::Deactivating();
1483 aWatchWindow
->Hide();
1484 aStackWindow
->Hide();
1485 rObjectCatalog
.Hide();
1489 void ModulWindowLayout::GetState (SfxItemSet
&rSet
, unsigned nWhich
)
1493 case SID_SHOW_PROPERTYBROWSER
:
1494 rSet
.Put(SfxVisibilityItem(nWhich
, false));
1497 case SID_BASICIDE_CHOOSEMACRO
:
1498 rSet
.Put(SfxVisibilityItem(nWhich
, true));
1503 void ModulWindowLayout::BasicAddWatch (OUString
const& rWatchStr
)
1505 aWatchWindow
->AddWatch(rWatchStr
);
1508 void ModulWindowLayout::BasicRemoveWatch ()
1510 aWatchWindow
->RemoveSelectedWatch();
1513 void ModulWindowLayout::OnFirstSize (tools::Long
const nWidth
, tools::Long
const nHeight
)
1515 AddToLeft(&rObjectCatalog
, Size(nWidth
* 0.20, nHeight
* 0.75));
1516 AddToBottom(aWatchWindow
.get(), Size(nWidth
* 0.67, nHeight
* 0.25));
1517 AddToBottom(aStackWindow
.get(), Size(nWidth
* 0.33, nHeight
* 0.25));
1520 ModulWindowLayout::SyntaxColors::SyntaxColors () :
1523 aConfig
.AddListener(this);
1528 ModulWindowLayout::SyntaxColors::~SyntaxColors ()
1530 aConfig
.RemoveListener(this);
1534 void ModulWindowLayout::SyntaxColors::ConfigurationChanged (utl::ConfigurationBroadcaster
*, ConfigurationHints
)
1539 // when a new configuration has to be set
1540 void ModulWindowLayout::SyntaxColors::NewConfig (bool bFirst
)
1544 TokenType eTokenType
;
1545 svtools::ColorConfigEntry eEntry
;
1549 { TokenType::Unknown
, svtools::FONTCOLOR
},
1550 { TokenType::Identifier
, svtools::BASICIDENTIFIER
},
1551 { TokenType::Whitespace
, svtools::FONTCOLOR
},
1552 { TokenType::Number
, svtools::BASICNUMBER
},
1553 { TokenType::String
, svtools::BASICSTRING
},
1554 { TokenType::EOL
, svtools::FONTCOLOR
},
1555 { TokenType::Comment
, svtools::BASICCOMMENT
},
1556 { TokenType::Error
, svtools::BASICERROR
},
1557 { TokenType::Operator
, svtools::BASICOPERATOR
},
1558 { TokenType::Keywords
, svtools::BASICKEYWORD
},
1561 Color aDocColor
= aConfig
.GetColorValue(svtools::DOCCOLOR
).nColor
;
1562 if (bFirst
|| aDocColor
!= m_aBackgroundColor
)
1564 m_aBackgroundColor
= aDocColor
;
1565 if (!bFirst
&& pEditor
)
1567 pEditor
->SetBackground(Wallpaper(m_aBackgroundColor
));
1568 pEditor
->Invalidate();
1572 Color aFontColor
= aConfig
.GetColorValue(svtools::FONTCOLOR
).nColor
;
1573 if (bFirst
|| aFontColor
!= m_aFontColor
)
1575 m_aFontColor
= aFontColor
;
1576 if (!bFirst
&& pEditor
)
1577 pEditor
->ChangeFontColor(m_aFontColor
);
1580 bool bChanged
= false;
1581 for (unsigned i
= 0; i
!= SAL_N_ELEMENTS(vIds
); ++i
)
1583 Color
const aColor
= aConfig
.GetColorValue(vIds
[i
].eEntry
).nColor
;
1584 Color
& rMyColor
= aColors
[vIds
[i
].eTokenType
];
1585 if (bFirst
|| aColor
!= rMyColor
)
1591 if (bChanged
&& !bFirst
&& pEditor
)
1592 pEditor
->UpdateSyntaxHighlighting();
1595 } // namespace basctl
1597 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */