2010-10-12 15:57:08 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2000-09-29 10:02:42 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:34:33 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:34:33 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:34:33 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:34:33 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:34:33 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
2008-04-11 09:34:33 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-29 10:02:42 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 23:24:33 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_basctl.hxx"
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <ide_pch.hxx>
|
|
|
|
|
|
|
|
#include <svtools/texteng.hxx>
|
|
|
|
#include <svtools/textview.hxx>
|
|
|
|
#include <svtools/xtextedt.hxx>
|
2005-04-13 08:49:28 +00:00
|
|
|
#include <basic/sbx.hxx>
|
2001-05-21 08:57:57 +00:00
|
|
|
#include <comphelper/processfactory.hxx>
|
2001-07-05 08:20:52 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/XFilePicker.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
|
2001-07-03 15:33:31 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/XFilterManager.hpp>
|
2001-07-05 08:20:52 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
|
2001-07-04 08:03:05 +00:00
|
|
|
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
|
2001-11-09 14:41:40 +00:00
|
|
|
#include <com/sun/star/script/XLibraryContainer2.hpp>
|
2004-05-03 06:56:52 +00:00
|
|
|
#include <com/sun/star/document/MacroExecMode.hpp>
|
2010-03-02 12:39:31 +00:00
|
|
|
#include <com/sun/star/script/ModuleType.hpp>
|
2005-04-18 13:24:20 +00:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
2000-09-29 10:02:42 +00:00
|
|
|
#include <sfx2/docfile.hxx>
|
|
|
|
#include <basic/basrdll.hxx>
|
|
|
|
|
|
|
|
#include <baside2.hrc>
|
|
|
|
#include <baside2.hxx>
|
|
|
|
#include <objdlg.hxx>
|
|
|
|
#include <iderdll.hxx>
|
|
|
|
#include <iderdll2.hxx>
|
|
|
|
|
|
|
|
#include <basobj.hxx>
|
2003-04-11 16:37:21 +00:00
|
|
|
#include <brkdlg.hxx>
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
#include <vcl/sound.hxx>
|
|
|
|
|
2000-11-21 16:58:31 +00:00
|
|
|
#include <unotools/textsearch.hxx>
|
2007-03-15 14:52:11 +00:00
|
|
|
#include <tools/diagnose_ex.h>
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-11-09 14:41:40 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
#define SPLIT_MARGIN 5
|
|
|
|
#define SPLIT_HEIGHT 2
|
|
|
|
|
|
|
|
#define LMARGPRN 1700
|
|
|
|
#define RMARGPRN 900
|
|
|
|
#define TMARGPRN 2000
|
|
|
|
#define BMARGPRN 1000
|
|
|
|
#define BORDERPRN 300
|
|
|
|
|
|
|
|
#define APPWAIT_START 100
|
|
|
|
|
|
|
|
#define VALIDWINDOW 0x1234
|
|
|
|
|
2007-08-03 08:57:30 +00:00
|
|
|
#if defined(OW) || defined(MTF)
|
2000-09-29 10:02:42 +00:00
|
|
|
#define FILTERMASK_ALL "*"
|
|
|
|
#else
|
|
|
|
#define FILTERMASK_ALL "*.*"
|
|
|
|
#endif
|
|
|
|
|
2001-05-21 08:57:57 +00:00
|
|
|
using namespace ::com::sun::star;
|
|
|
|
using namespace ::com::sun::star::uno;
|
2001-07-03 15:33:31 +00:00
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
2000-11-21 16:58:31 +00:00
|
|
|
using namespace utl;
|
2001-05-21 08:57:57 +00:00
|
|
|
using namespace comphelper;
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2007-01-19 07:43:06 +00:00
|
|
|
DBG_NAME( ModulWindow )
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
TYPEINIT1( ModulWindow , IDEBaseWindow );
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
void lcl_PrintHeader( Printer* pPrinter, sal_uInt16 nPages, sal_uInt16 nCurPage, const String& rTitle, bool bOutput )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
short nLeftMargin = LMARGPRN;
|
|
|
|
Size aSz = pPrinter->GetOutputSize();
|
|
|
|
short nBorder = BORDERPRN;
|
|
|
|
|
|
|
|
const Color aOldLineColor( pPrinter->GetLineColor() );
|
|
|
|
const Color aOldFillColor( pPrinter->GetFillColor() );
|
|
|
|
const Font aOldFont( pPrinter->GetFont() );
|
|
|
|
|
|
|
|
pPrinter->SetLineColor( Color( COL_BLACK ) );
|
|
|
|
pPrinter->SetFillColor();
|
|
|
|
|
|
|
|
Font aFont( aOldFont );
|
|
|
|
aFont.SetWeight( WEIGHT_BOLD );
|
|
|
|
aFont.SetAlign( ALIGN_BOTTOM );
|
|
|
|
pPrinter->SetFont( aFont );
|
|
|
|
|
|
|
|
long nFontHeight = pPrinter->GetTextHeight();
|
|
|
|
|
|
|
|
// 1.Border => Strich, 2+3 Border = Freiraum.
|
|
|
|
long nYTop = TMARGPRN-3*nBorder-nFontHeight;
|
|
|
|
|
|
|
|
long nXLeft = nLeftMargin-nBorder;
|
|
|
|
long nXRight = aSz.Width()-RMARGPRN+nBorder;
|
|
|
|
|
2009-05-19 11:32:44 +00:00
|
|
|
if( bOutput )
|
|
|
|
pPrinter->DrawRect( Rectangle(
|
|
|
|
Point( nXLeft, nYTop ),
|
|
|
|
Size( nXRight-nXLeft, aSz.Height() - nYTop - BMARGPRN + nBorder ) ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
long nY = TMARGPRN-2*nBorder;
|
|
|
|
Point aPos( nLeftMargin, nY );
|
2009-05-19 11:32:44 +00:00
|
|
|
if( bOutput )
|
|
|
|
pPrinter->DrawText( aPos, rTitle );
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( nPages != 1 )
|
|
|
|
{
|
|
|
|
aFont.SetWeight( WEIGHT_NORMAL );
|
|
|
|
pPrinter->SetFont( aFont );
|
|
|
|
String aPageStr( RTL_CONSTASCII_USTRINGPARAM( " [" ) );
|
|
|
|
aPageStr += String( IDEResId( RID_STR_PAGE ) );
|
|
|
|
aPageStr += ' ';
|
|
|
|
aPageStr += String::CreateFromInt32( nCurPage );
|
|
|
|
aPageStr += ']';
|
|
|
|
aPos.X() += pPrinter->GetTextWidth( rTitle );
|
2009-05-19 11:32:44 +00:00
|
|
|
if( bOutput )
|
|
|
|
pPrinter->DrawText( aPos, aPageStr );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
nY = TMARGPRN-nBorder;
|
|
|
|
|
2009-05-19 11:32:44 +00:00
|
|
|
if( bOutput )
|
|
|
|
pPrinter->DrawLine( Point( nXLeft, nY ), Point( nXRight, nY ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
pPrinter->SetFont( aOldFont );
|
|
|
|
pPrinter->SetFillColor( aOldFillColor );
|
|
|
|
pPrinter->SetLineColor( aOldLineColor );
|
|
|
|
}
|
|
|
|
|
|
|
|
void lcl_ConvertTabsToSpaces( String& rLine )
|
|
|
|
{
|
|
|
|
if ( rLine.Len() )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nPos = 0;
|
|
|
|
sal_uInt16 nMax = rLine.Len();
|
2000-09-29 10:02:42 +00:00
|
|
|
while ( nPos < nMax )
|
|
|
|
{
|
|
|
|
if ( rLine.GetChar( nPos ) == '\t' )
|
|
|
|
{
|
|
|
|
// Nicht 4 Blanks, sondern an 4er TabPos:
|
|
|
|
String aBlanker;
|
|
|
|
aBlanker.Fill( ( 4 - ( nPos % 4 ) ), ' ' );
|
|
|
|
rLine.Erase( nPos, 1 );
|
|
|
|
rLine.Insert( aBlanker, nPos );
|
|
|
|
nMax = rLine.Len();
|
|
|
|
}
|
|
|
|
nPos++; // Nicht optimal, falls Tab, aber auch nicht verkehrt...
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-15 14:52:11 +00:00
|
|
|
ModulWindow::ModulWindow( ModulWindowLayout* pParent, const ScriptDocument& rDocument, String aLibName,
|
2004-07-23 11:01:17 +00:00
|
|
|
String aName, ::rtl::OUString& aModule )
|
2007-03-15 14:52:11 +00:00
|
|
|
:IDEBaseWindow( pParent, rDocument, aLibName, aName )
|
2001-06-28 14:26:41 +00:00
|
|
|
,aXEditorWindow( this )
|
2001-09-03 10:56:10 +00:00
|
|
|
,m_aModule( aModule )
|
2001-06-28 14:26:41 +00:00
|
|
|
{
|
|
|
|
DBG_CTOR( ModulWindow, 0 );
|
|
|
|
nValid = VALIDWINDOW;
|
|
|
|
pLayout = pParent;
|
|
|
|
aXEditorWindow.Show();
|
2004-07-23 11:01:17 +00:00
|
|
|
|
2010-03-03 19:59:09 +00:00
|
|
|
SetBackground();
|
|
|
|
}
|
|
|
|
|
|
|
|
SbModuleRef ModulWindow::XModule()
|
|
|
|
{
|
2010-04-08 16:36:31 +01:00
|
|
|
// ModuleWindows can now be created as a result of the
|
|
|
|
// modules getting created via the api. This is a result of an
|
|
|
|
// elementInserted event from the BasicLibrary container.
|
|
|
|
// However the SbModule is also created from a different listener to
|
|
|
|
// the same event ( in basmgr ) Therefore it is possible when we look
|
|
|
|
// for xModule it may not yet be available, here we keep tring to access
|
|
|
|
// the module until such time as it exists
|
|
|
|
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( !xModule.Is() )
|
2004-07-23 11:01:17 +00:00
|
|
|
{
|
2010-03-03 19:59:09 +00:00
|
|
|
BasicManager* pBasMgr = GetDocument().getBasicManager();
|
|
|
|
if ( pBasMgr )
|
2004-07-23 11:01:17 +00:00
|
|
|
{
|
2010-03-03 19:59:09 +00:00
|
|
|
StarBASIC* pBasic = pBasMgr->GetLib( GetLibName() );
|
|
|
|
if ( pBasic )
|
|
|
|
{
|
|
|
|
xBasic = pBasic;
|
|
|
|
xModule = (SbModule*)pBasic->FindModule( GetName() );
|
|
|
|
}
|
2004-07-23 11:01:17 +00:00
|
|
|
}
|
|
|
|
}
|
2010-03-03 19:59:09 +00:00
|
|
|
return xModule;
|
2001-06-28 14:26:41 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
ModulWindow::~ModulWindow()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_DTOR( ModulWindow, 0 );
|
|
|
|
nValid = 0;
|
|
|
|
|
|
|
|
StarBASIC::Stop();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::GetFocus()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( nValid != VALIDWINDOW )
|
|
|
|
return;
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
aXEditorWindow.GetEdtWindow().GrabFocus();
|
|
|
|
// Basisklasse nicht rufen, weil Focus jetzt woanders...
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindow::DoInit()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
// Wird beim Umschalten der Fenster gerufen...
|
|
|
|
if ( GetVScrollBar() )
|
|
|
|
GetVScrollBar()->Hide();
|
|
|
|
GetHScrollBar()->Show();
|
|
|
|
GetEditorWindow().InitScrollBars();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::Paint( const Rectangle& )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::Resize()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
aXEditorWindow.SetPosSizePixel( Point( 0, 0 ),
|
|
|
|
Size( GetOutputSizePixel() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// "Import" von baside4.cxx
|
|
|
|
void CreateEngineForBasic( StarBASIC* pBasic );
|
|
|
|
|
|
|
|
void ModulWindow::CheckCompileBasic()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-10-24 09:27:33 +00:00
|
|
|
// Zur Laufzeit wird niemals compiliert!
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bRunning = StarBASIC::IsRunning();
|
|
|
|
sal_Bool bModified = ( !xModule->IsCompiled() ||
|
2001-10-24 09:27:33 +00:00
|
|
|
( GetEditEngine() && GetEditEngine()->IsModified() ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-10-24 09:27:33 +00:00
|
|
|
if ( !bRunning && bModified )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bDone = sal_False;
|
2004-01-06 16:11:19 +00:00
|
|
|
|
|
|
|
BasicIDEShell* pIDEShell = IDE_DLL()->GetShell();
|
|
|
|
pIDEShell->GetViewFrame()->GetWindow().EnterWait();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-10-24 09:27:33 +00:00
|
|
|
if( bModified )
|
|
|
|
{
|
|
|
|
AssertValidEditEngine();
|
2011-01-14 11:16:25 +01:00
|
|
|
GetEditorWindow().SetSourceInBasic( sal_False );
|
2001-10-24 09:27:33 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bWasModified = GetBasic()->IsModified();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-10-24 09:27:33 +00:00
|
|
|
bDone = GetBasic()->Compile( xModule );
|
|
|
|
if ( !bWasModified )
|
2011-01-14 11:16:25 +01:00
|
|
|
GetBasic()->SetModified( sal_False );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-10-24 09:27:33 +00:00
|
|
|
if ( bDone )
|
|
|
|
{
|
|
|
|
GetBreakPoints().SetBreakPointsInBasic( xModule );
|
|
|
|
}
|
|
|
|
|
2004-01-06 16:11:19 +00:00
|
|
|
pIDEShell->GetViewFrame()->GetWindow().LeaveWait();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-10-24 09:27:33 +00:00
|
|
|
aStatus.bError = !bDone;
|
2011-01-14 11:16:25 +01:00
|
|
|
aStatus.bIsRunning = sal_False;
|
2001-10-24 09:27:33 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::BasicExecute()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
2004-05-03 06:56:52 +00:00
|
|
|
|
|
|
|
// #116444# check security settings before macro execution
|
2007-03-15 14:52:11 +00:00
|
|
|
ScriptDocument aDocument( GetDocument() );
|
|
|
|
if ( aDocument.isDocument() )
|
2004-05-03 06:56:52 +00:00
|
|
|
{
|
2007-10-09 14:21:22 +00:00
|
|
|
if ( !aDocument.allowMacros() )
|
2004-05-03 06:56:52 +00:00
|
|
|
{
|
|
|
|
WarningBox( this, WB_OK, String( IDEResId( RID_STR_CANNOTRUNMACRO ) ) ).Execute();
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_False;
|
2004-05-03 06:56:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
CheckCompileBasic();
|
|
|
|
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() && xModule->IsCompiled() && !aStatus.bError )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-12-11 07:39:25 -08:00
|
|
|
if ( GetBreakPoints().size() )
|
2000-09-29 10:02:42 +00:00
|
|
|
aStatus.nBasicFlags = aStatus.nBasicFlags | SbDEBUG_BREAK;
|
|
|
|
|
|
|
|
if ( !aStatus.bIsRunning )
|
|
|
|
{
|
|
|
|
DBG_ASSERT( xModule.Is(), "Kein Modul!" );
|
|
|
|
AddStatus( BASWIN_RUNNINGBASIC );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nStart, nEnd, nCurMethodStart = 0;
|
2010-03-02 12:39:31 +00:00
|
|
|
TextSelection aSel = GetEditView()->GetSelection();
|
2010-09-29 14:32:58 +01:00
|
|
|
// Init cursor to top
|
|
|
|
nCurMethodStart = ( aSel.GetStart().GetPara() + 1 );
|
2000-09-29 10:02:42 +00:00
|
|
|
SbMethod* pMethod = 0;
|
|
|
|
// erstes Macro, sonst blind "Main" (ExtSearch?)
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uInt16 nMacro = 0; nMacro < xModule->GetMethods()->Count(); nMacro++ )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
SbMethod* pM = (SbMethod*)xModule->GetMethods()->Get( nMacro );
|
|
|
|
DBG_ASSERT( pM, "Method?" );
|
|
|
|
pM->GetLineRange( nStart, nEnd );
|
2010-09-29 14:32:58 +01:00
|
|
|
if ( nCurMethodStart >= nStart && nCurMethodStart <= nEnd )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-09-29 14:32:58 +01:00
|
|
|
// matched a method to the cursor position
|
2000-09-29 10:02:42 +00:00
|
|
|
pMethod = pM;
|
2010-09-29 14:32:58 +01:00
|
|
|
break;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( !pMethod )
|
2010-03-03 12:59:39 +00:00
|
|
|
{
|
2010-09-29 14:32:58 +01:00
|
|
|
// If not in a method then prompt the user
|
2011-03-09 16:20:50 -06:00
|
|
|
return ( BasicIDE::ChooseMacro( uno::Reference< frame::XModel >(), sal_False, rtl::OUString() ).getLength() > 0 ) ? sal_True : sal_False;
|
2010-03-03 12:59:39 +00:00
|
|
|
}
|
|
|
|
if ( pMethod )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
pMethod->SetDebugFlags( aStatus.nBasicFlags );
|
2011-01-14 11:16:25 +01:00
|
|
|
BasicDLL::SetDebugMode( sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
BasicIDE::RunMethod( pMethod );
|
2011-01-14 11:16:25 +01:00
|
|
|
BasicDLL::SetDebugMode( sal_False );
|
|
|
|
// Falls waehrend Interactive=sal_False abgebrochen
|
|
|
|
BasicDLL::EnableBreak( sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
ClearStatus( BASWIN_RUNNINGBASIC );
|
|
|
|
}
|
|
|
|
else
|
2011-01-14 11:16:25 +01:00
|
|
|
aStatus.bIsRunning = sal_False; // Abbruch von Reschedule()
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bDone = !aStatus.bError;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
return bDone;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::CompileBasic()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
CheckCompileBasic();
|
2001-10-24 09:27:33 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bIsCompiled = sal_False;
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() )
|
2001-10-24 09:27:33 +00:00
|
|
|
bIsCompiled = xModule->IsCompiled();
|
|
|
|
|
|
|
|
return bIsCompiled;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::BasicRun()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
|
|
|
|
aStatus.nBasicFlags = 0;
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bDone = BasicExecute();
|
2000-09-29 10:02:42 +00:00
|
|
|
return bDone;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::BasicStepOver()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
aStatus.nBasicFlags = SbDEBUG_STEPINTO | SbDEBUG_STEPOVER;
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bDone = BasicExecute();
|
2000-09-29 10:02:42 +00:00
|
|
|
return bDone;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::BasicStepInto()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
|
|
|
|
aStatus.nBasicFlags = SbDEBUG_STEPINTO;
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bDone = BasicExecute();
|
2000-09-29 10:02:42 +00:00
|
|
|
return bDone;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::BasicStepOut()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
|
|
|
|
aStatus.nBasicFlags = SbDEBUG_STEPOUT;
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bDone = BasicExecute();
|
2000-09-29 10:02:42 +00:00
|
|
|
return bDone;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ModulWindow::BasicStop()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
|
|
|
|
GetBasic()->Stop();
|
2011-01-14 11:16:25 +01:00
|
|
|
aStatus.bIsRunning = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::LoadBasic()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bDone = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-05-21 08:57:57 +00:00
|
|
|
Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
|
|
|
|
Reference < XFilePicker > xFP;
|
|
|
|
if( xMSF.is() )
|
|
|
|
{
|
2001-07-05 08:20:52 +00:00
|
|
|
Sequence <Any> aServiceType(1);
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILEOPEN_SIMPLE;
|
2001-05-21 08:57:57 +00:00
|
|
|
xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
|
2001-07-05 08:20:52 +00:00
|
|
|
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
|
2001-05-21 08:57:57 +00:00
|
|
|
}
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( aCurPath.Len() )
|
2001-05-21 08:57:57 +00:00
|
|
|
xFP->setDisplayDirectory ( aCurPath );
|
|
|
|
|
|
|
|
Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
|
|
|
|
xFltMgr->appendFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.bas" ) ) );
|
|
|
|
xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
|
|
|
|
xFltMgr->setCurrentFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
|
|
|
|
|
|
|
|
if( xFP->execute() == RET_OK )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-07-03 15:33:31 +00:00
|
|
|
Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
|
2001-05-21 08:57:57 +00:00
|
|
|
aCurPath = aPaths[0];
|
2011-01-14 11:16:25 +01:00
|
|
|
SfxMedium aMedium( aCurPath, STREAM_READ | STREAM_SHARE_DENYWRITE | STREAM_NOCREATE, sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
SvStream* pStream = aMedium.GetInStream();
|
|
|
|
if ( pStream )
|
|
|
|
{
|
|
|
|
AssertValidEditEngine();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uLong nLines = CalcLineCount( *pStream );
|
2000-09-29 10:02:42 +00:00
|
|
|
// nLines*4: ReadText/Formatting/Highlighting/Formatting
|
|
|
|
GetEditorWindow().CreateProgress( String( IDEResId( RID_STR_GENERATESOURCE ) ), nLines*4 );
|
2011-01-14 11:16:25 +01:00
|
|
|
GetEditEngine()->SetUpdateMode( sal_False );
|
2000-09-29 10:02:42 +00:00
|
|
|
GetEditView()->Read( *pStream );
|
2011-01-14 11:16:25 +01:00
|
|
|
GetEditEngine()->SetUpdateMode( sal_True );
|
|
|
|
GetEditorWindow().Update(); // Es wurde bei UpdateMode = sal_True nur Invalidiert
|
2000-09-29 10:02:42 +00:00
|
|
|
GetEditorWindow().ForceSyntaxTimeout();
|
|
|
|
GetEditorWindow().DestroyProgress();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uLong nError = aMedium.GetError();
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( nError )
|
|
|
|
ErrorHandler::HandleError( nError );
|
|
|
|
else
|
2011-01-14 11:16:25 +01:00
|
|
|
bDone = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_COULDNTREAD ) ) ).Execute();
|
|
|
|
}
|
|
|
|
return bDone;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::SaveBasicSource()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bDone = sal_False;
|
2001-05-21 08:57:57 +00:00
|
|
|
|
|
|
|
Reference< lang::XMultiServiceFactory > xMSF( ::comphelper::getProcessServiceFactory() );
|
|
|
|
Reference < XFilePicker > xFP;
|
|
|
|
if( xMSF.is() )
|
|
|
|
{
|
2001-07-05 08:20:52 +00:00
|
|
|
Sequence <Any> aServiceType(1);
|
|
|
|
aServiceType[0] <<= TemplateDescription::FILESAVE_AUTOEXTENSION_PASSWORD;
|
2001-05-21 08:57:57 +00:00
|
|
|
xFP = Reference< XFilePicker >( xMSF->createInstanceWithArguments(
|
2001-07-05 08:20:52 +00:00
|
|
|
::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.ui.dialogs.FilePicker" ) ), aServiceType ), UNO_QUERY );
|
2001-05-21 08:57:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Reference< XFilePickerControlAccess > xFPControl(xFP, UNO_QUERY);
|
2001-07-03 15:33:31 +00:00
|
|
|
xFPControl->enableControl(ExtendedFilePickerElementIds::CHECKBOX_PASSWORD, sal_False);
|
2001-07-23 09:55:47 +00:00
|
|
|
Any aValue;
|
|
|
|
aValue <<= (sal_Bool) sal_True;
|
|
|
|
xFPControl->setValue(ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION, 0, aValue);
|
2001-05-21 08:57:57 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( aCurPath.Len() )
|
2001-05-21 08:57:57 +00:00
|
|
|
xFP->setDisplayDirectory ( aCurPath );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-05-21 08:57:57 +00:00
|
|
|
Reference< XFilterManager > xFltMgr(xFP, UNO_QUERY);
|
|
|
|
xFltMgr->appendFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ), String( RTL_CONSTASCII_USTRINGPARAM( "*.bas" ) ) );
|
|
|
|
xFltMgr->appendFilter( String( IDEResId( RID_STR_FILTER_ALLFILES ) ), String( RTL_CONSTASCII_USTRINGPARAM( FILTERMASK_ALL ) ) );
|
|
|
|
xFltMgr->setCurrentFilter( String( RTL_CONSTASCII_USTRINGPARAM( "BASIC" ) ) );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-05-21 08:57:57 +00:00
|
|
|
if( xFP->execute() == RET_OK )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-07-03 15:33:31 +00:00
|
|
|
Sequence< ::rtl::OUString > aPaths = xFP->getFiles();
|
2001-05-21 08:57:57 +00:00
|
|
|
aCurPath = aPaths[0];
|
2011-01-14 11:16:25 +01:00
|
|
|
SfxMedium aMedium( aCurPath, STREAM_WRITE | STREAM_SHARE_DENYWRITE | STREAM_TRUNC, sal_True, sal_False );
|
2000-09-29 10:02:42 +00:00
|
|
|
SvStream* pStream = aMedium.GetOutStream();
|
|
|
|
if ( pStream )
|
|
|
|
{
|
2004-01-06 16:11:19 +00:00
|
|
|
EnterWait();
|
2000-09-29 10:02:42 +00:00
|
|
|
AssertValidEditEngine();
|
|
|
|
GetEditEngine()->Write( *pStream );
|
|
|
|
aMedium.Commit();
|
2004-01-06 16:11:19 +00:00
|
|
|
LeaveWait();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uLong nError = aMedium.GetError();
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( nError )
|
|
|
|
ErrorHandler::HandleError( nError );
|
|
|
|
else
|
2011-01-14 11:16:25 +01:00
|
|
|
bDone = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
ErrorBox( this, WB_OK | WB_DEF_OK, String( IDEResId( RID_STR_COULDNTWRITE) ) ).Execute();
|
|
|
|
}
|
|
|
|
|
|
|
|
return bDone;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool implImportDialog( Window* pWin, const String& rCurPath, const ScriptDocument& rDocument, const String& aLibName );
|
2009-09-11 09:40:28 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::ImportDialog()
|
2009-09-11 09:40:28 +00:00
|
|
|
{
|
|
|
|
const ScriptDocument& rDocument = GetDocument();
|
|
|
|
String aLibName = GetLibName();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bRet = implImportDialog( this, aCurPath, rDocument, aLibName );
|
2009-09-11 09:40:28 +00:00
|
|
|
return bRet;
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::ToggleBreakPoint( sal_uLong nLine )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-03-03 19:59:09 +00:00
|
|
|
DBG_ASSERT( XModule().Is(), "Kein Modul!" );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bNewBreakPoint = sal_False;
|
2001-10-24 09:27:33 +00:00
|
|
|
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-10-24 09:27:33 +00:00
|
|
|
CheckCompileBasic();
|
|
|
|
if ( aStatus.bError )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-10-24 09:27:33 +00:00
|
|
|
Sound::Beep();
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_False;
|
2001-10-24 09:27:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nLine );
|
|
|
|
if ( pBrk ) // entfernen
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
xModule->ClearBP( (sal_uInt16)nLine );
|
2010-12-11 07:39:25 -08:00
|
|
|
delete GetBreakPoints().remove( pBrk );
|
2001-10-24 09:27:33 +00:00
|
|
|
}
|
|
|
|
else // einen erzeugen
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
if ( xModule->SetBP( (sal_uInt16)nLine) )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-10-24 09:27:33 +00:00
|
|
|
GetBreakPoints().InsertSorted( new BreakPoint( nLine ) );
|
2011-01-14 11:16:25 +01:00
|
|
|
bNewBreakPoint = sal_True;
|
2001-10-24 09:27:33 +00:00
|
|
|
if ( StarBASIC::IsRunning() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uInt16 nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ )
|
2001-10-24 09:27:33 +00:00
|
|
|
{
|
|
|
|
SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod );
|
|
|
|
DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
|
|
|
|
pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-10-24 09:27:33 +00:00
|
|
|
if ( !bNewBreakPoint )
|
|
|
|
Sound::Beep();
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return bNewBreakPoint;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindow::UpdateBreakPoint( const BreakPoint& rBrk )
|
|
|
|
{
|
2010-03-03 19:59:09 +00:00
|
|
|
DBG_ASSERT( XModule().Is(), "Kein Modul!" );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() )
|
2001-10-24 09:27:33 +00:00
|
|
|
{
|
|
|
|
CheckCompileBasic();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2001-10-24 09:27:33 +00:00
|
|
|
if ( rBrk.bEnabled )
|
2011-01-14 11:16:25 +01:00
|
|
|
xModule->SetBP( (sal_uInt16)rBrk.nLine );
|
2001-10-24 09:27:33 +00:00
|
|
|
else
|
2011-01-14 11:16:25 +01:00
|
|
|
xModule->ClearBP( (sal_uInt16)rBrk.nLine );
|
2001-10-24 09:27:33 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::BasicToggleBreakPoint()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
AssertValidEditEngine();
|
|
|
|
|
|
|
|
TextSelection aSel = GetEditView()->GetSelection();
|
|
|
|
aSel.GetStart().GetPara()++; // Basic-Zeilen beginnen bei 1!
|
|
|
|
aSel.GetEnd().GetPara()++;
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bNewBreakPoint = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uLong nLine = aSel.GetStart().GetPara(); nLine <= aSel.GetEnd().GetPara(); nLine++ )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( ToggleBreakPoint( nLine ) )
|
2011-01-14 11:16:25 +01:00
|
|
|
bNewBreakPoint = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aXEditorWindow.GetBrkWindow().Invalidate();
|
|
|
|
return bNewBreakPoint;
|
|
|
|
}
|
|
|
|
|
2003-04-11 16:37:21 +00:00
|
|
|
|
|
|
|
void ModulWindow::BasicToggleBreakPointEnabled()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
AssertValidEditEngine();
|
|
|
|
|
|
|
|
ExtTextView* pView = GetEditView();
|
|
|
|
if ( pView )
|
|
|
|
{
|
|
|
|
TextSelection aSel = pView->GetSelection();
|
|
|
|
BreakPointList& rList = GetBreakPoints();
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uLong nLine = ++aSel.GetStart().GetPara(), nEnd = ++aSel.GetEnd().GetPara(); nLine <= nEnd; ++nLine )
|
2003-04-11 16:37:21 +00:00
|
|
|
{
|
|
|
|
BreakPoint* pBrk = rList.FindBreakPoint( nLine );
|
|
|
|
if ( pBrk )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
pBrk->bEnabled = pBrk->bEnabled ? sal_False : sal_True;
|
2003-04-11 16:37:21 +00:00
|
|
|
UpdateBreakPoint( *pBrk );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GetBreakPointWindow().Invalidate();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModulWindow::ManageBreakPoints()
|
|
|
|
{
|
|
|
|
BreakPointWindow& rBrkWin = GetBreakPointWindow();
|
|
|
|
BreakPointDialog aBrkDlg( &rBrkWin, GetBreakPoints() );
|
|
|
|
aBrkDlg.Execute();
|
|
|
|
rBrkWin.Invalidate();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
IMPL_LINK( ModulWindow, BasicErrorHdl, StarBASIC *, pBasic )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
GoOnTop();
|
|
|
|
|
|
|
|
// ReturnWert: BOOL
|
|
|
|
// FALSE: Abbrechen
|
|
|
|
// TRUE: Weiter....
|
|
|
|
String aErrorText( pBasic->GetErrorText() );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nErrorLine = pBasic->GetLine() - 1;
|
|
|
|
sal_uInt16 nErrCol1 = pBasic->GetCol1();
|
|
|
|
sal_uInt16 nErrCol2 = pBasic->GetCol2();
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( nErrCol2 != 0xFFFF )
|
|
|
|
nErrCol2++;
|
|
|
|
|
|
|
|
AssertValidEditEngine();
|
|
|
|
GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, nErrCol1 ), TextPaM( nErrorLine, nErrCol2 ) ) );
|
|
|
|
|
|
|
|
String aErrorTextPrefix;
|
|
|
|
if( pBasic->IsCompilerError() )
|
|
|
|
{
|
|
|
|
aErrorTextPrefix = String( IDEResId( RID_STR_COMPILEERROR ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aErrorTextPrefix = String( IDEResId( RID_STR_RUNTIMEERROR ) );
|
|
|
|
aErrorTextPrefix += StarBASIC::GetVBErrorCode( pBasic->GetErrorCode() );
|
|
|
|
aErrorTextPrefix += ' ';
|
|
|
|
pLayout->GetStackWindow().UpdateCalls();
|
|
|
|
}
|
|
|
|
// Wenn anderes Basic, dan sollte die IDE versuchen, da richtige
|
|
|
|
// Modul anzuzeigen...
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bMarkError = ( pBasic == GetBasic() ) ? sal_True : sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( bMarkError )
|
2011-01-14 11:16:25 +01:00
|
|
|
aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine, sal_True );
|
2005-04-18 13:24:20 +00:00
|
|
|
|
|
|
|
// #i47002#
|
|
|
|
Reference< awt::XWindow > xWindow = VCLUnoHelper::GetInterface( this );
|
|
|
|
|
2001-09-11 14:40:15 +00:00
|
|
|
ErrorHandler::HandleError( StarBASIC::GetErrorCode() );
|
2005-04-18 13:24:20 +00:00
|
|
|
|
|
|
|
// #i47002#
|
|
|
|
Window* pWindow = VCLUnoHelper::GetWindow( xWindow );
|
|
|
|
if ( !pWindow )
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_False;
|
2005-04-18 13:24:20 +00:00
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( bMarkError )
|
|
|
|
aXEditorWindow.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER );
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
long ModulWindow::BasicBreakHdl( StarBASIC* pBasic )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
|
2007-01-16 15:28:29 +00:00
|
|
|
// #i69280 Required in Window despite normal usage in next command!
|
|
|
|
(void)pBasic;
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
// ReturnWert: sal_uInt16 => siehe SB-Debug-Flags
|
|
|
|
sal_uInt16 nErrorLine = pBasic->GetLine();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
// Gibt es hier einen BreakPoint?
|
|
|
|
BreakPoint* pBrk = GetBreakPoints().FindBreakPoint( nErrorLine );
|
2003-11-05 11:38:01 +00:00
|
|
|
if ( pBrk )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-11-05 11:38:01 +00:00
|
|
|
pBrk->nHitCount++;
|
|
|
|
if ( pBrk->nHitCount < pBrk->nStopAfter && GetBasic()->IsBreak() )
|
2000-09-29 10:02:42 +00:00
|
|
|
return aStatus.nBasicFlags; // weiterlaufen...
|
|
|
|
}
|
|
|
|
|
|
|
|
nErrorLine--; // EditEngine begint bei 0, Basic bei 1
|
|
|
|
// Alleine schon damit gescrollt wird...
|
|
|
|
AssertValidEditEngine();
|
|
|
|
GetEditView()->SetSelection( TextSelection( TextPaM( nErrorLine, 0 ), TextPaM( nErrorLine, 0 ) ) );
|
|
|
|
aXEditorWindow.GetBrkWindow().SetMarkerPos( nErrorLine );
|
|
|
|
|
|
|
|
pLayout->GetWatchWindow().UpdateWatches();
|
|
|
|
pLayout->GetStackWindow().UpdateCalls();
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
aStatus.bIsInReschedule = sal_True;
|
|
|
|
aStatus.bIsRunning = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
AddStatus( BASWIN_INRESCHEDULE );
|
|
|
|
|
|
|
|
BasicIDE::InvalidateDebuggerSlots();
|
|
|
|
|
|
|
|
while( aStatus.bIsRunning )
|
|
|
|
Application::Yield();
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
aStatus.bIsInReschedule = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
aXEditorWindow.GetBrkWindow().SetMarkerPos( MARKER_NOMARKER );
|
|
|
|
|
|
|
|
ClearStatus( BASWIN_INRESCHEDULE );
|
|
|
|
|
|
|
|
return aStatus.nBasicFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindow::BasicAddWatch()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
String aWatchStr;
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bInserted = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
AssertValidEditEngine();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bAdd = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
if ( !GetEditView()->HasSelection() )
|
|
|
|
{
|
|
|
|
TextPaM aWordStart;
|
|
|
|
String aWord = GetEditEngine()->GetWord( GetEditView()->GetSelection().GetEnd(), &aWordStart );
|
|
|
|
if ( aWord.Len() )
|
|
|
|
{
|
|
|
|
TextSelection aSel( aWordStart );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16& rIndex = aSel.GetEnd().GetIndex();
|
2007-01-16 15:28:29 +00:00
|
|
|
rIndex = rIndex + aWord.Len();
|
2000-09-29 10:02:42 +00:00
|
|
|
GetEditView()->SetSelection( aSel );
|
2011-01-14 11:16:25 +01:00
|
|
|
bAdd = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( bAdd )
|
|
|
|
{
|
|
|
|
TextSelection aSel = GetEditView()->GetSelection();
|
|
|
|
if ( aSel.GetStart().GetPara() == aSel.GetEnd().GetPara() )
|
|
|
|
{
|
|
|
|
aWatchStr = GetEditView()->GetSelected();
|
|
|
|
pLayout->GetWatchWindow().AddWatch( aWatchStr );
|
|
|
|
pLayout->GetWatchWindow().UpdateWatches();
|
2011-01-14 11:16:25 +01:00
|
|
|
bInserted = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !bInserted )
|
|
|
|
Sound::Beep();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ModulWindow::BasicRemoveWatch()
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bRemoved = pLayout->GetWatchWindow().RemoveSelectedWatch();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
if ( !bRemoved )
|
|
|
|
Sound::Beep();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModulWindow::EditMacro( const String& rMacroName )
|
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
2010-03-03 19:59:09 +00:00
|
|
|
DBG_ASSERT( XModule().Is(), "Kein Modul!" );
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-10-24 09:27:33 +00:00
|
|
|
CheckCompileBasic();
|
|
|
|
|
|
|
|
if ( !aStatus.bError )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nStart, nEnd;
|
2001-10-24 09:27:33 +00:00
|
|
|
SbMethod* pMethod = (SbMethod*)xModule->Find( rMacroName, SbxCLASS_METHOD );
|
|
|
|
if ( pMethod )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-10-24 09:27:33 +00:00
|
|
|
pMethod->GetLineRange( nStart, nEnd );
|
|
|
|
if ( nStart )
|
|
|
|
{
|
|
|
|
// Basic beginnt bei 1
|
|
|
|
nStart--;
|
|
|
|
nEnd--;
|
|
|
|
}
|
|
|
|
TextSelection aSel( TextPaM( nStart, 0 ), TextPaM( nStart, 0 ) );
|
|
|
|
AssertValidEditEngine();
|
|
|
|
TextView * pView = GetEditView();
|
|
|
|
// ggf. hinscrollen, so dass erste Zeile oben...
|
|
|
|
long nVisHeight = GetOutputSizePixel().Height();
|
|
|
|
if ( (long)pView->GetTextEngine()->GetTextHeight() > nVisHeight )
|
|
|
|
{
|
|
|
|
long nMaxY = pView->GetTextEngine()->GetTextHeight() - nVisHeight;
|
|
|
|
long nOldStartY = pView->GetStartDocPos().Y();
|
|
|
|
long nNewStartY = nStart * pView->GetTextEngine()->GetCharHeight();
|
|
|
|
nNewStartY = Min( nNewStartY, nMaxY );
|
|
|
|
pView->Scroll( 0, -(nNewStartY-nOldStartY) );
|
2011-01-14 11:16:25 +01:00
|
|
|
pView->ShowCursor( sal_False, sal_True );
|
2001-10-24 09:27:33 +00:00
|
|
|
GetEditVScrollBar().SetThumbPos( pView->GetStartDocPos().Y() );
|
|
|
|
}
|
|
|
|
pView->SetSelection( aSel );
|
|
|
|
pView->ShowCursor();
|
|
|
|
pView->GetWindow()->GrabFocus();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::StoreData()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
// StoreData wird gerufen, wenn der BasicManager zerstoert oder
|
|
|
|
// dieses Fenster beendet wird.
|
|
|
|
// => Keine Unterbrechungen erwuenscht!
|
|
|
|
// Und bei SAVE, wenn AppBasic...
|
2011-01-14 11:16:25 +01:00
|
|
|
GetEditorWindow().SetSourceInBasic( sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
sal_Bool ModulWindow::CanClose()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
sal_Bool ModulWindow::AllowUndo()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
return GetEditorWindow().CanModify();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::UpdateData()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
2010-03-03 19:59:09 +00:00
|
|
|
DBG_ASSERT( XModule().Is(), "Kein Modul!" );
|
2000-09-29 10:02:42 +00:00
|
|
|
// UpdateData wird gerufen, wenn sich der Source von aussen
|
|
|
|
// geaendert hat.
|
|
|
|
// => Keine Unterbrechungen erwuenscht!
|
2001-08-29 11:29:09 +00:00
|
|
|
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-04-23 15:38:46 +00:00
|
|
|
SetModule( xModule->GetSource32() );
|
2001-10-24 09:27:33 +00:00
|
|
|
|
|
|
|
if ( GetEditView() )
|
|
|
|
{
|
|
|
|
TextSelection aSel = GetEditView()->GetSelection();
|
2003-04-23 15:38:46 +00:00
|
|
|
setTextEngineText( GetEditEngine(), xModule->GetSource32() );
|
2001-10-24 09:27:33 +00:00
|
|
|
GetEditView()->SetSelection( aSel );
|
2011-01-14 11:16:25 +01:00
|
|
|
GetEditEngine()->SetModified( sal_False );
|
2007-03-15 14:52:11 +00:00
|
|
|
BasicIDE::MarkDocumentModified( GetDocument() );
|
2001-10-24 09:27:33 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-19 11:32:44 +00:00
|
|
|
sal_Int32 ModulWindow::countPages( Printer* pPrinter )
|
|
|
|
{
|
|
|
|
return FormatAndPrint( pPrinter, -1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindow::printPage( sal_Int32 nPage, Printer* pPrinter )
|
|
|
|
{
|
|
|
|
FormatAndPrint( pPrinter, nPage );
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2009-05-19 11:32:44 +00:00
|
|
|
/* implementation note: this is totally inefficient for the XRenderable interface
|
|
|
|
usage since the whole "document" will be format for every page. Should this ever
|
|
|
|
become a problem we should
|
|
|
|
- format only once for every new printer
|
|
|
|
- keep an index list for each page which is the starting paragraph
|
|
|
|
*/
|
|
|
|
sal_Int32 ModulWindow::FormatAndPrint( Printer* pPrinter, sal_Int32 nPrintPage )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
|
|
|
|
AssertValidEditEngine();
|
|
|
|
|
|
|
|
MapMode eOldMapMode( pPrinter->GetMapMode() );
|
|
|
|
Font aOldFont( pPrinter->GetFont() );
|
|
|
|
|
|
|
|
Font aFont( GetEditEngine()->GetFont() );
|
|
|
|
aFont.SetAlign( ALIGN_BOTTOM );
|
2011-01-14 11:16:25 +01:00
|
|
|
aFont.SetTransparent( sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
aFont.SetSize( Size( 0, 360 ) );
|
|
|
|
pPrinter->SetFont( aFont );
|
|
|
|
pPrinter->SetMapMode( MAP_100TH_MM );
|
|
|
|
|
|
|
|
String aTitle( CreateQualifiedName() );
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nLineHeight = (sal_uInt16) pPrinter->GetTextHeight(); // etwas mehr.
|
|
|
|
sal_uInt16 nParaSpace = 10;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
Size aPaperSz = pPrinter->GetOutputSize();
|
|
|
|
aPaperSz.Width() -= (LMARGPRN+RMARGPRN);
|
|
|
|
aPaperSz.Height() -= (TMARGPRN+BMARGPRN);
|
|
|
|
|
|
|
|
// nLinepPage stimmt nicht, wenn Zeilen umgebrochen werden muessen...
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nLinespPage = (sal_uInt16) (aPaperSz.Height()/nLineHeight);
|
|
|
|
sal_uInt16 nCharspLine = (sal_uInt16) (aPaperSz.Width() / pPrinter->GetTextWidth( 'X' ) );
|
|
|
|
sal_uLong nParas = GetEditEngine()->GetParagraphCount();
|
2000-09-29 10:02:42 +00:00
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nPages = (sal_uInt16) (nParas/nLinespPage+1 );
|
|
|
|
sal_uInt16 nCurPage = 1;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
// Header drucken...
|
2009-05-19 11:32:44 +00:00
|
|
|
lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nPrintPage == 0 );
|
2000-09-29 10:02:42 +00:00
|
|
|
Point aPos( LMARGPRN, TMARGPRN );
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uLong nPara = 0; nPara < nParas; nPara++ )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
String aLine( GetEditEngine()->GetText( nPara ) );
|
|
|
|
lcl_ConvertTabsToSpaces( aLine );
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nLines = aLine.Len()/nCharspLine+1;
|
|
|
|
for ( sal_uInt16 nLine = 0; nLine < nLines; nLine++ )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
String aTmpLine( aLine, nLine*nCharspLine, nCharspLine );
|
|
|
|
aPos.Y() += nLineHeight;
|
|
|
|
if ( aPos.Y() > ( aPaperSz.Height()+TMARGPRN ) )
|
|
|
|
{
|
|
|
|
nCurPage++;
|
2009-05-19 11:32:44 +00:00
|
|
|
lcl_PrintHeader( pPrinter, nPages, nCurPage, aTitle, nCurPage-1 == nPrintPage );
|
2000-09-29 10:02:42 +00:00
|
|
|
aPos = Point( LMARGPRN, TMARGPRN+nLineHeight );
|
|
|
|
}
|
2009-05-19 11:32:44 +00:00
|
|
|
if( nCurPage-1 == nPrintPage )
|
|
|
|
pPrinter->DrawText( aPos, aTmpLine );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
aPos.Y() += nParaSpace;
|
|
|
|
}
|
|
|
|
|
|
|
|
pPrinter->SetFont( aOldFont );
|
|
|
|
pPrinter->SetMapMode( eOldMapMode );
|
2009-05-19 11:32:44 +00:00
|
|
|
|
|
|
|
return sal_Int32(nCurPage);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::ExecuteCommand( SfxRequest& rReq )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
AssertValidEditEngine();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nSlot = rReq.GetSlot();
|
2000-09-29 10:02:42 +00:00
|
|
|
switch ( nSlot )
|
|
|
|
{
|
|
|
|
case SID_BASICRUN:
|
|
|
|
{
|
|
|
|
BasicRun();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICCOMPILE:
|
|
|
|
{
|
|
|
|
CompileBasic();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICSTEPOVER:
|
|
|
|
{
|
|
|
|
BasicStepOver();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICSTEPINTO:
|
|
|
|
{
|
|
|
|
BasicStepInto();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICSTEPOUT:
|
|
|
|
{
|
|
|
|
BasicStepOut();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICLOAD:
|
|
|
|
{
|
|
|
|
LoadBasic();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICSAVEAS:
|
|
|
|
{
|
|
|
|
SaveBasicSource();
|
|
|
|
}
|
|
|
|
break;
|
2009-09-11 09:40:28 +00:00
|
|
|
case SID_IMPORT_DIALOG:
|
|
|
|
{
|
|
|
|
ImportDialog();
|
|
|
|
}
|
|
|
|
break;
|
2000-09-29 10:02:42 +00:00
|
|
|
case SID_BASICIDE_MATCHGROUP:
|
|
|
|
{
|
|
|
|
if ( !GetEditView()->MatchGroup() )
|
|
|
|
Sound::Beep();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICIDE_TOGGLEBRKPNT:
|
|
|
|
{
|
|
|
|
BasicToggleBreakPoint();
|
|
|
|
}
|
|
|
|
break;
|
2003-04-11 16:37:21 +00:00
|
|
|
case SID_BASICIDE_MANAGEBRKPNTS:
|
|
|
|
{
|
|
|
|
ManageBreakPoints();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICIDE_TOGGLEBRKPNTENABLED:
|
|
|
|
{
|
|
|
|
BasicToggleBreakPointEnabled();
|
|
|
|
}
|
|
|
|
break;
|
2000-09-29 10:02:42 +00:00
|
|
|
case SID_BASICIDE_ADDWATCH:
|
|
|
|
{
|
|
|
|
BasicAddWatch();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICIDE_REMOVEWATCH:
|
|
|
|
{
|
|
|
|
BasicRemoveWatch();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_CUT:
|
|
|
|
{
|
2001-11-12 21:39:49 +00:00
|
|
|
if ( !IsReadOnly() )
|
|
|
|
{
|
|
|
|
GetEditView()->Cut();
|
2006-01-03 11:41:51 +00:00
|
|
|
SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
|
|
|
|
if ( pBindings )
|
|
|
|
pBindings->Invalidate( SID_DOC_MODIFIED );
|
2001-11-12 21:39:49 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_COPY:
|
|
|
|
{
|
|
|
|
GetEditView()->Copy();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_PASTE:
|
|
|
|
{
|
2001-11-12 21:39:49 +00:00
|
|
|
if ( !IsReadOnly() )
|
|
|
|
{
|
|
|
|
GetEditView()->Paste();
|
2006-01-03 11:41:51 +00:00
|
|
|
SfxBindings* pBindings = BasicIDE::GetBindingsPtr();
|
|
|
|
if ( pBindings )
|
|
|
|
pBindings->Invalidate( SID_DOC_MODIFIED );
|
2001-11-12 21:39:49 +00:00
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_BASICIDE_BRKPNTSCHANGED:
|
|
|
|
{
|
|
|
|
GetBreakPointWindow().Invalidate();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::GetState( SfxItemSet &rSet )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
SfxWhichIter aIter(rSet);
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uInt16 nWh = aIter.FirstWhich(); 0 != nWh; nWh = aIter.NextWhich() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
switch ( nWh )
|
|
|
|
{
|
|
|
|
// allgemeine Items:
|
2001-11-12 21:39:49 +00:00
|
|
|
case SID_CUT:
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-11-12 21:39:49 +00:00
|
|
|
if ( !GetEditView() || !GetEditView()->HasSelection() )
|
|
|
|
rSet.DisableItem( nWh );
|
|
|
|
|
|
|
|
if ( IsReadOnly() )
|
|
|
|
rSet.DisableItem( nWh );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-11-12 21:39:49 +00:00
|
|
|
case SID_COPY:
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-11-12 21:39:49 +00:00
|
|
|
if ( !GetEditView() || !GetEditView()->HasSelection() )
|
|
|
|
rSet.DisableItem( nWh );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
break;
|
2001-11-09 14:41:40 +00:00
|
|
|
case SID_PASTE:
|
|
|
|
{
|
2001-11-12 21:39:49 +00:00
|
|
|
if ( !IsPasteAllowed() )
|
|
|
|
rSet.DisableItem( nWh );
|
|
|
|
|
|
|
|
if ( IsReadOnly() )
|
2001-11-09 14:41:40 +00:00
|
|
|
rSet.DisableItem( nWh );
|
|
|
|
}
|
|
|
|
break;
|
2000-09-29 10:02:42 +00:00
|
|
|
case SID_BASICIDE_STAT_POS:
|
|
|
|
{
|
|
|
|
TextView* pView = GetEditView();
|
|
|
|
if ( pView )
|
|
|
|
{
|
|
|
|
TextSelection aSel = pView->GetSelection();
|
|
|
|
String aPos( IDEResId( RID_STR_LINE ) );
|
|
|
|
aPos += ' ';
|
|
|
|
aPos += String::CreateFromInt32( aSel.GetEnd().GetPara()+1 );
|
|
|
|
aPos += String( RTL_CONSTASCII_USTRINGPARAM( ", " ) );
|
|
|
|
aPos += String( IDEResId( RID_STR_COLUMN ) );
|
|
|
|
aPos += ' ';
|
|
|
|
aPos += String::CreateFromInt32( aSel.GetEnd().GetIndex()+1 );
|
|
|
|
SfxStringItem aItem( SID_BASICIDE_STAT_POS, aPos );
|
|
|
|
rSet.Put( aItem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case SID_ATTR_INSERT:
|
|
|
|
{
|
|
|
|
TextView* pView = GetEditView();
|
|
|
|
if ( pView )
|
|
|
|
{
|
|
|
|
SfxBoolItem aItem( SID_ATTR_INSERT, pView->IsInsertMode() );
|
|
|
|
rSet.Put( aItem );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::DoScroll( ScrollBar* pCurScrollBar )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DBG_CHKTHIS( ModulWindow, 0 );
|
|
|
|
if ( ( pCurScrollBar == GetHScrollBar() ) && GetEditView() )
|
|
|
|
{
|
|
|
|
// Nicht mit dem Wert Scrollen, sondern lieber die Thumb-Pos fuer die
|
|
|
|
// VisArea verwenden:
|
|
|
|
long nDiff = GetEditView()->GetStartDocPos().X() - pCurScrollBar->GetThumbPos();
|
|
|
|
GetEditView()->Scroll( nDiff, 0 );
|
2011-01-14 11:16:25 +01:00
|
|
|
GetEditView()->ShowCursor( sal_False, sal_True );
|
2000-09-29 10:02:42 +00:00
|
|
|
pCurScrollBar->SetThumbPos( GetEditView()->GetStartDocPos().X() );
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
sal_Bool ModulWindow::IsModified()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
return GetEditEngine() ? GetEditEngine()->IsModified() : sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::GoOnTop()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
IDE_DLL()->GetShell()->GetViewFrame()->ToTop();
|
|
|
|
}
|
|
|
|
|
2001-08-29 11:29:09 +00:00
|
|
|
String ModulWindow::GetSbModuleName()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
String aModuleName;
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() )
|
2000-09-29 10:02:42 +00:00
|
|
|
aModuleName = xModule->GetName();
|
|
|
|
return aModuleName;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
String ModulWindow::GetTitle()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-08-29 11:29:09 +00:00
|
|
|
return GetSbModuleName();
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void ModulWindow::FrameWindowMoved()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
void ModulWindow::ShowCursor( sal_Bool bOn )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( GetEditEngine() )
|
|
|
|
{
|
|
|
|
TextView* pView = GetEditEngine()->GetActiveView();
|
|
|
|
if ( pView )
|
|
|
|
{
|
|
|
|
if ( bOn )
|
|
|
|
pView->ShowCursor();
|
|
|
|
else
|
|
|
|
pView->HideCursor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
Window* ModulWindow::GetLayoutWindow()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
return pLayout;
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindow::AssertValidEditEngine()
|
|
|
|
{
|
|
|
|
if ( !GetEditEngine() )
|
|
|
|
GetEditorWindow().CreateEditEngine();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindow::Deactivating()
|
|
|
|
{
|
|
|
|
if ( GetEditView() )
|
|
|
|
GetEditView()->EraseVirtualDevice();
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 ModulWindow::StartSearchAndReplace( const SvxSearchItem& rSearchItem, sal_Bool bFromStart )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2001-03-09 15:57:00 +00:00
|
|
|
// Mann koennte fuer das blinde Alle-Ersetzen auch auf
|
|
|
|
// Syntaxhighlighting/Formatierung verzichten...
|
|
|
|
AssertValidEditEngine();
|
|
|
|
ExtTextView* pView = GetEditView();
|
|
|
|
TextSelection aSel;
|
|
|
|
if ( bFromStart )
|
|
|
|
{
|
|
|
|
aSel = pView->GetSelection();
|
|
|
|
if ( !rSearchItem.GetBackward() )
|
|
|
|
pView->SetSelection( TextSelection() );
|
|
|
|
else
|
|
|
|
pView->SetSelection( TextSelection( TextPaM( 0xFFFFFFFF, 0xFFFF ), TextPaM( 0xFFFFFFFF, 0xFFFF ) ) );
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bForward = !rSearchItem.GetBackward();
|
|
|
|
sal_uInt16 nFound = 0;
|
2001-03-09 15:57:00 +00:00
|
|
|
if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND ) ||
|
|
|
|
( rSearchItem.GetCommand() == SVX_SEARCHCMD_FIND_ALL ) )
|
|
|
|
{
|
|
|
|
nFound = pView->Search( rSearchItem.GetSearchOptions() , bForward );
|
|
|
|
}
|
|
|
|
else if ( ( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE ) ||
|
|
|
|
( rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL ) )
|
|
|
|
{
|
2005-01-13 16:49:06 +00:00
|
|
|
if ( !IsReadOnly() )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bAll = rSearchItem.GetCommand() == SVX_SEARCHCMD_REPLACE_ALL;
|
2005-01-13 16:49:06 +00:00
|
|
|
nFound = pView->Replace( rSearchItem.GetSearchOptions() , bAll , bForward );
|
|
|
|
}
|
2001-03-09 15:57:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( bFromStart && !nFound )
|
|
|
|
pView->SetSelection( aSel );
|
|
|
|
|
|
|
|
return nFound;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
::svl::IUndoManager* ModulWindow::GetUndoManager()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( GetEditEngine() )
|
|
|
|
return &GetEditEngine()->GetUndoManager();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
sal_uInt16 ModulWindow::GetSearchOptions()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uInt16 nOptions = SEARCH_OPTIONS_SEARCH |
|
2005-01-13 16:49:06 +00:00
|
|
|
SEARCH_OPTIONS_WHOLE_WORDS |
|
|
|
|
SEARCH_OPTIONS_BACKWARDS |
|
|
|
|
SEARCH_OPTIONS_REG_EXP |
|
|
|
|
SEARCH_OPTIONS_EXACT |
|
|
|
|
SEARCH_OPTIONS_SELECTION |
|
|
|
|
SEARCH_OPTIONS_SIMILARITY;
|
|
|
|
|
|
|
|
if ( !IsReadOnly() )
|
|
|
|
{
|
|
|
|
nOptions |= SEARCH_OPTIONS_REPLACE;
|
|
|
|
nOptions |= SEARCH_OPTIONS_REPLACE_ALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return nOptions;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::BasicStarted()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2010-03-03 19:59:09 +00:00
|
|
|
if ( XModule().Is() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
aStatus.bIsRunning = sal_True;
|
2003-11-05 11:38:01 +00:00
|
|
|
BreakPointList& rList = GetBreakPoints();
|
2010-12-11 07:39:25 -08:00
|
|
|
if ( rList.size() )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2003-11-05 11:38:01 +00:00
|
|
|
rList.ResetHitCount();
|
|
|
|
rList.SetBreakPointsInBasic( xModule );
|
2011-01-14 11:16:25 +01:00
|
|
|
for ( sal_uInt16 nMethod = 0; nMethod < xModule->GetMethods()->Count(); nMethod++ )
|
2001-10-24 09:27:33 +00:00
|
|
|
{
|
|
|
|
SbMethod* pMethod = (SbMethod*)xModule->GetMethods()->Get( nMethod );
|
|
|
|
DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
|
|
|
|
pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
|
|
|
|
}
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindow::BasicStopped()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
aStatus.bIsRunning = sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
GetBreakPointWindow().SetMarkerPos( MARKER_NOMARKER );
|
|
|
|
}
|
|
|
|
|
2004-07-23 11:01:17 +00:00
|
|
|
BasicEntryDescriptor ModulWindow::CreateEntryDescriptor()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2007-03-15 14:52:11 +00:00
|
|
|
ScriptDocument aDocument( GetDocument() );
|
2004-07-23 11:01:17 +00:00
|
|
|
String aLibName( GetLibName() );
|
2007-03-15 14:52:11 +00:00
|
|
|
LibraryLocation eLocation = aDocument.getLibraryLocation( aLibName );
|
2010-03-02 12:39:31 +00:00
|
|
|
String aModName( GetName() );
|
|
|
|
String aLibSubName;
|
2010-03-03 19:59:09 +00:00
|
|
|
if( xBasic.Is() && aDocument.isInVBAMode() && XModule().Is() )
|
2010-03-02 12:39:31 +00:00
|
|
|
{
|
|
|
|
switch( xModule->GetModuleType() )
|
|
|
|
{
|
2010-04-16 17:28:52 +02:00
|
|
|
case script::ModuleType::DOCUMENT:
|
2010-03-02 12:39:31 +00:00
|
|
|
{
|
|
|
|
aLibSubName = String( IDEResId( RID_STR_DOCUMENT_OBJECTS ) );
|
|
|
|
uno::Reference< container::XNameContainer > xLib = aDocument.getOrCreateLibrary( E_SCRIPTS, aLibName );
|
|
|
|
if( xLib.is() )
|
|
|
|
{
|
|
|
|
String sObjName;
|
2010-04-20 10:31:03 +01:00
|
|
|
ModuleInfoHelper::getObjectName( xLib, aModName, sObjName );
|
2010-03-02 12:39:31 +00:00
|
|
|
if( sObjName.Len() )
|
|
|
|
{
|
|
|
|
aModName.AppendAscii(" (").Append(sObjName).AppendAscii(")");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2010-04-16 17:28:52 +02:00
|
|
|
case script::ModuleType::FORM:
|
2010-03-02 12:39:31 +00:00
|
|
|
aLibSubName = String( IDEResId( RID_STR_USERFORMS ) );
|
|
|
|
break;
|
2010-04-16 17:28:52 +02:00
|
|
|
case script::ModuleType::NORMAL:
|
2010-03-02 12:39:31 +00:00
|
|
|
aLibSubName = String( IDEResId( RID_STR_NORMAL_MODULES ) );
|
|
|
|
break;
|
2010-04-16 17:28:52 +02:00
|
|
|
case script::ModuleType::CLASS:
|
2010-03-02 12:39:31 +00:00
|
|
|
aLibSubName = String( IDEResId( RID_STR_CLASS_MODULES ) );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return BasicEntryDescriptor( aDocument, eLocation, aLibName, aLibSubName, aModName, OBJ_TYPE_MODULE );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
void ModulWindow::SetReadOnly( sal_Bool b )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
if ( GetEditView() )
|
|
|
|
GetEditView()->SetReadOnly( b );
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::IsReadOnly()
|
2001-11-12 21:39:49 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bReadOnly = sal_False;
|
2001-11-12 21:39:49 +00:00
|
|
|
|
|
|
|
if ( GetEditView() )
|
|
|
|
bReadOnly = GetEditView()->IsReadOnly();
|
|
|
|
|
|
|
|
return bReadOnly;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindow::IsPasteAllowed()
|
2001-11-12 21:39:49 +00:00
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool bPaste = sal_False;
|
2001-11-12 21:39:49 +00:00
|
|
|
|
|
|
|
// get clipboard
|
|
|
|
Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
|
|
|
|
if ( xClipboard.is() )
|
|
|
|
{
|
|
|
|
// get clipboard content
|
|
|
|
const sal_uInt32 nRef = Application::ReleaseSolarMutex();
|
|
|
|
Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
|
|
|
|
Application::AcquireSolarMutex( nRef );
|
|
|
|
if ( xTransf.is() )
|
|
|
|
{
|
|
|
|
datatransfer::DataFlavor aFlavor;
|
|
|
|
SotExchange::GetFormatDataFlavor( SOT_FORMAT_STRING, aFlavor );
|
|
|
|
if ( xTransf->isDataFlavorSupported( aFlavor ) )
|
|
|
|
{
|
2011-01-14 11:16:25 +01:00
|
|
|
bPaste = sal_True;
|
2001-11-12 21:39:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bPaste;
|
|
|
|
}
|
|
|
|
|
2000-09-29 10:02:42 +00:00
|
|
|
ModulWindowLayout::ModulWindowLayout( Window* pParent ) :
|
|
|
|
Window( pParent, WB_CLIPCHILDREN ),
|
|
|
|
aVSplitter( this, WinBits( WB_VSCROLL ) ),
|
|
|
|
aHSplitter( this, WinBits( WB_HSCROLL ) ),
|
2002-07-05 09:22:53 +00:00
|
|
|
aWatchWindow( this ),
|
|
|
|
aStackWindow( this ),
|
2011-01-14 11:16:25 +01:00
|
|
|
bVSplitted(sal_False),
|
|
|
|
bHSplitted(sal_False),
|
2002-07-05 09:22:53 +00:00
|
|
|
m_pModulWindow(0),
|
2010-11-13 17:22:01 +00:00
|
|
|
m_aImagesNormal(IDEResId(RID_IMGLST_LAYOUT))
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2002-07-05 09:22:53 +00:00
|
|
|
SetBackground(GetSettings().GetStyleSettings().GetWindowColor());
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
aVSplitter.SetSplitHdl( LINK( this, ModulWindowLayout, SplitHdl ) );
|
|
|
|
aHSplitter.SetSplitHdl( LINK( this, ModulWindowLayout, SplitHdl ) );
|
|
|
|
aVSplitter.Show();
|
|
|
|
aHSplitter.Show();
|
|
|
|
|
|
|
|
aWatchWindow.Show();
|
|
|
|
aStackWindow.Show();
|
|
|
|
|
2002-07-05 09:22:53 +00:00
|
|
|
Color aColor(GetSettings().GetStyleSettings().GetFieldTextColor());
|
|
|
|
m_aSyntaxColors[TT_UNKNOWN] = aColor;
|
|
|
|
m_aSyntaxColors[TT_WHITESPACE] = aColor;
|
|
|
|
m_aSyntaxColors[TT_EOL] = aColor;
|
2009-10-16 00:05:16 +02:00
|
|
|
m_aColorConfig.AddListener(this);
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_IDENTIFIER]
|
2003-03-18 15:17:10 +00:00
|
|
|
= Color(m_aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).nColor);
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_NUMBER]
|
2003-03-18 15:17:10 +00:00
|
|
|
= Color(m_aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor);
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_STRING]
|
2003-03-18 15:17:10 +00:00
|
|
|
= Color(m_aColorConfig.GetColorValue(svtools::BASICSTRING).nColor);
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_COMMENT]
|
2003-03-18 15:17:10 +00:00
|
|
|
= Color(m_aColorConfig.GetColorValue(svtools::BASICCOMMENT).nColor);
|
2002-07-05 13:51:15 +00:00
|
|
|
m_aSyntaxColors[TT_ERROR]
|
2003-03-18 15:17:10 +00:00
|
|
|
= Color(m_aColorConfig.GetColorValue(svtools::BASICERROR).nColor);
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_OPERATOR]
|
2003-03-18 15:17:10 +00:00
|
|
|
= Color(m_aColorConfig.GetColorValue(svtools::BASICOPERATOR).nColor);
|
2008-11-28 11:39:37 +00:00
|
|
|
m_aSyntaxColors[TT_KEYWORDS]
|
2003-03-18 15:17:10 +00:00
|
|
|
= Color(m_aColorConfig.GetColorValue(svtools::BASICKEYWORD).nColor);
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
Font aFont( GetFont() );
|
|
|
|
Size aSz( aFont.GetSize() );
|
|
|
|
aSz.Height() *= 3;
|
|
|
|
aSz.Height() /= 2;
|
|
|
|
aFont.SetSize( aSz );
|
|
|
|
aFont.SetWeight( WEIGHT_BOLD );
|
2002-07-05 09:22:53 +00:00
|
|
|
aFont.SetColor(GetSettings().GetStyleSettings().GetWindowTextColor());
|
2000-09-29 10:02:42 +00:00
|
|
|
SetFont( aFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
ModulWindowLayout::~ModulWindowLayout()
|
|
|
|
{
|
2009-10-16 00:05:16 +02:00
|
|
|
m_aColorConfig.RemoveListener(this);
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindowLayout::Resize()
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
// ScrollBars, etc. passiert in BasicIDEShell:Adjust...
|
|
|
|
ArrangeWindows();
|
|
|
|
}
|
|
|
|
|
2010-12-11 22:45:31 +01:00
|
|
|
void ModulWindowLayout::Paint( const Rectangle& )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
DrawText( Point(), String( IDEResId( RID_STR_NOMODULE ) ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ModulWindowLayout::ArrangeWindows()
|
|
|
|
{
|
|
|
|
Size aSz = GetOutputSizePixel();
|
|
|
|
|
|
|
|
// prueffen, ob der Splitter in einem gueltigen Bereich liegt...
|
|
|
|
long nMinPos = SPLIT_MARGIN;
|
|
|
|
long nMaxPos = aSz.Height() - SPLIT_MARGIN;
|
|
|
|
|
|
|
|
long nVSplitPos = aVSplitter.GetSplitPosPixel();
|
|
|
|
long nHSplitPos = aHSplitter.GetSplitPosPixel();
|
|
|
|
if ( !bVSplitted )
|
|
|
|
{
|
|
|
|
// Wenn noch nie gesplitted wurde, Verhaeltniss = 3 : 4
|
|
|
|
nVSplitPos = aSz.Height() * 3 / 4;
|
|
|
|
aVSplitter.SetSplitPosPixel( nVSplitPos );
|
|
|
|
}
|
|
|
|
if ( !bHSplitted )
|
|
|
|
{
|
|
|
|
// Wenn noch nie gesplitted wurde, Verhaeltniss = 2 : 3
|
|
|
|
nHSplitPos = aSz.Width() * 2 / 3;
|
|
|
|
aHSplitter.SetSplitPosPixel( nHSplitPos );
|
|
|
|
}
|
|
|
|
if ( ( nVSplitPos < nMinPos ) || ( nVSplitPos > nMaxPos ) )
|
|
|
|
nVSplitPos = ( nVSplitPos < nMinPos ) ? 0 : ( aSz.Height() - SPLIT_HEIGHT );
|
|
|
|
|
|
|
|
Size aXEWSz;
|
|
|
|
aXEWSz.Width() = aSz.Width();
|
|
|
|
aXEWSz.Height() = nVSplitPos + 1;
|
2002-07-05 09:22:53 +00:00
|
|
|
if ( m_pModulWindow )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
2002-07-05 09:22:53 +00:00
|
|
|
DBG_CHKOBJ( m_pModulWindow, ModulWindow, 0 );
|
|
|
|
m_pModulWindow->SetPosSizePixel( Point( 0, 0 ), aXEWSz );
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
aVSplitter.SetDragRectPixel( Rectangle( Point( 0, 0 ), Size( aSz.Width(), aSz.Height() ) ) );
|
|
|
|
aVSplitter.SetPosPixel( Point( 0, nVSplitPos ) );
|
|
|
|
aVSplitter.SetSizePixel( Size( aSz.Width(), SPLIT_HEIGHT ) );
|
|
|
|
|
|
|
|
aHSplitter.SetDragRectPixel( Rectangle( Point( 0, nVSplitPos+SPLIT_HEIGHT ), Size( aSz.Width(), aSz.Height() - nVSplitPos - SPLIT_HEIGHT ) ) );
|
|
|
|
aHSplitter.SetPosPixel( Point( nHSplitPos, nVSplitPos ) );
|
|
|
|
aHSplitter.SetSizePixel( Size( SPLIT_HEIGHT, aSz.Height() - nVSplitPos ) );
|
|
|
|
|
|
|
|
Size aWWSz;
|
|
|
|
Point aWWPos( 0, nVSplitPos+SPLIT_HEIGHT );
|
|
|
|
aWWSz.Width() = nHSplitPos;
|
|
|
|
aWWSz.Height() = aSz.Height() - aWWPos.Y();
|
|
|
|
if ( !aWatchWindow.IsFloatingMode() )
|
|
|
|
aWatchWindow.SetPosSizePixel( aWWPos, aWWSz );
|
|
|
|
|
|
|
|
Size aSWSz;
|
|
|
|
Point aSWPos( nHSplitPos+SPLIT_HEIGHT, nVSplitPos+SPLIT_HEIGHT );
|
|
|
|
aSWSz.Width() = aSz.Width() - aSWPos.X();
|
|
|
|
aSWSz.Height() = aSz.Height() - aSWPos.Y();
|
|
|
|
if ( !aStackWindow.IsFloatingMode() )
|
|
|
|
aStackWindow.SetPosSizePixel( aSWPos, aSWSz );
|
|
|
|
|
|
|
|
if ( aStackWindow.IsFloatingMode() && aWatchWindow.IsFloatingMode() )
|
|
|
|
aHSplitter.Hide();
|
|
|
|
else
|
|
|
|
aHSplitter.Show();
|
|
|
|
|
|
|
|
long nHDoubleClickSplitPosX = aSz.Width()-aHSplitter.GetSizePixel().Width();
|
|
|
|
if ( aHSplitter.GetSplitPosPixel() < nHDoubleClickSplitPosX )
|
|
|
|
aHSplitter.SetLastSplitPosPixel( nHDoubleClickSplitPosX );
|
|
|
|
|
|
|
|
|
|
|
|
long nHDoubleClickSplitPosY = aSz.Height()-aVSplitter.GetSizePixel().Height();
|
|
|
|
if ( aVSplitter.GetSplitPosPixel() < nHDoubleClickSplitPosY )
|
|
|
|
aVSplitter.SetLastSplitPosPixel( nHDoubleClickSplitPosY );
|
|
|
|
}
|
|
|
|
|
|
|
|
IMPL_LINK( ModulWindowLayout, SplitHdl, Splitter *, pSplitter )
|
|
|
|
{
|
|
|
|
if ( pSplitter == &aVSplitter )
|
2011-01-14 11:16:25 +01:00
|
|
|
bVSplitted = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
else
|
2011-01-14 11:16:25 +01:00
|
|
|
bHSplitted = sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
|
|
|
|
ArrangeWindows();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_Bool ModulWindowLayout::IsToBeDocked( DockingWindow* pDockingWindow, const Point& rPos, Rectangle& rRect )
|
2000-09-29 10:02:42 +00:00
|
|
|
{
|
|
|
|
// prueffen, ob als Dock oder als Child:
|
|
|
|
// TRUE: Floating
|
|
|
|
// FALSE: Child
|
|
|
|
Point aPosInMe = ScreenToOutputPixel( rPos );
|
|
|
|
Size aSz = GetOutputSizePixel();
|
|
|
|
if ( ( aPosInMe.X() > 0 ) && ( aPosInMe.X() < aSz.Width() ) &&
|
|
|
|
( aPosInMe.Y() > 0 ) && ( aPosInMe.Y() < aSz.Height() ) )
|
|
|
|
{
|
|
|
|
long nVSplitPos = aVSplitter.GetSplitPosPixel();
|
|
|
|
long nHSplitPos = aHSplitter.GetSplitPosPixel();
|
|
|
|
if ( pDockingWindow == &aWatchWindow )
|
|
|
|
{
|
|
|
|
if ( ( aPosInMe.Y() > nVSplitPos ) && ( aPosInMe.X() < nHSplitPos ) )
|
|
|
|
{
|
|
|
|
rRect.SetSize( Size( nHSplitPos, aSz.Height() - nVSplitPos ) );
|
|
|
|
rRect.SetPos( OutputToScreenPixel( Point( 0, nVSplitPos ) ) );
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( pDockingWindow == &aStackWindow )
|
|
|
|
{
|
|
|
|
if ( ( aPosInMe.Y() > nVSplitPos ) && ( aPosInMe.X() > nHSplitPos ) )
|
|
|
|
{
|
|
|
|
rRect.SetSize( Size( aSz.Width() - nHSplitPos, aSz.Height() - nVSplitPos ) );
|
|
|
|
rRect.SetPos( OutputToScreenPixel( Point( nHSplitPos, nVSplitPos ) ) );
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_True;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-01-14 11:16:25 +01:00
|
|
|
return sal_False;
|
2000-09-29 10:02:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindowLayout::DockaWindow( DockingWindow* pDockingWindow )
|
|
|
|
{
|
|
|
|
if ( pDockingWindow == &aWatchWindow )
|
|
|
|
{
|
|
|
|
// evtl. Sonderbehandlung...
|
|
|
|
ArrangeWindows();
|
|
|
|
}
|
|
|
|
else if ( pDockingWindow == &aStackWindow )
|
|
|
|
{
|
|
|
|
// evtl. Sonderbehandlung...
|
|
|
|
ArrangeWindows();
|
|
|
|
}
|
2011-03-01 18:57:17 +01:00
|
|
|
#if OSL_DEBUG_LEVEL > 0
|
2000-09-29 10:02:42 +00:00
|
|
|
else
|
2011-03-01 17:55:09 +01:00
|
|
|
OSL_FAIL( "Wer will sich denn hier andocken ?" );
|
2000-09-29 10:02:42 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindowLayout::SetModulWindow( ModulWindow* pModWin )
|
|
|
|
{
|
2002-07-05 09:22:53 +00:00
|
|
|
m_pModulWindow = pModWin;
|
2000-09-29 10:02:42 +00:00
|
|
|
ArrangeWindows();
|
|
|
|
}
|
|
|
|
|
2002-07-05 09:22:53 +00:00
|
|
|
// virtual
|
|
|
|
void ModulWindowLayout::DataChanged(DataChangedEvent const & rDCEvt)
|
|
|
|
{
|
|
|
|
Window::DataChanged(rDCEvt);
|
|
|
|
if (rDCEvt.GetType() == DATACHANGED_SETTINGS
|
|
|
|
&& (rDCEvt.GetFlags() & SETTINGS_STYLE) != 0)
|
|
|
|
{
|
|
|
|
bool bInvalidate = false;
|
|
|
|
Color aColor(GetSettings().GetStyleSettings().GetWindowColor());
|
|
|
|
if (aColor
|
|
|
|
!= rDCEvt.GetOldSettings()->GetStyleSettings().GetWindowColor())
|
|
|
|
{
|
|
|
|
SetBackground(Wallpaper(aColor));
|
|
|
|
bInvalidate = true;
|
|
|
|
}
|
|
|
|
aColor = GetSettings().GetStyleSettings().GetWindowTextColor();
|
|
|
|
if (aColor != rDCEvt.GetOldSettings()->
|
|
|
|
GetStyleSettings().GetWindowTextColor())
|
|
|
|
{
|
|
|
|
Font aFont(GetFont());
|
|
|
|
aFont.SetColor(aColor);
|
|
|
|
SetFont(aFont);
|
|
|
|
bInvalidate = true;
|
|
|
|
}
|
|
|
|
if (bInvalidate)
|
|
|
|
Invalidate();
|
|
|
|
aColor = GetSettings().GetStyleSettings().GetFieldTextColor();
|
|
|
|
if (aColor != m_aSyntaxColors[TT_UNKNOWN])
|
|
|
|
{
|
|
|
|
m_aSyntaxColors[TT_UNKNOWN] = aColor;
|
|
|
|
m_aSyntaxColors[TT_WHITESPACE] = aColor;
|
|
|
|
m_aSyntaxColors[TT_EOL] = aColor;
|
|
|
|
updateSyntaxHighlighting();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// virtual
|
2009-10-16 00:05:16 +02:00
|
|
|
void ModulWindowLayout::ConfigurationChanged( utl::ConfigurationBroadcaster*, sal_uInt32 )
|
2002-07-05 09:22:53 +00:00
|
|
|
{
|
|
|
|
{
|
2003-03-18 15:17:10 +00:00
|
|
|
Color aColor(m_aColorConfig.GetColorValue(svtools::BASICIDENTIFIER).
|
2002-07-05 09:22:53 +00:00
|
|
|
nColor);
|
|
|
|
bool bChanged = aColor != m_aSyntaxColors[TT_IDENTIFIER];
|
|
|
|
m_aSyntaxColors[TT_IDENTIFIER] = aColor;
|
2003-03-18 15:17:10 +00:00
|
|
|
aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICNUMBER).nColor);
|
2002-07-09 14:08:00 +00:00
|
|
|
if (bChanged || aColor != m_aSyntaxColors[TT_NUMBER])
|
|
|
|
bChanged = true;
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_NUMBER] = aColor;
|
2003-03-18 15:17:10 +00:00
|
|
|
aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICSTRING).nColor);
|
2002-07-09 14:08:00 +00:00
|
|
|
if (bChanged || aColor != m_aSyntaxColors[TT_STRING])
|
|
|
|
bChanged = true;
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_STRING] = aColor;
|
2003-03-18 15:17:10 +00:00
|
|
|
aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICCOMMENT).
|
2002-07-05 09:22:53 +00:00
|
|
|
nColor);
|
2002-07-09 14:08:00 +00:00
|
|
|
if (bChanged || aColor != m_aSyntaxColors[TT_COMMENT])
|
|
|
|
bChanged = true;
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_COMMENT] = aColor;
|
2003-03-18 15:17:10 +00:00
|
|
|
aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICERROR).nColor);
|
2002-07-09 14:08:00 +00:00
|
|
|
if (bChanged || aColor != m_aSyntaxColors[TT_ERROR])
|
|
|
|
bChanged = true;
|
2002-07-05 13:51:15 +00:00
|
|
|
m_aSyntaxColors[TT_ERROR] = aColor;
|
2003-03-18 15:17:10 +00:00
|
|
|
aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICOPERATOR).
|
2002-07-05 09:22:53 +00:00
|
|
|
nColor);
|
2002-07-09 14:08:00 +00:00
|
|
|
if (bChanged || aColor != m_aSyntaxColors[TT_OPERATOR])
|
|
|
|
bChanged = true;
|
2002-07-05 09:22:53 +00:00
|
|
|
m_aSyntaxColors[TT_OPERATOR] = aColor;
|
2003-03-18 15:17:10 +00:00
|
|
|
aColor = Color(m_aColorConfig.GetColorValue(svtools::BASICKEYWORD).
|
2002-07-05 09:22:53 +00:00
|
|
|
nColor);
|
2008-11-28 11:39:37 +00:00
|
|
|
if (bChanged || aColor != m_aSyntaxColors[TT_KEYWORDS])
|
2002-07-09 14:08:00 +00:00
|
|
|
bChanged = true;
|
2008-11-28 11:39:37 +00:00
|
|
|
m_aSyntaxColors[TT_KEYWORDS] = aColor;
|
2002-07-05 09:22:53 +00:00
|
|
|
if (bChanged)
|
|
|
|
updateSyntaxHighlighting();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ModulWindowLayout::updateSyntaxHighlighting()
|
|
|
|
{
|
|
|
|
if (m_pModulWindow != 0)
|
|
|
|
{
|
|
|
|
EditorWindow & rEditor = m_pModulWindow->GetEditorWindow();
|
2011-01-14 11:16:25 +01:00
|
|
|
sal_uLong nCount = rEditor.GetEditEngine()->GetParagraphCount();
|
|
|
|
for (sal_uLong i = 0; i < nCount; ++i)
|
2002-07-05 09:22:53 +00:00
|
|
|
rEditor.DoDelayedSyntaxHighlight(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-09 16:20:50 -06:00
|
|
|
Image ModulWindowLayout::getImage(sal_uInt16 nId) const
|
2002-07-05 09:22:53 +00:00
|
|
|
{
|
2010-11-13 17:22:01 +00:00
|
|
|
return m_aImagesNormal.GetImage(nId);
|
2002-07-05 09:22:53 +00:00
|
|
|
}
|
2010-10-12 15:57:08 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|