LibreOffice Module basctl (master) 1
baside2.cxx
Go to the documentation of this file.
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 <baside3.hxx>
22#include <basobj.hxx>
23#include <basidesh.hxx>
24#include "brkdlg.hxx"
25#include <iderdll.hxx>
26#include <iderid.hxx>
27#include "moduldlg.hxx"
28#include <docsignature.hxx>
29#include <officecfg/Office/BasicIDE.hxx>
30
31#include <helpids.h>
32#include <strings.hrc>
33
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/XFilePicker3.hpp>
42#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
44#include <comphelper/string.hxx>
45#include <svl/srchdefs.hxx>
46#include <sfx2/bindings.hxx>
47#include <sfx2/docfile.hxx>
49#include <sfx2/request.hxx>
50#include <sfx2/viewfrm.hxx>
51#include <sot/exchange.hxx>
52#include <svl/eitem.hxx>
53#include <svl/srchitem.hxx>
54#include <svl/stritem.hxx>
55#include <svl/visitem.hxx>
56#include <svl/whiter.hxx>
57#include <svx/svxids.hrc>
58#include <tools/debug.hxx>
59#include <utility>
60#include <vcl/locktoplevels.hxx>
61#include <vcl/errinf.hxx>
62#include <vcl/event.hxx>
63#include <vcl/print.hxx>
64#include <vcl/svapp.hxx>
65#include <vcl/textview.hxx>
66#include <vcl/weld.hxx>
67#include <vcl/xtextedt.hxx>
69#include <cassert>
70#include <osl/diagnose.h>
71#include <officecfg/Office/Common.hxx>
72
73namespace basctl
74{
75
76namespace
77{
78
79namespace Print
80{
81 tools::Long const nLeftMargin = 1700;
82 tools::Long const nRightMargin = 900;
83 tools::Long const nTopMargin = 2000;
84 tools::Long const nBottomMargin = 1000;
85 tools::Long const nBorder = 300;
86}
87
88short const ValidWindow = 0x1234;
89
90// What (who) are OW and MTF? Compare to baside3.cxx where an
91// identically named variable, used in the same way, has the value
92// "*.*" on Windows, "*" otherwise. Is that what should be done here,
93// too?
94
95#if defined(OW) || defined(MTF)
96char const FilterMask_All[] = "*";
97#else
98constexpr OUStringLiteral FilterMask_All = u"*.*";
99#endif
100
101} // end anonymous namespace
102
103using namespace ::com::sun::star;
104using namespace ::com::sun::star::uno;
105using namespace ::com::sun::star::ui::dialogs;
106using namespace utl;
107using namespace comphelper;
108
109namespace
110{
111
112void lcl_PrintHeader( Printer* pPrinter, sal_uInt16 nPages, sal_uInt16 nCurPage, const OUString& rTitle, bool bOutput )
113{
114 Size const aSz = pPrinter->GetOutputSize();
115
116 const Color aOldLineColor( pPrinter->GetLineColor() );
117 const Color aOldFillColor( pPrinter->GetFillColor() );
118 const vcl::Font aOldFont( pPrinter->GetFont() );
119
120 pPrinter->SetLineColor( COL_BLACK );
121 pPrinter->SetFillColor();
122
123 vcl::Font aFont( aOldFont );
124 aFont.SetWeight( WEIGHT_BOLD );
125 aFont.SetAlignment( ALIGN_BOTTOM );
126 pPrinter->SetFont( aFont );
127
128 tools::Long nFontHeight = pPrinter->GetTextHeight();
129
130 // 1st Border => line, 2+3 Border = free space
131 tools::Long nYTop = Print::nTopMargin - 3*Print::nBorder - nFontHeight;
132
135
136 if( bOutput )
137 pPrinter->DrawRect(tools::Rectangle(
138 Point(nXLeft, nYTop),
139 Size(nXRight - nXLeft, aSz.Height() - nYTop - Print::nBottomMargin + Print::nBorder)
140 ));
141
142
144 Point aPos(Print::nLeftMargin, nY);
145 if( bOutput )
146 pPrinter->DrawText( aPos, rTitle );
147 if ( nPages != 1 )
148 {
149 aFont.SetWeight( WEIGHT_NORMAL );
150 pPrinter->SetFont( aFont );
151 aPos.AdjustX(pPrinter->GetTextWidth( rTitle ) );
152
153 if( bOutput )
154 {
155 OUString aPageStr = " [" + IDEResId(RID_STR_PAGE) + " " + OUString::number( nCurPage ) + "]";
156 pPrinter->DrawText( aPos, aPageStr );
157 }
158 }
159
161
162 if( bOutput )
163 pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
164
165 pPrinter->SetFont( aOldFont );
166 pPrinter->SetFillColor( aOldFillColor );
167 pPrinter->SetLineColor( aOldLineColor );
168}
169
170void lcl_ConvertTabsToSpaces( OUString& rLine )
171{
172 if ( rLine.isEmpty() )
173 return;
174
175 OUStringBuffer aResult( rLine );
176 sal_Int32 nPos = 0;
177 sal_Int32 nMax = aResult.getLength();
178 while ( nPos < nMax )
179 {
180 if ( aResult[nPos] == '\t' )
181 {
182 // not 4 Blanks, but at 4 TabPos:
183 OUStringBuffer aBlanker;
184 string::padToLength(aBlanker, ( 4 - ( nPos % 4 ) ), ' ');
185 aResult.remove( nPos, 1 );
186 aResult.insert( nPos, aBlanker );
187 nMax = aResult.getLength();
188 }
189 ++nPos;
190 }
191 rLine = aResult.makeStringAndClear();
192}
193
194} // namespace
195
197 const OUString& aLibName, const OUString& aName, OUString aModule)
198 : BaseWindow(pParent, rDocument, aLibName, aName)
199 , m_rLayout(*pParent)
200 , m_nValid(ValidWindow)
201 , m_aXEditorWindow(VclPtr<ComplexEditorWindow>::Create(this))
202 , m_aModule(std::move(aModule))
203{
204 m_aXEditorWindow->Show();
206}
207
209{
210 // ModuleWindows can now be created as a result of the
211 // modules getting created via the api. This is a result of an
212 // elementInserted event from the BasicLibrary container.
213 // However the SbModule is also created from a different listener to
214 // the same event ( in basmgr ) Therefore it is possible when we look
215 // for m_xModule it may not yet be available, here we keep trying to access
216 // the module until such time as it exists
217
218 if ( !m_xModule.is() )
219 {
221 if ( pBasMgr )
222 {
223 StarBASIC* pBasic = pBasMgr->GetLib( GetLibName() );
224 if ( pBasic )
225 {
226 m_xBasic = pBasic;
227 m_xModule = pBasic->FindModule( GetName() );
228 }
229 }
230 }
231 return m_xModule;
232}
233
235{
236 disposeOnce();
237}
238
240{
241 m_nValid = 0;
243 m_aXEditorWindow.disposeAndClear();
245}
246
247
249{
250 if (m_nValid != ValidWindow)
251 return;
252 m_aXEditorWindow->GetEdtWindow().GrabFocus();
253 // don't call basic calls because focus is somewhere else...
254}
255
257{
259}
260
262{
263}
264
266{
267 m_aXEditorWindow->SetPosSizePixel( Point( 0, 0 ), GetOutputSizePixel() );
268}
269
271{
272 if ( !XModule().is() )
273 return;
274
275 // never compile while running!
276 bool const bRunning = StarBASIC::IsRunning();
277 bool const bModified = ( !m_xModule->IsCompiled() ||
278 ( GetEditEngine() && GetEditEngine()->IsModified() ) );
279
280 if ( bRunning || !bModified )
281 return;
282
283 bool bDone = false;
284
286
289
290 bool bWasModified = GetBasic()->IsModified();
291
292 {
293 // tdf#106529: only use strict compilation mode when compiling from the IDE
294 css::uno::ContextLayer layer(comphelper::NewFlagContext("BasicStrict"));
295 bDone = m_xModule->Compile();
296 }
297 if ( !bWasModified )
298 GetBasic()->SetModified(false);
299
300 if ( bDone )
301 {
303 }
304
306
307 m_aStatus.bError = !bDone;
308 m_aStatus.bIsRunning = false;
309}
310
312{
313 // #116444# check security settings before macro execution
315 bool bMacrosDisabled = officecfg::Office::Common::Security::Scripting::DisableMacrosExecution::get();
316 if (bMacrosDisabled || (aDocument.isDocument() && !aDocument.allowMacros()))
317 {
318 std::unique_ptr<weld::MessageDialog> xBox(
319 Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning,
320 VclButtonsType::Ok, IDEResId(RID_STR_CANNOTRUNMACRO)));
321 xBox->run();
322 return;
323 }
324
326
327 if ( !XModule().is() || !m_xModule->IsCompiled() || m_aStatus.bError )
328 return;
329
330 if ( GetBreakPoints().size() )
331 m_aStatus.nBasicFlags = m_aStatus.nBasicFlags | BasicDebugFlags::Break;
332
333 if ( !m_aStatus.bIsRunning )
334 {
335 DBG_ASSERT( m_xModule.is(), "No Module!" );
337 sal_uInt16 nStart, nEnd;
339 // Init cursor to top
340 const sal_uInt32 nCurMethodStart = aSel.GetStart().GetPara() + 1;
341 SbMethod* pMethod = nullptr;
342 // first Macro, else blind "Main" (ExtSearch?)
343 for (sal_uInt32 nMacro = 0; nMacro < m_xModule->GetMethods()->Count(); nMacro++)
344 {
345 SbMethod* pM = static_cast<SbMethod*>(m_xModule->GetMethods()->Get(nMacro));
346 assert(pM && "Method?");
347 pM->GetLineRange( nStart, nEnd );
348 if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd )
349 {
350 // matched a method to the cursor position
351 pMethod = pM;
352 break;
353 }
354 }
355 if ( !pMethod )
356 {
357 // If not in a method then prompt the user
358 ChooseMacro(GetFrameWeld(), uno::Reference<frame::XModel>());
359 return;
360 }
363 RunMethod(pMethod);
365 // if cancelled during Interactive=false
368 }
369 else
370 m_aStatus.bIsRunning = false; // cancel of Reschedule()
371}
372
374{
376
377 XModule().is() && m_xModule->IsCompiled();
378}
379
381{
382 m_aStatus.nBasicFlags = BasicDebugFlags::NONE;
383 BasicExecute();
384}
385
387{
388 m_aStatus.nBasicFlags = BasicDebugFlags::StepInto | BasicDebugFlags::StepOver;
389 BasicExecute();
390}
391
392
394{
395 m_aStatus.nBasicFlags = BasicDebugFlags::StepInto;
396 BasicExecute();
397}
398
400{
401 m_aStatus.nBasicFlags = BasicDebugFlags::StepOut;
402 BasicExecute();
403}
404
405
407{
409 m_aStatus.bIsRunning = false;
410}
411
413{
414 sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
415 FileDialogFlags::NONE, this->GetFrameWeld());
418
419 xFP->appendFilter( "BASIC" , "*.bas" );
420 xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
421 xFP->setCurrentFilter( "BASIC" );
422
423 if( aDlg.Execute() != ERRCODE_NONE )
424 return;
425
426 Sequence< OUString > aPaths = xFP->getSelectedFiles();
427 SfxMedium aMedium( aPaths[0], StreamMode::READ | StreamMode::SHARE_DENYWRITE | StreamMode::NOCREATE );
428 SvStream* pStream = aMedium.GetInStream();
429 if ( pStream )
430 {
432 sal_uInt32 nLines = CalcLineCount( *pStream );
433 // nLines*4: ReadText/Formatting/Highlighting/Formatting
434 GetEditorWindow().CreateProgress( IDEResId(RID_STR_GENERATESOURCE), nLines*4 );
435 GetEditEngine()->SetUpdateMode( false );
436 // tdf#139196 - import macros using either default or utf-8 text encoding
437 pStream->StartReadingUnicodeText(RTL_TEXTENCODING_UTF8);
438 if (pStream->Tell() == 3)
439 pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
440 GetEditView()->Read( *pStream );
441 GetEditEngine()->SetUpdateMode( true );
445 ErrCode nError = aMedium.GetError();
446 if ( nError )
448 }
449 else
450 {
451 std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(GetFrameWeld(),
452 VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTREAD)));
453 xBox->run();
454 }
455}
456
457
459{
460 sfx2::FileDialogHelper aDlg(ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
461 FileDialogFlags::NONE, this->GetFrameWeld());
463 const Reference<XFilePicker3>& xFP = aDlg.GetFilePicker();
464
465 xFP.queryThrow<XFilePickerControlAccess>()->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, Any(true));
466
467 xFP->appendFilter( "BASIC", "*.bas" );
468 xFP->appendFilter( IDEResId(RID_STR_FILTER_ALLFILES), FilterMask_All );
469 xFP->setCurrentFilter( "BASIC" );
470
471 if( aDlg.Execute() != ERRCODE_NONE )
472 return;
473
474 Sequence< OUString > aPaths = xFP->getSelectedFiles();
475 SfxMedium aMedium( aPaths[0], StreamMode::WRITE | StreamMode::SHARE_DENYWRITE | StreamMode::TRUNC );
476 SvStream* pStream = aMedium.GetOutStream();
477 if ( pStream )
478 {
479 EnterWait();
481 // tdf#139196 - export macros using utf-8 including BOM
482 pStream->SetStreamCharSet(RTL_TEXTENCODING_UTF8);
483 pStream->WriteUChar(0xEF).WriteUChar(0xBB).WriteUChar(0xBF);
484 GetEditEngine()->Write( *pStream );
485 aMedium.Commit();
486 LeaveWait();
487 ErrCode nError = aMedium.GetError();
488 if ( nError )
490 }
491 else
492 {
493 std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(GetFrameWeld(),
494 VclMessageType::Warning, VclButtonsType::Ok, IDEResId(RID_STR_COULDNTWRITE)));
495 xErrorBox->run();
496 }
497}
498
500{
501 const ScriptDocument& rDocument = GetDocument();
502 OUString aLibName = GetLibName();
503 implImportDialog(GetFrameWeld(), rDocument, aLibName);
504}
505
506void ModulWindow::ToggleBreakPoint( sal_uInt16 nLine )
507{
508 DBG_ASSERT( XModule().is(), "No Module!" );
509
510 if ( !XModule().is() )
511 return;
512
514 if ( m_aStatus.bError )
515 {
516 return;
517 }
518
519 BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine );
520 if ( pBrk ) // remove
521 {
522 m_xModule->ClearBP( nLine );
523 GetBreakPoints().remove( pBrk );
524 }
525 else // create one
526 {
527 if ( m_xModule->SetBP( nLine ))
528 {
530 if ( StarBASIC::IsRunning() )
531 {
532 for (sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count(); nMethod++)
533 {
534 SbMethod* pMethod
535 = static_cast<SbMethod*>(m_xModule->GetMethods()->Get(nMethod));
536 assert(pMethod && "Method not found! (NULL)");
537 pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break );
538 }
539 }
540 }
541 }
542}
543
545{
546 DBG_ASSERT( XModule().is(), "No Module!" );
547
548 if ( XModule().is() )
549 {
551
552 if ( rBrk.bEnabled )
553 m_xModule->SetBP( rBrk.nLine );
554 else
555 m_xModule->ClearBP( rBrk.nLine );
556 }
557}
558
559
561{
563
565 aSel.GetStart().GetPara()++; // Basic lines start at 1!
566 aSel.GetEnd().GetPara()++;
567
568 for ( sal_uInt32 nLine = aSel.GetStart().GetPara(); nLine <= aSel.GetEnd().GetPara(); ++nLine )
569 {
570 ToggleBreakPoint( nLine );
571 }
572
573 m_aXEditorWindow->GetBrkWindow().Invalidate();
574}
575
576
578{
580
581 TextView* pView = GetEditView();
582 if ( !pView )
583 return;
584
585 TextSelection aSel = pView->GetSelection();
587
588 for ( sal_uInt32 nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine )
589 {
590 BreakPoint* pBrk = rList.FindBreakPoint( nLine );
591 if ( pBrk )
592 {
593 pBrk->bEnabled = !pBrk->bEnabled;
594 UpdateBreakPoint( *pBrk );
595 }
596 }
597
599}
600
602{
604 BreakPointDialog aBrkDlg(rBrkWin.GetFrameWeld(), GetBreakPoints());
605 aBrkDlg.run();
606 rBrkWin.Invalidate();
607}
608
610{
612
613 // Return value: BOOL
614 // FALSE: cancel
615 // TRUE: go on...
616 sal_uInt16 nErrorLine = StarBASIC::GetLine() - 1;
617 sal_uInt16 nErrCol1 = StarBASIC::GetCol1();
618 sal_uInt16 nErrCol2 = StarBASIC::GetCol2();
619 if ( nErrCol2 != 0xFFFF )
620 nErrCol2++;
621
623 GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, nErrCol1 ), TextPaM( nErrorLine, nErrCol2 ) ) );
624
625 // if other basic, the IDE should try to display the correct module
626 bool const bMarkError = pBasic == GetBasic();
627 if ( bMarkError )
628 m_aXEditorWindow->GetBrkWindow().SetMarkerPos(nErrorLine, true);
629
630 // #i47002#
632
633 // tdf#118572 make a currently running dialog, regardless of what its modal
634 // to, insensitive to user input until after this error dialog goes away.
636 aBusy.incBusy(nullptr);
637
639
640 aBusy.decBusy();
641
642 // #i47002#
643 VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( xWindow );
644 if ( !pWindow )
645 return;
646
647 if ( bMarkError )
648 m_aXEditorWindow->GetBrkWindow().SetNoMarker();
649 return;
650}
651
653{
654 // Return value: sal_uInt16 => see SB-Debug-Flags
655 sal_uInt16 nErrorLine = StarBASIC::GetLine();
656
657
658 BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nErrorLine );
659 if ( pBrk )
660 {
661 pBrk->nHitCount++;
662 if ( pBrk->nHitCount <= pBrk->nStopAfter && GetBasic()->IsBreak() )
663 return m_aStatus.nBasicFlags; // go on...
664 }
665
666 nErrorLine--; // EditEngine starts at 0, Basic at 1
667
669 GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, 0 ), TextPaM( nErrorLine, 0 ) ) );
670 m_aXEditorWindow->GetBrkWindow().SetMarkerPos( nErrorLine );
671
672 m_rLayout.UpdateDebug(false);
673
675 m_aStatus.bIsRunning = true;
676
678
680
683
685 m_aXEditorWindow->GetBrkWindow().SetNoMarker();
686
688
689 return m_aStatus.nBasicFlags;
690}
691
693{
695 bool bAdd = true;
696 if ( !GetEditView()->HasSelection() )
697 {
698 // tdf#57307 - expand selection to include connector punctuations
699 TextSelection aSel;
700 OUString aWord = GetEditEngine()->GetWord( GetEditView()->GetSelection().GetEnd(), &aSel.GetStart(), &aSel.GetEnd() );
701 if ( !aWord.isEmpty() )
702 GetEditView()->SetSelection( aSel );
703 else
704 bAdd = false;
705 }
706 if ( bAdd )
707 {
709 if ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() ) // single line selection
710 m_rLayout.BasicAddWatch(GetEditView()->GetSelected());
711 }
712}
713
714
715void ModulWindow::EditMacro( const OUString& rMacroName )
716{
717 DBG_ASSERT( XModule().is(), "No Module!" );
718
719 if ( !XModule().is() )
720 return;
721
723
724 if ( m_aStatus.bError )
725 return;
726
727 sal_uInt16 nStart, nEnd;
728 SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->Find( rMacroName, SbxClassType::Method ));
729 if ( !pMethod )
730 return;
731
732 pMethod->GetLineRange( nStart, nEnd );
733 if ( nStart )
734 {
735 nStart--;
736 nEnd--;
737 }
738 TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) );
740 TextView * pView = GetEditView();
741 // scroll if applicable so that first line is at the top
742 tools::Long nVisHeight = GetOutputSizePixel().Height();
743 if ( pView->GetTextEngine()->GetTextHeight() > nVisHeight )
744 {
745 tools::Long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight;
746 tools::Long nOldStartY = pView->GetStartDocPos().Y();
747 tools::Long nNewStartY = static_cast<tools::Long>(nStart) * pView->GetTextEngine()->GetCharHeight();
748 nNewStartY = std::min( nNewStartY, nMaxY );
749 pView->Scroll( 0, -(nNewStartY-nOldStartY) );
750 pView->ShowCursor( false );
752 }
753 pView->SetSelection( aSel );
754 pView->ShowCursor();
755 pView->GetWindow()->GrabFocus();
756}
757
759{
760 // StoreData is called when the BasicManager is destroyed or
761 // this window is closed.
762 // => interrupts undesired!
764}
765
767{
768 return GetEditorWindow().CanModify();
769}
770
772{
773 DBG_ASSERT( XModule().is(), "No Module!" );
774 // UpdateData is called when the source has changed from outside
775 // => interrupts undesired!
776
777 if ( !XModule().is() )
778 return;
779
780 SetModule( m_xModule->GetSource32() );
781
782 if ( GetEditView() )
783 {
785 setTextEngineText(*GetEditEngine(), m_xModule->GetSource32());
786 GetEditView()->SetSelection( aSel );
787 GetEditEngine()->SetModified( false );
789 }
790}
791
792sal_Int32 ModulWindow::countPages( Printer* pPrinter )
793{
794 return FormatAndPrint( pPrinter, -1 );
795}
796
797void ModulWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
798{
799 FormatAndPrint( pPrinter, nPage );
800}
801
802/* implementation note: this is totally inefficient for the XRenderable interface
803 usage since the whole "document" will be format for every page. Should this ever
804 become a problem we should
805 - format only once for every new printer
806 - keep an index list for each page which is the starting paragraph
807*/
808sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
809{
811
812 MapMode eOldMapMode( pPrinter->GetMapMode() );
813 vcl::Font aOldFont( pPrinter->GetFont() );
814
815 vcl::Font aFont( GetEditEngine()->GetFont() );
816 aFont.SetAlignment( ALIGN_BOTTOM );
817 aFont.SetTransparent( true );
818 aFont.SetFontSize( Size( 0, 360 ) );
819 pPrinter->SetFont( aFont );
820 pPrinter->SetMapMode(MapMode(MapUnit::Map100thMM));
821
822 OUString aTitle( CreateQualifiedName() );
823
824 sal_Int32 nLineHeight = pPrinter->GetTextHeight();
825 if(nLineHeight == 0)
826 {
827 nLineHeight = 1;
828 }
829
830 Size aPaperSz = pPrinter->GetOutputSize();
833
834 // nLinepPage is not correct if there's a line break
835 sal_Int32 nLinespPage = aPaperSz.Height()/nLineHeight;
836 tools::Long nXTextWidth = pPrinter->approximate_digit_width();
837
838 sal_Int32 nCharspLine = aPaperSz.Width() / std::max<tools::Long>(nXTextWidth, 1);
839 const sal_uInt32 nParas = GetEditEngine()->GetParagraphCount();
840
841 sal_Int32 nPages = nParas/nLinespPage+1;
842 sal_Int32 nCurPage = 1;
843
844 lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 );
846 for ( sal_uInt32 nPara = 0; nPara < nParas; ++nPara )
847 {
848 OUString aLine( GetEditEngine()->GetText( nPara ) );
849 lcl_ConvertTabsToSpaces( aLine );
850 sal_Int32 nLines = aLine.getLength()/nCharspLine+1;
851 for (sal_Int32 nLine = 0; nLine < nLines; ++nLine)
852 {
853 sal_Int32 nBeginIndex = nLine*nCharspLine;
854 sal_Int32 nCopyCount = std::min<sal_Int32>(nCharspLine, aLine.getLength()-nBeginIndex);
855 OUString aTmpLine = aLine.copy(nBeginIndex, nCopyCount);
856 aPos.AdjustY(nLineHeight );
857 if ( aPos.Y() > ( aPaperSz.Height() + Print::nTopMargin ) )
858 {
859 nCurPage++;
860 lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nCurPage-1 == nPrintPage );
861 aPos = Point(Print::nLeftMargin, Print::nTopMargin + nLineHeight);
862 }
863 if( nCurPage-1 == nPrintPage )
864 pPrinter->DrawText( aPos, aTmpLine );
865 }
866 aPos.AdjustY(10 ); // nParaSpace
867 }
868
869 pPrinter->SetFont( aOldFont );
870 pPrinter->SetMapMode( eOldMapMode );
871
872 return nCurPage;
873}
874
876{
878 switch (rReq.GetSlot())
879 {
880 case SID_DELETE:
881 {
882 if (!IsReadOnly())
883 {
884 KeyEvent aFakeDelete(0, KEY_DELETE);
885 (void)GetEditView()->KeyInput(aFakeDelete);
886 }
887 break;
888 }
889 case SID_SELECTALL:
890 {
892 TextView * pView = GetEditView();
893 pView->SetSelection( aSel );
894 pView->GetWindow()->GrabFocus();
895 break;
896 }
897 case SID_BASICRUN:
898 {
899 BasicRun();
900 }
901 break;
902 case SID_BASICCOMPILE:
903 {
904 CompileBasic();
905 }
906 break;
907 case SID_BASICSTEPOVER:
908 {
910 }
911 break;
912 case SID_BASICSTEPINTO:
913 {
915 }
916 break;
917 case SID_BASICSTEPOUT:
918 {
919 BasicStepOut();
920 }
921 break;
922 case SID_BASICLOAD:
923 {
924 LoadBasic();
925 }
926 break;
927 case SID_BASICSAVEAS:
928 {
930 }
931 break;
932 case SID_IMPORT_DIALOG:
933 {
934 ImportDialog();
935 }
936 break;
937 case SID_BASICIDE_MATCHGROUP:
938 {
940 }
941 break;
942 case SID_BASICIDE_TOGGLEBRKPNT:
943 {
945 }
946 break;
947 case SID_BASICIDE_MANAGEBRKPNTS:
948 {
950 }
951 break;
952 case SID_BASICIDE_TOGGLEBRKPNTENABLED:
953 {
955 }
956 break;
957 case SID_BASICIDE_ADDWATCH:
958 {
960 }
961 break;
962 case SID_BASICIDE_REMOVEWATCH:
963 {
965 }
966 break;
967 case SID_CUT:
968 {
969 if ( !IsReadOnly() )
970 {
971 GetEditView()->Cut();
972 if (SfxBindings* pBindings = GetBindingsPtr())
973 pBindings->Invalidate( SID_DOC_MODIFIED );
974 }
975 }
976 break;
977 case SID_COPY:
978 {
979 GetEditView()->Copy();
980 }
981 break;
982 case SID_PASTE:
983 {
984 if ( !IsReadOnly() )
985 {
986 GetEditView()->Paste();
987 if (SfxBindings* pBindings = GetBindingsPtr())
988 pBindings->Invalidate( SID_DOC_MODIFIED );
989 }
990 }
991 break;
992 case SID_BASICIDE_BRKPNTSCHANGED:
993 {
995 }
996 break;
997 case SID_SHOWLINES:
998 {
999 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(rReq.GetSlot());
1000 bool bLineNumbers = pItem && pItem->GetValue();
1001 m_aXEditorWindow->SetLineNumberDisplay(bLineNumbers);
1002
1003 std::shared_ptr<comphelper::ConfigurationChanges> batch(comphelper::ConfigurationChanges::create());
1004 officecfg::Office::BasicIDE::EditorSettings::LineNumbering::set(bLineNumbers, batch);
1005 batch->commit();
1006 }
1007 break;
1008 case SID_BASICIDE_DELETECURRENT:
1009 {
1011 {
1012 // tdf#134551 don't delete the window if last module is removed until this block
1013 // is complete
1014 VclPtr<ModulWindow> xKeepRef(this);
1017 }
1018 }
1019 break;
1020 case FID_SEARCH_OFF:
1021 GrabFocus();
1022 break;
1023 case SID_GOTOLINE:
1024 {
1025 GotoLineDialog aGotoDlg(GetFrameWeld());
1026 if (aGotoDlg.run() == RET_OK)
1027 {
1028 if (sal_Int32 const nLine = aGotoDlg.GetLineNumber())
1029 {
1030 TextSelection const aSel(TextPaM(nLine - 1, 0), TextPaM(nLine - 1, 0));
1031 GetEditView()->SetSelection(aSel);
1032 }
1033 }
1034 break;
1035 }
1036 }
1037}
1038
1040{
1041 switch (rReq.GetSlot())
1042 {
1043 case SID_SIGNATURE:
1044 {
1045 DocumentSignature aSignature(m_aDocument);
1046 if (aSignature.supportsSignatures())
1047 {
1048 aSignature.signScriptingContent(rReq.GetFrameWeld());
1049 if (SfxBindings* pBindings = GetBindingsPtr())
1050 pBindings->Invalidate(SID_SIGNATURE);
1051 }
1052 }
1053 break;
1054 }
1055}
1056
1058{
1059 SfxWhichIter aIter(rSet);
1060 for ( sal_uInt16 nWh = aIter.FirstWhich(); nWh != 0; nWh = aIter.NextWhich() )
1061 {
1062 switch ( nWh )
1063 {
1064 case SID_CUT:
1065 {
1066 if ( !GetEditView() || !GetEditView()->HasSelection() )
1067 rSet.DisableItem( nWh );
1068
1069 if ( IsReadOnly() )
1070 rSet.DisableItem( nWh );
1071 }
1072 break;
1073 case SID_COPY:
1074 {
1075 if ( !GetEditView() || !GetEditView()->HasSelection() )
1076 rSet.DisableItem( nWh );
1077 }
1078 break;
1079 case SID_PASTE:
1080 {
1081 if ( !IsPasteAllowed() )
1082 rSet.DisableItem( nWh );
1083
1084 if ( IsReadOnly() )
1085 rSet.DisableItem( nWh );
1086 }
1087 break;
1088 case SID_BASICIDE_STAT_POS:
1089 {
1090 TextView* pView = GetEditView();
1091 if ( pView )
1092 {
1093 TextSelection aSel = pView->GetSelection();
1094 OUString aPos = IDEResId( RID_STR_LINE ) +
1095 " " +
1096 OUString::number(aSel.GetEnd().GetPara()+1) +
1097 ", " +
1098 IDEResId( RID_STR_COLUMN ) +
1099 " " +
1100 OUString::number(aSel.GetEnd().GetIndex()+1);
1101 SfxStringItem aItem( SID_BASICIDE_STAT_POS, aPos );
1102 rSet.Put( aItem );
1103 }
1104 }
1105 break;
1106 case SID_BASICIDE_STAT_TITLE:
1107 {
1108 // search for current procedure name (Sub or Function)
1109 TextView* pView = GetEditView();
1110 if ( pView )
1111 {
1112 OUString sProcName;
1113
1114 TextSelection aSel = pView->GetSelection();
1115
1116 sal_uInt32 i = aSel.GetStart().GetPara();
1117 do
1118 {
1119 OUString aCurrLine = GetEditEngine()->GetText( i );
1120 OUString sProcType;
1121 if (GetEditorWindow().GetProcedureName(aCurrLine, sProcType, sProcName))
1122 break;
1123 } while (i--);
1124
1125 OUString aTitle = CreateQualifiedName();
1126 if (!sProcName.isEmpty())
1127 aTitle += "." + sProcName;
1128
1129 if (IsReadOnly())
1130 aTitle += " (" + IDEResId(RID_STR_READONLY) + ")";
1131
1132 SfxStringItem aTitleItem( SID_BASICIDE_STAT_TITLE, aTitle );
1133 rSet.Put( aTitleItem );
1134 }
1135 }
1136 break;
1137 case SID_ATTR_INSERT:
1138 {
1139 TextView* pView = GetEditView();
1140 if ( pView )
1141 {
1142 SfxBoolItem aItem( SID_ATTR_INSERT, pView->IsInsertMode() );
1143 rSet.Put( aItem );
1144 }
1145 }
1146 break;
1147 case SID_SHOWLINES:
1148 {
1149 bool bLineNumbers = ::officecfg::Office::BasicIDE::EditorSettings::LineNumbering::get();
1150 rSet.Put(SfxBoolItem(nWh, bLineNumbers));
1151 break;
1152 }
1153 case SID_SELECTALL:
1154 {
1155 if ( !GetEditView() )
1156 rSet.DisableItem( nWh );
1157 }
1158 break;
1159 }
1160 }
1161}
1162
1163void ModulWindow::DoScroll( Scrollable* pCurScrollBar )
1164{
1165 if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
1166 {
1167 // don't scroll with the value but rather use the Thumb-Pos for the VisArea:
1168 tools::Long nDiff = GetEditView()->GetStartDocPos().X() - pCurScrollBar->GetThumbPos();
1169 GetEditView()->Scroll( nDiff, 0 );
1170 GetEditView()->ShowCursor( false );
1171 pCurScrollBar->SetThumbPos( GetEditView()->GetStartDocPos().X() );
1172
1173 }
1174}
1175
1177{
1178 return GetEditEngine() && GetEditEngine()->IsModified();
1179}
1180
1182{
1183 OUString aModuleName;
1184 if ( XModule().is() )
1185 aModuleName = m_xModule->GetName();
1186 return aModuleName;
1187}
1188
1190{
1191 return GetSbModuleName();
1192}
1193
1195{
1196 if ( GetEditEngine() )
1197 {
1198 TextView* pView = GetEditEngine()->GetActiveView();
1199 if ( pView )
1200 {
1201 if ( bOn )
1202 pView->ShowCursor();
1203 else
1204 pView->HideCursor();
1205 }
1206 }
1207}
1208
1210{
1211 if ( !GetEditEngine() )
1213}
1214
1216{
1217 bool bLineNumbers = ::officecfg::Office::BasicIDE::EditorSettings::LineNumbering::get();
1218 m_aXEditorWindow->SetLineNumberDisplay(bLineNumbers);
1219 Show();
1220}
1221
1223{
1224 Hide();
1225}
1226
1227sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem, bool bFromStart )
1228{
1229 if (IsSuspended())
1230 return 0;
1231
1232 // one could also relinquish syntaxhighlighting/formatting instead of the stupid replace-everything...
1234 TextView* pView = GetEditView();
1235 TextSelection aSel;
1236 if ( bFromStart )
1237 {
1238 aSel = pView->GetSelection();
1239 if ( !rSearchItem.GetBackward() )
1240 pView->SetSelection( TextSelection() );
1241 else
1243 }
1244
1245 bool const bForward = !rSearchItem.GetBackward();
1246 sal_uInt16 nFound = 0;
1247 if ( ( rSearchItem.GetCommand() == SvxSearchCmd::FIND ) ||
1248 ( rSearchItem.GetCommand() == SvxSearchCmd::FIND_ALL ) )
1249 {
1250 nFound = pView->Search( rSearchItem.GetSearchOptions() , bForward ) ? 1 : 0;
1251 }
1252 else if ( ( rSearchItem.GetCommand() == SvxSearchCmd::REPLACE ) ||
1253 ( rSearchItem.GetCommand() == SvxSearchCmd::REPLACE_ALL ) )
1254 {
1255 if ( !IsReadOnly() )
1256 {
1257 bool const bAll = rSearchItem.GetCommand() == SvxSearchCmd::REPLACE_ALL;
1258 nFound = pView->Replace( rSearchItem.GetSearchOptions() , bAll , bForward );
1259 }
1260 }
1261
1262 if ( bFromStart && !nFound )
1263 pView->SetSelection( aSel );
1264
1265 return nFound;
1266}
1267
1269{
1270 if ( GetEditEngine() )
1271 return &GetEditEngine()->GetUndoManager();
1272 return nullptr;
1273}
1274
1276{
1277 SearchOptionFlags nOptions = SearchOptionFlags::SEARCH |
1278 SearchOptionFlags::WHOLE_WORDS |
1279 SearchOptionFlags::BACKWARDS |
1280 SearchOptionFlags::REG_EXP |
1281 SearchOptionFlags::EXACT |
1282 SearchOptionFlags::SELECTION |
1283 SearchOptionFlags::SIMILARITY;
1284
1285 if ( !IsReadOnly() )
1286 {
1287 nOptions |= SearchOptionFlags::REPLACE;
1288 nOptions |= SearchOptionFlags::REPLACE_ALL;
1289 }
1290
1291 return nOptions;
1292}
1293
1295{
1296 if ( !XModule().is() )
1297 return;
1298
1299 m_aStatus.bIsRunning = true;
1300 BreakPointList& rList = GetBreakPoints();
1301 if ( rList.size() )
1302 {
1303 rList.ResetHitCount();
1305 for (sal_uInt32 nMethod = 0; nMethod < m_xModule->GetMethods()->Count(); nMethod++)
1306 {
1307 SbMethod* pMethod = static_cast<SbMethod*>(m_xModule->GetMethods()->Get(nMethod));
1308 assert(pMethod && "Method not found! (NULL)");
1309 pMethod->SetDebugFlags( pMethod->GetDebugFlags() | BasicDebugFlags::Break );
1310 }
1311 }
1312}
1313
1315{
1316 m_aStatus.bIsRunning = false;
1318}
1319
1321{
1323 OUString aLibName( GetLibName() );
1324 LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
1325 OUString aModName( GetName() );
1326 OUString aLibSubName;
1327 if( m_xBasic.is() && aDocument.isInVBAMode() && XModule().is() )
1328 {
1329 switch( m_xModule->GetModuleType() )
1330 {
1331 case script::ModuleType::DOCUMENT:
1332 {
1333 aLibSubName = IDEResId( RID_STR_DOCUMENT_OBJECTS );
1334 uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
1335 if( xLib.is() )
1336 {
1337 OUString sObjName;
1338 ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
1339 if( !sObjName.isEmpty() )
1340 {
1341 aModName += " (" + sObjName + ")";
1342 }
1343 }
1344 break;
1345 }
1346 case script::ModuleType::FORM:
1347 aLibSubName = IDEResId( RID_STR_USERFORMS );
1348 break;
1349 case script::ModuleType::NORMAL:
1350 aLibSubName = IDEResId( RID_STR_NORMAL_MODULES );
1351 break;
1352 case script::ModuleType::CLASS:
1353 aLibSubName = IDEResId( RID_STR_CLASS_MODULES );
1354 break;
1355 }
1356 }
1357 return EntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE );
1358}
1359
1361{
1362 if ( GetEditView() )
1363 GetEditView()->SetReadOnly( b );
1364}
1365
1367{
1368 return GetEditView() && GetEditView()->IsReadOnly();
1369}
1370
1372{
1373 bool bPaste = false;
1374
1375 // get clipboard
1377 if ( xClipboard.is() )
1378 {
1379
1380 Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
1381 if ( xTransf.is() )
1382 {
1383 datatransfer::DataFlavor aFlavor;
1384 SotExchange::GetFormatDataFlavor( SotClipboardFormatId::STRING, aFlavor );
1385 if ( xTransf->isDataFlavorSupported( aFlavor ) )
1386 bPaste = true;
1387 }
1388 }
1389
1390 return bPaste;
1391}
1392
1394{
1395 bool bLineNumbers = ::officecfg::Office::BasicIDE::EditorSettings::LineNumbering::get();
1396 m_aXEditorWindow->SetLineNumberDisplay(bLineNumbers);
1397}
1398
1399OUString ModulWindow::GetHid () const
1400{
1402}
1404{
1405 return TYPE_MODULE;
1406}
1407
1409{
1410 return !IsSuspended();
1411}
1412
1413
1415{
1416 OUString const aModule = getTextEngineText(*GetEditEngine());
1417
1418 // update module in basic
1419 assert(m_xModule.is());
1420
1421 // update module in module window
1422 SetModule(aModule);
1423
1424 // update module in library
1425 OSL_VERIFY(m_aDocument.updateModule(m_aLibName, m_aName, aModule));
1426
1427 GetEditEngine()->SetModified(false);
1429}
1430
1432 Layout(pParent),
1433 pChild(nullptr),
1434 aWatchWindow(VclPtr<WatchWindow>::Create(this)),
1435 aStackWindow(VclPtr<StackWindow>::Create(this)),
1436 rObjectCatalog(rObjectCatalog_)
1437{ }
1438
1440{
1441 disposeOnce();
1442}
1443
1445{
1446 aWatchWindow.disposeAndClear();
1447 aStackWindow.disposeAndClear();
1448 pChild.clear();
1450}
1451
1452void ModulWindowLayout::UpdateDebug (bool bBasicStopped)
1453{
1454 aWatchWindow->UpdateWatches(bBasicStopped);
1455 aStackWindow->UpdateCalls();
1456}
1457
1459{
1460 rRenderContext.DrawText(Point(), IDEResId(RID_STR_NOMODULE));
1461}
1462
1464{
1465 assert(dynamic_cast<ModulWindow*>(&rChild));
1466 pChild = &static_cast<ModulWindow&>(rChild);
1467 aWatchWindow->Show();
1468 aStackWindow->Show();
1472 Layout::Activating(rChild);
1473 aSyntaxColors.SetActiveEditor(&pChild->GetEditorWindow());
1474}
1475
1477{
1480 aWatchWindow->Hide();
1481 aStackWindow->Hide();
1483 pChild = nullptr;
1484}
1485
1486void ModulWindowLayout::GetState (SfxItemSet &rSet, unsigned nWhich)
1487{
1488 switch (nWhich)
1489 {
1490 case SID_SHOW_PROPERTYBROWSER:
1491 rSet.Put(SfxVisibilityItem(nWhich, false));
1492 break;
1493
1494 case SID_BASICIDE_CHOOSEMACRO:
1495 rSet.Put(SfxVisibilityItem(nWhich, true));
1496 break;
1497 }
1498}
1499
1500void ModulWindowLayout::BasicAddWatch (OUString const& rWatchStr)
1501{
1502 aWatchWindow->AddWatch(rWatchStr);
1503}
1504
1506{
1507 aWatchWindow->RemoveSelectedWatch();
1508}
1509
1511{
1512 aWatchWindow->Show(bVisible);
1514}
1515
1517{
1518 aStackWindow->Show(bVisible);
1520}
1521
1523{
1524 AddToLeft(&rObjectCatalog, Size(nWidth * 0.20, nHeight * 0.75));
1525 AddToBottom(aWatchWindow.get(), Size(nWidth * 0.67, nHeight * 0.25));
1526 AddToBottom(aStackWindow.get(), Size(nWidth * 0.33, nHeight * 0.25));
1527}
1528
1530 pEditor(nullptr)
1531{
1532 aConfig.AddListener(this);
1533
1534 NewConfig(true);
1535}
1536
1538{
1539 aConfig.RemoveListener(this);
1540}
1541
1542// virtual
1544{
1545 NewConfig(false);
1546}
1547
1548// when a new configuration has to be set
1550{
1551 static struct
1552 {
1553 TokenType eTokenType;
1555 }
1556 const vIds[] =
1557 {
1558 { TokenType::Unknown, svtools::FONTCOLOR },
1559 { TokenType::Identifier, svtools::BASICIDENTIFIER },
1560 { TokenType::Whitespace, svtools::FONTCOLOR },
1561 { TokenType::Number, svtools::BASICNUMBER },
1562 { TokenType::String, svtools::BASICSTRING },
1563 { TokenType::EOL, svtools::FONTCOLOR },
1564 { TokenType::Comment, svtools::BASICCOMMENT },
1565 { TokenType::Error, svtools::BASICERROR },
1566 { TokenType::Operator, svtools::BASICOPERATOR },
1567 { TokenType::Keywords, svtools::BASICKEYWORD },
1568 };
1569
1570 Color aDocColor = aConfig.GetColorValue(svtools::BASICEDITOR).nColor;
1571 if (bFirst || aDocColor != m_aBackgroundColor)
1572 {
1573 m_aBackgroundColor = aDocColor;
1574 if (!bFirst && pEditor)
1575 {
1576 pEditor->SetBackground(Wallpaper(m_aBackgroundColor));
1577 pEditor->Invalidate();
1578 }
1579 }
1580
1581 Color aFontColor = aConfig.GetColorValue(svtools::FONTCOLOR).nColor;
1582 if (bFirst || aFontColor != m_aFontColor)
1583 {
1584 m_aFontColor = aFontColor;
1585 if (!bFirst && pEditor)
1586 pEditor->ChangeFontColor(m_aFontColor);
1587 }
1588
1589 bool bChanged = false;
1590 for (const auto& vId: vIds)
1591 {
1592 Color const aColor = aConfig.GetColorValue(vId.eEntry).nColor;
1593 Color& rMyColor = aColors[vId.eTokenType];
1594 if (bFirst || aColor != rMyColor)
1595 {
1596 rMyColor = aColor;
1597 bChanged = true;
1598 }
1599 }
1600 if (bChanged && !bFirst && pEditor)
1601 pEditor->UpdateSyntaxHighlighting();
1602}
1603
1604} // namespace basctl
1605
1606/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScriptDocument aDocument
Definition: basobj2.cxx:194
static void Yield()
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
static bool IsQuit()
static void SetDebugMode(bool bDebugMode)
static void EnableBreak(bool bEnable)
StarBASIC * GetLib(sal_uInt16 nLib) const
static DialogMask HandleError(ErrCode nId, weld::Window *pParent=nullptr, DialogMask nMask=DialogMask::MAX)
Size GetOutputSize() const
float approximate_digit_width() const
const vcl::Font & GetFont() const
void SetFont(const vcl::Font &rNewFont)
void DrawRect(const tools::Rectangle &rRect)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void SetLineColor()
void SetMapMode()
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
void SetFillColor()
const Color & GetLineColor() const
const MapMode & GetMapMode() const
tools::Long GetTextHeight() const
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
const Color & GetFillColor() const
constexpr tools::Long Y() const
tools::Long AdjustY(tools::Long nVertMove)
constexpr tools::Long X() const
BasicDebugFlags GetDebugFlags() const
void SetDebugFlags(BasicDebugFlags n)
void GetLineRange(sal_uInt16 &, sal_uInt16 &)
bool IsModified() const
virtual void SetThumbPos(tools::Long nThumbPos) override
virtual tools::Long GetThumbPos() const=0
virtual void SetThumbPos(tools::Long nThumbPos)=0
bool GetValue() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void DisableItem(sal_uInt16 nWhich)
ErrCode GetError() const
SvStream * GetOutStream()
SvStream * GetInStream()
bool Commit()
sal_uInt16 GetSlot() const
const T * GetArg(sal_uInt16 nSlotId) const
weld::Window * GetFrameWeld() const
vcl::Window & GetWindow() const
SfxViewFrame & GetViewFrame() const
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
constexpr tools::Long Height() const
tools::Long AdjustHeight(tools::Long n)
tools::Long AdjustWidth(tools::Long n)
constexpr tools::Long Width() const
static bool GetFormatDataFlavor(SotClipboardFormatId nFormat, css::datatransfer::DataFlavor &rFlavor)
static bool IsRunning()
static sal_uInt16 GetCol2()
static void Stop()
static sal_uInt16 GetLine()
static ErrCode const & GetErrorCode()
static sal_uInt16 GetCol1()
SbModule * FindModule(std::u16string_view)
virtual void SetModified(bool) override
sal_uInt64 Tell() const
void StartReadingUnicodeText(rtl_TextEncoding eReadBomCharSet)
SvStream & WriteUChar(unsigned char nChar)
void SetStreamCharSet(rtl_TextEncoding eCharSet)
SvxSearchCmd GetCommand() const
const i18nutil::SearchOptions2 & GetSearchOptions() const
bool GetBackward() const
SfxUndoManager & GetUndoManager()
TextView * GetActiveView() const
OUString GetWord(const TextPaM &rCursorPos, TextPaM *pStartOfWord=nullptr, TextPaM *pEndOfWord=nullptr)
tools::Long GetTextHeight() const
void Write(SvStream &rOutput)
void SetModified(bool bModified)
bool IsModified() const
OUString GetText(LineEnd aSeparator=LINEEND_LF) const
sal_uInt32 GetParagraphCount() const
void SetUpdateMode(bool bUpdate)
tools::Long GetCharHeight() const
sal_uInt32 GetPara() const
sal_Int32 GetIndex() const
const TextPaM & GetStart() const
const TextPaM & GetEnd() const
void SetSelection(const TextSelection &rNewSel)
void Scroll(tools::Long nHorzScroll, tools::Long nVertScroll)
void ShowCursor(bool bGotoCursor=true, bool bForceVisCursor=true)
vcl::Window * GetWindow() const
void Read(SvStream &rInput)
bool IsReadOnly() const
bool IsInsertMode() const
void SetReadOnly(bool bReadOnly)
bool Search(const i18nutil::SearchOptions2 &rSearchOptions, bool bForward)
void Paste()
void Cut()
void Copy()
void MatchGroup()
bool KeyInput(const KeyEvent &rKeyEvent)
const TextSelection & GetSelection() const
sal_uInt16 Replace(const i18nutil::SearchOptions2 &rSearchOptions, bool bAll, bool bForward)
void HideCursor()
TextEngine * GetTextEngine() const
const Point & GetStartDocPos() const
void incBusy(const weld::Widget *pIgnore)
static css::uno::Reference< css::awt::XWindow > GetInterface(vcl::Window *pWindow)
static vcl::Window * GetWindow(const css::uno::Reference< css::awt::XWindow > &rxWindow)
virtual void dispose() override
Definition: bastypes.cxx:78
friend class ModulWindow
Definition: bastypes.hxx:170
const OUString & GetLibName() const
Definition: bastypes.hxx:234
ScriptDocument m_aDocument
Definition: bastypes.hxx:166
OUString CreateQualifiedName()
Definition: bastypes.cxx:213
const OUString & GetName() const
Definition: bastypes.hxx:236
OUString m_aLibName
Definition: bastypes.hxx:167
void AddStatus(int n)
Definition: bastypes.hxx:218
void ClearStatus(int n)
Definition: bastypes.hxx:219
const ScriptDocument & GetDocument() const
Definition: bastypes.hxx:232
bool IsSuspended() const
Definition: bastypes.hxx:229
ScrollAdaptor * GetHScrollBar() const
Definition: bastypes.hxx:187
void InsertSorted(BreakPoint pBrk)
Definition: breakpoint.cxx:52
size_t size() const
Definition: breakpoint.cxx:141
void SetBreakPointsInBasic(SbModule *pModule)
Definition: breakpoint.cxx:66
void remove(const BreakPoint *ptr)
Definition: breakpoint.cxx:127
BreakPoint * FindBreakPoint(sal_uInt16 nLine)
Definition: breakpoint.cxx:77
void SetLayoutWindow(Layout *)
Definition: bastypes.cxx:365
void Show(bool=true)
Definition: bastypes.cxx:375
encapsulates (actions on) the signature/state of a document
bool supportsSignatures() const
determines whether the instance is valid
void signScriptingContent(weld::Window *pDialogParent) const
signs the scripting content inside the document
void CreateProgress(const OUString &rText, sal_uInt32 nRange)
Definition: baside2b.cxx:1392
sal_Int32 GetLineNumber() const
Definition: moduldl2.cxx:169
virtual void dispose() override
Definition: layout.cxx:60
void AddToLeft(DockingWindow *pWin, Size const &rSize)
Definition: layout.hxx:57
virtual void Deactivating()
Definition: layout.cxx:126
virtual void Activating(BaseWindow &)
Definition: layout.cxx:117
void AddToBottom(DockingWindow *pWin, Size const &rSize)
Definition: layout.hxx:58
void ArrangeWindows()
Definition: layout.cxx:83
virtual void ConfigurationChanged(utl::ConfigurationBroadcaster *, ConfigurationHints) override
Definition: baside2.cxx:1543
void SetActiveEditor(EditorWindow *pEditor_)
Definition: baside2.hxx:441
ObjectCatalog & rObjectCatalog
Definition: baside2.hxx:432
virtual void dispose() override
Definition: baside2.cxx:1444
void ShowWatchWindow(bool bVisible)
Definition: baside2.cxx:1510
void ShowStackWindow(bool bVisible)
Definition: baside2.cxx:1516
ModulWindowLayout(vcl::Window *pParent, ObjectCatalog &)
Definition: baside2.cxx:1431
VclPtr< ModulWindow > pChild
Definition: baside2.hxx:428
virtual void Activating(BaseWindow &) override
Definition: baside2.cxx:1463
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: baside2.cxx:1458
VclPtr< StackWindow > aStackWindow
Definition: baside2.hxx:431
virtual void Deactivating() override
Definition: baside2.cxx:1476
virtual void OnFirstSize(tools::Long nWidth, tools::Long nHeight) override
Definition: baside2.cxx:1522
basctl::ModulWindowLayout::SyntaxColors aSyntaxColors
virtual ~ModulWindowLayout() override
Definition: baside2.cxx:1439
void BasicAddWatch(OUString const &)
Definition: baside2.cxx:1500
virtual void UpdateDebug(bool bBasicStopped) override
Definition: baside2.cxx:1452
VclPtr< WatchWindow > aWatchWindow
Definition: baside2.hxx:430
virtual void GetState(SfxItemSet &, unsigned nWhich) override
Definition: baside2.cxx:1486
void ManageBreakPoints()
Definition: baside2.cxx:601
BreakPointWindow & GetBreakPointWindow()
Definition: baside2.hxx:368
void BasicToggleBreakPoint()
Definition: baside2.cxx:560
virtual void printPage(sal_Int32 nPage, Printer *pPrinter) override
Definition: baside2.cxx:797
virtual void Activating() override
Definition: baside2.cxx:1215
sal_Int32 FormatAndPrint(Printer *pPrinter, sal_Int32 nPage)
Definition: baside2.cxx:808
virtual sal_Int32 countPages(Printer *pPrinter) override
Definition: baside2.cxx:792
BasicDebugFlags BasicBreakHdl()
Definition: baside2.cxx:652
virtual sal_uInt16 StartSearchAndReplace(SvxSearchItem const &, bool bFromStart=false) override
Definition: baside2.cxx:1227
virtual void OnNewDocument() override
Definition: baside2.cxx:1393
virtual bool IsModified() override
Definition: baside2.cxx:1176
ScrollAdaptor & GetEditVScrollBar()
Definition: baside2.hxx:370
StarBASIC * GetBasic()
Definition: baside2.hxx:327
void EditMacro(const OUString &rMacroName)
Definition: baside2.cxx:715
virtual OUString GetHid() const override
Definition: baside2.cxx:1399
virtual void BasicStopped() override
Definition: baside2.cxx:1314
void CheckCompileBasic()
Definition: baside2.cxx:270
BasicStatus m_aStatus
Definition: baside2.hxx:290
SbModuleRef const & XModule()
Definition: baside2.cxx:208
virtual void SetReadOnly(bool bReadOnly) override
Definition: baside2.cxx:1360
virtual void ExecuteGlobal(SfxRequest &rReq) override
Definition: baside2.cxx:1039
SbModuleRef m_xModule
Definition: baside2.hxx:291
virtual void UpdateData() override
Definition: baside2.cxx:771
virtual void StoreData() override
Definition: baside2.cxx:758
void SetModule(const OUString &aModule)
Definition: baside2.hxx:384
virtual void dispose() override
Definition: baside2.cxx:239
VclPtr< ComplexEditorWindow > m_aXEditorWindow
Definition: baside2.hxx:289
virtual void GetState(SfxItemSet &) override
Definition: baside2.cxx:1057
void ShowCursor(bool bOn)
Definition: baside2.cxx:1194
BreakPointList & GetBreakPoints()
Definition: baside2.hxx:374
virtual void Deactivating() override
Definition: baside2.cxx:1222
EditorWindow & GetEditorWindow()
Definition: baside2.hxx:367
OUString GetSbModuleName()
Definition: baside2.cxx:1181
virtual EntryDescriptor CreateEntryDescriptor() override
Definition: baside2.cxx:1320
virtual void GetFocus() override
Definition: baside2.cxx:248
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: baside2.cxx:261
virtual ItemType GetType() const override
Definition: baside2.cxx:1403
virtual SearchOptionFlags GetSearchOptions() override
Definition: baside2.cxx:1275
StarBASICRef m_xBasic
Definition: baside2.hxx:287
virtual void ExecuteCommand(SfxRequest &rReq) override
Definition: baside2.cxx:875
void BasicErrorHdl(StarBASIC const *pBasic)
Definition: baside2.cxx:609
void SaveBasicSource()
Definition: baside2.cxx:458
virtual SfxUndoManager * GetUndoManager() override
Definition: baside2.cxx:1268
virtual void DoScroll(Scrollable *pCurScrollBar) override
Definition: baside2.cxx:1163
TextView * GetEditView()
Definition: baside2.hxx:373
virtual bool HasActiveEditor() const override
Definition: baside2.cxx:1408
void ToggleBreakPoint(sal_uInt16 nLine)
Definition: baside2.cxx:506
virtual bool AllowUndo() override
Definition: baside2.cxx:766
virtual bool IsReadOnly() override
Definition: baside2.cxx:1366
virtual void BasicStarted() override
Definition: baside2.cxx:1294
virtual void DoInit() override
Definition: baside2.cxx:256
ExtTextEngine * GetEditEngine()
Definition: baside2.hxx:372
virtual void Resize() override
Definition: baside2.cxx:265
virtual ~ModulWindow() override
Definition: baside2.cxx:234
void UpdateBreakPoint(const BreakPoint &rBrk)
Definition: baside2.cxx:544
virtual OUString GetTitle() override
Definition: baside2.cxx:1189
ModulWindowLayout & m_rLayout
Definition: baside2.hxx:286
void BasicToggleBreakPointEnabled()
Definition: baside2.cxx:577
void AssertValidEditEngine()
Definition: baside2.cxx:1209
static void getObjectName(const css::uno::Reference< css::container::XNameContainer > &rLib, const OUString &rModName, OUString &rObjName)
Definition: bastype2.cxx:52
A docking window that contains a tree of the currently loaded macros.
void UpdateEntries()
Update the entries of Object Catalog Treelist.
encapsulates a document which contains Basic scripts and dialogs
bool removeModule(const OUString &_rLibName, const OUString &_rModuleName) const
removes a given script module from the document
BasicManager * getBasicManager() const
returns the BasicManager associated with this instance
bool updateModule(const OUString &_rLibName, const OUString &_rModName, const OUString &_rModuleCode) const
updates a given module with new code
static std::shared_ptr< ConfigurationChanges > create()
const css::uno::Reference< css::ui::dialogs::XFilePicker3 > & GetFilePicker() const
void SetContext(Context _eNewContext)
T * get() const
bool is() const
void SetFontSize(const Size &)
void SetTransparent(bool bTransparent)
void SetAlignment(TextAlign)
void PaintImmediately()
void GrabFocus()
void LeaveWait()
void Show(bool bVisible=true, ShowFlags nFlags=ShowFlags::NONE)
const vcl::Font & GetFont() const
Size GetOutputSizePixel() const
void EnterWait()
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
weld::Window * GetFrameWeld() const
virtual OUString GetText() const
css::uno::Reference< css::datatransfer::clipboard::XClipboard > GetClipboard()
void SetBackground()
virtual short run()
#define DBG_ASSERT(sCon, aError)
float u
#define ERRCODE_NONE
ALIGN_BOTTOM
constexpr OUStringLiteral HID_BASICIDE_MODULWINDOW
Definition: helpids.h:27
OUString aName
constexpr sal_uInt16 KEY_DELETE
sal_uInt16 nPos
def Print(s)
tools::Long const nRightMargin
Definition: dlged.cxx:1082
tools::Long const nBottomMargin
Definition: dlged.cxx:1084
tools::Long const nTopMargin
Definition: dlged.cxx:1083
tools::Long const nBorder
Definition: dlged.cxx:1085
tools::Long const nLeftMargin
Definition: dlged.cxx:1081
void RunMethod(SbMethod const *pMethod)
Definition: basobj3.cxx:276
SfxBindings * GetBindingsPtr()
Definition: basobj3.cxx:426
void setTextEngineText(ExtTextEngine &, std::u16string_view)
Definition: baside2b.cxx:130
constexpr OUStringLiteral FilterMask_All
Definition: baside3.cxx:75
bool implImportDialog(weld::Window *pWin, const ScriptDocument &rDocument, const OUString &aLibName)
Definition: baside3.cxx:784
OUString ChooseMacro(weld::Window *pParent, const uno::Reference< frame::XModel > &rxLimitToDocument, const uno::Reference< frame::XFrame > &xDocFrame, bool bChooseOnly)
Definition: basobj2.cxx:228
OUString getTextEngineText(ExtTextEngine &)
Helper functions to get/set text in TextEngine using the stream interface.
Definition: baside2b.cxx:118
Shell * GetShell()
Definition: iderdll.cxx:80
void MarkDocumentModified(const ScriptDocument &rDocument)
Definition: basobj3.cxx:249
sal_uInt32 CalcLineCount(SvStream &rStream)
Definition: bastypes.cxx:659
@ BASWIN_INRESCHEDULE
Definition: bastypes.hxx:148
@ BASWIN_RUNNINGBASIC
Definition: bastypes.hxx:145
void InvalidateDebuggerSlots()
Definition: basobj3.cxx:343
@ OBJ_TYPE_MODULE
Definition: bastype2.hxx:55
ItemType
Definition: sbxitem.hxx:28
@ TYPE_MODULE
Definition: sbxitem.hxx:32
OUString IDEResId(TranslateId aId)
Definition: iderdll.cxx:108
static void lcl_PrintHeader(Printer *pPrinter, const OUString &rTitle)
Definition: dlged.cxx:1088
bool QueryDelModule(std::u16string_view rName, weld::Widget *pParent)
Definition: bastypes.cxx:774
size
css::uno::Reference< css::uno::XCurrentContext > NewFlagContext(const OUString &sName)
int i
void Create(SwFormatVertOrient &rItem, SvStream &rStrm, sal_uInt16 nVersionAbusedAsSize)
long Long
ConfigurationHints
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
BasicDebugFlags
static SfxItemSet & rSet
SearchOptionFlags
BasicDebugFlags nBasicFlags
Definition: bastypes.hxx:69
sal_uInt16 nLine
Definition: breakpoint.hxx:34
TokenType
#define TEXT_INDEX_ALL
#define TEXT_PARA_ALL
bool bVisible
Count
void GetSelection(struct ESelection &rSel, SvxTextForwarder const *pForwarder) noexcept
RET_OK