initial import

This commit is contained in:
Jens-Heiner Rechtien
2000-09-18 15:18:56 +00:00
commit c25ec0608a
493 changed files with 152257 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
/*************************************************************************
*
* $RCSfile: basrid.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BASRID_HXX
#define _BASRID_HXX
#ifndef _TOOLS_RESID_HXX //autogen
#include <tools/resid.hxx>
#endif
class BasicResId: public ResId
{
public:
BasicResId( USHORT nId );
};
#endif //_BASRID_HXX
+81
View File
@@ -0,0 +1,81 @@
/*************************************************************************
*
* $RCSfile: sb.hrc,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SB_HRC
#define _SB_HRC
#include <svtools/solar.hrc>
#ifndef IDS_SBERR_START
#define IDS_SBERR_START RID_BASIC_START
#endif
#define IDS_SBERR_TERMINATED IDS_SBERR_START+2000
#define IDS_SBERR_STOREREF IDS_SBERR_START+2001
// #define IDS_SBERR_LIBLOAD IDS_SBERR_START+2002
// #define IDS_SBERR_LIBSAVE IDS_SBERR_START+2003
// #define IDS_SBERR_MGROPEN IDS_SBERR_START+2004
// #define IDS_SBERR_MGRSAVE IDS_SBERR_START+2005
// #define IDS_SBERR_REMOVELIB IDS_SBERR_START+2006
// #define IDS_SBERR_UNLOADLIB IDS_SBERR_START+2007
#endif
+76
View File
@@ -0,0 +1,76 @@
/*************************************************************************
*
* $RCSfile: sb.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SB_HXX
#define _SB_HXX
#ifndef _SBERRORS_HXX
#include "sberrors.hxx"
#endif
#include <sbdef.hxx>
#include <sbmeth.hxx>
#include <sbmod.hxx>
#include <sbprop.hxx>
#include <sbstar.hxx>
#endif
+70
View File
@@ -0,0 +1,70 @@
/*************************************************************************
*
* $RCSfile: testtool.hrc,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#define S_INVALID_KEYCODE 257
#define S_MANDATORY_FILE 258
#define S_READING_LONGNAMES 259
#define S_READING_SLOT_IDS 260
#define S_READING_CONTROLS 261
#define S_READING_BASIC_MODULE 262
#define S_STARTING_APPLICATION 263
+147
View File
@@ -0,0 +1,147 @@
/*************************************************************************
*
* $RCSfile: ttmsg.hrc,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:07 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <svtools/ttglobal.hrc>
// Hier sind die Messages aus dem Verzeichnis /basic/source/testtool enhalten
///////////////////////////////
// Fehlermeldungen, die in das Resultfile gelangen.
// *********************
// *** !!ACHTUNG!! ***
// *********************
// Die Nummern dürfen sich NIE! ändern,
// da sie in den Resultfiles gespeichert sind, und bei erneutem Anzeigen
// statdessen die entsprechenden neuen oder garkeine Strings angzeigt werden.
///////////////////////////////
#define S_NAME_NOT_THERE ( TT_START + 0 )
#define S_DOUBLE_NAME ( TT_START + 1 )
#define S_READING_FILE ( TT_START + 2 )
#define S_CANNOT_OPEN_FILE ( TT_START + 3 )
#define S_INVALID_LINE ( TT_START + 4 )
#define S_SHORTNAME_UNKNOWN ( TT_START + 5 )
#define S_LONGNAME_UNKNOWN ( TT_START + 6 )
#define S_FIRST_SHORTNAME_REQ_ASTRX ( TT_START + 7 )
#define S_TIMOUT_WAITING ( TT_START + 8 )
#define S_APPLICATION_RESTARTED ( TT_START + 9 )
#define S_APPLICATION_START_FAILED ( TT_START + 10 )
#define S_TIMOUT_SENDING ( TT_START + 11 )
#define S_NO_CONNECTION ( TT_START + 12 )
#define S_NO_FILES_FOUND ( TT_START + 13 )
#define S_ERRORS_DETECTED ( TT_START + 14 )
#define S_NO_ERRORS_DETECTED ( TT_START + 15 )
#define S_WARNINGS_DETECTED ( TT_START + 16 )
#define S_NO_WARNINGS_DETECTED ( TT_START + 17 )
#define S_UNKNOWN_SLOT_CONTROL ( TT_START + 18 )
#define S_RETURN_SEQUENCE_MISSMATCH ( TT_START + 19 )
#define S_RETURNED_VALUE_ID_MISSMATCH ( TT_START + 20 )
#define S_RETURNED_VALUE_NO_RECEIVER ( TT_START + 21 )
#define S_UNKNOWN_METHOD ( TT_START + 22 )
#define S_INCLUDE_FILE_WARNINGS_DETECTED ( TT_START + 23 )
#define S_NO_INCLUDE_FILE_WARNINGS_DETECTED ( TT_START + 24 )
// Stings
/*
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
#define S_ ( TT_START + 0 )
*/
+44
View File
@@ -0,0 +1,44 @@
touch: ..\%__SRC%\misc\basic.hid %_DEST%\bin%_EXT%\basic.hid
..\%__SRC%\lib\basic.lib %_DEST%\lib%_EXT%\basic.lib
..\%__SRC%\lib\*.so %_DEST%\lib%_EXT%\*.so
..\%__SRC%\lib\*.a %_DEST%\lib%_EXT%\*.a
..\%__SRC%\slb\sb.lib %_DEST%\lib%_EXT%\xsb.lib
..\%__SRC%\srs\classes.srs %_DEST%\res%_EXT%\basic.srs
..\%__SRC%\res\*.srs %_DEST%\res%_EXT%\*.srs
..\%__SRC%\bin\sb?????.dll %_DEST%\bin%_EXT%\sb?????.dll
..\%__SRC%\bin\sb?????.sym %_DEST%\bin%_EXT%\sb?????.sym
..\%__SRC%\misc\sb?????.map %_DEST%\bin%_EXT%\sb?????.map
..\%__SRC%\bin\testtool.exe %_DEST%\bin%_EXT%\testtool.exe
..\%__SRC%\bin\testtool %_DEST%\bin%_EXT%\testtool.bin
..\%__SRC%\bin\stt%UPD%49.res %_DEST%\bin%_EXT%\testtool.res
..\%__SRC%\bin\stt*.res %_DEST%\bin%_EXT%\stt*.res
..\%__SRC%\inc\classes %_DEST%\bin%_EXT%\classes
..\%__SRC%\inc\keycodes %_DEST%\bin%_EXT%\keycodes
..\%__SRC%\inc\res_type %_DEST%\bin%_EXT%\res_type
..\%__SRC%\lib\app.lib %_DEST%\lib%_EXT%\app.lib
..\%__SRC%\lib\libapp.a %_DEST%\lib%_EXT%\libapp.a
..\%__SRC%\lib\sample.lib %_DEST%\lib%_EXT%\sample.lib
..\%__SRC%\lib\libsample.a %_DEST%\lib%_EXT%\libsample.a
mkdir: %_DEST%\inc%_EXT%\basic
hedabu: ..\inc\sbdef.hxx %_DEST%\inc%_EXT%\basic\sbdef.hxx
hedabu: ..\inc\sbmod.hxx %_DEST%\inc%_EXT%\basic\sbmod.hxx
hedabu: ..\inc\sbjsmod.hxx %_DEST%\inc%_EXT%\basic\sbjsmod.hxx
hedabu: ..\inc\sbmeth.hxx %_DEST%\inc%_EXT%\basic\sbmeth.hxx
hedabu: ..\inc\sbprop.hxx %_DEST%\inc%_EXT%\basic\sbprop.hxx
hedabu: ..\inc\sbstar.hxx %_DEST%\inc%_EXT%\basic\sbstar.hxx
hedabu: ..\inc\sbuno.hxx %_DEST%\inc%_EXT%\basic\sbuno.hxx
hedabu: ..\inc\basmgr.hxx %_DEST%\inc%_EXT%\basic\basmgr.hxx
hedabu: ..\inc\sberrors.hxx %_DEST%\inc%_EXT%\basic\sberrors.hxx
hedabu: ..\inc\basrdll.hxx %_DEST%\inc%_EXT%\basic\basrdll.hxx
hedabu: ..\inc\stdobj1.hxx %_DEST%\inc%_EXT%\basic\sbstdobj.hxx
hedabu: ..\inc\hilight.hxx %_DEST%\inc%_EXT%\basic\hilight.hxx
hedabu: ..\inc\process.hxx %_DEST%\inc%_EXT%\basic\process.hxx
hedabu: ..\inc\testtool.hrc %_DEST%\inc%_EXT%\basic\testtool.hrc
hedabu: ..\inc\ttmsg.hrc %_DEST%\inc%_EXT%\basic\ttmsg.hrc
hedabu: ..\inc\mybasic.hxx %_DEST%\inc%_EXT%\basic\mybasic.hxx
hedabu: ..\inc\testtool.hxx %_DEST%\inc%_EXT%\basic\testtool.hxx
hedabu: ..\inc\basicrt.hxx %_DEST%\inc%_EXT%\basic\basicrt.hxx
hedabu: ..\inc\dispdefs.hxx %_DEST%\inc%_EXT%\basic\dispdefs.hxx
hedabu: ..\inc\ttstrhlp.hxx %_DEST%\inc%_EXT%\basic\ttstrhlp.hxx
File diff suppressed because it is too large Load Diff
+228
View File
@@ -0,0 +1,228 @@
/*************************************************************************
*
* $RCSfile: app.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BASICAPP_HXX
#define _BASICAPP_HXX
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#ifndef _HELP_HXX //autogen
#include <vcl/help.hxx>
#endif
#ifndef _MENU_HXX //autogen
#include <vcl/menu.hxx>
#endif
#ifndef _WRKWIN_HXX //autogen
#include <vcl/wrkwin.hxx>
#endif
#ifndef _TIMER_HXX //autogen
#include <vcl/timer.hxx>
#endif
#ifndef _SFXBRDCST_HXX
#include <svtools/brdcst.hxx>
#endif
#ifndef _SFXLSTNER_HXX
#include <svtools/lstner.hxx>
#endif
class BasicFrame;
#include "mybasic.hxx"
class EditList;
class AppWin;
class AppEdit;
class AppBasEd;
class MsgEdit;
class AppError;
class StatusLine;
class BasicPrinter;
struct TTLogMsg;
class BasicApp : public Application {
short nWait; // Wait-Zaehler
public:
// Help* pHelp; // Hilfesystem
BasicFrame* pFrame; // Frame Window
// MenuBar* pMainMenu; // Hauptmenue
Accelerator* pMainAccel; // Acceleratoren
#ifndef VCL
void Main( int, char*[] );
#else
void Main( );
#endif
void LoadIniFile();
void SetFocus();
void Wait( BOOL );
DECL_LINK( LateInit, void * );
};
typedef USHORT FileType;
#define FT_NO_FILE (FileType)0x00 // Ein Fehler ist aufgetreten ...
#define FT_BASIC_SOURCE (FileType)0x01
#define FT_BASIC_INCLUDE (FileType)0x02
#define FT_RESULT_FILE (FileType)0x04
#define FT_RESULT_FILE_TXT (FileType)0x08
#define FT_BASIC_LIBRARY (FileType)0x10
struct WinInfoRec;
class DisplayHidDlg;
class FloatingExecutionStatus;
class BasicFrame : public WorkWindow, public SfxBroadcaster, public SfxListener
{
virtual BOOL Close(); // Schliessen
BOOL CloseAll(); // Alle Fenster schliessen
BOOL CompileAll(); // Alle Texte compilieren
AutoTimer aLineNum; // Zeigt die Zeilennummer an
virtual void Resize();
virtual void Move();
void LoadLibrary();
void SaveLibrary();
BOOL bIsAutoRun;
DisplayHidDlg* pDisplayHidDlg;
// BreakPoint *pRunToCursorBP;
SbxVariable *pEditVar;
Timer aCheckFiles; // Prüfen der Dateien auf Änderungen
BOOL bAutoReload;
DECL_LINK( CheckAllFiles, Timer* );
MyBasicRef pBasic; // BASIC-Engine
String aAppName; // Inhalt der Titelteile der App:
String aAppFile; // AppName AppFile [AppMode]
String aAppMode;
void UpdateTitle();
DECL_LINK( CloseButtonClick, void* );
DECL_LINK( FloatButtonClick, void* );
DECL_LINK( HideButtonClick, void* );
FloatingExecutionStatus *pExecutionStatus;
public:
BOOL IsAutoRun();
void SetAutoRun( BOOL bAuto );
BOOL bInBreak; // TRUE, wenn im Break-Handler
StatusLine* pStatus; // Statuszeile
EditList* pList; // List der Edit-Fenster
AppWin* pWork; // aktuelles Edit-Fenster
BasicPrinter* pPrn; // Drucker
BOOL bDisas; // TRUE: disassemble
USHORT nFlags; // Debugging-Flags
USHORT nMaximizedWindows; // Anzahl der Fenster, die maximized sind
void FocusWindow( AppWin *pWin );
void WinMax_Restore();
void WinShow_Hide();
void RemoveWindow( AppWin *pWin );
void AddWindow( AppWin *pWin );
void WindowRenamed( AppWin *pWin );
BasicFrame();
~BasicFrame();
MyBasic& Basic() { return *pBasic; }
void AddToLRU(String const& aFile);
void LoadLRU();
DECL_LINK( InitMenu, Menu * );
DECL_LINK( DeInitMenu, Menu * );
DECL_LINK( HighlightMenu, Menu * );
DECL_LINK( MenuCommand, Menu * );
DECL_LINK( Accel, Accelerator * );
DECL_LINK( ShowLineNr, AutoTimer * );
MsgEdit* GetMsgTree( String aLogFileName );
DECL_LINK( Log, TTLogMsg * );
DECL_LINK( WinInfo, WinInfoRec * );
BOOL LoadFile( String aFilename );
long Command( short,BOOL=FALSE );// Kommando-Handler
BOOL SaveAll(); // Alle Fenster speichern
BOOL QueryFileName( String& rName, FileType nFileType, BOOL bSave );// Dateinamen ermitteln
DECL_LINK( ModuleWinExists, String* );
AppBasEd* FindModuleWin( const String& );
AppError* FindErrorWin( const String& );
AppWin* FindWin( const String& );
AppWin* FindWin( USHORT nWinId );
USHORT BreakHandler(); // Break-Handler-Callback
void SetEditVar( SbxVariable *pVar ){ pEditVar = pVar;}
SbxVariable* GetEditVar(){ return pEditVar;}
BOOL IsAutoReload() { return bAutoReload; }
void LoadIniFile();
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
void SetAppMode( const String &aNewMode ){ aAppMode = aNewMode; UpdateTitle(); }
String GenRealString( const String &aResString );
};
extern BasicApp aBasicApp;
#endif
+338
View File
@@ -0,0 +1,338 @@
/*************************************************************************
*
* $RCSfile: appbased.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SBXCLASS_HXX //autogen
#include <svtools/sbx.hxx>
#endif
#ifndef _TEXTENG_HXX //autogen
#include <svtools/texteng.hxx>
#endif
#ifndef _TEXTVIEW_HXX //autogen
#include <svtools/textview.hxx>
#endif
#ifndef _SB_SBMETH_HXX //autogen
#include <sbmeth.hxx>
#endif
#ifndef _CLIP_HXX //autogen
#include <vcl/clip.hxx>
#endif
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
#include "basic.hrc"
#include "status.hxx"
#include "appbased.hxx"
#include "brkpnts.hxx"
#include "testtool.hxx" // defines für das Syntaxhighlighting
TYPEINIT1(AppBasEd,AppEdit);
AppBasEd::AppBasEd( BasicFrame* pParent, SbModule* p )
: AppEdit( pParent )
, pBreakpoints( NULL )
{
pBreakpoints = new BreakpointWindow( this );
pBreakpoints->SetFont( ((TextEdit*)pDataEdit)->GetTextEditImp().pTextEngine->GetFont() );
pBreakpoints->Show();
((TextEdit*)pDataEdit)->GetTextEditImp().pTextView->SetAutoIndentMode( TRUE );
((TextEdit*)pDataEdit)->GetTextEditImp().pTextEngine->SetMaxTextLen( STRING_MAXLEN );
((TextEdit*)pDataEdit)->GetTextEditImp().pTextEngine->SetWordDelimiters( CUniString(" ,.;:(){}[]\"'+-*/<>^\\") );
((TextEdit*)pDataEdit)->GetTextEditImp().SyntaxHighlight( TRUE );
((TextEdit*)pDataEdit)->SaveAsUTF8( TRUE );
String aEmpty;
pMod = p;
if( !pMod )
{
String aModName = *pNoName;
aModName += String::CreateFromInt32( nCount );
pMod = pFrame->Basic().MakeModule( aModName, aEmpty );
}
bCompiled = pMod->IsCompiled();
pBreakpoints->SetModule( pMod );
// Icon definieren:
// pIcon = new Icon( ResId( RID_WORKICON ) );
// if( pIcon ) SetIcon( *pIcon );
SetText( pMod->GetName() );
pDataEdit->SetText( pMod->GetSource() );
// Wurde ein Modul übergeben, dann den Quelltext von Platte laden
if ( p )
LoadSource();
// Erst nach Laden des Quelltextes die Events weiterleiten
((TextEdit*)pDataEdit)->SetBreakpointWindow( pBreakpoints );
// Compiled-Flag pflegen:
pDataEdit->SetModifyHdl( LINK( this, AppBasEd, EditChange ) );
}
AppBasEd::~AppBasEd()
{
pBreakpoints->SaveBreakpoints( GetText() );
delete pBreakpoints;
pMod->SetName( CUniString("--").Append( pMod->GetName() ) );
}
void AppBasEd::SFX_NOTIFY( SfxBroadcaster&, const TypeId&,
const SfxHint& rHint, const TypeId& )
{
const SfxSimpleHint* p = PTR_CAST(SfxSimpleHint,&rHint);
if( p )
{
ULONG nHintId = p->GetId();
if( nHintId == SBX_HINT_LANGUAGE_EXTENSION_LOADED )
{
((TextEdit*)pDataEdit)->GetTextEditImp().InvalidateSyntaxHighlight();
}
}
}
FileType AppBasEd::GetFileType()
{
return FT_BASIC_SOURCE;
}
IMPL_LINK_INLINE_START( AppBasEd, EditChange, void *, p )
{
bCompiled = FALSE;
return TRUE;
}
IMPL_LINK_INLINE_END( AppBasEd, EditChange, void *, p )
// Set up the menu
long AppBasEd::InitMenu( Menu* pMenu )
{
AppEdit::InitMenu (pMenu );
BOOL bRunning = pFrame->Basic().IsRunning();
pMenu->EnableItem( RID_RUNCOMPILE, !bCompiled && !bRunning );
return TRUE;
}
long AppBasEd::DeInitMenu( Menu* pMenu )
{
AppEdit::DeInitMenu (pMenu );
pMenu->EnableItem( RID_RUNCOMPILE );
return TRUE;
}
// Menu Handler
void AppBasEd::Command( const CommandEvent& rCEvt )
{
switch( rCEvt.GetCommand() ) {
case RID_TOGLEBRKPNT:
((TextEdit*)pDataEdit)->GetBreakpointWindow()->ToggleBreakpoint( pDataEdit->GetLineNr() );
break;
default:
AppEdit::Command( rCEvt );
}
}
// Sourcecode-Datei laden
void AppBasEd::Resize()
{
if( pDataEdit ) {
AppEdit::Resize();
// Breakpoint window einfügen
Size aEditSize = pDataEdit->GetSizePixel();
Point aEditPos = pDataEdit->GetPosPixel();
pBreakpoints->SetPosPixel( aEditPos );
aEditPos.X() += BREAKPOINTSWIDTH;
pDataEdit->SetPosPixel( aEditPos );
aEditSize.Width() -= BREAKPOINTSWIDTH;
pDataEdit->SetSizePixel( aEditSize );
aEditSize.Width() = BREAKPOINTSWIDTH;
pBreakpoints->SetSizePixel( aEditSize );
}
}
void AppBasEd::PostLoad()
{
pMod->SetName( GetText() );
pMod->Clear();
pMod->SetSource( pDataEdit->GetText() );
AppEdit::PostLoad();
pBreakpoints->LoadBreakpoints( GetText() );
}
USHORT AppBasEd::ImplSave()
{
pBreakpoints->SaveBreakpoints( GetText() );
return AppEdit::ImplSave();
}
void AppBasEd::Reload()
{
TextSelection aSelMemo = pDataEdit->GetSelection();
LoadSource();
pDataEdit->SetSelection( aSelMemo );
}
// Sourcecode-Datei nach Änderung auf Platte neu laden
void AppBasEd::LoadSource()
{
BOOL bErr;
// if( pDataEdit->GetText().Len() != 0 ) return;
String aName = pMod->GetName();
bErr = !pDataEdit->Load( aName );
pBreakpoints->LoadBreakpoints( GetText() );
if( bErr )
ErrorBox( this, ResId( IDS_READERROR ) ).Execute();
else
UpdateFileInfo( HAS_BEEN_LOADED );
}
// mit neuem Namen speichern
void AppBasEd::PostSaveAs()
{
pMod->SetName( GetText() );
AppEdit::PostSaveAs();
}
// Compilieren
BOOL AppBasEd::Compile()
{
if( !pDataEdit->HasText() || bCompiled )
return TRUE;
pMod->SetSource( pDataEdit->GetText() );
BOOL bRes = FALSE;
if( pFrame->Basic().Compile( pMod ) )
{
bRes = TRUE;
if( pFrame->bDisas )
Disassemble();
TextSelection aSel( pDataEdit->GetSelection() );
String aString;
pFrame->pStatus->Message( aString );
if( aSel.HasRange() )
aSel.GetStart() = aSel.GetEnd(), pDataEdit->SetSelection( aSel );
pBreakpoints->SetBPsInModule();
}
else
{
BasicError* pErr = pFrame->Basic().aErrors.First();
if( pErr ) pErr->Show();
}
return bCompiled = bRes;
}
void AppBasEd::Disassemble()
{
String aText;
if( pFrame->Basic().Disassemble( pMod, aText ) )
Clipboard::CopyString( aText );
}
void AppBasEd::Run()
{
SbxArray* pAllModules = pFrame->Basic().GetModules();
for (USHORT i = 0; i < pAllModules->Count(); i++)
{
if ( (pAllModules->Get(i)->GetName()).Copy(0,2).CompareToAscii( "--" ) == COMPARE_EQUAL )
{
SbxVariableRef pMod = pAllModules->Get(i); // Kleiner Hack um ums basic rumzukommen. Sollte demnächst wieder dirkt gehen.
pFrame->Basic().Remove(pMod);
i--;
}
}
SbMethod* pMain = (SbMethod*) pMod->Find( CUniString("Main"), SbxCLASS_METHOD );
if( pMain )
{
pMain->SetDebugFlags( pFrame->nFlags );
// Loest Call aus!
pFrame->SetAppMode( String( ResId ( IDS_APPMODE_RUN ) ) );
pMain->Run();
if (aBasicApp.pFrame)
{
BasicError* pErr = aBasicApp.pFrame->Basic().aErrors.First();
if( pErr ) pErr->Show();
aBasicApp.pFrame->SetAppMode( String() );
}
pMain->SetDebugFlags( 0 );
}
}
+108
View File
@@ -0,0 +1,108 @@
/*************************************************************************
*
* $RCSfile: appbased.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _APPBASED_HXX
#define _APPBASED_HXX
#ifndef _SB_SBMOD_HXX //autogen
#include <sbmod.hxx>
#endif
#ifndef _SB_APPEDIT_HXX
#include "appedit.hxx"
#endif
#ifndef _SB_TEXTEDIT_HXX
#include "textedit.hxx"
#endif
class BasicFrame;
class BreakpointWindow;
class AppBasEd : public AppEdit { // Editor-Window:
SbModuleRef pMod; // compiliertes Modul
BOOL bCompiled; // TRUE, wenn compiliert
protected:
DECL_LINK( EditChange, void * );
#define BREAKPOINTSWIDTH 15
BreakpointWindow *pBreakpoints;
virtual USHORT ImplSave(); // Datei speichern
public:
TYPEINFO();
AppBasEd( BasicFrame*, SbModule* );
~AppBasEd();
FileType GetFileType(); // Liefert den Filetype
SbModule* GetModule() { return pMod; }
long InitMenu( Menu* ); // Initialisierung des Menues
virtual long DeInitMenu( Menu* ); // rücksetzen, so daß wieder alle Shortcuts enabled sind
virtual void Command( const CommandEvent& rCEvt ); // Kommando-Handler
virtual void Resize(); // Berücksichtigt die Breakpointleiste
virtual void PostLoad(); // Nachbearbeiten des geladenen (Source am Modul setzen)
virtual void PostSaveAs(); // Nachbearbeiten des Modils ...
void Reload();
void LoadSource(); // Quelltext zu Objekt laden
BOOL Compile(); // Text compilieren
void Run(); // Image laufenlassen
void Disassemble(); // Image disassemblieren
const String& GetModName() const { return pMod->GetName(); }
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
};
#endif
+286
View File
@@ -0,0 +1,286 @@
/*************************************************************************
*
* $RCSfile: appedit.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _TEXTVIEW_HXX //autogen
#include <svtools/textview.hxx>
#endif
#ifndef _TEXTENG_HXX //autogen
#include <svtools/texteng.hxx>
#endif
#ifndef _UNDO_HXX
#include <svtools/undo.hxx>
#endif
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
#include "basic.hrc"
#include "appedit.hxx"
#include "brkpnts.hxx"
TYPEINIT1(AppEdit,AppWin);
AppEdit::AppEdit( BasicFrame* pParent )
: AppWin( pParent )
, nCurTextWidth(5)
, pVScroll( NULL )
, pHScroll( NULL )
{
String aEmpty;
// evtl. den Untitled-String laden:
pDataEdit = new TextEdit( this, WB_LEFT );
// Icon definieren:
// pIcon = new Icon( ResId( RID_WORKICON ) );
// if( pIcon ) SetIcon( *pIcon );
pDataEdit->SetText( aEmpty );
pDataEdit->Show();
pVScroll = new ScrollBar( this, WB_VSCROLL|WB_DRAG );
pVScroll->Show();
pVScroll->SetScrollHdl( LINK( this, AppEdit, Scroll ) );
pHScroll = new ScrollBar( this, WB_HSCROLL|WB_DRAG );
pHScroll->Show();
pHScroll->SetScrollHdl( LINK( this, AppEdit, Scroll ) );
InitScrollBars();
}
AppEdit::~AppEdit()
{
DataEdit *pHold = pDataEdit;
pDataEdit = NULL; // Erst abklemmen, dann löschen
delete pHold;
delete pHScroll;
delete pVScroll;
}
IMPL_LINK( AppEdit, Scroll, ScrollBar*, pScroll )
{
if ( !pHScroll || !pVScroll )
return 0;
TextView *pTextView = ((TextEdit*)pDataEdit)->aEdit.pTextView;
pTextView->SetStartDocPos( Point( pHScroll->GetThumbPos(), pVScroll->GetThumbPos() ) );
pTextView->Invalidate();
if ( ((TextEdit*)pDataEdit)->GetBreakpointWindow() )
((TextEdit*)pDataEdit)->GetBreakpointWindow()->Scroll( 0, ((TextEdit*)pDataEdit)->GetBreakpointWindow()->GetCurYOffset() - pTextView->GetStartDocPos().Y() );
return 0L;
}
void AppEdit::InitScrollBars()
{
if ( !pHScroll || !pVScroll )
return;
TextView *pTextView = ((TextEdit*)pDataEdit)->aEdit.pTextView;
// Kopiert und angepasst.
SetScrollBarRanges();
Size aOutSz( pTextView->GetWindow()->GetOutputSizePixel() );
pVScroll->SetVisibleSize( aOutSz.Height() );
pVScroll->SetPageSize( aOutSz.Height() * 8 / 10 );
pVScroll->SetLineSize( GetTextHeight() );
pVScroll->SetThumbPos( pTextView->GetStartDocPos().Y() );
pVScroll->Show();
pHScroll->SetVisibleSize( aOutSz.Width() );
pHScroll->SetPageSize( aOutSz.Width() * 8 / 10 );
pHScroll->SetLineSize( GetTextWidth( CUniString("x") ) );
pHScroll->SetThumbPos( pTextView->GetStartDocPos().X() );
pHScroll->Show();
}
void AppEdit::SetScrollBarRanges()
{
// Extra-Methode, nicht InitScrollBars, da auch fuer EditEngine-Events.
if ( !pHScroll || !pVScroll )
return;
pHScroll->SetRange( Range( 0, nCurTextWidth ) );
pVScroll->SetRange( Range( 0, ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetTextHeight() ) );
}
USHORT AppEdit::GetLineNr(){ return pDataEdit->GetLineNr(); }
FileType AppEdit::GetFileType()
{
return FT_BASIC_SOURCE;
}
// Set up the menu
long AppEdit::InitMenu( Menu* pMenu )
{
AppWin::InitMenu (pMenu );
USHORT UndoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetUndoActionCount();
USHORT RedoCount = ((TextEdit*)pDataEdit)->aEdit.pTextEngine->GetUndoManager().GetRedoActionCount();
pMenu->EnableItem( RID_EDITUNDO, UndoCount > 0 );
pMenu->EnableItem( RID_EDITREDO, RedoCount > 0 );
return TRUE;
}
long AppEdit::DeInitMenu( Menu* pMenu )
{
AppWin::DeInitMenu (pMenu );
pMenu->EnableItem( RID_EDITUNDO );
pMenu->EnableItem( RID_EDITREDO );
return TRUE;
}
// Sourcecode-Datei laden
void AppEdit::Resize()
{
if( !pDataEdit )
return;
Point rHStart,rVStart;
Size rHSize,rVSize;
Size rNewSize( GetOutputSizePixel() );
if ( pHScroll )
{
rHSize = pHScroll->GetSizePixel();
ULONG nHieght = rHSize.Height();
rNewSize.Height() -= nHieght;
rHStart.Y() = rNewSize.Height();
}
if ( pVScroll )
{
rVSize = pVScroll->GetSizePixel();
ULONG nWidth = rVSize.Width();
rNewSize.Width() -= nWidth;
rVStart.X() = rNewSize.Width();
}
rHSize.Width() = rNewSize.Width();
rVSize.Height() = rNewSize.Height();
if ( pHScroll )
{
pHScroll->SetPosPixel( rHStart );
pHScroll->SetSizePixel( rHSize );
}
if ( pVScroll )
{
pVScroll->SetPosPixel( rVStart );
pVScroll->SetSizePixel( rVSize );
}
pDataEdit->SetPosPixel( Point() );
pDataEdit->SetSizePixel( rNewSize );
TextView *pTextView = ((TextEdit*)pDataEdit)->aEdit.pTextView;
// Kopiert und adaptiert
long nVisY = pTextView->GetStartDocPos().Y();
pTextView->ShowCursor();
Size aOutSz( pTextView->GetWindow()->GetOutputSizePixel() );
long nMaxVisAreaStart = pTextView->GetTextEngine()->GetTextHeight() - aOutSz.Height();
if ( nMaxVisAreaStart < 0 )
nMaxVisAreaStart = 0;
if ( pTextView->GetStartDocPos().Y() > nMaxVisAreaStart )
{
Point aStartDocPos( pTextView->GetStartDocPos() );
aStartDocPos.Y() = nMaxVisAreaStart;
pTextView->SetStartDocPos( aStartDocPos );
pTextView->ShowCursor();
// pModulWindow->GetBreakPointWindow().GetCurYOffset() = aStartDocPos.Y();
}
InitScrollBars();
if ( nVisY != pTextView->GetStartDocPos().Y() )
pTextView->GetWindow()->Invalidate();
}
void AppEdit::PostLoad()
{
}
// mit neuem Namen speichern
void AppEdit::PostSaveAs()
{
}
void AppEdit::Highlight( USHORT nLine, USHORT nCol1, USHORT nCol2 )
{
((TextEdit*)pDataEdit)->Highlight( nLine, nCol1, nCol2 );
ToTop();
}
+101
View File
@@ -0,0 +1,101 @@
/*************************************************************************
*
* $RCSfile: appedit.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _APPEDIT_HXX
#define _APPEDIT_HXX
#ifndef _SCRBAR_HXX //autogen
#include <vcl/scrbar.hxx>
#endif
#include "appwin.hxx"
#include "textedit.hxx"
class BasicFrame;
class AppEdit : public AppWin { // Editor-Window:
public:
ScrollBar *pVScroll;
ScrollBar *pHScroll;
void SetScrollBarRanges();
ULONG nCurTextWidth;
private:
void InitScrollBars();
protected:
DECL_LINK( Scroll, ScrollBar* );
public:
TYPEINFO();
AppEdit( BasicFrame* );
~AppEdit();
USHORT GetLineNr(); // Aktuelle Zeilennummer
FileType GetFileType(); // Liefert den Filetype
virtual long InitMenu( Menu* ); // Initialisierung des Menues
virtual long DeInitMenu( Menu* ); // rücksetzen, so daß wieder alle Shortcuts enabled sind
// long Command( short ); // Kommando-Handler
void Resize();
void PostLoad(); // Nachbearbeiten des geladenen (Source am Modul setzen)
void PostSaveAs(); // Nachbearbeiten des Modils ...
void Mark( short, short, short );// Text markieren
void Highlight( USHORT nLine, USHORT nCol1, USHORT nCol2 );
virtual BOOL ReloadAllowed(){ return !StarBASIC::IsRunning(); }
};
#endif
+115
View File
@@ -0,0 +1,115 @@
/*************************************************************************
*
* $RCSfile: apperror.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "basic.hrc"
#include "apperror.hxx"
TYPEINIT1(AppError,AppWin);
AppError::AppError( BasicFrame* pParent, String aFileName )
: AppWin( pParent )
{
SetText( aFileName ); // Muß vor new MsgEdit stehen!!
pDataEdit = new MsgEdit( this, pParent, WB_HSCROLL | WB_VSCROLL | WB_LEFT );
DirEntry aEntry( aFileName );
UpdateFileInfo( HAS_BEEN_LOADED );
// Icon definieren:
// pIcon = new Icon( ResId( RID_WORKICON ) );
// if( pIcon ) SetIcon( *pIcon );
pDataEdit->Show();
GrabFocus();
}
AppError::~AppError()
{
DataEdit* pTemp = pDataEdit;
pDataEdit = NULL;
delete pTemp;
}
// Set up the menu
long AppError::InitMenu( Menu* pMenu )
{
AppWin::InitMenu (pMenu );
pMenu->EnableItem( RID_EDITUNDO, FALSE );
pMenu->EnableItem( RID_EDITREDO, FALSE );
return TRUE;
}
long AppError::DeInitMenu( Menu* pMenu )
{
AppWin::DeInitMenu (pMenu );
pMenu->EnableItem( RID_EDITUNDO );
pMenu->EnableItem( RID_EDITREDO );
return TRUE;
}
USHORT AppError::GetLineNr(){ return pDataEdit->GetLineNr(); }
FileType AppError::GetFileType()
{
return FT_RESULT_FILE;
}
+81
View File
@@ -0,0 +1,81 @@
/*************************************************************************
*
* $RCSfile: apperror.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <appwin.hxx>
#include <msgedit.hxx>
class AppError : public AppWin
{
protected:
DECL_LINK( EditChange, MsgEdit * );
public:
TYPEINFO();
AppError( BasicFrame*, String );
~AppError();
// long Command( short nID );
virtual long InitMenu( Menu* ); // Initialisierung des Menues
virtual long DeInitMenu( Menu* ); // rücksetzen, so daß wieder alle Shortcuts enabled sind
USHORT GetLineNr(); // Aktuelle Zeilennummer
FileType GetFileType(); // Liefert den Filetype
MsgEdit* GetMsgTree() { return ((MsgEdit*)pDataEdit); }
virtual BOOL ReloadAllowed(){ return !StarBASIC::IsRunning(); }
};
+647
View File
@@ -0,0 +1,647 @@
/*************************************************************************
*
* $RCSfile: appwin.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _FSYS_HXX //autogen
#include <tools/fsys.hxx>
#endif
#ifndef _CLIP_HXX //autogen
#include <vcl/clip.hxx>
#endif
#include "basic.hrc"
#include "app.hxx"
#include "mybasic.hxx"
#include "status.hxx"
#include "appwin.hxx"
#include "dataedit.hxx"
#include "dialogs.hxx"
String *AppWin::pNoName = NULL; // enthaelt den "Untitled"-String
short AppWin::nNumber = 0; // fortlaufende Nummer
short AppWin::nCount = 0; // Anzahl Editfenster
TYPEINIT0(AppWin);
AppWin::AppWin( BasicFrame* pParent )
: DockingWindow( pParent, WB_SIZEMOVE | WB_CLOSEABLE | WB_PINABLE )
, pDataEdit(NULL)
, nSkipReload(0)
, bHasFile( FALSE )
, bReloadAborted( FALSE )
, bFind( TRUE )
, pFrame( pParent )
{
// evtl. den Untitled-String laden:
if( !pNoName )
pNoName = new String( ResId( IDS_NONAME ) );
nCount++;
// Maximized Status von aktuellem Fenster holen
USHORT nInitialWinState;
if ( pFrame->pWork )
{
nInitialWinState = pFrame->pWork->GetWinState();
nInitialWinState &= TT_WIN_STATE_MAX | TT_WIN_STATE_FLOAT;
}
else
nInitialWinState = TT_WIN_STATE_MAX;
StartListening( *pFrame );
pFrame->AddWindow( this );
ShowTitleButton( TITLE_BUTTON_DOCKING );
ShowTitleButton( TITLE_BUTTON_HIDE );
SetActivateMode( ACTIVATE_MODE_GRABFOCUS );
Cascade( nCount );
if ( TT_WIN_STATE_MAX == nInitialWinState )
Maximize();
}
AppWin::~AppWin()
{
nCount--;
pFrame->RemoveWindow( this );
pFrame = NULL; // So daß nach BasicRun nicht mehr versucht wird Fenstertext zu setzen
}
void AppWin::SetText( const XubString& rStr )
{
DockingWindow::SetText( rStr );
pFrame->WindowRenamed( this );
}
void AppWin::TitleButtonClick( USHORT nButton )
{
if ( TITLE_BUTTON_DOCKING == nButton )
if ( TT_WIN_STATE_MAX != nWinState )
Maximize();
else
Restore();
else // if ( TITLE_BUTTON_HIDE == nButton )
Minimize( TRUE );
}
void AppWin::Maximize()
{
if ( TT_WIN_STATE_MAX != nWinState )
{
nNormalPos = GetPosPixel();
nNormalSize = GetSizePixel();
SetFloatingMode( FALSE );
pFrame->nMaximizedWindows++;
nWinState = TT_WIN_STATE_MAX;
}
long nTitleHeight;
{
long nDummy1, nDummy2, nDummy3;
pFrame->GetBorder( nDummy1, nTitleHeight, nDummy2, nDummy3 );
}
Size aSize = pFrame->GetOutputSizePixel();
aSize.Height() -= nTitleHeight;
aSize.Height() -= 2;
aSize.Width() -= 2;
SetSizePixel( aSize );
SetPosPixel( Point( 1,1 ) );
pFrame->WinMax_Restore();
}
void AppWin::Restore()
{
SetFloatingMode( TRUE );
SetPosSizePixel( nNormalPos, nNormalSize );
if ( TT_WIN_STATE_MAX == nWinState )
pFrame->nMaximizedWindows--;
nWinState = TT_WIN_STATE_FLOAT;
pFrame->WinMax_Restore();
}
void AppWin::Minimize( BOOL bMinimize )
{
if ( bMinimize )
nWinState |= TT_WIN_STATE_HIDE;
else
nWinState &= ~TT_WIN_STATE_HIDE;
pFrame->WinMax_Restore();
}
void AppWin::Cascade( USHORT nNr )
{
Restore();
nNr--;
nNr %= 10;
nNr++;
long nTitleHeight;
{
long nDummy1, nDummy2, nDummy3;
pFrame->GetBorder( nDummy1, nTitleHeight, nDummy2, nDummy3 );
}
Size aWinSize = pFrame->GetOutputSizePixel();
aWinSize.Width() -= aWinSize.Width() / 5; // auf 80 % reduzieren
aWinSize.Height() -= nTitleHeight * nNr; // Unten entsprechen kürzen
aWinSize.Height() -= 2;
Point nPos( nTitleHeight * nNr, nTitleHeight * nNr );
SetPosSizePixel( nPos, aWinSize );
}
void AppWin::RequestHelp( const HelpEvent& )
{
Help();
}
void AppWin::Help()
{
String s = pDataEdit->GetSelected();
if( s.Len() ) {
// Leerstellen davor weg:
while( s.GetChar(0) == ' ' ) s.Erase( 0, 1 );
// aBasicApp.pHelp->Start( s );
} else {
// aBasicApp.pHelp->Start( HELP_INDEX );
}
}
void AppWin::Resize()
{
if( pDataEdit )
{
pDataEdit->SetPosPixel( Point( 0, 0 ) );
pDataEdit->SetSizePixel( GetOutputSizePixel() );
}
}
void AppWin::GetFocus()
{
pFrame->FocusWindow( this );
if( pDataEdit ) // Im Destruktor wird GetFocus gerufen, daher diese Abfrage
{
pDataEdit->GrabFocus();
// InitMenu(GetpApp()->GetAppMenu()->GetPopupMenu( RID_APPEDIT )); // So daß Delete richtig ist
}
}
long AppWin::PreNotify( NotifyEvent& rNEvt )
{
if ( rNEvt.GetType() == EVENT_MOUSEBUTTONDOWN )
Activate();
if ( rNEvt.GetType() == EVENT_GETFOCUS )
if ( pFrame->pList->Last() != this )
Activate();
return FALSE; // Der event soll weiter verarbeitet werden
}
void AppWin::Activate()
{
GrabFocus();
}
// Set up the menu
long AppWin::InitMenu( Menu* pMenu )
{
Clipboard cb;
TextSelection r = pDataEdit->GetSelection();
BOOL bMarked = r.HasRange();
pMenu->EnableItem( RID_EDITREPEAT, (aFind.Len() != 0 ) );
pMenu->EnableItem( RID_EDITCUT, bMarked );
pMenu->EnableItem( RID_EDITCOPY, bMarked );
// pMenu->EnableItem( RID_EDITPASTE, (cb.GetDataLen( FORMAT_STRING ) != 0 ) );
pMenu->EnableItem( RID_EDITPASTE, (cb.HasFormat( FORMAT_STRING ) ) );
pMenu->EnableItem( RID_EDITDEL, bMarked );
// pMenu->EnableItem( RID_HELPTOPIC, bMarked );
BOOL bHasText = pDataEdit->HasText();
BOOL bRunning = pFrame->Basic().IsRunning();
BOOL bCanExecute = BOOL( (!bRunning && bHasText) || pFrame->bInBreak );
pMenu->EnableItem( RID_RUNSTART, bCanExecute );
pMenu->EnableItem( RID_RUNBREAK, bRunning && !pFrame->bInBreak);
pMenu->EnableItem( RID_RUNSTOP, bRunning );
pMenu->EnableItem( RID_RUNTOCURSOR, bCanExecute );
pMenu->EnableItem( RID_RUNSTEPINTO, bCanExecute );
pMenu->EnableItem( RID_RUNSTEPOVER, bCanExecute );
return TRUE;
}
long AppWin::DeInitMenu( Menu* pMenu )
{
pMenu->EnableItem( RID_EDITREPEAT );
pMenu->EnableItem( RID_EDITCUT );
pMenu->EnableItem( RID_EDITCOPY );
pMenu->EnableItem( RID_EDITPASTE );
pMenu->EnableItem( RID_EDITDEL );
pMenu->EnableItem( RID_RUNSTART );
pMenu->EnableItem( RID_RUNBREAK );
pMenu->EnableItem( RID_RUNSTOP );
pMenu->EnableItem( RID_RUNTOCURSOR );
pMenu->EnableItem( RID_RUNSTEPINTO );
pMenu->EnableItem( RID_RUNSTEPOVER );
return TRUE;
}
// Menu Handler
void AppWin::Command( const CommandEvent& rCEvt )
{
TextSelection r = pDataEdit->GetSelection();
BOOL bHasMark = r.HasRange();
switch( rCEvt.GetCommand() ) {
case RID_FILESAVE:
QuerySave( QUERY_DISK_CHANGED | SAVE_NOT_DIRTY ); break;
case RID_FILESAVEAS:
SaveAs(); break;
case RID_EDITSEARCH:
Find(); break;
case RID_EDITREPLACE:
Replace(); break;
case RID_EDITREPEAT:
Repeat(); break;
case RID_EDITCUT:
if( bHasMark ) pDataEdit->Cut(); break;
case RID_EDITCOPY:
if( bHasMark ) pDataEdit->Copy(); break;
case RID_EDITPASTE:
if( Clipboard::HasFormat( FORMAT_STRING ) ) pDataEdit->Paste(); break;
case RID_EDITDEL:
/*if( bHasMark ) */pDataEdit->Delete();
break;
case RID_EDITUNDO:
pDataEdit->Undo();
break;
case RID_EDITREDO:
pDataEdit->Redo();
break;
case COMMAND_CONTEXTMENU:
{
PopupMenu *pKontext = NULL;
pDataEdit->BuildKontextMenu( pKontext );
if ( pKontext )
{
USHORT nRes = pKontext->Execute( this, GetPointerPosPixel() );
if ( nRes )
pFrame->Command( nRes );
delete pKontext;
}
}
}
}
BOOL AppWin::IsSkipReload()
{
return nSkipReload != 0;
}
void AppWin::SkipReload( BOOL bSkip )
{
DBG_ASSERT( bSkip || nSkipReload, "SkipReload aufgehoben ohne es zu aktivieren");
if ( bSkip )
nSkipReload++;
else
nSkipReload--;
}
BOOL AppWin::DiskFileChanged( USHORT nWhat )
{
if ( !bHasFile )
return FALSE;
switch ( nWhat )
{
case SINCE_LAST_LOAD:
{
if ( bReloadAborted )
return TRUE;
else
return DiskFileChanged( SINCE_LAST_ASK_RELOAD );
}
break;
case SINCE_LAST_ASK_RELOAD:
{
String aFilename( GetText() );
DirEntry aFile( aFilename );
FileStat aStat( aFile );
return ( !aLastAccess.GetError() != !aStat.GetError() )
|| aLastAccess.IsYounger( aStat ) || aStat.IsYounger( aLastAccess );
}
break;
default:
DBG_ERROR("Not Implemented in AppWin::DiskFileChanged");
}
return TRUE;
}
void AppWin::UpdateFileInfo( USHORT nWhat )
{
switch ( nWhat )
{
case HAS_BEEN_LOADED:
{
bReloadAborted = FALSE;
UpdateFileInfo( ASKED_RELOAD );
}
break;
case ASKED_RELOAD:
{
String aFilename( GetText() );
DirEntry aFile( aFilename );
aLastAccess.Update( aFile );
}
break;
default:
DBG_ERROR("Not Implemented in AppWin::UpdateFileInfo");
}
}
void AppWin::CheckReload()
{
if ( IsSkipReload() || !bHasFile )
return;
String aFilename( GetText() );
DirEntry aFile( aFilename );
if ( !aFilename.Len() )
return;
if ( !aFile.Exists() )
return;
// FileStat aStat( aFile );
if ( DiskFileChanged( SINCE_LAST_ASK_RELOAD ) && ReloadAllowed() )
{
UpdateFileInfo( ASKED_RELOAD );
ToTop();
Update();
if ( (IsModified() && QueryBox( this, ResId( IDS_ASKDIRTYRELOAD ) ).Execute() == RET_YES )
|| ( !IsModified() && ( pFrame->IsAutoReload() || QueryBox( this, ResId( IDS_ASKRELOAD ) ).Execute() == RET_YES ) ) )
{
Reload();
}
else
{
bReloadAborted = TRUE;
}
}
}
void AppWin::Reload()
{
SkipReload();
TextSelection aSelMemo = pDataEdit->GetSelection();
Load( GetText() );
pDataEdit->SetSelection( aSelMemo );
SkipReload( FALSE );
}
// Datei laden
void AppWin::Load( const String& aName )
{
SkipReload();
BOOL bErr;
// if( !QuerySave() )
// return;
bErr = !pDataEdit->Load( aName );
if( bErr )
ErrorBox( this, ResId( IDS_READERROR ) ).Execute();
else
{
DirEntry aEntry( aName );
String aModName = aEntry.GetFull();
SetText( aModName );
UpdateFileInfo( HAS_BEEN_LOADED );
PostLoad();
bHasFile = TRUE;
}
SkipReload( FALSE );
}
// Datei speichern
USHORT AppWin::ImplSave()
{
SkipReload();
BOOL bResult = SAVE_RES_NOT_SAVED;
String s1 = *pNoName;
String s2 = GetText().Copy( 0, s1.Len() );
if( s1 == s2 )
bResult = SaveAs();
else {
String aName = GetText();
if ( pDataEdit->Save( aName ) )
{
bResult = SAVE_RES_SAVED;
bHasFile = TRUE;
}
else
{
bResult = SAVE_RES_ERROR;
ErrorBox( this, ResId( IDS_WRITEERROR ) ).Execute();
}
UpdateFileInfo( HAS_BEEN_LOADED );
}
SkipReload( FALSE );
return bResult;
}
// mit neuem Namen speichern
USHORT AppWin::SaveAs()
{
SkipReload();
String s1 = *pNoName;
String s2 = GetText().Copy( 0, s1.Len() );
if( s1 == s2 ) s2.Erase();
else s2 = GetText();
if( pFrame->QueryFileName( s2, GetFileType(), TRUE ) )
{
SetText( s2 );
PostSaveAs();
SkipReload( FALSE );
return ImplSave();
}
else
{
SkipReload( FALSE );
return SAVE_RES_CANCEL;
}
}
// Soll gespeichert werden?
USHORT AppWin::QuerySave( QueryBits nBits )
{
BOOL bQueryDirty = ( nBits & QUERY_DIRTY ) != 0;
BOOL bQueryDiskChanged = ( nBits & QUERY_DISK_CHANGED ) != 0;
BOOL bSaveNotDirty = ( nBits & SAVE_NOT_DIRTY ) != 0;
SkipReload();
short nResult;
if ( IsModified() || bSaveNotDirty )
nResult = RET_YES;
else
nResult = RET_NO;
if( ( ( IsModified() || bSaveNotDirty ) && bQueryDirty ) || ( DiskFileChanged( SINCE_LAST_LOAD ) && bQueryDiskChanged ) )
{
ToTop();
if ( ( ( IsModified() && bQueryDirty ) && DiskFileChanged( SINCE_LAST_LOAD ) )
|| ( IsModified() && ( DiskFileChanged( SINCE_LAST_LOAD ) && bQueryDiskChanged ) ) )
nResult = QueryBox( this, ResId( IDS_ASK_DIRTY_AND_DISKCHANGE_SAVE ) ).Execute();
else if ( ( IsModified() && bQueryDirty ) )
nResult = QueryBox( this, ResId( IDS_ASK_DIRTY_SAVE ) ).Execute();
else
nResult = QueryBox( this, ResId( IDS_ASK_DISKCHANGE_SAVE ) ).Execute();
}
USHORT nReturn;
switch( nResult )
{
case RET_YES:
nReturn = ImplSave();
break;
case RET_NO:
nReturn = SAVE_RES_NOT_SAVED;
break;
case RET_CANCEL:
nReturn = SAVE_RES_CANCEL;
break;
}
SkipReload( FALSE );
return nReturn;
}
BOOL AppWin::Close()
{
switch ( QuerySave( QUERY_DIRTY ) )
{
case SAVE_RES_NOT_SAVED:
case SAVE_RES_SAVED:
{
DockingWindow::Close();
delete this;
return TRUE;
}
break;
case SAVE_RES_ERROR: // Fehlermeldung schon ausgegeben
return FALSE;
break;
case SAVE_RES_CANCEL:
return FALSE;
break;
default:
DBG_ERROR("Not Implemented in AppWin::Close")
return FALSE;
}
}
// Text suchen
void AppWin::Find()
{
ResId aResId( IDD_FIND_DIALOG );
FindDialog aDlg( this, aResId, aFind );
if( aDlg.Execute() ) {
bFind = TRUE;
Repeat();
}
}
// Text ersetzen
void AppWin::Replace()
{
ResId aResId( IDD_REPLACE_DIALOG );
ReplaceDialog* pDlg = new ReplaceDialog
(this, aResId, aFind, aReplace );
if( pDlg->Execute() ) {
bFind = FALSE;
Repeat();
}
}
// Suchen/ersetzen wiederholen
void AppWin::Repeat()
{
if( (aFind.Len() != 0 ) && ( pDataEdit->Find( aFind ) || (ErrorBox(this,ResId(IDS_PATTERNNOTFOUND)).Execute() && FALSE) ) && !bFind )
pDataEdit->ReplaceSelected( aReplace );
}
+175
View File
@@ -0,0 +1,175 @@
/*************************************************************************
*
* $RCSfile: appwin.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _APPWIN_HXX
#define _APPWIN_HXX
//#include <sb.hxx>
#ifndef _SV_DOCKWIN_HXX
#include <vcl/dockwin.hxx>
#endif
#ifndef _FSYS_HXX //autogen
#include <tools/fsys.hxx>
#endif
#include "app.hxx"
#include "dataedit.hxx"
typedef USHORT QueryBits;
#define QUERY_NONE ( QueryBits ( 0x00 ) )
#define QUERY_DIRTY ( QueryBits ( 0x01 ) )
#define QUERY_DISK_CHANGED ( QueryBits ( 0x02 ) )
#define QUERY_ALL ( QUERY_DIRTY | QUERY_DISK_CHANGED )
#define SAVE_NOT_DIRTY ( QueryBits ( 0x04 ) )
#define SAVE_RES_SAVED TRUE
#define SAVE_RES_NOT_SAVED FALSE
#define SAVE_RES_ERROR 3
#define SAVE_RES_CANCEL 4
#define SINCE_LAST_LOAD 1
#define SINCE_LAST_ASK_RELOAD 2
#define HAS_BEEN_LOADED 1 // includes ASKED_RELOAD
#define ASKED_RELOAD 2
#define TT_WIN_STATE_MAX 0x01
#define TT_WIN_STATE_FLOAT 0x02
#define TT_WIN_STATE_HIDE 0x04
class BasicFrame;
class AppWin : public DockingWindow, public SfxListener // Dokumentfenster
{
friend MsgEdit;
protected:
static short nNumber; // fortlaufende Nummer
static short nCount; // Anzahl Editfenster
static String *pNoName; // "Untitled"
FileStat aLastAccess; // Wann wurde die geladene Dateiversion verändert
USHORT nSkipReload; // Manchmal darf kein Reload erfolgen
BOOL bHasFile; // Ansonsten hat reload auch keinen Sinn
BOOL bReloadAborted; // Wird gesetzt, wenn reload abgelehnt wurde, so daß beim Schließen nochmal gefragt werden kann
short nId; // ID-Nummer( "Unbenannt n" )
BasicFrame* pFrame; // Parent-Window
// Icon* pIcon; // Dokument-Icon
String aFind; // Suchstring
String aReplace; // Ersetze-String
BOOL bFind; // TRUE, wenn Suchen und nicht Ersetzen
void RequestHelp( const HelpEvent& );// Hilfe-Handler
void GetFocus(); // aktivieren
virtual USHORT ImplSave(); // Datei speichern
USHORT nWinState; // Maximized, Iconized oder Normal
Point nNormalPos; // Position wenn Normal
Size nNormalSize; // Größe wenn Normal
virtual long PreNotify( NotifyEvent& rNEvt );
USHORT nWinId;
public:
TYPEINFO();
AppWin( BasicFrame* );
~AppWin();
DataEdit* pDataEdit; // Daten-Flaeche
virtual USHORT GetLineNr()=0; // Aktuelle Zeilennummer
virtual long InitMenu( Menu* ); // Initialisierung des Menues
virtual long DeInitMenu( Menu* ); // rücksetzen, so daß wieder alle Shortcuts enabled sind
virtual void Command( const CommandEvent& rCEvt ); // Kommando-Handler
virtual void Resize(); // Aenderung Fenstergroesse
virtual void Help(); // Hilfe aktivieren
virtual void Load( const String& ); // Datei laden
virtual void PostLoad(){} // Nachbearbeiten des geladenen (Source am Modul setzen)
virtual USHORT SaveAs(); // Datei unter neuem Namen speichern
virtual void PostSaveAs(){} // Nachbearbeiten des Moduls ...
virtual void Find(); // Text suchen
virtual void Replace(); // Text ersetzen
virtual void Repeat(); // Suche wiederholen
virtual BOOL Close(); // Fenster schliessen
virtual void Activate(); // Fenster wurde aktiviert
virtual FileType GetFileType()=0; // Liefert den Filetype
virtual BOOL ReloadAllowed(){ return TRUE; } // Ermöglicht dem Dok temporär NEIN zu sagen
virtual void Reload(); // Reload nach änderung auf Platte
void CheckReload(); // Prüft und Fragt ob reloaded werden soll
BOOL DiskFileChanged( USHORT nWhat ); // Prüft ob die Datei sich verändert hat
void UpdateFileInfo( USHORT nWhat ); // Merkt sich den aktuellen Zustand der Datei
BOOL IsSkipReload(); // Soll reload getestet werden
void SkipReload( BOOL bSkip = TRUE );
USHORT GetWinState(){ return nWinState; }
void Maximize();
void Restore();
void Minimize( BOOL bMinimize );
void Cascade( USHORT nNr );
USHORT QuerySave( QueryBits nBits = QUERY_ALL ); // Speichern
BOOL IsModified() { return pDataEdit->IsModified(); }
BasicFrame* GetBasicFrame() { return pFrame; }
virtual void TitleButtonClick( USHORT nButton );
virtual void SetText( const XubString& rStr );
USHORT GetWinId() { return nWinId; }
void SetWinId( USHORT nId ) { nWinId = nId; }
};
DECLARE_LIST( EditList, AppWin* );
#endif
+218
View File
@@ -0,0 +1,218 @@
/*************************************************************************
*
* $RCSfile: basic.hrc,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#define RID_OPTLIST 101
#define RID_OPTLINES 102
#define RID_OPTPACKS 103
#define RID_OPTPACKD 104
#define RID_OPTWARN1 105
#define RID_OPTWARN2 106
#define RID_OPTVIRT 107
#define RID_PARAMS 108
#define RID_RETTYPE 109
#define RID_RETVAL 110
//#define RID_APPICON 500
//#define RID_APPICON2 501
//#define RID_WORKICON 502
//#define RID_LOADICON 503
//#define RID_SAVEICON 504
#define RID_APPMENUBAR 1000
#define RID_APPFILE 1001
#define RID_APPEDIT 1002
#define RID_APPRUN 1003
#define RID_APPWINDOW 1004
#define RID_APPHELP 1005
#define RID_FILE 1100
#define RID_FILENEW 1101
#define RID_FILEOPEN 1102
#define RID_FILECLOSE 1103
#define RID_FILESAVE 1104
#define RID_FILESAVEAS 1105
#define RID_FILELOADLIB 1106
#define RID_FILESAVELIB 1107
#define RID_FILEPRINT 1109
#define RID_FILESETUP 1110
#define RID_QUIT 1111
#define IDM_FILE_LRU1 1112
#define IDM_FILE_LRU2 (IDM_FILE_LRU1 + 1)
#define IDM_FILE_LRU3 (IDM_FILE_LRU2 + 1)
#define IDM_FILE_LRU4 (IDM_FILE_LRU3 + 1)
#define RID_EDIT 1200
#define RID_EDITUNDO 1201
#define RID_EDITREDO 1202
#define RID_EDITCUT 1203
#define RID_EDITCOPY 1204
#define RID_EDITPASTE 1205
#define RID_EDITDEL 1206
#define RID_EDITSEARCH 1207
#define RID_EDITREPLACE 1208
#define RID_EDITREPEAT 1209
#define RID_RUN 1300
#define RID_RUNCOMPILE 1301
#define RID_RUNSTART 1302
#define RID_RUNBREAK 1304
#define RID_RUNSTOP 1303
#define RID_RUNNEXTERR 1307
#define RID_RUNPREVERR 1308
#define RID_RUNDISAS 1310
#define RID_RUNSTEPINTO 1311
#define RID_RUNSTEPOVER 1312
#define RID_RUNTOCURSOR 1313
#define RID_TOGLEBRKPNT 1314
#define RID_TT_EXTRAS_NAME 1400
#define RID_TT_EXTRAS 1401
#define RID_OPTIONS 1402
#define RID_DECLARE_HELPER 1403
#define RID_WINDOW 1501
#define RID_WINTILE 1502
#define RID_WINTILEHORZ 1503
#define RID_WINTILEVERT 1504
#define RID_WINCASCADE 1505
#define RID_WIN_FILE1 1520
#define RID_WIN_FILEn 1599
#define RID_HELP 1601
//#define RID_HELPINDEX 1602
//#define RID_HELPKEYS 1603
//#define RID_HELPINTRO 1604
//#define RID_HELPTOPIC 1605
#define RID_HELPABOUT 1606
#define RID_POPUP 1700
#define RID_POPUPEDITVAR 1701
#define IDS_APPNAME 2000
#define IDS_APPNAME2 2001
#define IDS_APPMODE_BREAK 2002
#define IDS_APPMODE_RUN 2003
#define IDS_NONAME 2100
#define IDS_NONAMEFILE 2101
#define IDS_INCFILE 2102
#define IDS_LIBFILE 2103
#define IDS_RESFILE 2104
#define IDS_TXTFILE 2105
#define IDS_READERROR 2103
#define IDS_WRITEERROR 2104
#define IDS_COMPERROR 2105
#define IDS_CONTINUE 2106
#define IDS_CANCEL 2107
#define IDS_NOPRINTERERROR 2108
#define IDS_PATTERNNOTFOUND 2109
#define IDS_INVALID_VALUE 2110
#define IDS_ASK_DIRTY_SAVE 2200
#define IDS_ASK_DISKCHANGE_SAVE 2201
#define IDS_ASK_DIRTY_AND_DISKCHANGE_SAVE 2202
#define IDS_ASKSAVEERROR 2203
#define IDS_ASKRELOAD 2204
#define IDS_ASKDIRTYRELOAD 2205
#define IDS_LOADDLG 2300
#define IDS_SAVEDLG 2301
#define IDS_BASFILTER 2304
#define IDS_LIBFILTER 2305
#define IDS_INCFILTER 2306
#define IDS_RESFILTER 2307
#define IDS_TXTFILTER 2308
#define IDS_PAGE 2401
#define IDS_PRINTMSG 2402
#define IDS_CANTLOAD 2501
#define IDS_CANTSAVE 2502
#define IDS_ERROR1 2601
#define IDS_ERROR2 2602
#define IDS_WARNING1 2603
#define IDS_NO_LONGNAME 2604
#define IDS_WARNING_PREFIX 2605
#define IDS_OBJECT 2606
#define IDS_EDIT_VAR 2607
#define IDS_NOMAINPGM 2701
#define IDS_DISASWIN 2702
#define IDS_RUNNING 2703
#define IDS_NOT_YET_IMPLEMENTED 2704
#define IDS_LOSS_OF_INFORMATION 2705
#define RID_ACCEL 3000
#define IDD_LOADSAVE_DIALOG 4001
#define IDD_ABOUT_DIALOG 4002
#define IDD_TT_ABOUT_DIALOG 4003
#define IDD_FIND_DIALOG 4004
#define IDD_REPLACE_DIALOG 4005
#define IDD_PRINT_DIALOG 4006
#define IDD_OPTIONS_DLG 4007
#define RID_TP_SPECIAL 4008
#define RID_TP_GENERIC 4009
#define IDD_DISPLAY_HID 4010
#define IDD_EDIT_VAR 4010
//#define RID_APPFONT 5000
//#define RID_APPEDITFONT 5001
//#define RID_DLGBRUSH 5002
#define RID_CALLDLG 6001
#define MBP_PLUS 8001
#define MBP_MINUS 8002
#define MBP_ASSERT 8003
#define RID_IMGLST_LAYOUT 8004
#define MAIN_ACCEL 9001
#define LOAD_CONF 10001
#define WORK 10002
#define FILENAME 10003
File diff suppressed because it is too large Load Diff
+163
View File
@@ -0,0 +1,163 @@
/*************************************************************************
*
* $RCSfile: basicrt.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "sbintern.hxx"
#include "runtime.hxx"
#include "basicrt.hxx"
const String BasicRuntime::GetModuleName( SbxNameType nType )
{
return pRun->GetModule()->GetName( nType );
}
const String BasicRuntime::GetMethodName( SbxNameType nType )
{
return pRun->GetMethod()->GetName( nType );
}
xub_StrLen BasicRuntime::GetLine()
{
return pRun->nLine;
}
xub_StrLen BasicRuntime::GetCol1()
{
return pRun->nCol1;
}
xub_StrLen BasicRuntime::GetCol2()
{
return pRun->nCol2;
}
BasicRuntime BasicRuntime::GetNextRuntime()
{
return BasicRuntime ( pRun->pNext );
}
const String BasicErrorStackEntry::GetModuleName( SbxNameType nType )
{
return pEntry->aMethod->GetModule()->GetName( nType );
}
const String BasicErrorStackEntry::GetMethodName( SbxNameType nType )
{
return pEntry->aMethod->GetName( nType );
}
xub_StrLen BasicErrorStackEntry::GetLine()
{
return pEntry->nLine;
}
xub_StrLen BasicErrorStackEntry::GetCol1()
{
return pEntry->nCol1;
}
xub_StrLen BasicErrorStackEntry::GetCol2()
{
return pEntry->nCol2;
}
BasicRuntime BasicRuntimeAccess::GetRuntime()
{
return BasicRuntime( pINST->pRun );
}
BOOL BasicRuntimeAccess::HasRuntime()
{
return pINST ? ( pINST->pRun != NULL ) : FALSE;
}
USHORT BasicRuntimeAccess::GetStackEntryCount()
{
return GetSbData()->pErrStack->Count();
}
BasicErrorStackEntry BasicRuntimeAccess::GetStackEntry( USHORT nIndex )
{
return BasicErrorStackEntry( GetSbData()->pErrStack->GetObject( nIndex ) );
}
BOOL BasicRuntimeAccess::HasStack()
{
return GetSbData()->pErrStack != NULL;
}
void BasicRuntimeAccess::DeleteStack()
{
delete GetSbData()->pErrStack;
GetSbData()->pErrStack = NULL;
}
BOOL BasicRuntimeAccess::IsRunInit()
{
return GetSbData()->bRunInit;
}
+79
View File
@@ -0,0 +1,79 @@
/*************************************************************************
*
* $RCSfile: basmsg.hrc,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <svtools/ttglobal.hrc>
// Hier sind die Messages aus dem Verzeichnis /basic/source/app enhalten
///////////////////////////////
// Fehlermeldungen, die in das Resultfile gelangen.
// *********************
// *** !!ACHTUNG!! ***
// *********************
// Die Nummern dürfen sich NIE! ändern,
// da sie in den Resultfiles gespeichert sind, und bei erneutem Anzeigen
// statdessen die entsprechenden neuen oder garkeine Strings angzeigt werden.
///////////////////////////////
#define S_PROG_START ( BAS_START + 0 )
#define S_ERROR_OUTSIDE_TESTCASE ( BAS_START + 1 )
#define S_WARNING_PREFIX ( BAS_START + 2 )
+142
View File
@@ -0,0 +1,142 @@
/*************************************************************************
*
* $RCSfile: basmsg.src,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "basmsg.hrc"
// Hier sind die Messages aus dem Verzeichnis /basic/source/app enhalten
///////////////////////////////
// Fehlermeldungen, die in das Resultfile gelangen.
// *********************
// *** !!ACHTUNG!! ***
// *********************
// Die Nummern dürfen sich NIE! ändern,
// da sie in den Resultfiles gespeichert sind, und bei erneutem Anzeigen
// statdessen die entsprechenden neuen oder garkeine Strings angzeigt werden.
///////////////////////////////
String S_PROG_START
{
Text = "Programmstart: ($Arg1); ($Arg2)";
Text[ english_us ] = "Program start: ($Arg1); ($Arg2)";
Text[ LANGUAGE_USER1 ] = "Programmstart: <Datum>; <Uhrzeit>";
Text[ portuguese ] = "Início do programa: ($Arg1); ($Arg2)";
Text[ russian ] = "Program start: ($Arg1); ($Arg2)";
Text[ greek ] = "Program start: ($Arg1); ($Arg2)";
Text[ dutch ] = "Programma start: ($Arg1); ($Arg2)";
Text[ french ] = "Démarrage du programme : ($Arg1); ($Arg2)";
Text[ spanish ] = "Inicio de programa: ($Arg1); ($Arg2)";
Text[ italian ] = "Program start: ($Arg1); ($Arg2)";
Text[ danish ] = "Program start: ($Arg1); ($Arg2)";
Text[ swedish ] = "Program start: ($Arg1); ($Arg2)";
Text[ polish ] = "Uruchomienie programu: ($Arg1); ($Arg2)";
Text[ portuguese_brazilian ] = "Programmstart: ($Arg1); ($Arg2)";
Text[ japanese ] = "Program start: ($Arg1); ($Arg2)";
Text[ korean ] = "Programmstart: ($Arg1); ($Arg2)";
Text[ chinese_simplified ] = "Program start: ($Arg1); ($Arg2)";
Text[ chinese_traditional ] = "Program start: ($Arg1); ($Arg2)";
Text[ arabic ] = "Program start: ($Arg1); ($Arg2)";
Text[ turkish ] = "Program baþlatma: ($Arg1); ($Arg2)";
};
String S_ERROR_OUTSIDE_TESTCASE
{
Text = "Fehler außerhalb eines Testcase.";
Text[ english_us ] = "Error outside of test case";
Text[ portuguese ] = "Erro fora de um «test case».";
Text[ russian ] = "Error outside of test case.";
Text[ greek ] = "Error outside of test case.";
Text[ dutch ] = "Fout buiten testcase.";
Text[ french ] = "Erreur en dehors d'un scénario de test (test case).";
Text[ spanish ] = "Error fuera de un Testcase.";
Text[ italian ] = "Error outside of test case";
Text[ danish ] = "Error outside of test case.";
Text[ swedish ] = "Error outside of test case";
Text[ polish ] = "B³¹d poza Testcase.";
Text[ portuguese_brazilian ] = "Fehler außerhalb eines Testcase.";
Text[ japanese ] = "Error outside of test case.";
Text[ korean ] = "Å×½ºÆ® ÄÉÀ̽º ¿ÜºÎÀÇ ¿À·ù";
Text[ chinese_simplified ] = "Error outside of test case";
Text[ chinese_traditional ] = "Error outside of test case";
Text[ arabic ] = "Error outside of test case";
Text[ turkish ] = "Error outside of test case";
};
String S_WARNING_PREFIX
{
Text = "Warnung: ";
Text[ english_us ] = "Warning: ";
Text[ portuguese ] = "Aviso: ";
Text[ russian ] = "Ïðåäóïðåæäåíèå: ";
Text[ greek ] = "Warning: ";
Text[ dutch ] = "Waarschuwing: ";
Text[ french ] = "Avertissement : ";
Text[ spanish ] = "Advertencia: ";
Text[ italian ] = "Warning: ";
Text[ danish ] = "Warning: ";
Text[ swedish ] = "Warning: ";
Text[ polish ] = "Ostrze¿enie: ";
Text[ portuguese_brazilian ] = "Warning: ";
Text[ japanese ] = "Œx��: ";
Text[ korean ] = "°æ°í: ";
Text[ chinese_simplified ] = "Warning: ";
Text[ chinese_traditional ] = "Warning: ";
Text[ arabic ] = "ÊÍÐíÑ: ";
Text[ turkish ] = "Uyarý: ";
};
+434
View File
@@ -0,0 +1,434 @@
/*************************************************************************
*
* $RCSfile: brkpnts.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _LIST_HXX //autogen
#include <tools/list.hxx>
#endif
#ifndef _SBXCLASS_HXX //autogen
#include <svtools/sbx.hxx>
#endif
#ifndef _SB_SBMOD_HXX //autogen
#include <sbmod.hxx>
#endif
#ifndef _SB_SBSTAR_HXX //autogen
#include <sbstar.hxx>
#endif
#ifndef _SB_SBMETH_HXX //autogen
#include <sbmeth.hxx>
#endif
#ifndef _SV_IMAGE_HXX //autogen
#include <vcl/image.hxx>
#endif
#ifndef _TEXTDATA_HXX //autogen
#include <svtools/textdata.hxx>
#endif
#ifndef _SV_CONFIG_HXX //autogen
#include <vcl/config.hxx>
#endif
#ifndef _SV_GRADIENT_HXX
#include <vcl/gradient.hxx>
#endif
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
#include <brkpnts.hxx>
#include "basic.hrc"
#include "resids.hrc"
struct Breakpoint
{
USHORT nLine;
Breakpoint( USHORT nL ) { nLine = nL; }
};
ImageList* BreakpointWindow::pImages = NULL;
BreakpointWindow::BreakpointWindow( Window *pParent )
: Window( pParent )
, nCurYOffset( 0 )
, pModule( NULL )
{
if ( !pImages )
pImages = new ImageList( ResId( RID_IMGLST_LAYOUT ) );
Gradient aGradient( GRADIENT_AXIAL, Color( 185, 182, 215 ), Color( 250, 245, 255 ) );
aGradient.SetAngle(900);
SetBackground( aGradient );
Show();
}
void BreakpointWindow::Reset()
{
Breakpoint* pBrk = First();
while ( pBrk )
{
delete pBrk;
pBrk = Next();
}
Clear();
pModule->ClearAllBP();
}
void BreakpointWindow::SetModule( SbModule *pMod )
{
pModule = pMod;
USHORT i;
for ( i=0 ; i < pModule->GetBPCount() ; i++ )
{
InsertBreakpoint( pModule->GetBP( i ) );
}
SetBPsInModule();
}
void BreakpointWindow::SetBPsInModule()
{
pModule->ClearAllBP();
Breakpoint* pBrk = First();
while ( pBrk )
{
pModule->SetBP( (USHORT)pBrk->nLine );
#ifdef DEBUG
DBG_ASSERT( pModule->IsBP( (USHORT)pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" )
#endif
pBrk = Next();
}
for ( USHORT nMethod = 0; nMethod < pModule->GetMethods()->Count(); nMethod++ )
{
SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Get( nMethod );
DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
}
}
void BreakpointWindow::InsertBreakpoint( USHORT nLine )
{
Breakpoint* pNewBrk = new Breakpoint( nLine );
Breakpoint* pBrk = First();
while ( pBrk )
{
if ( nLine <= pBrk->nLine )
{
if ( pBrk->nLine != nLine )
Insert( pNewBrk );
else
delete pNewBrk;
pNewBrk = NULL;
pBrk = NULL;
}
else
pBrk = Next();
}
// Keine Einfuegeposition gefunden => LIST_APPEND
if ( pNewBrk )
Insert( pNewBrk, LIST_APPEND );
// vielleicht mal etwas genauer...
Invalidate();
if ( pModule->SetBP( nLine ) )
{
#ifdef DEBUG
DBG_ASSERT( pModule->IsBP( nLine ), "Brechpunkt wurde nicht gesetzt" )
#endif
if ( StarBASIC::IsRunning() )
{
for ( USHORT nMethod = 0; nMethod < pModule->GetMethods()->Count(); nMethod++ )
{
SbMethod* pMethod = (SbMethod*)pModule->GetMethods()->Get( nMethod );
DBG_ASSERT( pMethod, "Methode nicht gefunden! (NULL)" );
pMethod->SetDebugFlags( pMethod->GetDebugFlags() | SbDEBUG_BREAK );
}
}
}
#ifdef DEBUG
DBG_ASSERT( pModule->IsBP( nLine ), "Brechpunkt wurde nicht gesetzt" )
#endif
}
Breakpoint* BreakpointWindow::FindBreakpoint( ULONG nLine )
{
Breakpoint* pBrk = First();
while ( pBrk )
{
if ( pBrk->nLine == nLine )
return pBrk;
pBrk = Next();
}
return (Breakpoint*)0;
}
void BreakpointWindow::AdjustBreakpoints( ULONG nLine, BOOL bInserted )
{
if ( nLine == TEXT_PARA_ALL+1 )
return;
Breakpoint* pBrk = First();
while ( pBrk )
{
BOOL bDelBrk = FALSE;
if ( pBrk->nLine == nLine )
{
if ( bInserted )
pBrk->nLine++;
else
bDelBrk = TRUE;
}
else if ( pBrk->nLine > nLine )
{
if ( bInserted )
pBrk->nLine++;
else
pBrk->nLine--;
}
if ( bDelBrk )
{
ULONG n = GetCurPos();
delete Remove( pBrk );
pBrk = Seek( n );
}
else
{
pBrk = Next();
}
}
}
void BreakpointWindow::LoadBreakpoints( String aFilename )
{
Config aConfig(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
aConfig.SetGroup("Breakpoints");
ByteString aBreakpoints;
aBreakpoints = aConfig.ReadKey( ByteString( aFilename, RTL_TEXTENCODING_UTF8 ) );
xub_StrLen i;
for ( i = 0 ; i < aBreakpoints.GetTokenCount( ';' ) ; i++ )
{
InsertBreakpoint( aBreakpoints.GetToken( i, ';' ).ToInt32() );
}
}
void BreakpointWindow::SaveBreakpoints( String aFilename )
{
ByteString aBreakpoints;
Breakpoint* pBrk = First();
while ( pBrk )
{
if ( aBreakpoints.Len() )
aBreakpoints += ';';
aBreakpoints += ByteString::CreateFromInt32( pBrk->nLine );
pBrk = Next();
}
Config aConfig(Config::GetConfigName( Config::GetDefDirectory(), CUniString("testtool") ));
aConfig.SetGroup("Breakpoints");
if ( aBreakpoints.Len() )
aConfig.WriteKey( ByteString( aFilename, RTL_TEXTENCODING_UTF8 ), aBreakpoints );
else
aConfig.DeleteKey( ByteString( aFilename, RTL_TEXTENCODING_UTF8 ) );
}
void BreakpointWindow::Paint( const Rectangle& )
{
Size aOutSz( GetOutputSize() );
long nLineHeight = GetTextHeight();
Image aBrk( pImages->GetImage( IMGID_BRKENABLED ) );
Size aBmpSz( aBrk.GetSizePixel() );
aBmpSz = PixelToLogic( aBmpSz );
Point aBmpOff( 0, 0 );
aBmpOff.X() = ( aOutSz.Width() - aBmpSz.Width() ) / 2;
aBmpOff.Y() = ( nLineHeight - aBmpSz.Height() ) / 2;
Breakpoint* pBrk = First();
while ( pBrk )
{
#ifdef DEBUG
DBG_ASSERT( pModule->IsBP( pBrk->nLine ), "Brechpunkt wurde nicht gesetzt" )
#endif
ULONG nLine = pBrk->nLine-1;
ULONG nY = nLine*nLineHeight - nCurYOffset;
DrawImage( Point( 0, nY ) + aBmpOff, aBrk );
pBrk = Next();
}
ShowMarker( TRUE );
}
Breakpoint* BreakpointWindow::FindBreakpoint( const Point& rMousePos )
{
long nLineHeight = GetTextHeight();
long nYPos = rMousePos.Y() + nCurYOffset;
Breakpoint* pBrk = First();
while ( pBrk )
{
ULONG nLine = pBrk->nLine-1;
long nY = nLine*nLineHeight;
if ( ( nYPos > nY ) && ( nYPos < ( nY + nLineHeight ) ) )
return pBrk;
pBrk = Next();
}
return 0;
}
void BreakpointWindow::ToggleBreakpoint( USHORT nLine )
{
BOOL bNewBreakPoint = FALSE;
Breakpoint* pBrk = FindBreakpoint( nLine );
if ( pBrk ) // entfernen
{
pModule->ClearBP( nLine );
delete Remove( pBrk );
}
else // einen erzeugen
{
InsertBreakpoint( nLine );
}
// vielleicht mal etwas genauer...
Invalidate();
}
void BreakpointWindow::ShowMarker( BOOL bShow )
{
if ( nMarkerPos == MARKER_NOMARKER )
return;
Size aOutSz( GetOutputSize() );
long nLineHeight = GetTextHeight();
Image aMarker;
if ( bErrorMarker )
aMarker = pImages->GetImage( IMGID_ERRORMARKER );
else
aMarker = pImages->GetImage( IMGID_STEPMARKER );
Size aMarkerSz( aMarker.GetSizePixel() );
aMarkerSz = PixelToLogic( aMarkerSz );
Point aMarkerOff( 0, 0 );
aMarkerOff.X() = ( aOutSz.Width() - aMarkerSz.Width() ) / 2;
aMarkerOff.Y() = ( nLineHeight - aMarkerSz.Height() ) / 2;
ULONG nY = nMarkerPos*nLineHeight - nCurYOffset;
Point aPos( 0, nY );
aPos += aMarkerOff;
if ( bShow )
DrawImage( aPos, aMarker );
else
Invalidate( Rectangle( aPos, aMarkerSz ) );
}
void BreakpointWindow::MouseButtonDown( const MouseEvent& rMEvt )
{
if ( rMEvt.GetClicks() == 2 )
{
Point aMousePos( PixelToLogic( rMEvt.GetPosPixel() ) );
long nLineHeight = GetTextHeight();
long nYPos = aMousePos.Y() + nCurYOffset;
long nLine = nYPos / nLineHeight + 1;
ToggleBreakpoint( nLine );
// vielleicht mal etwas genauer...
Invalidate();
}
}
void BreakpointWindow::SetMarkerPos( USHORT nLine, BOOL bError )
{
ShowMarker( FALSE ); // Alten wegzeichen...
nMarkerPos = nLine;
bErrorMarker = bError;
ShowMarker( TRUE ); // Neuen zeichnen...
Update();
}
void BreakpointWindow::Scroll( long nHorzScroll, long nVertScroll )
{
nCurYOffset -= nVertScroll;
Window::Scroll( nHorzScroll, nVertScroll );
}
+130
View File
@@ -0,0 +1,130 @@
/*************************************************************************
*
* $RCSfile: brkpnts.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SV_WINDOW_HXX //autogen
#include <vcl/window.hxx>
#endif
#define MARKER_NOMARKER 0xFFFF
class SbModule;
class BreakpointListe;
struct Breakpoint;
class ImageList;
DECLARE_LIST( BreakpointList, Breakpoint* );
class BreakpointWindow : public Window, public BreakpointList
{
public:
BreakpointWindow( Window *pParent );
// ~BreakpointWindow();
void Reset();
void SetModule( SbModule *pMod );
void SetBPsInModule();
void InsertBreakpoint( USHORT nLine );
void ToggleBreakpoint( USHORT nLine );
void AdjustBreakpoints( ULONG nLine, BOOL bInserted );
void LoadBreakpoints( String aFilename );
void SaveBreakpoints( String aFilename );
protected:
Breakpoint* FindBreakpoint( ULONG nLine );
private:
BreakpointListe *pBreakpoints;
private:
long nCurYOffset;
USHORT nMarkerPos;
SbModule* pModule;
BOOL bErrorMarker;
static ImageList *pImages;
protected:
virtual void Paint( const Rectangle& );
Breakpoint* FindBreakpoint( const Point& rMousePos );
void ShowMarker( BOOL bShow );
virtual void MouseButtonDown( const MouseEvent& rMEvt );
public:
// void SetModulWindow( ModulWindow* pWin )
// { pModulWindow = pWin; }
void SetMarkerPos( USHORT nLine, BOOL bErrorMarker = FALSE );
void Scroll( long nHorzScroll, long nVertScroll );
long& GetCurYOffset() { return nCurYOffset; }
};
+155
View File
@@ -0,0 +1,155 @@
/*************************************************************************
*
* $RCSfile: dataedit.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:08 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef DATAEDIT_HXX
#define DATAEDIT_HXX
#ifndef _SV_MENU_HXX
#include <vcl/menu.hxx>
#endif
#ifndef _LINK_HXX //autogen
#include <tools/link.hxx>
#endif
#ifndef _SV_GEN_HXX
#include <tools/gen.hxx>
#endif
#ifndef _TEXTDATA_HXX //autogen
#include <svtools/textdata.hxx>
#endif
class String;
class Font;
// Find, Load und Save müssen implementiert werden,
// die anderen müssen in MemberType existieren
#define DATA_FUNC_DEF( MemberName, MemberType ) \
public: \
MemberType MemberName; \
BOOL Find( const String& rStr ); \
BOOL Load( const String& rStr ); \
BOOL Save( const String& rStr ); \
\
void GrabFocus(){ MemberName.GrabFocus(); } \
void Show(){ MemberName.Show(); } \
void SetPosPixel( const Point& rNewPos ){ MemberName.SetPosPixel(rNewPos); }\
void SetSizePixel( const Size& rNewSize ){ MemberName.SetSizePixel(rNewSize); } \
Size GetSizePixel(){ return MemberName.GetSizePixel(); } \
Point GetPosPixel(){ return MemberName.GetPosPixel(); } \
void Update(){ MemberName.Update(); } \
void SetFont( const Font& rNewFont ){ MemberName.SetFont(rNewFont); } \
\
void Delete(); \
void Cut(); \
void Copy(); \
void Paste(); \
void Undo(); \
void Redo(); \
String GetText() const; \
void SetText( const String& rStr ); \
BOOL HasText() const; \
String GetSelected(); \
TextSelection GetSelection() const; \
void SetSelection( const TextSelection& rSelection ); \
USHORT GetLineNr() const; \
void ReplaceSelected( const String& rStr ); \
BOOL IsModified(); \
void SetModifyHdl( Link l );
class DataEdit
{
public:
virtual ~DataEdit(){}
virtual void Delete()=0;
virtual void Cut()=0;
virtual void Copy()=0;
virtual void Paste()=0;
virtual void Undo()=0;
virtual void Redo()=0;
virtual BOOL Find( const String& )=0; // Text suchen & markieren
virtual BOOL Load( const String& )=0; // Text aus Datei laden
virtual BOOL Save( const String& )=0; // Text in Datei speichern
virtual String GetSelected()=0;
virtual void GrabFocus()=0;
virtual TextSelection GetSelection() const=0;
virtual void SetSelection( const TextSelection& rSelection )=0;
virtual USHORT GetLineNr() const=0;
virtual String GetText() const=0;
virtual void SetText( const String& rStr )=0;
virtual BOOL HasText() const=0; // damit vermeiden wir GetText.Len()
virtual void ReplaceSelected( const String& rStr )=0;
virtual BOOL IsModified()=0;
virtual void SetModifyHdl( Link )=0;
virtual void Show()=0;
virtual void SetPosPixel( const Point& rNewPos )=0;
virtual void SetSizePixel( const Size& rNewSize )=0;
virtual Size GetSizePixel()=0;
virtual Point GetPosPixel()=0;
virtual void Update()=0;
virtual void SetFont( const Font& rNewFont )=0;
virtual void BuildKontextMenu( PopupMenu *&pMenu ){;} // Wer will kann hier eigene Einträge hinzufügen
};
#endif
File diff suppressed because it is too large Load Diff
+307
View File
@@ -0,0 +1,307 @@
/*************************************************************************
*
* $RCSfile: dialogs.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _DIALOGS_HXX
#define _DIALOGS_HXX
#ifndef _DIALOG_HXX //autogen
#include <vcl/dialog.hxx>
#endif
#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif
#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif
#ifndef _SV_FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _SV_TABDLG_HXX //autogen
#include <vcl/tabdlg.hxx>
#endif
#ifndef _SV_TABCTRL_HXX //autogen
#include <vcl/tabctrl.hxx>
#endif
#ifndef _SV_TABPAGE_HXX //autogen
#include <vcl/tabpage.hxx>
#endif
#ifndef _SV_GROUP_HXX //autogen
#include <vcl/group.hxx>
#endif
#ifndef _SV_CONFIG_HXX //autogen
#include <vcl/config.hxx>
#endif
#ifndef _TOOLS_LIST_HXX
#include <tools/list.hxx>
#endif
#ifndef _SV_LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif
#ifndef _SV_FLOATWIN_HXX //autogen
#include <vcl/floatwin.hxx>
#endif
#ifndef _SV_TOOLBOX_HXX //autogen
#include <vcl/toolbox.hxx>
#endif
class SbxVariable;
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
class AboutDialog : public ModalDialog {
FixedText a1,a3,a4,aVersionString;
OKButton aOk;
// FixedIcon aIcon;
public:
AboutDialog (Window*, const ResId&);
};
class FindDialog : public ModalDialog {
FixedText aFT1;
Edit aFind;
OKButton aOk;
CancelButton aCancel;
String* pFind;
DECL_LINK( ButtonClick, Button * );
public:
FindDialog (Window*, const ResId&, String&);
};
class ReplaceDialog : public ModalDialog {
FixedText aFT1;
FixedText aFT2;
Edit aFind;
Edit aReplace;
OKButton aOk;
CancelButton aCancel;
String* pFind;
String* pReplace;
DECL_LINK( ButtonClick, Button * );
public:
ReplaceDialog (Window*, const ResId&, String&, String&);
};
class ConfEdit : public PushButton
{
FixedText aText;
ByteString aKeyName;
Edit aEdit;
public:
ConfEdit( Window* pParent, USHORT nResText, USHORT nResEdit, USHORT nResButton, const ByteString& aKN );
void Save();
void Click();
};
class OptionsDialog : public ModelessDialog
{
private:
TabControl aTabCtrl;
OKButton aOK;
CancelButton aCancel;
DECL_LINK( OKClick, Button * );
public:
OptionsDialog( Window* pParent, const ResId& );
~OptionsDialog();
virtual BOOL Close();
DECL_LINK( ActivatePageHdl, TabControl * );
};
class SpecialOptions : public TabPage
{
GroupBox aDirs;
ConfEdit aLog;
ConfEdit aBasis;
ConfEdit aHID;
GroupBox aOther;
FixedText aTimeoutText;
TimeField aServerTimeout;
CheckBox aAutoReload;
public:
SpecialOptions( Window* );
void Save();
};
DECLARE_LIST( StringList, String * );
#define C_KEY_ALLE CByteString("Alle")
#define C_KEY_AKTUELL CByteString("Aktuell")
#define C_KEY_DELETE CByteString("Deleted Groups")
class GenericOptions : public TabPage
{
GroupBox aGbArea;
ComboBox aCbArea;
PushButton aPbNewArea;
PushButton aPbDelArea;
GroupBox aGbValue;
ComboBox aCbValue;
PushButton aPbNewValue;
PushButton aPbDelValue;
Config aConf;
String aTempConfName;
Config *pTempConf;
ByteString aLastGroupName;
String ReadKey( const ByteString &aGroup, const ByteString &aKey );
BOOL HasKey( Config &aConfig, const ByteString &aKey );
void LoadValues();
StringList* GetAllGroups();
void LoadData();
DECL_LINK( LoadGroup, ComboBox* );
DECL_LINK( DelGroup, Button* );
DECL_LINK( NewGroup, Button* );
DECL_LINK( DelValue, Button* );
DECL_LINK( NewValue, Button* );
DECL_LINK( CheckButtonsHdl, ComboBox* );
void CheckButtons( ComboBox &aCB, Button &aNewB, Button &aDelB );
public:
GenericOptions( Window* );
~GenericOptions();
void Save();
};
struct WinInfoRec;
class SplitWindow;
class DisplayHidDlg : public FloatingWindow
{
protected:
ToolBox aTbConf;
FixedText aFtControls;
MultiListBox aMlbControls;
FixedText aFtSlots;
MultiListBox aMlbSlots;
PushButton aPbKopieren;
PushButton aPbBenennen;
PushButton aPbSelectAll;
OKButton aOKClose;
DockingWindow* pControls;
DockingWindow* pSlots;
SplitWindow *pSplit;
ULONG nDisplayMode;
DECL_LINK( Select, void* );
DECL_LINK( SelectAll, PushButton* );
DECL_LINK( CopyToClipboard, void* );
public:
DisplayHidDlg( Window * pParent );
virtual ~DisplayHidDlg();
virtual void Resize();
void AddData( WinInfoRec* pWinInfo );
};
class VarEditDialog : public ModelessDialog
{
protected:
FixedText aFixedTextRID_FT_NAME;
FixedText aFixedTextRID_FT_CONTENT;
FixedText aFixedTextRID_FT_NEW_CONTENT;
FixedText aFixedTextRID_FT_NAME_VALUE;
FixedText aFixedTextRID_FT_CONTENT_VALUE;
RadioButton aRadioButtonRID_RB_NEW_BOOL_T;
RadioButton aRadioButtonRID_RB_NEW_BOOL_F;
NumericField aNumericFieldRID_NF_NEW_INTEGER;
NumericField aNumericFieldRID_NF_NEW_LONG;
Edit aEditRID_ED_NEW_STRING;
OKButton aOKButtonRID_OK;
CancelButton aCancelButtonRID_CANCEL;
SbxVariable *pVar;
DECL_LINK( OKClick, Button * );
// BOOL bCompare = FALSE;
// String aCompareString;
public:
VarEditDialog( Window * pParent, SbxVariable *pPVar );
};
#endif
+164
View File
@@ -0,0 +1,164 @@
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1.1.1 $
#
# last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library 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 for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJNAME=BASIC
TARGET=app
# --- Settings ------------------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- Allgemein ------------------------------------------------------------
.INCLUDE : $(UPD)minor.mk
RSCUPDVER=$(RSCREVISION)SV$(UPD)$(UPDMINOR)
CXXFILES = \
ttstrhlp.cxx \
ttbasic.cxx \
basicrt.cxx \
processw.cxx \
process.cxx \
brkpnts.cxx \
app.cxx \
mybasic.cxx \
status.cxx \
printer.cxx \
appwin.cxx \
appedit.cxx \
appbased.cxx \
apperror.cxx \
textedit.cxx \
msgedit.cxx \
dialogs.cxx \
comm_bas.cxx \
testbasi.cxx
OBJFILES = \
$(OBJ)$/ttstrhlp.obj \
$(OBJ)$/ttbasic.obj \
$(OBJ)$/basicrt.obj \
$(OBJ)$/processw.obj \
$(OBJ)$/process.obj \
$(OBJ)$/brkpnts.obj \
$(OBJ)$/app.obj \
$(OBJ)$/mybasic.obj \
$(OBJ)$/status.obj \
$(OBJ)$/printer.obj \
$(OBJ)$/appwin.obj \
$(OBJ)$/appedit.obj \
$(OBJ)$/appbased.obj \
$(OBJ)$/apperror.obj \
$(OBJ)$/textedit.obj \
$(OBJ)$/msgedit.obj \
$(OBJ)$/dialogs.obj \
$(OBJ)$/comm_bas.obj \
$(SLO)$/sbintern.obj
SRCFILES = \
basic.src \
ttmsg.src \
basmsg.src \
svtmsg.src \
testtool.src
LIBTARGET = NO
LIB1TARGET=$(LB)$/app.lib
LIB1ARCHIV=$(LB)$/libapp.a
LIB1OBJFILES = \
$(OBJ)$/ttstrhlp.obj \
$(OBJ)$/basicrt.obj \
$(OBJ)$/processw.obj \
$(OBJ)$/process.obj \
$(OBJ)$/brkpnts.obj \
$(OBJ)$/app.obj \
$(OBJ)$/mybasic.obj \
$(OBJ)$/status.obj \
$(OBJ)$/printer.obj \
$(OBJ)$/appwin.obj \
$(OBJ)$/appedit.obj \
$(OBJ)$/appbased.obj \
$(OBJ)$/apperror.obj \
$(OBJ)$/textedit.obj \
$(OBJ)$/msgedit.obj \
$(OBJ)$/dialogs.obj \
$(OBJ)$/comm_bas.obj \
$(SLO)$/sbintern.obj
.IF "$(depend)" == ""
ALL: $(LB)$/app.lib \
ALLTAR
.ENDIF
# --- Targets ------------------------------------------------------------
.INCLUDE : target.mk
+858
View File
@@ -0,0 +1,858 @@
/*************************************************************************
*
* $RCSfile: msgedit.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
/*************************************************************************
File Versions so far:
No Version Initial Implementation without Version Information
Version 2 changed order of entries(New Entries at the end)
Version 3 Changed Charset from CHARSET_IBMPC to RTL_TEXTENCODING_UTF8
*************************************************************************/
#ifndef _INTN_HXX //autogen
#include <tools/intn.hxx>
#endif
#ifndef _TIME_HXX //autogen
#include <tools/time.hxx>
#endif
#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif
#ifndef _MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SOUND_HXX //autogen
#include <vcl/sound.hxx>
#endif
#ifndef _FSYS_HXX //autogen
#include <tools/fsys.hxx>
#endif
#ifndef _CLIP_HXX //autogen
#include <vcl/clip.hxx>
#endif
#ifndef NOOLDSV //autogen
#include <vcl/system.hxx>
#endif
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
#ifndef _SV_SYSTEM_HXX
#include <vcl/system.hxx>
#endif
#include "basic.hrc"
#include "msgedit.hxx"
#include "app.hxx"
#include "appbased.hxx"
#include "basmsg.hrc"
#define WARNING_PREFIX String( ResId( S_WARNING_PREFIX ) )
#define VERSION_STRING CUniString("File Format Version: ")
#define THIS_VERSION 2
#define LOGTYPE( pEntry ) ((pEntry && pEntry->GetUserData())?((TTDebugData*)pEntry->GetUserData())->aLogType:LOG_ERROR)
MsgEdit::MsgEdit( AppWin* pParent, BasicFrame *pBF, const WinBits& aBits )
: aEditTree( pParent, pBF, aBits | WB_HASBUTTONS | WB_HASLINES | WB_HASBUTTONSATROOT )
, pBasicFrame(pBF)
, pCurrentRun(NULL)
, pCurrentTestCase(NULL)
, pCurrentError(NULL)
, nVersion(0)
, bFileLoading(FALSE)
, bModified(FALSE)
, pAppWin( pParent )
{
SetFont( System::GetStandardFont(STDFONT_FIXED) );
aEditTree.SetNodeBitmaps( Bitmap( ResId (MBP_PLUS) ), Bitmap( ResId (MBP_MINUS) ) );
aEditTree.SetSelectionMode( MULTIPLE_SELECTION );
if ( aEditTree.GetModel()->GetSortMode() != SortNone )
aEditTree.GetModel()->SetSortMode( SortNone );
pParent->bHasFile = Load( pParent->GetText() );
}
MsgEdit::~MsgEdit()
{}
#define ADD_TTDEBUGDATA( aLBoxEntry ) \
{ \
TTDebugData *pData = new TTDebugData; \
*pData = aDebugData; \
aLBoxEntry->SetUserData( pData ); \
} \
void MsgEdit::AddAnyMsg( TTLogMsg *LogMsg )
{
if ( LogMsg->aDebugData.aFilename.Copy(0,2).CompareToAscii( "--" ) == COMPARE_EQUAL )
LogMsg->aDebugData.aFilename.Erase(0,2);
xub_StrLen nPos;
LogMsg->aDebugData.aMsg.ConvertLineEnd();
if ( (nPos = LogMsg->aDebugData.aMsg.Search( CUniString("\n").ConvertLineEnd() )) != STRING_NOTFOUND )
{
xub_StrLen nSysLineEndLen = CUniString("\n").ConvertLineEnd().Len();
String aLastPart = LogMsg->aDebugData.aMsg.Copy( nPos+nSysLineEndLen );
LogMsg->aDebugData.aMsg.Erase( nPos );
AddAnyMsg( LogMsg );
LogMsg->aDebugData.aMsg = aLastPart;
AddAnyMsg( LogMsg );
}
else
{
String aUILogMsg( pBasicFrame->GenRealString( LogMsg->aDebugData.aMsg ) );
switch ( LogMsg->aDebugData.aLogType )
{
case LOG_RUN:
{
if ( LogMsg->aDebugData.aMsg.Len() == 0 )
{
LogMsg->aDebugData.aMsg = GEN_RES_STR2( S_PROG_START,
GetpApp()->GetAppInternational().GetDate(Date()),
GetpApp()->GetAppInternational().GetTime(Time(),FALSE) );
aUILogMsg = pBasicFrame->GenRealString( LogMsg->aDebugData.aMsg );
}
AddRun( aUILogMsg, LogMsg->aDebugData ); break;
}
case LOG_TEST_CASE: AddTestCase( aUILogMsg, LogMsg->aDebugData ); break;
case LOG_ERROR: AddError( aUILogMsg, LogMsg->aDebugData ); break;
case LOG_CALL_STACK:AddCallStack( aUILogMsg, LogMsg->aDebugData ); break;
case LOG_MESSAGE: AddMessage( aUILogMsg, LogMsg->aDebugData ); break;
case LOG_WARNING: AddWarning( aUILogMsg, LogMsg->aDebugData ); break;
case LOG_ASSERTION: AddAssertion( aUILogMsg, LogMsg->aDebugData ); break;
}
if ( !bFileLoading )
{ // Kommt vom Testtool und muß gleich geschrieben werden.
BOOL bFileWasChanged = pAppWin->DiskFileChanged( SINCE_LAST_LOAD );
DBG_ASSERT( aLogFileName == LogMsg->aLogFileName, "Logging to different logfile as before" );
SvFileStream aStrm( LogMsg->aLogFileName, STREAM_STD_WRITE );
String aLogMsg = Impl_MakeSaveText( LogMsg->aDebugData ).AppendAscii("\n");
if( aStrm.IsOpen() )
{
aLogMsg.ConvertLineEnd(LINEEND_CRLF);
aStrm.Seek(STREAM_SEEK_TO_END);
aStrm << ByteString( aLogMsg, RTL_TEXTENCODING_UTF8 ).GetBuffer();
aStrm.Close();
}
if ( !bFileWasChanged )
pAppWin->UpdateFileInfo( HAS_BEEN_LOADED );
}
}
}
void MsgEdit::AddRun( String aMsg, TTDebugData aDebugData )
{
if ( !bFileLoading || ( bFileLoading && nVersion >= 2 ) )
pCurrentRun = aEditTree.InsertEntry( aMsg, NULL, FALSE, 0 );
else // Erstes Dateiformat
pCurrentRun = aEditTree.InsertEntry( aMsg ); // und damit an Ende!
aEditTree.ShowEntry( pCurrentRun );
pCurrentTestCase = NULL;
pCurrentError = NULL;
aDebugData.aLogType = LOG_RUN; // Da auch von anderswo aufgerufen
ADD_TTDEBUGDATA( pCurrentRun );
}
void MsgEdit::AddTestCase( String aMsg, TTDebugData aDebugData )
{
if ( pCurrentRun )
{
if ( aMsg.Len() == 0 ) // Am Ende des Testcase
{
pCurrentTestCase = NULL;
}
else
{
pCurrentTestCase = aEditTree.InsertEntry( aMsg, pCurrentRun );
aEditTree.ShowEntry( pCurrentTestCase );
aDebugData.aLogType = LOG_TEST_CASE; // Da auch von anderswo aufgerufen
ADD_TTDEBUGDATA( pCurrentTestCase );
}
}
pCurrentError = NULL;
}
void MsgEdit::AddError( String aMsg, TTDebugData aDebugData )
{
if ( !pCurrentTestCase )
{
TTLogMsg aLogMsg;
aLogMsg.aDebugData = aDebugData;
aLogMsg.aDebugData.aMsg = GEN_RES_STR0( S_ERROR_OUTSIDE_TESTCASE );
aLogMsg.aDebugData.aLogType = LOG_TEST_CASE;
aLogMsg.aLogFileName = aLogFileName;
AddAnyMsg( &aLogMsg );
}
if ( pCurrentTestCase )
{
pCurrentError = aEditTree.InsertEntry( aMsg, pCurrentTestCase );
aEditTree.ShowEntry( pCurrentError );
aDebugData.aLogType = LOG_ERROR; // Da auch von anderswo aufgerufen
ADD_TTDEBUGDATA( pCurrentError );
}
}
void MsgEdit::AddCallStack( String aMsg, TTDebugData aDebugData )
{
DBG_ASSERT( pCurrentError, "Callstack ohne CurrentError im Journal" );
if ( pCurrentError )
{
SvLBoxEntry *pThisEntry = aEditTree.InsertEntry( aMsg, pCurrentError ,0 );
aDebugData.aLogType = LOG_CALL_STACK; // Da auch von anderswo aufgerufen
ADD_TTDEBUGDATA( pThisEntry );
}
}
void MsgEdit::AddMessage( String aMsg, TTDebugData aDebugData )
{
SvLBoxEntry *pThisEntry = NULL;
if ( pCurrentTestCase )
pThisEntry = aEditTree.InsertEntry( aMsg, pCurrentTestCase );
else if ( pCurrentRun )
{
pThisEntry = aEditTree.InsertEntry( aMsg, pCurrentRun );
aEditTree.ShowEntry( pThisEntry );
}
else
{
AddRun( aMsg, aDebugData );
pThisEntry = aEditTree.InsertEntry( aMsg, pCurrentRun );
aEditTree.ShowEntry( pThisEntry );
}
aDebugData.aLogType = LOG_MESSAGE; // Da auch von anderswo aufgerufen
ADD_TTDEBUGDATA( pThisEntry );
}
void MsgEdit::AddWarning( String aMsg, TTDebugData aDebugData )
{
SvLBoxEntry *pThisEntry = NULL;
String aCompleteMsg;
aCompleteMsg = WARNING_PREFIX.Append( aMsg );
if ( pCurrentTestCase )
pThisEntry = aEditTree.InsertEntry( aCompleteMsg, pCurrentTestCase );
else if ( pCurrentRun )
{
pThisEntry = aEditTree.InsertEntry( aCompleteMsg, pCurrentRun );
aEditTree.ShowEntry( pThisEntry );
}
else
{
AddRun( aMsg, aDebugData );
pThisEntry = aEditTree.InsertEntry( aCompleteMsg, pCurrentRun );
aEditTree.ShowEntry( pThisEntry );
}
aDebugData.aLogType = LOG_WARNING; // Da auch von anderswo aufgerufen
ADD_TTDEBUGDATA( pThisEntry );
while ( !aEditTree.IsEntryVisible( pThisEntry ) && ( pThisEntry = aEditTree.GetParent( pThisEntry ) ) )
aEditTree.InvalidateEntry( pThisEntry );
}
void MsgEdit::AddAssertion( String aMsg, TTDebugData aDebugData )
{
SvLBoxEntry *pThisEntry = NULL;
if ( pCurrentTestCase )
pThisEntry = aEditTree.InsertEntry( aMsg, pCurrentTestCase );
else if ( pCurrentRun )
{
pThisEntry = aEditTree.InsertEntry( aMsg, pCurrentRun );
aEditTree.ShowEntry( pThisEntry );
}
else
{
AddRun( aMsg, aDebugData );
pThisEntry = aEditTree.InsertEntry( aMsg, pCurrentRun );
aEditTree.ShowEntry( pThisEntry );
}
aDebugData.aLogType = LOG_ASSERTION; // Da auch von anderswo aufgerufen
ADD_TTDEBUGDATA( pThisEntry );
while ( !aEditTree.IsEntryVisible( pThisEntry ) && ( pThisEntry = aEditTree.GetParent( pThisEntry ) ) )
aEditTree.InvalidateEntry( pThisEntry );
}
/*
SvLBoxEntry* GetEntry( SvLBoxEntry* pParent, ULONG nPos ) const { return SvLBox::GetEntry(pParent,nPos); }
SvLBoxEntry* GetEntry( ULONG nRootPos ) const { return SvLBox::GetEntry(nRootPos);}
SvLBoxEntry* FirstChild(SvLBoxEntry* pParent ) const { return (SvLBoxEntry*)(pModel->FirstChild(pParent)); }
SvLBoxEntry* NextSibling(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->NextSibling( pEntry )); }
SvLBoxEntry* PrevSibling(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->PrevSibling( pEntry )); }
SvLBoxEntry* FirstSelected() const { return (SvLBoxEntry*)SvListView::FirstSelected(); }
SvLBoxEntry* NextSelected( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(SvListView::NextSelected(pEntry)); }
SvLBoxEntry* PrevSelected( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(SvListView::PrevSelected(pEntry)); }
SvLBoxEntry* LastSelected() const { return (SvLBoxEntry*)(SvListView::LastSelected()); }
SvLBoxEntry* GetEntry( SvLBoxEntry* pParent, ULONG nPos ) const { return (SvLBoxEntry*)(pModel->GetEntry(pParent,nPos)); }
SvLBoxEntry* GetEntry( ULONG nRootPos ) const { return (SvLBoxEntry*)(pModel->GetEntry(nRootPos)); }
SvLBoxEntry* GetParent( SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->GetParent(pEntry)); }
SvLBoxEntry* GetRootLevelParent(SvLBoxEntry* pEntry ) const { return (SvLBoxEntry*)(pModel->GetRootLevelParent( pEntry ));}
BOOL IsInChildList( SvListEntry* pParent, SvListEntry* pChild) const;
SvListEntry* GetEntry( SvListEntry* pParent, ULONG nPos ) const;
SvListEntry* GetEntry( ULONG nRootPos ) const;
SvListEntry* GetEntryAtAbsPos( ULONG nAbsPos ) const;
SvListEntry* GetParent( SvListEntry* pEntry ) const;
SvListEntry* GetRootLevelParent( SvListEntry* pEntry ) const;
*/
//#define CHECK( pMemo ) if ( pMemo && !aEditTree.GetViewData( pMemo ) ) pMemo = NULL
#define CHECK( pMemo ) if ( pMemo && !aEditTree.GetModel()->IsInChildList( NULL, pMemo ) ) pMemo = NULL
void MsgEdit::Delete()
{
aEditTree.RemoveSelection();
CHECK( pCurrentRun );
CHECK( pCurrentTestCase );
CHECK( pCurrentError );
bModified = TRUE;
lModify.Call( NULL );
}
void MsgEdit::Cut(){ Copy(); Delete(); bModified = TRUE; lModify.Call( NULL ); }
void MsgEdit::Copy(){ Clipboard::Clear();Clipboard::CopyString( GetSelected() ); }
/**/void MsgEdit::Paste(){ Sound::Beep(); }
void MsgEdit::Undo(){ Sound::Beep(); }
void MsgEdit::Redo(){ Sound::Beep(); }
String MsgEdit::Impl_MakeText( SvLBoxEntry *pEntry ) const
{
String aRet;
TTDebugData *aData = (TTDebugData*)pEntry->GetUserData();
switch ( aData->aLogType )
{
case LOG_RUN: aRet.AppendAscii("\n"); break;
case LOG_TEST_CASE: break;
case LOG_ERROR: break;
case LOG_CALL_STACK:aRet.AppendAscii("--> "); break;
case LOG_MESSAGE: break;
case LOG_WARNING: break;
case LOG_ASSERTION: break;
default:DBG_ERROR("Unbekannter Typ im ResultFenster");
}
aRet += aEditTree.GetEntryText( pEntry );
return aRet;
}
String MsgEdit::Impl_MakeSaveText( TTDebugData aData ) const
{
// LogType;Filename;Line;Col1;Col2;Message
String aRet;
aRet += String::CreateFromInt32( (int)aData.aLogType );
aRet += ';';
aRet += aData.aFilename;
aRet += ';';
aRet += String::CreateFromInt32( aData.nLine );
aRet += ';';
aRet += String::CreateFromInt32( aData.nCol1 );
aRet += ';';
aRet += String::CreateFromInt32( aData.nCol2 );
aRet += ';';
aRet += '"';
aRet += aData.aMsg;
aRet += '"';
return aRet;
}
String MsgEdit::Impl_MakeSaveText( SvLBoxEntry *pEntry ) const
{
// LogType;Filename;Line;Col1;Col2;Message
String aRet;
TTDebugData *aData = (TTDebugData*)pEntry->GetUserData();
if ( aEditTree.PrevSibling( pEntry ) && LOGTYPE( aEditTree.PrevSibling( pEntry ) ) == LOG_TEST_CASE )
{ // Um Cases richtig abzuschliessen, so daß Warnings und Msgs in Hirarchie richtig.
aRet += String::CreateFromInt32( (int)LOG_TEST_CASE );
aRet.AppendAscii(";;0;0;0;\"\"\n");
}
aRet += Impl_MakeSaveText( *aData );
return aRet;
}
String MsgEdit::GetSelected()
{
String aRet;
SvLBoxEntry *pEntry = aEditTree.FirstSelected();
while ( pEntry )
{
aRet += Impl_MakeText( pEntry );
aRet += '\n';
pEntry = aEditTree.NextSelected( pEntry );
}
aRet.ConvertLineEnd();
return aRet;
}
TextSelection MsgEdit::GetSelection() const
{
ULONG nStart=0,nEnd=0;
if ( aEditTree.FirstSelected() )
{
nStart = aEditTree.GetModel()->GetAbsPos(aEditTree.FirstSelected() );
if ( aEditTree.LastSelected() )
nEnd = aEditTree.GetModel()->GetAbsPos(aEditTree.LastSelected() );
return TextSelection( TextPaM( nStart, 0 ), TextPaM( nEnd, STRING_MAXLEN ) );
}
else
return TextSelection();
}
void MsgEdit::SetSelection( const TextSelection& rSelection )
{
USHORT nStart,nEnd;
while ( aEditTree.GetSelectionCount() )
aEditTree.Select( aEditTree.FirstSelected(), FALSE );
if ( rSelection.HasRange() )
{
nStart = rSelection.GetStart().GetPara();
nEnd = rSelection.GetEnd().GetPara();
for ( int i = nStart ; i <= nEnd ; i++ )
aEditTree.Select( aEditTree.GetModel()->GetEntryAtAbsPos( i ), TRUE );
}
}
USHORT MsgEdit::GetLineNr() const
{
if ( aEditTree.GetCurEntry() )
return aEditTree.GetModel()->GetAbsPos(aEditTree.GetCurEntry() ) + 1;
else
return 0;
}
void MsgEdit::ReplaceSelected( const String& rStr ){ Sound::Beep();DBG_ERROR("Not Implemented"); }
BOOL MsgEdit::IsModified(){ return bModified; }
void MsgEdit::SetModifyHdl( Link l ){ lModify = l; }
String MsgEdit::GetText() const
{
String aRet;
SvLBoxEntry *pEntry = aEditTree.First();
while ( pEntry )
{
aRet += Impl_MakeText( pEntry );
aRet += '\n';
pEntry = aEditTree.Next( pEntry );
}
aRet.ConvertLineEnd();
return aRet;
}
/**/void MsgEdit::SetText( const String& rStr ){ DBG_ERROR("Not Implemented"); }
BOOL MsgEdit::HasText() const { return aEditTree.First() != NULL; }
// Es wird entweder ab Beginn oder ab Markierungsbegin + 1 gesucht.
BOOL MsgEdit::Find( const String& s )
{
TextSelection r = GetSelection();
USHORT bgn = (USHORT) r.GetStart().GetPara() + 1;
if ( r.GetStart().GetPara() == 0 ) bgn = 0; // Suchen ganz von Anfang
SvLBoxEntry *pEntry = aEditTree.GetModel()->GetEntryAtAbsPos( bgn );
while ( pEntry )
{
if( aEditTree.GetEntryText( pEntry ).Search( s, 0 ) != STRING_NOTFOUND )
{
aEditTree.SetCurEntry( pEntry );
return TRUE;
}
pEntry = aEditTree.Next( pEntry );
}
return FALSE;
}
/******************************************************************
Zum Fileformat der *.res Dateien:
Die Informationenn werden als Semikolon getrennte Strings
zusammengebastelt. Reihenfolge:
LogType;Filename;Line;Col1;Col2;Message
******************************************************************/
BOOL MsgEdit::Load( const String& aName )
{
aLogFileName = aName;
BOOL bOk = TRUE, bFirstLine = TRUE;
BOOL bLoadError = FALSE;
SvFileStream aStrm( aName, STREAM_STD_READ );
if( aStrm.IsOpen() )
{
aEditTree.Clear();
String aLine;
bFileLoading = TRUE; // So daß nicht gleich wieder auf Platte mitgelogt wird.
TTLogMsg *pLogMsg = new TTLogMsg;
while( !aStrm.IsEof() && bOk )
{
if ( nVersion >= 3 ) // Wir habe utf8
aStrm.ReadByteStringLine( aLine, RTL_TEXTENCODING_UTF8 );
else
aStrm.ReadByteStringLine( aLine, RTL_TEXTENCODING_IBM_850 );
if( aStrm.GetError() != SVSTREAM_OK )
bOk = FALSE;
#define TOKEN( n ) aLine.GetToken( n )
if ( aLine.GetTokenCount() >= 6 )
{
// LogType;Filename;Line;Col1;Col2;Message
TTDebugData aDebugData;
aDebugData.aLogType = TTLogType( TOKEN(0).ToInt32() );
aDebugData.aFilename = TOKEN(1);
aDebugData.nLine = TOKEN(2).ToInt32();
aDebugData.nCol1 = TOKEN(3).ToInt32();
aDebugData.nCol2 = TOKEN(4).ToInt32();
aDebugData.aMsg = aLine.GetQuotedToken( 5, CUniString("\"\"") );
aDebugData.aMsg.Erase(0,1); // Anführungszeichen entfernen
aDebugData.aMsg.Erase(aDebugData.aMsg.Len()-1,1);
pLogMsg->aLogFileName.Erase();
pLogMsg->aDebugData = aDebugData;
AddAnyMsg( pLogMsg );
}
else if ( bFirstLine && (aLine.Search( VERSION_STRING ) == 0) )
nVersion = aLine.Copy( VERSION_STRING.Len() ).ToInt32();
else bLoadError = TRUE;
bFirstLine = FALSE;
}
bFileLoading = FALSE;
delete pLogMsg;
aStrm.Close();
if ( nVersion < 2 && !bLoadError )
Save( aName ); // Muß sein, sonst passiert beim mitloggen Blödsinn.
}
else
bOk = FALSE;
return bOk;
}
BOOL MsgEdit::Save( const String& aName )
{
BOOL bOk = TRUE;
BOOL bIsText = DirEntry( aName ).GetExtension().CompareIgnoreCaseToAscii("TXT") == COMPARE_EQUAL;
if ( bIsText && !QueryBox( NULL, ResId( IDS_LOSS_OF_INFORMATION ) ).Execute() )
return FALSE;
SvFileStream aStrm( aName, STREAM_STD_WRITE | STREAM_TRUNC );
if( aStrm.IsOpen() )
{
if ( bIsText )
{
String aSave = GetText();
aSave.ConvertLineEnd(LINEEND_CRLF);
aStrm << ByteString( aSave, RTL_TEXTENCODING_UTF8 ).GetBuffer();
}
else
{
// LogType;Filename;Line;Col1;Col2;Message
String aSave = VERSION_STRING.Append( UniString::CreateFromInt32( 3 ) ).AppendAscii("\n"); // Version 2
SvLBoxEntry *pRun = aEditTree.First();
while ( pRun && aEditTree.NextSibling( pRun ) )
pRun = aEditTree.NextSibling( pRun );
aSave.ConvertLineEnd(LINEEND_CRLF);
aStrm << ByteString( aSave, RTL_TEXTENCODING_UTF8 ).GetBuffer();
SvLBoxEntry *pEntry;
while ( pRun )
{
pEntry = pRun;
while ( pEntry && ( pEntry == pRun || LOGTYPE( pEntry ) != LOG_RUN ) )
{
aSave = Impl_MakeSaveText( pEntry );
aSave += '\n';
aSave.ConvertLineEnd(LINEEND_CRLF);
aStrm << ByteString( aSave, RTL_TEXTENCODING_UTF8 ).GetBuffer();
pEntry = aEditTree.Next( pEntry );
}
pRun = aEditTree.PrevSibling( pRun );
}
}
if( aStrm.GetError() != SVSTREAM_OK )
bOk = FALSE;
else
{
bModified = FALSE;
lModify.Call( NULL );
}
}
else
bOk = FALSE;
return bOk;
}
TTTreeListBox::TTTreeListBox( Window* pParent, BasicFrame* pBF, WinBits nWinStyle )
: SvTreeListBox( pParent, nWinStyle )
, pBasicFrame(pBF)
//, nDeselectParent(0)
{}
BOOL TTTreeListBox::DoubleClickHdl()
{
SvLBoxEntry *pThisEntry = GetHdlEntry();
if ( pThisEntry && pThisEntry->GetUserData() && ((TTDebugData*)pThisEntry->GetUserData())->aFilename.Len() > 0 )
{
TTDebugData *aData = (TTDebugData*)pThisEntry->GetUserData();
if ( pBasicFrame->FindModuleWin( aData->aFilename ) )
{
AppEdit *pWin = pBasicFrame->FindModuleWin( aData->aFilename );
pWin->ToTop();
}
else
pBasicFrame->LoadFile( aData->aFilename );
if ( pBasicFrame->pWork && pBasicFrame->pWork->ISA(AppEdit) )
((AppEdit*)pBasicFrame->pWork)->Highlight( aData->nLine, aData->nCol1, aData->nCol2 );
return FALSE;
}
return TRUE;
}
/*ULONG TTTreeListBox::SelectChildren( SvLBoxEntry* pParent, BOOL bSelect )
{
SvLBoxEntry *pEntry = FirstChild( pParent );
ULONG nRet = 0;
while ( pEntry )
{
nRet++;
Select( pEntry, bSelect );
pEntry = NextSibling( pEntry );
}
return nRet;
}
void TTTreeListBox::SelectHdl()
{
SvLBoxEntry* pHdlEntry = GetHdlEntry();
SelectChildren( pHdlEntry, TRUE );
Select( pHdlEntry, TRUE );
// InitMenu(pApp->GetAppMenu()->GetPopupMenu( RID_APPEDIT )); // So daß Delete richtig ist
}
void TTTreeListBox::DeselectHdl()
{
SvLBoxEntry* pHdlEntry = GetHdlEntry();
if ( GetParent( pHdlEntry ) )
{
nDeselectParent++;
Select( GetParent( pHdlEntry ), FALSE );
nDeselectParent--;
}
if ( !nDeselectParent )
{
SelectChildren( pHdlEntry, FALSE );
Select( pHdlEntry, FALSE );
}
Invalidate();
} */
void TTTreeListBox::KeyInput( const KeyEvent& rKEvt )
{
switch ( rKEvt.GetKeyCode().GetFunction() )
{
case KEYFUNC_CUT:
Control::GetParent()->Command( CommandEvent( Point(), RID_EDITCUT ) );
break;
case KEYFUNC_COPY:
Control::GetParent()->Command( CommandEvent( Point(), RID_EDITCOPY ) );
break;
case KEYFUNC_PASTE:
Control::GetParent()->Command( CommandEvent( Point(), RID_EDITPASTE ) );
break;
case KEYFUNC_DELETE:
Control::GetParent()->Command( CommandEvent( Point(), RID_EDITDEL ) );
break;
default:
SvTreeListBox::KeyInput( rKEvt );
}
}
TTFeatures TTTreeListBox::GetFeatures( SvLBoxEntry* pEntry )
{
switch ( LOGTYPE( pEntry ) )
{
case LOG_MESSAGE:
return HasNothing;
case LOG_WARNING :
return HasWarning;
case LOG_ERROR:
case LOG_CALL_STACK:
return HasError;
case LOG_RUN:
case LOG_TEST_CASE:
{
SvLBoxEntry* pThisEntry = FirstChild( pEntry );
TTFeatures aResult = HasNothing;
while ( pThisEntry && !( (aResult & HasError) == HasError ) )
{
if ( !IsEntryVisible( pThisEntry ) )
aResult |= GetFeatures( pThisEntry );
pThisEntry = NextSibling( pThisEntry );
}
return aResult;
}
case LOG_ASSERTION:
return HasAssertion;
default:
DBG_ERROR("Unbekannter Typ im ResultFenster");
}
return HasNothing; // da der Comp nich sieht, daß kein dafault nötig ist.
}
class TTLBoxString : public SvLBoxString
{
public:
TTLBoxString( SvLBoxEntry* pEntry, USHORT nFlags,
const String& rStr ) : SvLBoxString(pEntry,nFlags,rStr) {}
virtual void Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags,
SvLBoxEntry* pEntry);
};
void TTLBoxString::Paint( const Point& rPos, SvLBox& rDev, USHORT nFlags,
SvLBoxEntry* pEntry )
{
TTFeatures aFeatures = ((TTTreeListBox*)&rDev)->GetFeatures( pEntry );
if ( aFeatures != HasNothing )
{
Font aOldFont( rDev.GetFont());
Font aFont( aOldFont );
if ( ( aFeatures & HasError ) != 0 || ( aFeatures & HasWarning ) != 0 )
{
Color aCol;
if ( ( aFeatures & HasError ) == HasError )
aCol = Color( 255, 120, 120 ); // Rot
else
aCol = Color( 255, 200, 120 ); // Ocker oder so
if( rDev.IsSelected(pEntry) )
aFont.SetColor( aCol );
else
{
aFont.SetFillColor( aCol );
aFont.SetTransparent( FALSE );
}
}
else // also HasAssertion
{
if( rDev.IsSelected(pEntry) )
{
Color aCol( 255, 255, 153 );
aFont.SetColor( aCol );
}
else
{
Size aSize( rDev.GetTextWidth( GetText() ), rDev.GetTextHeight() );
Rectangle aRect( rPos, aSize );
static Bitmap aBmp( ResId( MBP_ASSERT ) );
static BitmapEx aBmpEx( aBmp );
static Wallpaper aWP( aBmpEx );
rDev.DrawWallpaper( aRect, aWP );
}
// virtual void NotifyScrolling( long nLines );
}
rDev.SetFont( aFont );
rDev.DrawText( rPos, GetText() );
rDev.SetFont( aOldFont );
}
else
SvLBoxString::Paint( rPos, rDev, nFlags, pEntry );
}
void TTTreeListBox::InitEntry(SvLBoxEntry* pEntry,
const String& rStr ,const Image& rImg1, const Image& rImg2 )
{
USHORT nColToHilite = 1; //0==Bitmap;1=="Spalte1";2=="Spalte2"
SvTreeListBox::InitEntry( pEntry, rStr, rImg1, rImg2 );
SvLBoxString* pCol = (SvLBoxString*)pEntry->GetItem( nColToHilite );
TTLBoxString* pStr = new TTLBoxString( pEntry, 0, pCol->GetText() );
pEntry->ReplaceItem( pStr, nColToHilite );
}
+134
View File
@@ -0,0 +1,134 @@
/*************************************************************************
*
* $RCSfile: msgedit.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _MSGEDIT_HXX
#define _MSGEDIT_HXX
#ifndef _SVTREEBOX_HXX //autogen
#include <svtools/svtreebx.hxx>
#endif
#include "dataedit.hxx"
#include "testtool.hxx"
class BasicFrame;
class AppWin;
#define SelectChildren SelectChilds // Sonst wird mir schlecht
typedef USHORT TTFeatures; // Bitfeld für Features der Entrys
#define HasNothing TTFeatures(0x00)
#define HasError TTFeatures(0x01)
#define HasWarning TTFeatures(0x02)
#define HasAssertion TTFeatures(0x04)
class TTTreeListBox : public SvTreeListBox
{
protected:
// virtual void Command( const CommandEvent& rCEvt );
// USHORT nDeselectParent;
BasicFrame *pBasicFrame;
void InitEntry( SvLBoxEntry*, const String&, const Image&, const Image& );
public:
TTTreeListBox( Window* pParent, BasicFrame* pBF, WinBits nWinStyle=0 );
~TTTreeListBox(){}
// virtual void SelectHdl();
// virtual void DeselectHdl();
virtual BOOL DoubleClickHdl();
virtual void KeyInput( const KeyEvent& rKEvt );
// ULONG SelectChildren( SvLBoxEntry* pParent, BOOL bSelect );
TTFeatures GetFeatures( SvLBoxEntry* );
};
class MsgEdit : public DataEdit
{
SvLBoxEntry *pCurrentRun;
SvLBoxEntry *pCurrentTestCase;
SvLBoxEntry *pCurrentError;
protected:
BOOL bModified;
Link lModify;
BasicFrame *pBasicFrame;
BOOL bFileLoading; // TRUE während eine Datei geladen wird.
String Impl_MakeText( SvLBoxEntry *pEntry ) const;
String Impl_MakeSaveText( SvLBoxEntry *pEntry ) const;
String Impl_MakeSaveText( TTDebugData aData ) const;
USHORT nVersion; // Speichert die Dateiversion
AppWin* pAppWin;
String aLogFileName; // Name der Logdatei
public:
MsgEdit( AppWin*, BasicFrame *pBF, const WinBits& );
~MsgEdit();
void AddAnyMsg( TTLogMsg *LogMsg );
void AddRun( String aMsg, TTDebugData aDebugData );
void AddTestCase( String aMsg, TTDebugData aDebugData );
void AddError( String aMsg, TTDebugData aDebugData );
void AddCallStack( String aMsg, TTDebugData aDebugData );
void AddMessage( String aMsg, TTDebugData aDebugData );
void AddWarning( String aMsg, TTDebugData aDebugData );
void AddAssertion( String aMsg, TTDebugData aDebugData );
DATA_FUNC_DEF( aEditTree, TTTreeListBox )
};
#endif
+330
View File
@@ -0,0 +1,330 @@
/*************************************************************************
*
* $RCSfile: mybasic.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SBXCLASS_HXX //autogen
#include <svtools/sbx.hxx>
#endif
// AB-Uno-Test
//#define unotest
#ifdef unotest
#ifndef _USR_UNO_HXX
#include <usr/uno.hxx>
#endif
#include <sbuno.hxx>
#include <sbunoobj.hxx>
#endif
#include "sbintern.hxx"
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
#include "mybasic.hxx"
#include "basic.hrc"
#include "appbased.hxx"
#include "status.hxx"
#include "basic.hrc"
#include "object.hxx"
#include "comm_bas.hxx"
#include "processw.hxx"
TYPEINIT1(MyBasic,StarBASIC)
class MyFactory : public SbxFactory
{
public:
virtual SbxBase* Create( UINT16 nSbxId, UINT32 = SBXCR_SBX );
};
static SampleObjectFac aFac1;
static MyFactory aFac2;
static CommunicationFactory aComManFac;
static ProcessFactory aProcessFac;
static short nInst = 0;
SbxBase* MyFactory::Create( UINT16 nSbxId, UINT32 nCr )
{
if( nCr == SBXCR_TEST && nSbxId == SBXID_MYBASIC )
return new MyBasic;
else
return NULL;
}
MyBasic::MyBasic() : StarBASIC()
{
nError = 0;
if( !nInst++ )
{
AddFactory( &aFac1 );
AddFactory( &aFac2 );
AddFactory( &aComManFac );
AddFactory( &aProcessFac );
}
SbxVariable* p = new SbxCollection( CUniString("MyColl") );
p->SetName( CUniString("Objects") );
Insert( p );
// AB-Uno-Test
#ifdef unotest
// Uno-Service-Manager holenReflection Service bolen
createAndSetDefaultServiceManager(); // spaeter schon erledigt
// Uno-Test-Objekt holen
UsrAny aObjAny = getIntrospectionTestObject();
// Objekt verpacken in ein SbUnoObject packen
String aName( "UnoObject" );
SbxObjectRef xSbUnoObj = GetSbUnoObject( aName, aObjAny );
//SbxObjectRef xSbUnoObj = new SbUnoObject( aName, aObjAny );
Insert( (SbxObject*)xSbUnoObj );
#endif
pTestObject = NULL;
}
Link MyBasic::GenLogHdl()
{
return LINK( GetpApp()->GetAppWindow(), BasicFrame, Log );
}
Link MyBasic::GenWinInfoHdl()
{
return LINK( GetpApp()->GetAppWindow(), BasicFrame, WinInfo );
}
Link MyBasic::GenModuleWinExistsHdl()
{
return LINK( GetpApp()->GetAppWindow(), BasicFrame, ModuleWinExists );
}
void MyBasic::StartListening( SfxBroadcaster &rBroadcaster )
{
((BasicFrame*)GetpApp()->GetAppWindow())->StartListening( rBroadcaster );
}
void MyBasic::SetCompileModule( SbModule *pMod )
{
GetSbData()->pCompMod = pMod;
}
SbModule *MyBasic::GetCompileModule()
{
return GetSbData()->pCompMod;
}
String MyBasic::GenRealString( const String &aResString )
{
return ((BasicFrame*)GetpApp()->GetAppWindow())->GenRealString( aResString );
}
void MyBasic::LoadIniFile()
{
}
SbTextType MyBasic::GetSymbolType( const String &rSymbol, BOOL bWasTTControl )
{
return SB_SYMBOL; // Alles was hier landet ist vom Typ SB_SYMBOL und bleibt es auch
}
MyBasic::~MyBasic()
{
aErrors.Clear();
if( !--nInst )
{
RemoveFactory( &aFac1 );
RemoveFactory( &aFac2 );
RemoveFactory( &aComManFac );
RemoveFactory( &aProcessFac );
}
}
BOOL MyBasic::Compile( SbModule* p )
{
aErrors.Clear();
nError = 0;
return StarBASIC::Compile( p );
}
BOOL MyBasic::ErrorHdl()
{
AppEdit *CurrWin = aBasicApp.pFrame->FindModuleWin( GetActiveModule()->GetName() );
if(CurrWin)
CurrWin->ToTop();
else
{ // erstmal Fenster aufmachen
String aModName = GetActiveModule()->GetName();
if ( aModName.Copy(0,2).CompareToAscii("--") == COMPARE_EQUAL )
aModName.Erase(0,2);
GetActiveModule()->SetName(aModName);
AppWin* p = new AppBasEd( aBasicApp.pFrame, GetActiveModule() );
p->Show();
p->GrabFocus();
}
if( IsCompilerError() )
{
aErrors.Insert(
new BasicError
( aBasicApp.pFrame->pWork,
0, StarBASIC::GetErrorText(), GetLine(), GetCol1(), GetCol2() ),
LIST_APPEND );
nError++;
return BOOL( nError < 20 ); // Abbruch nach 20 Fehlern
}
else
{
ReportRuntimeError();
return FALSE;
}
}
void MyBasic::ReportRuntimeError()
{
String nErrorText;
nErrorText = GetSpechialErrorText();
BasicError( aBasicApp.pFrame->pWork,
GetVBErrorCode( GetErrorCode() ), nErrorText, GetLine(),
GetCol1(), GetCol2() ).Show();
}
const String MyBasic::GetSpechialErrorText()
{
return GetErrorText();
}
USHORT MyBasic::BreakHdl()
{
SbModule* pMod = GetActiveModule();
if( pMod )
{
AppEdit* pWin = aBasicApp.pFrame->FindModuleWin( pMod->GetName() );
if( !pWin )
{ // erstmal Fenster aufmachen
String aModName = GetActiveModule()->GetName();
if ( aModName.Copy(0,2).CompareToAscii("--") == COMPARE_EQUAL )
aModName.Erase(0,2);
GetActiveModule()->SetName(aModName);
AppWin* p = new AppBasEd( aBasicApp.pFrame, GetActiveModule() );
p->Show();
p->GrabFocus();
p->ToTop();
pWin = aBasicApp.pFrame->FindModuleWin( aModName );
}
pWin->Highlight( GetLine(), GetCol1(), GetCol2() );
}
if( IsBreak() ) // Wenn Breakpoint (oder "Run to Cursor")
{
// if ( GetActiveModule()->IsBP(GetLine()) )
// GetActiveModule()->ClearBP(GetLine());
return aBasicApp.pFrame->BreakHandler();
}
else
{
return aBasicApp.pFrame->BreakHandler();
}
}
/***************************************************************************
|*
|* class BasicError
|*
***************************************************************************/
BasicError::BasicError
( AppWin* w, USHORT nE, const String& r, USHORT nL, USHORT nC1, USHORT nC2 )
: aText( ResId( IDS_ERROR1 ) )
{
pWin = w;
nLine = nL;
nCol1 = nC1;
nCol2 = nC2;
if( nE )
{
aText += String::CreateFromInt32( nE );
aText.AppendAscii(": ");
aText += r;
}
else
aText = r;
}
// Dies ist ein Beispiel, wie die Fehler-Information geschickt
// aufgebaut werden kann, um ein Statement zu highlighten.
void BasicError::Show()
{
if( pWin && pWin->ISA(AppEdit) ) {
((AppEdit*)pWin)->Highlight( nLine, nCol1, nCol2 );
aBasicApp.pFrame->pStatus->Message( aText );
} else MessBox( aBasicApp.pFrame, WB_OK, aBasicApp.pFrame->GetText(),
aText ).Execute();
}
+216
View File
@@ -0,0 +1,216 @@
/*************************************************************************
*
* $RCSfile: printer.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _PRINT_HXX //autogen
#include <vcl/print.hxx>
#endif
#ifndef _DIALOG_HXX //autogen
#include <vcl/dialog.hxx>
#endif
#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
#include "app.hxx"
#include "printer.hxx"
#include "basic.hrc"
#include "resids.hrc"
class PrintingDialog : public ModelessDialog {
String aName;
FixedText aText;
CancelButton aCancel;
public:
PrintingDialog( Window*, BasicPrinter*, ResId&, String& );
void ChangeMessage( short );
};
BasicPrinter::BasicPrinter() : Printer()
{
nPage = 0; nLine = 9999;
SetMapMode( MapMode( MAP_POINT ) );
Size s( GetOutputSize() );
// 10-Punkt-Schrift verwenden
Font aFont( FAMILY_MODERN, Size( 0, 10 ) );
aFont.SetPitch( PITCH_FIXED );
SetFont( aFont );
// Ausgabe: 6 Zeilen/Zoll = 12 Punkt
nLines = (short) s.Height() / 12;
nYoff = 12;
SetStartPrintHdl( LINK( this, BasicPrinter, StartPrintHdl ) );
SetEndPrintHdl( LINK( this, BasicPrinter, EndPrintHdl ) );
SetPrintPageHdl( LINK( this, BasicPrinter, PrintPageHdl ) );
}
void BasicPrinter::Header()
{
if( nPage ) EndPage();
nPage++;
StartPage();
String aHdr;
String aPage( ResId( IDS_PAGE ) );
aPage.Append( String::CreateFromInt32(nPage) );
aHdr = aFile.Copy( 0, 80 - aPage.Len() );
aHdr.Expand( 80 - aPage.Len(), ' ' );
aHdr += aPage;
DrawText( Point( 0, 0 ), aHdr );
nLine = 2;
}
void BasicPrinter::Print( const String& rFile, const String& rText, BasicFrame *pFrame )
{
nPage = 0; nLine = 9999;
aFile = rFile;
// Dialog einrichten
ResId aResId( IDD_PRINT_DIALOG );
pDlg = new PrintingDialog
( aBasicApp.pFrame, this, aResId, aFile );
// Position des Dialogs setzen
Size s1 = aBasicApp.pFrame->GetSizePixel();
Size s2 = pDlg->GetSizePixel();
pDlg->SetPosPixel( Point( (s1.Width() - s2.Width() ) / 2,
(s1.Height()- s2.Height() ) / 2 ) );
// PRINT-Menu disablen
MenuBar* pBar = pFrame->GetMenuBar();
Menu* pFileMenu = pBar->GetPopupMenu( RID_APPFILE );
pFileMenu->EnableItem( RID_FILEPRINT, FALSE );
pDlg->ChangeMessage( 1 );
pDlg->Show();
StartJob( rFile );
StartPage();
xub_StrLen nDone=0;
while( nDone < rText.Len() )
{
if( nLine >= nLines ) Header();
xub_StrLen nLineEnd = min( rText.Search( '\n', nDone ), rText.Search( '\r', nDone ) );
DrawText( Point( 0, nLine * nYoff ), rText, nDone, nLineEnd-nDone-1 );
nDone = nLineEnd;
if( nDone <= rText.Len() && rText.GetChar(nDone) == '\r' ) nDone++;
if( nDone <= rText.Len() && rText.GetChar(nDone) == '\n' ) nDone++;
nLine++;
Application::Reschedule();
}
EndPage();
EndJob();
nPage = 1;
while( IsPrinting() ) Application::Reschedule();
delete pDlg; pDlg = NULL;
pFileMenu->EnableItem( RID_FILEPRINT, TRUE );
}
IMPL_LINK_INLINE_START( BasicPrinter, StartPrintHdl, Printer *, pPrinter )
{
if( pDlg ) pDlg->Show();
return 0;
}
IMPL_LINK_INLINE_END( BasicPrinter, StartPrintHdl, Printer *, pPrinter )
IMPL_LINK_INLINE_START( BasicPrinter, EndPrintHdl, Printer *, pPrinter )
{
if( pDlg ) pDlg->Hide();
return 0;
}
IMPL_LINK_INLINE_END( BasicPrinter, EndPrintHdl, Printer *, pPrinter )
IMPL_LINK_INLINE_START( BasicPrinter, PrintPageHdl, Printer *, pPrinter )
{
if( pDlg ) pDlg->ChangeMessage( nPage );
return 0;
}
IMPL_LINK_INLINE_END( BasicPrinter, PrintPageHdl, Printer *, pPrinter )
IMPL_LINK_INLINE( BasicPrinter, Abort , void *, EMPTYARG,
{
AbortJob();
return 0L;
}
)
/////////////////////////////////////////////////////////////////////////
PrintingDialog::PrintingDialog
( Window* pParent, BasicPrinter* pPrn, ResId& rId, String& rName )
: ModelessDialog( pParent, rId ),
aCancel( this, ResId( RID_CANCEL ) ),
aText ( this, ResId( RID_TEXT ) ),
aName ( rName )
{
FreeResource();
aCancel.SetClickHdl( LINK( pPrn, BasicPrinter, Abort ) );
}
void PrintingDialog::ChangeMessage( short nPage )
{
String aMsg( ResId( IDS_PRINTMSG ) );
aMsg += aName;
aMsg += CUniString("\n");
aMsg += String( ResId( IDS_PAGE ) );
aMsg += String::CreateFromInt32( nPage );
aText.SetText( aMsg );
}
+92
View File
@@ -0,0 +1,92 @@
/*************************************************************************
*
* $RCSfile: printer.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BASICPRN_HXX
#define _BASICPRN_HXX
#ifndef _PRINT_HXX //autogen
#include <vcl/print.hxx>
#endif
class PrintingDialog;
class BasicPrinter : public Printer {
short nLine; // aktuelle Zeile
short nPage; // aktuelle Seite
short nLines; // Zeilen pro Seite
short nYoff; // Zeilenabstand in Points
String aFile; // Dateiname
PrintingDialog* pDlg; // Druck-Dialog
void Header(); // Seitenkopf drucken
public:
BasicPrinter();
void Print( const String& rFile, const String& rText, BasicFrame *pFrame );
DECL_LINK( Abort, void * );
DECL_LINK( StartPrintHdl, Printer * );
DECL_LINK( EndPrintHdl, Printer * );
DECL_LINK( PrintPageHdl, Printer * );
#if defined( PM20 )
// StarView-Bug, bald wieder zu entfernen:
virtual void SetPageQueueSize( USHORT ) {}
#endif
};
#endif
+222
View File
@@ -0,0 +1,222 @@
/*************************************************************************
*
* $RCSfile: process.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifdef WNT
#include <tools/prewin.h>
#include "winbase.h"
#include <tools/postwin.h>
#endif
#ifndef _ERRCODE_HXX //autogen
#include <tools/errcode.hxx>
#endif
#ifndef _VOS_PROCESS_HXX_
#include <vos/process.hxx>
#endif
#ifndef _SBXCORE_HXX
#include <svtools/sbxcore.hxx>
#endif
#ifndef _STRING_HXX
#include <tools/string.hxx>
#endif
#ifndef _OSL_FILE_HXX_
#include <osl/file.hxx>
#endif
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
//#ifndef _BYTE_STRING_LIST
//DECLARE_LIST( ByteStringList, ByteString * );
//#define _BYTE_STRING_LIST
//#endif
#include "process.hxx"
// Konstruktor für den Process
Process::Process()
: bWasGPF( FALSE )
, pArgumentList( NULL )
, pProcess( NULL )
, bHasBeenStarted( FALSE )
{
}
// Destruktor
Process::~Process()
{
delete pArgumentList;
delete pProcess;
}
BOOL Process::ImplIsRunning()
{
if ( pProcess && bHasBeenStarted )
{
NAMESPACE_VOS(OProcess::TProcessInfo) aProcessInfo;
pProcess->getInfo( NAMESPACE_VOS(OProcess::TData_ExitCode), &aProcessInfo );
if ( !(aProcessInfo.Fields & NAMESPACE_VOS(OProcess::TData_ExitCode)) )
return TRUE;
else
return FALSE;
}
else
return FALSE;
}
long Process::ImplGetExitCode()
{
if ( pProcess )
{
NAMESPACE_VOS(OProcess::TProcessInfo) aProcessInfo;
pProcess->getInfo( NAMESPACE_VOS(OProcess::TData_ExitCode), &aProcessInfo );
if ( !(aProcessInfo.Fields & NAMESPACE_VOS(OProcess::TData_ExitCode)) )
SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT );
return aProcessInfo.Code;
}
else
SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT );
return 0;
}
////////////////////////////////////////////////////////////////////////////
// Die Methoden:
void Process::SetImage( const String &aAppPath, const String &aAppParams )
{ // Imagedatei des Executables
if ( pProcess && ImplIsRunning() )
SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT );
else
{
delete pArgumentList;
delete pProcess;
xub_StrLen i, nCount = aAppParams.GetQuotedTokenCount( CUniString("\"\"" ), ' ' );
NAMESPACE_RTL(OUString) *pParamList = new NAMESPACE_RTL(OUString)[nCount];
for ( i = 0 ; i < nCount ; i++ )
{
NAMESPACE_RTL(OUString) aTemp = NAMESPACE_RTL(OUString)(aAppParams.GetQuotedToken( i, CUniString("\"\"" ), ' ' ));
if ( aTemp.getLength() )
pParamList[i] = aTemp;
}
pArgumentList = new NAMESPACE_VOS(OArgumentList)( pParamList, nCount );
NAMESPACE_RTL(OUString) aNormalizedAppPath;
osl::FileBase::normalizePath( NAMESPACE_RTL(OUString)(aAppPath), aNormalizedAppPath );
pProcess = new NAMESPACE_VOS(OProcess)( aNormalizedAppPath );
bHasBeenStarted = FALSE;
}
}
BOOL Process::Start()
{ // Programm wird gestartet
BOOL bSuccess=FALSE;
if ( pProcess && !ImplIsRunning() )
{
bWasGPF = FALSE;
#ifdef WNT
// sal_uInt32 nErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_NOALIGNMENTFAULTEXCEPT | SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);
sal_uInt32 nErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_NOALIGNMENTFAULTEXCEPT | SEM_NOGPFAULTERRORBOX);
try
{
#endif
bSuccess = pProcess->execute( (NAMESPACE_VOS(OProcess)::TProcessOption)
( NAMESPACE_VOS(OProcess)::TOption_SearchPath
/*| NAMESPACE_VOS(OProcess)::TOption_Detached*/
/*| NAMESPACE_VOS(OProcess)::TOption_Wait*/ ),
*pArgumentList ) == NAMESPACE_VOS(OProcess)::E_None;
#ifdef WNT
}
catch( ... )
{
bWasGPF = TRUE;
}
nErrorMode = SetErrorMode(nErrorMode);
#endif
bHasBeenStarted = bSuccess;
}
else
SbxBase::SetError( SbxERR_NO_ACTIVE_OBJECT );
return bSuccess;
}
ULONG Process::GetExitCode()
{ // ExitCode des Programms(nachdem es beendet ist)
return ImplGetExitCode();
}
BOOL Process::IsRunning()
{ // Programm läuft noch
return ImplIsRunning();
}
BOOL Process::WasGPF()
{ // Programm mit GPF o.ä. abgebrochen
#ifdef WNT
return ImplGetExitCode() == 3221225477;
#else
return bWasGPF;
#endif
}
+324
View File
@@ -0,0 +1,324 @@
/*************************************************************************
*
* $RCSfile: processw.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ERRCODE_HXX //autogen
#include <tools/errcode.hxx>
#endif
#ifndef _SBX_SBXOBJECT_HXX //autogen
#include <svtools/sbxobj.hxx>
#endif
#ifndef _SBXCLASS_HXX //autogen
#include <svtools/sbx.hxx>
#endif
#ifndef __SBX_SBXVARIABLE_HXX //autogen
#include <svtools/sbxvar.hxx>
#endif
//#include <osl/thread.h>
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
#include "processw.hxx"
//#include "collelem.hxx"
// Makro MEMBER()
#include "macfix.hxx"
// Der Process hat folgende Elemente:
// 1) Properties:
// Keine
// 2) Methoden:
// SetImage( Filename )
// BOOL Start
// USHORT GetExitCode
// BOOL IsRunning
// BOOL WasGPF
// Diese Implementation ist ein Beispiel fuer eine tabellengesteuerte
// Version, die sehr viele Elemente enthalten kann. Die Elemente werden
// je nach Bedarf aus der Tabelle in das Objekt uebernommen.
// Das nArgs-Feld eines Tabelleneintrags ist wie folgt verschluesselt:
#define _ARGSMASK 0x00FF // Bis zu 255 Argumente
#define _RWMASK 0x0F00 // Maske fuer R/W-Bits
#define _TYPEMASK 0xF000 // Maske fuer den Typ des Eintrags
#define _READ 0x0100 // kann gelesen werden
#define _BWRITE 0x0200 // kann as Lvalue verwendet werden
#define _LVALUE _BWRITE // kann as Lvalue verwendet werden
#define _READWRITE 0x0300 // beides
#define _OPT 0x0400 // TRUE: optionaler Parameter
#define _METHOD 0x1000 // Masken-Bit fuer eine Methode
#define _PROPERTY 0x2000 // Masken-Bit fuer eine Property
#define _COLL 0x4000 // Masken-Bit fuer eine Collection
// Kombination von oberen Bits:
#define _FUNCTION 0x1100 // Maske fuer Function
#define _LFUNCTION 0x1300 // Maske fuer Function, die auch als Lvalue geht
#define _ROPROP 0x2100 // Maske Read Only-Property
#define _WOPROP 0x2200 // Maske Write Only-Property
#define _RWPROP 0x2300 // Maske Read/Write-Property
#define _COLLPROP 0x4100 // Maske Read-Collection-Element
#define COLLNAME "Elements" // Name der Collection, hier mal hart verdrahtet
ProcessWrapper::Methods ProcessWrapper::aProcessMethods[] = {
// Imagedatei des Executables
{ "SetImage", SbxEMPTY, 1 | _FUNCTION, MEMBER(ProcessWrapper::PSetImage) },
// Zwei Named Parameter
{ "Filename",SbxSTRING },
{ "Params",SbxSTRING, _OPT },
// Programm wird gestartet
{ "Start", SbxBOOL, 0 | _FUNCTION, MEMBER(ProcessWrapper::PStart) },
// ExitCode des Programms(nachdem es beendet ist)
{ "GetExitCode", SbxULONG, 0 | _FUNCTION, MEMBER(ProcessWrapper::PGetExitCode) },
// Programm läuft noch
{ "IsRunning", SbxBOOL, 0 | _FUNCTION, MEMBER(ProcessWrapper::PIsRunning) },
// Programm mit GPF o.ä. abgebrochen
{ "WasGPF", SbxBOOL, 0 | _FUNCTION, MEMBER(ProcessWrapper::PWasGPF) },
{ NULL, SbxNULL, -1 }}; // Tabellenende
// Konstruktor für den Process
ProcessWrapper::ProcessWrapper() : SbxObject( CUniString("Process") )
{
pProcess = new Process();
SetName( CUniString("Process") );
pMethods = &aProcessMethods[0];
}
// Destruktor
ProcessWrapper::~ProcessWrapper()
{
delete pProcess;
}
// Suche nach einem Element:
// Hier wird linear durch die Methodentabelle gegangen, bis eine
// passende Methode gefunden wurde.
// Wenn die Methode/Property nicht gefunden wurde, nur NULL ohne
// Fehlercode zurueckliefern, da so auch eine ganze Chain von
// Objekten nach der Methode/Property befragt werden kann.
SbxVariable* ProcessWrapper::Find( const String& rName, SbxClassType t )
{
// Ist das Element bereits vorhanden?
SbxVariable* pRes = SbxObject::Find( rName, t );
if( !pRes && t != SbxCLASS_OBJECT )
{
// sonst suchen
Methods* p = pMethods;
short nIndex = 0;
BOOL bFound = FALSE;
while( p->nArgs != -1 )
{
if( rName.CompareIgnoreCaseToAscii( p->pName ) == COMPARE_EQUAL )
{
bFound = TRUE; break;
}
nIndex += ( p->nArgs & _ARGSMASK ) + 1;
p = pMethods + nIndex;
}
if( bFound )
{
// Args-Felder isolieren:
short nAccess = ( p->nArgs & _RWMASK ) >> 8;
short nType = ( p->nArgs & _TYPEMASK );
String aName( p->pName, RTL_TEXTENCODING_ASCII_US );
SbxClassType eCT = SbxCLASS_OBJECT;
if( nType & _PROPERTY )
eCT = SbxCLASS_PROPERTY;
else if( nType & _METHOD )
eCT = SbxCLASS_METHOD;
pRes = Make( aName, eCT, p->eType );
// Wir setzen den Array-Index + 1, da ja noch andere
// Standard-Properties existieren, die auch aktiviert
// werden muessen.
pRes->SetUserData( nIndex + 1 );
pRes->SetFlags( nAccess );
}
}
return pRes;
}
// Aktivierung eines Elements oder Anfordern eines Infoblocks
void ProcessWrapper::SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCT,
const SfxHint& rHint, const TypeId& rHT )
{
const SbxHint* pHint = PTR_CAST(SbxHint,&rHint);
if( pHint )
{
SbxVariable* pVar = pHint->GetVar();
SbxArray* pPar = pVar->GetParameters();
USHORT nIndex = (USHORT) pVar->GetUserData();
// kein Index: weiterreichen!
if( nIndex )
{
ULONG t = pHint->GetId();
if( t == SBX_HINT_INFOWANTED )
pVar->SetInfo( GetInfo( (short) pVar->GetUserData() ) );
else
{
BOOL bWrite = FALSE;
if( t == SBX_HINT_DATACHANGED )
bWrite = TRUE;
if( t == SBX_HINT_DATAWANTED || bWrite )
{
// Parameter-Test fuer Methoden:
USHORT nPar = pMethods[ --nIndex ].nArgs & 0x00FF;
// Element 0 ist der Returnwert
if( ( !pPar && nPar )
|| ( pPar && pPar->Count() < nPar+1 ) )
SetError( SbxERR_WRONG_ARGS );
// Alles klar, man kann den Call ausfuehren
else
{
(this->*(pMethods[ nIndex ].pFunc))( pVar, pPar, bWrite );
}
}
}
}
SbxObject::SFX_NOTIFY( rBC, rBCT, rHint, rHT );
}
}
// Zusammenbau der Infostruktur fuer einzelne Elemente
SbxInfo* ProcessWrapper::GetInfo( short nIdx )
{
Methods* p = &pMethods[ nIdx ];
// Wenn mal eine Hilfedatei zur Verfuegung steht:
// SbxInfo* pInfo = new SbxInfo( Hilfedateiname, p->nHelpId );
SbxInfo* pInfo = new SbxInfo;
short nPar = p->nArgs & _ARGSMASK;
for( short i = 0; i < nPar; i++ )
{
p++;
String aName( p->pName, RTL_TEXTENCODING_ASCII_US );
USHORT nFlags = ( p->nArgs >> 8 ) & 0x03;
if( p->nArgs & _OPT )
nFlags |= SBX_OPTIONAL;
pInfo->AddParam( aName, p->eType, nFlags );
}
return pInfo;
}
////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////
// Properties und Methoden legen beim Get (bPut = FALSE) den Returnwert
// im Element 0 des Argv ab; beim Put (bPut = TRUE) wird der Wert aus
// Element 0 gespeichert.
// Die Methoden:
void ProcessWrapper::PSetImage( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite )
{ // Imagedatei des Executables
if ( pPar->Count() >= 2 )
pProcess->SetImage(pPar->Get( 1 )->GetString(), pPar->Get( 2 )->GetString() );
else
pProcess->SetImage(pPar->Get( 1 )->GetString(), String() );
}
void ProcessWrapper::PStart( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite )
{ // Programm wird gestartet
pVar->PutBool( pProcess->Start() );
}
void ProcessWrapper::PGetExitCode( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite )
{ // ExitCode des Programms(nachdem es beendet ist)
pVar->PutULong( pProcess->GetExitCode() );
}
void ProcessWrapper::PIsRunning( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite )
{ // Programm läuft noch
pVar->PutBool( pProcess->IsRunning() );
}
void ProcessWrapper::PWasGPF( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite )
{ // Programm mit GPF o.ä. abgebrochen
pVar->PutBool( pProcess->WasGPF() );
}
// Die Factory legt unser Objekte an.
SbxObject* ProcessFactory::CreateObject( const String& rClass )
{
if( rClass.CompareIgnoreCaseToAscii( "Process" ) == COMPARE_EQUAL )
return new ProcessWrapper();
return NULL;
}
+131
View File
@@ -0,0 +1,131 @@
/*************************************************************************
*
* $RCSfile: processw.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _PROCESSW_HXX
#define _PROCESSW_HXX
#ifndef __SBX_SBX_FACTORY_HXX //autogen
#include <svtools/sbxfac.hxx>
#endif
#ifndef __SBX_SBXVARIABLE_HXX //autogen
#include <svtools/sbxvar.hxx>
#endif
#ifndef _SBX_SBXOBJECT_HXX //autogen
#include <svtools/sbxobj.hxx>
#endif
#include "process.hxx"
class ProcessWrapper : public SbxObject
{
// Definition eines Tabelleneintrags. Dies wird hier gemacht,
// da dadurch die Methoden und Properties als private deklariert
// werden koennen.
#if defined ( ICC ) || defined ( HPUX ) || defined ( C50 )
public:
#endif
typedef void( ProcessWrapper::*pMeth )
( SbxVariable* pThis, SbxArray* pArgs, BOOL bWrite );
#if defined ( ICC ) || defined ( HPUX )
private:
#endif
struct Methods {
const char* pName; // Name des Eintrags
SbxDataType eType; // Datentyp
short nArgs; // Argumente und Flags
pMeth pFunc; // Function Pointer
};
static Methods aProcessMethods[]; // Methodentabelle
Methods *pMethods; // Aktuelle Methodentabelle
// Methoden
void PSetImage( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite );
void PStart( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite );
void PGetExitCode( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite );
void PIsRunning( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite );
void PWasGPF( SbxVariable* pVar, SbxArray* pPar, BOOL bWrite );
// Interne Member und Methoden
Process *pProcess;
// Infoblock auffuellen
SbxInfo* GetInfo( short nIdx );
// Broadcaster Notification
virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
const SfxHint& rHint, const TypeId& rHintType );
public:
ProcessWrapper();
~ProcessWrapper();
// Suchen eines Elements
virtual SbxVariable* Find( const String&, SbxClassType );
};
// Die dazugehoerige Factory:
class ProcessFactory : public SbxFactory
{
public:
virtual SbxObject* CreateObject( const String& );
};
#endif
+148
View File
@@ -0,0 +1,148 @@
/*************************************************************************
*
* $RCSfile: resids.hrc,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _RESIDS_HRC
#define _RESIDS_HRC
#define RID_OK 1
#define RID_CANCEL 2
#define RID_FILENAME 3
#define RID_PATHNAME 4
#define RID_FILELIST 5
#define RID_DIRSLIST 6
#define RID_FIND 7
#define RID_REPLACE 8
//#define RID_ICON 9
//#define RID_EDITFIELD 10
#define RID_TEXT 11
//#define RID_FRAME1 12
//#define RID_FRAME2 13
#define RID_VERSIONSTRING 14
#define RID_FIXEDTEXT1 15
#define RID_FIXEDTEXT2 16
// OptionsDialog
#define RES_TC_OPTIONS 20
// SpecialOptions
#define RID_TP_SPE 30
#define GB_DIRECTORIES 31
#define LOG_TEXT 32
#define BASIS_TEXT 33
#define HID_TEXT 34
#define GB_OTHER 35
#define TIMEOUT_TEXT 36
#define LOG_NAME 37
#define BASIS_NAME 38
#define HID_NAME 39
#define LOG_SET 40
#define BASIS_SET 41
#define HID_SET 42
#define SERVER_TIMEOUT 43
#define CB_AUTORELOAD 44
// GenericOptions
#define RID_TP_GEN 50
#define RID_GB_AREA 51
#define RID_CB_AREA 52
#define RID_PB_NEW_AREA 53
#define RID_PD_DEL_AREA 54
#define RID_GB_VALUE 55
#define RID_CB_VALUE 56
#define RID_PB_NEW_VALUE 57
#define RID_PB_DEL_VALUE 58
// DisplayHId
#define RID_TB_CONF 70
#define RID_FT_CONTROLS 71
#define RID_MLB_CONTROLS 72
#define RID_FT_SLOTS 73
#define RID_MLB_SLOTS 74
#define RID_PB_KOPIEREN 75
#define RID_PB_BENENNEN 76
#define RID_PB_SELECTALL 77
#define RID_OK_CLOSE 78
// BreakpointWindow
#define IMGID_BRKENABLED 80
#define IMGID_BRKDISABLED 81
#define IMGID_STEPMARKER 82
#define IMGID_ERRORMARKER 83
// Edit Variables
#define RID_FT_NAME 90
#define RID_FT_CONTENT 91
#define RID_FT_NEW_CONTENT 92
#define RID_FT_NAME_VALUE 93
#define RID_FT_CONTENT_VALUE 94
#define RID_RB_NEW_BOOL_T 95
#define RID_RB_NEW_BOOL_F 96
#define RID_NF_NEW_INTEGER 97
#define RID_NF_NEW_LONG 98
#define RID_ED_NEW_STRING 99
#endif
+157
View File
@@ -0,0 +1,157 @@
/*************************************************************************
*
* $RCSfile: status.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "app.hxx"
#include "basic.hrc"
#include "appwin.hxx"
#include "status.hxx"
#include <vcl/system.hxx>
#include <vcl/decoview.hxx>
StatusLine::StatusLine( BasicFrame* p )
: TaskBar( p )
, pFrame( p )
{
Show();
}
TaskToolBox* StatusLine::CreateTaskToolBox()
{
TaskToolBox *pTTB = new TaskToolBox( this );
pTTB->SetActivateTaskHdl( LINK( this, StatusLine, ActivateTask ) );
// pTTB->Show();
return pTTB;
}
TaskStatusBar* StatusLine::CreateTaskStatusBar()
{
TaskStatusBar* pBar = new TaskStatusBar( this, WB_3DLOOK | WB_BORDER | WB_LEFT );
USHORT nCharWidth = GetTextWidth( '0' ); // Angenommen, alle Zahlen sind gleich breit
pBar->InsertItem( ST_MESSAGE, GetTextWidth( 'X' ) * 20, SIB_LEFT | SIB_IN | SIB_AUTOSIZE );
pBar->InsertItem( ST_LINE, 5*nCharWidth );
pBar->InsertStatusField();
return pBar;
}
void StatusLine::Message( String& s )
{
GetStatusBar()->SetItemText( ST_MESSAGE, s );
}
void StatusLine::Pos( String& s )
{
GetStatusBar()->SetItemText( ST_LINE, s );
}
IMPL_LINK( StatusLine, ActivateTask, TaskToolBox*, pTTB )
{
USHORT nFirstWinPos=0;
MenuBar* pMenu = pFrame->GetMenuBar();
PopupMenu* pWinMenu = pMenu->GetPopupMenu( RID_APPWINDOW );
while ( pWinMenu->GetItemId( nFirstWinPos ) < RID_WIN_FILE1 && nFirstWinPos < pWinMenu->GetItemCount() )
nFirstWinPos++;
nFirstWinPos += pTTB->GetItemPos( pTTB->GetCurItemId() ) / 2;
USHORT x;
x = pTTB->GetItemPos( pTTB->GetCurItemId() );
x = pWinMenu->GetItemId( nFirstWinPos );
x = pWinMenu->GetItemCount();
AppWin* pWin = pFrame->FindWin( pWinMenu->GetItemText( pWinMenu->GetItemId( nFirstWinPos ) ) );
if ( pWin )
{
pWin->Minimize( FALSE );
pWin->ToTop();
}
return 0;
}
void StatusLine::LoadTaskToolBox()
{
USHORT nFirstWinPos=0;
MenuBar* pMenu = pFrame->GetMenuBar();
PopupMenu* pWinMenu = pMenu->GetPopupMenu( RID_APPWINDOW );
while ( pWinMenu->GetItemId( nFirstWinPos ) < RID_WIN_FILE1 && nFirstWinPos < pWinMenu->GetItemCount() )
nFirstWinPos++;
TaskToolBox* pTaskToolBox = GetTaskToolBox();
pTaskToolBox->StartUpdateTask();
while ( nFirstWinPos < pWinMenu->GetItemCount() )
{ // Es gibt Fenster
Window* pWin = pFrame->FindWin( pWinMenu->GetItemId( nFirstWinPos ) );
if ( pWin )
pTaskToolBox->UpdateTask( Image(), pWin->GetText(), pWin == pFrame->pList->Last() && !( pFrame->pList->Last()->GetWinState() & TT_WIN_STATE_HIDE ) );
nFirstWinPos++;
}
pTaskToolBox->EndUpdateTask();
}
+93
View File
@@ -0,0 +1,93 @@
/*************************************************************************
*
* $RCSfile: status.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BASICSTATUS_HXX
#define _BASICSTATUS_HXX
#ifndef _TASKBAR_HXX
#include <svtools/taskbar.hxx>
#endif
#ifndef _SV_STATUS_HXX
#include <vcl/status.hxx>
#endif
#define ST_MESSAGE 1
#define ST_LINE 2
class BasicFrame;
class StatusLine : public TaskBar
{
protected:
BasicFrame* pFrame;
// virtual TaskButtonBar* CreateButtonBar();
virtual TaskToolBox* CreateTaskToolBox();
virtual TaskStatusBar* CreateTaskStatusBar();
DECL_LINK( ActivateTask, TaskToolBox* );
public:
StatusLine( BasicFrame* );
void Message( String& ); // Text anzeigen
void Pos( String& s ); // Textposition anzeigen
void LoadTaskToolBox();
};
#endif
File diff suppressed because it is too large Load Diff
+62
View File
@@ -0,0 +1,62 @@
/*************************************************************************
*
* $RCSfile: testbasi.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#define testtool
#include "mybasic.cxx"
+81
View File
@@ -0,0 +1,81 @@
/*************************************************************************
*
* $RCSfile: testtool.idl,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
module
"484E40E0-1F23-101C-9961-04021C007002"
"5A30E000-1F23-101C-9961-04021C007002"
App
[
HelpText( "Test" ),
TypeLibFile( "testtool.tlb" )
]
{
interface TestToolAutomation
[
uuid( "6706E171-FB05-101B-804c-04021c007002" )
]
{
void Start( String aFilePath );
BOOL Call( String aProcName, UINT32 nUId );
void Close( );
}
}
+221
View File
@@ -0,0 +1,221 @@
/*************************************************************************
*
* $RCSfile: testtool.src,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "testtool.hrc"
///////////////////////////////
// Strings
///////////////////////////////
String S_INVALID_KEYCODE
{
Text = "Ist kein gültiger KeyCode!";
Text[ english_us ] = "Is an invalid KeyCode!";
Text[ portuguese ] = "Não é um KeyCode válido!";
Text[ russian ] = "Is an invalid KeyCode!";
Text[ greek ] = "Is an invalid KeyCode!";
Text[ dutch ] = "Is geen geldige KeyCode!";
Text[ french ] = "KeyCode incorrect !";
Text[ spanish ] = "¡No es un KeyCode correcto!";
Text[ italian ] = "Is an invalid KeyCode!";
Text[ danish ] = "Is an invalid KeyCode!";
Text[ swedish ] = "Is an invalid KeyCode!";
Text[ polish ] = "Nieprawid³owy KeyCode!";
Text[ portuguese_brazilian ] = "Ist kein gültiger KeyCode!";
Text[ japanese ] = "Is an invalid KeyCode!";
Text[ korean ] = "Ű Äڵ尡 ¸ÂÁö¾Ê½À´Ï´Ù!";
Text[ chinese_simplified ] = "Is an invalid KeyCode!";
Text[ chinese_traditional ] = "Ist kein gültiger KeyCode!";
Text[ arabic ] = "Is an invalid KeyCode!";
Text[ turkish ] = "Geçerli bir KeyCode deðil!";
};
String S_MANDATORY_FILE
{
Text = "\nwurde nicht gefunden.\nDiese Datei ist unentbehrlich.";
Text[ english_us ] = "\ncould not be found.\nThis file is indispensable.";
Text[ portuguese ] = "\nnão foi encontrado.\nEste ficheiro é indispensável.";
Text[ russian ] = "\ncould not be found.\nThis file is indispensable.";
Text[ greek ] = "\ncould not be found.\nThis file is indispensable.";
Text[ dutch ] = "\nniet gevonden.\nDit bestand is onontbeerlijk.";
Text[ french ] = "\nn'a pas pu être détecté.\nCe fichier est indispensable.";
Text[ spanish ] = "\nno se encontró.\nEste archivo es imprescindible.";
Text[ italian ] = "\ncould not be found.\nThis file is indispensable.";
Text[ danish ] = "\ncould not be found.\nThis file is indispensable.";
Text[ swedish ] = "\ncould not be found.\nThis file is indispensable.";
Text[ polish ] = "\nnie znaleziono.\n.Plik ten jest niezbêdny.";
Text[ portuguese_brazilian ] = "\nwurde nicht gefunden.\nDiese Datei ist unentbehrlich.";
Text[ japanese ] = "\ncould not be found.\nThis file is indispensable.";
Text[ korean ] = "\n¹ß°ßµÇÁö ¾Ê½À´Ï´Ù.\nÀÌ ÆÄÀÏÀº ¹Ýµå½Ã ÀÖ¾î¾ßÇÕ´Ï´Ù.";
Text[ chinese_simplified ] = "\ncould not be found.\nThis file is indispensable.";
Text[ chinese_traditional ] = "\nwurde nicht gefunden.\nDiese Datei ist unentbehrlich.";
Text[ arabic ] = "\ncould not be found.\nThis file is indispensable.";
Text[ turkish ] = "\nbulunamadý.\nBu dosya mutlaka gerekli.";
};
String S_READING_LONGNAMES
{
Text = "Einlesen der Langnamen";
Text[ english_us ] = "Reading long names";
Text[ portuguese ] = "Leitura dos nomes extensos";
Text[ russian ] = "Reading long names";
Text[ greek ] = "Reading long names";
Text[ dutch ] = "Lezen van volledige namen";
Text[ french ] = "Lecture des noms de fichiers longs (long names)";
Text[ spanish ] = "Leyendo nombres largos";
Text[ italian ] = "Reading long names";
Text[ danish ] = "Reading long names";
Text[ swedish ] = "Reading long names";
Text[ polish ] = "Czytanie pe³nych nazw";
Text[ portuguese_brazilian ] = "Einlesen der Langnamen";
Text[ japanese ] = "Reading long names";
Text[ korean ] = "±ä À̸§ Àбâ";
Text[ chinese_simplified ] = "Reading long names";
Text[ chinese_traditional ] = "Einlesen der Langnamen";
Text[ arabic ] = "Reading long names";
Text[ turkish ] = "Uzun adlar okunuyor";
};
String S_READING_SLOT_IDS
{
Text = "Einlesen der Slot IDs";
Text[ english_us ] = "Reading Slot IDs";
Text[ portuguese ] = "Leitura dos Slot IDs";
Text[ russian ] = "Reading Slot IDs";
Text[ greek ] = "Reading Slot IDs";
Text[ dutch ] = "Lezen van de Slot IDs";
Text[ french ] = "Lecture des Slot IDs";
Text[ spanish ] = "Leyendo Slot IDs";
Text[ italian ] = "Reading Slot IDs";
Text[ danish ] = "Reading Slot IDs";
Text[ swedish ] = "Reading Slot IDs";
Text[ polish ] = "Czytanie Slot ID";
Text[ portuguese_brazilian ] = "Einlesen der Slot IDs";
Text[ japanese ] = "Reading Slot IDs";
Text[ korean ] = "½½·Ô ¾ÆÀ̵ð Àбâ";
Text[ chinese_simplified ] = "Reading Slot IDs";
Text[ chinese_traditional ] = "Einlesen der Slot IDs";
Text[ arabic ] = "Reading Slot IDs";
Text[ turkish ] = "Slot ID'ler okunuyor";
};
String S_READING_CONTROLS
{
Text = "Einlesen der Controls";
Text[ english_us ] = "Reading Controls";
Text[ portuguese ] = "Leitura dos Controls";
Text[ russian ] = "Reading Controls";
Text[ greek ] = "Reading Controls";
Text[ dutch ] = "Leuen van de Controls";
Text[ french ] = "Lecture des contrôles";
Text[ spanish ] = "Leyendo Controls";
Text[ italian ] = "Reading Controls";
Text[ danish ] = "Reading Controls";
Text[ swedish ] = "Reading Controls";
Text[ polish ] = "Odczyt pól kontrolnych";
Text[ portuguese_brazilian ] = "Einlesen der Controls";
Text[ japanese ] = "Reading Controls";
Text[ korean ] = "ÄÁÆ®·Ñ Àбâ";
Text[ chinese_simplified ] = "Reading Controls";
Text[ chinese_traditional ] = "Einlesen der Controls";
Text[ arabic ] = "Reading Controls";
Text[ turkish ] = "Control'ler okunuyor";
};
String S_READING_BASIC_MODULE
{
Text = "Einlesen BASIC Modul";
Text[ english_us ] = "Reading BASIC module";
Text[ portuguese ] = "Leitura do módulo BASIC";
Text[ russian ] = "Reading BASIC module";
Text[ greek ] = "Reading BASIC module";
Text[ dutch ] = "Lezen van BASIC module";
Text[ french ] = "Lecture du module BASIC";
Text[ spanish ] = "Leyendo módulo BASIC";
Text[ italian ] = "Reading BASIC module";
Text[ danish ] = "Reading BASIC module";
Text[ swedish ] = "Reading BASIC module";
Text[ polish ] = "Czytanie modu³u BASIC";
Text[ portuguese_brazilian ] = "Einlesen BASIC Modul";
Text[ japanese ] = "Reading BASIC module";
Text[ korean ] = "BASIC ¸ðµâ Àбâ";
Text[ chinese_simplified ] = "Reading BASIC module";
Text[ chinese_traditional ] = "Einlesen BASIC Modul";
Text[ arabic ] = "Reading BASIC module";
Text[ turkish ] = "BASIC modülü okunuyor";
};
String S_STARTING_APPLICATION
{
Text = "Starten der Applikation";
Text[ english_us ] = "Starting application";
Text[ portuguese ] = "A iniciar aplicação";
Text[ russian ] = "Starting application";
Text[ greek ] = "Starting application";
Text[ dutch ] = "Starten van applicatie";
Text[ french ] = "Démarrage de l'application";
Text[ spanish ] = "Iniciando la aplicación";
Text[ italian ] = "Starting application";
Text[ danish ] = "Starting application";
Text[ swedish ] = "Starting application";
Text[ polish ] = "Uruchamianie aplikacji";
Text[ portuguese_brazilian ] = "Starten der Applikation";
Text[ japanese ] = "Starting application";
Text[ korean ] = "ÀÀ¿ëÇÁ·Î±×·¥ ½ÃÀÛ";
Text[ chinese_simplified ] = "Starting application";
Text[ chinese_traditional ] = "Starten der Applikation";
Text[ arabic ] = "Starting application";
Text[ turkish ] = "Uygulama baþlatýlýyor";
};
+898
View File
@@ -0,0 +1,898 @@
/*************************************************************************
*
* $RCSfile: textedit.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SYSTEM_HXX //autogen
#include <vcl/system.hxx>
#endif
#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif
#ifndef _TEXTENG_HXX //autogen
#include <svtools/texteng.hxx>
#endif
#ifndef _TEXTVIEW_HXX //autogen
#include <svtools/textview.hxx>
#endif
#ifndef _TXTATTR_HXX //autogen
#include <svtools/txtattr.hxx>
#endif
#ifndef __SBX_SBXMETHOD_HXX //autogen
#include <svtools/sbxmeth.hxx>
#endif
#ifndef _BASIC_TTRESHLP_HXX
#include "ttstrhlp.hxx"
#endif
#include "basic.hrc"
#include "textedit.hxx"
#include "appedit.hxx"
#include "brkpnts.hxx"
#include "testtool.hxx" // defines für das Syntaxhighlighting
TextEditImp::TextEditImp( AppEdit* pParent, const WinBits& aBits )
: Window( pParent, aBits )
, pAppEdit( pParent )
, bHighlightning( FALSE )
, bDoSyntaxHighlight( FALSE )
, bDelayHighlight( TRUE )
, nTipId( 0 )
{
pTextEngine = new TextEngine();
pTextEngine->SetMaxTextLen( STRING_MAXLEN );
pTextEngine->EnableUndo( TRUE );
pTextView = new TextView( pTextEngine, this );
pTextEngine->InsertView( pTextView );
pTextEngine->SetModified( FALSE );
aSyntaxIdleTimer.SetTimeout( 200 );
aSyntaxIdleTimer.SetTimeoutHdl( LINK( this, TextEditImp, SyntaxTimerHdl ) );
aImplSyntaxIdleTimer.SetTimeout( 1 );
aImplSyntaxIdleTimer.SetTimeoutHdl( LINK( this, TextEditImp, SyntaxTimerHdl ) );
StartListening( *pTextEngine );
HideTipTimer.SetTimeout( 5000 ); // 5 Sekunden
ShowTipTimer.SetTimeout( 500 ); // 1/2 Sekunde
HideTipTimer.SetTimeoutHdl( LINK( this, TextEditImp, HideVarContents ) );
ShowTipTimer.SetTimeoutHdl( LINK( this, TextEditImp, ShowVarContents ) );
}
TextEditImp::~TextEditImp()
{
pTextEngine->RemoveView( pTextView );
delete pTextView;
delete pTextEngine;
}
void TextEditImp::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
{
if ( rHint.ISA( TextHint ) )
{
const TextHint& rTextHint = (const TextHint&)rHint;
if( rTextHint.GetId() == TEXT_HINT_VIEWSCROLLED )
{
pAppEdit->pHScroll->SetThumbPos( pTextView->GetStartDocPos().X() );
pAppEdit->pVScroll->SetThumbPos( pTextView->GetStartDocPos().Y() );
if ( ((TextEdit*)(pAppEdit->pDataEdit))->GetBreakpointWindow() )
((TextEdit*)(pAppEdit->pDataEdit))->GetBreakpointWindow()->Scroll( 0, ((TextEdit*)(pAppEdit->pDataEdit))->GetBreakpointWindow()->GetCurYOffset() - pTextView->GetStartDocPos().Y() );
}
else if( rTextHint.GetId() == TEXT_HINT_TEXTHEIGHTCHANGED )
{
if ( pTextView->GetStartDocPos().Y() )
{
long nOutHeight = GetOutputSizePixel().Height();
long nTextHeight = pTextEngine->GetTextHeight();
if ( nTextHeight < nOutHeight )
pTextView->Scroll( 0, pTextView->GetStartDocPos().Y() );
}
pAppEdit->SetScrollBarRanges();
}
else if( rTextHint.GetId() == TEXT_HINT_TEXTFORMATTED )
{
ULONG nWidth = pTextEngine->CalcTextWidth();
if ( (ULONG)nWidth != pAppEdit->nCurTextWidth )
{
pAppEdit->nCurTextWidth = nWidth;
if ( pAppEdit->pHScroll )
{ // Initialisierung abgeschlossen?
pAppEdit->pHScroll->SetRange( Range( 0, (long)nWidth) );
pAppEdit->pHScroll->SetThumbPos( pTextView->GetStartDocPos().X() );
}
}
}
else if( rTextHint.GetId() == TEXT_HINT_PARAINSERTED )
{
if ( ((TextEdit*)(pAppEdit->pDataEdit))->GetBreakpointWindow() )
((TextEdit*)(pAppEdit->pDataEdit))->GetBreakpointWindow()->AdjustBreakpoints( rTextHint.GetValue()+1, TRUE );
// Lästiges anpassen für 2 Zeichen am Zeilenende statt einem(Hartverdrateter Default)
pTextEngine->SetMaxTextLen( STRING_MAXLEN - pTextEngine->GetParagraphCount() );
}
else if( rTextHint.GetId() == TEXT_HINT_PARAREMOVED )
{
if ( ((TextEdit*)(pAppEdit->pDataEdit))->GetBreakpointWindow() )
((TextEdit*)(pAppEdit->pDataEdit))->GetBreakpointWindow()->AdjustBreakpoints( rTextHint.GetValue()+1, FALSE );
// Lästiges anpassen für 2 Zeichen am Zeilenende statt einem(Hartverdrateter Default)
pTextEngine->SetMaxTextLen( STRING_MAXLEN - pTextEngine->GetParagraphCount() );
}
else if( rTextHint.GetId() == TEXT_HINT_FORMATPARA )
{
DoDelayedSyntaxHighlight( rTextHint.GetValue() );
ModifyHdl.Call( NULL );
}
}
}
#define TEXTATTR_SPECHIAL 55
class TextAttribSpechial : public TextAttrib
{
private:
FontWeight maFontWeight;
public:
TextAttribSpechial( const FontWeight& rFontWeight );
TextAttribSpechial( const TextAttribSpechial& rAttr );
~TextAttribSpechial() {;}
virtual void SetFont( Font& rFont ) const;
virtual TextAttrib* Clone() const;
virtual int operator==( const TextAttrib& rAttr ) const;
};
TextAttribSpechial::TextAttribSpechial( const FontWeight& rFontWeight )
: TextAttrib( TEXTATTR_SPECHIAL ), maFontWeight( rFontWeight )
{}
TextAttribSpechial::TextAttribSpechial( const TextAttribSpechial& rAttr )
: TextAttrib( rAttr ), maFontWeight( rAttr.maFontWeight )
{}
void TextAttribSpechial::SetFont( Font& rFont ) const
{
rFont.SetWeight( maFontWeight );
}
TextAttrib* TextAttribSpechial::Clone() const
{
return new TextAttribSpechial( *this );
}
int TextAttribSpechial::operator==( const TextAttrib& rAttr ) const
{
return ( ( TextAttrib::operator==(rAttr ) ) &&
( maFontWeight == ((const TextAttribSpechial&)rAttr).maFontWeight ) );
}
void TextEditImp::ImpDoHighlight( const String& rSource, ULONG nLineOff )
{
SbTextPortions aPortionList;
pAppEdit->GetBasicFrame()->Basic().Highlight( rSource, aPortionList );
USHORT nCount = aPortionList.Count();
if ( !nCount )
return;
SbTextPortion& rLast = aPortionList[nCount-1];
if ( rLast.nStart > rLast.nEnd ) // Nur bis Bug von MD behoben
{
#ifdef DEBUG
DBG_ERROR( "MD-Bug nicht beseitigt!" );
#endif
nCount--;
aPortionList.Remove( nCount);
if ( !nCount )
return;
}
/// hier werden die Type für das Testtool nachbearbeitet
USHORT i;
BOOL bWasTTControl = FALSE;
for ( i = 0; i < aPortionList.Count(); i++ )
{
SbTextPortion& r = aPortionList[i];
// DBG_ASSERT( r.nStart <= r.nEnd, "Highlight: Start > End?" );
if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoben
continue;
SbTextType eType = r.eType;
Color aColor;
switch ( eType )
{
case SB_SYMBOL:
{
String aSymbol = rSource.Copy( r.nStart, r.nEnd - r.nStart +1 );
r.eType = pAppEdit->GetBasicFrame()->Basic().GetSymbolType( aSymbol, bWasTTControl );
if ( r.eType == TT_CONTROL )
bWasTTControl = TRUE;
else
bWasTTControl = FALSE;
}
break;
case SB_PUNCTUATION:
{
String aPunctuation = rSource.Copy( r.nStart, r.nEnd - r.nStart +1 );
if ( aPunctuation.CompareToAscii( "." ) != COMPARE_EQUAL )
bWasTTControl = FALSE;
}
break;
default:
bWasTTControl = FALSE;
}
}
// Evtl. Optimieren:
// Wenn haufig gleiche Farbe, dazwischen Blank ohne Farbe,
// ggf. zusammenfassen, oder zumindest das Blank,
// damit weniger Attribute
if ( TRUE /*bOptimizeHighlight*/ )
{
// Es muessen nur die Blanks und Tabs mit attributiert werden.
// Wenn zwei gleiche Attribute hintereinander eingestellt werden,
// optimiert das die EditEngine.
xub_StrLen nLastEnd = 0;
xub_StrLen nLine = aPortionList[0].nLine;
for ( USHORT i = 0; i < nCount; i++ )
{
SbTextPortion& r = aPortionList[i];
DBG_ASSERT( r.nLine == nLine, "doch mehrere Zeilen ?" );
DBG_ASSERT( r.nStart <= r.nEnd, "Highlight: Start > End?" );
if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoben
continue;
if ( r.nStart > nLastEnd )
{
// Kann ich mich drauf verlassen, dass alle ausser
// Blank und Tab gehighlightet wird ?!
r.nStart = nLastEnd;
}
nLastEnd = r.nEnd+1;
if ( ( i == (nCount-1) ) && ( r.nEnd < rSource.Len() ) )
r.nEnd = rSource.Len()-1;
}
}
BOOL bWasModified = pTextEngine->IsModified();
for ( i = 0; i < aPortionList.Count(); i++ )
{
SbTextPortion& r = aPortionList[i];
// DBG_ASSERT( r.nStart <= r.nEnd, "Highlight: Start > End?" );
if ( r.nStart > r.nEnd ) // Nur bis Bug von MD behoben
continue;
SbTextType eCol = r.eType;
Color aColor;
xub_StrLen nLine = nLineOff+r.nLine-1; // -1, weil Basic bei 1 beginnt
switch ( eCol )
{
case SB_KEYWORD:
aColor = Color( COL_BLUE );
break;
case SB_SYMBOL:
aColor = Color( RGB_COLORDATA( 0x00, 0x60, 0x00 ) );
break;
case SB_STRING:
aColor = Color( COL_RED );
break;
case SB_NUMBER:
aColor = Color( COL_MAGENTA );
break;
case SB_PUNCTUATION:
aColor = Color( COL_BLACK );
break;
case SB_COMMENT:
aColor = Color( COL_GRAY );
break;
case TT_KEYWORD:
case TT_LOCALCMD:
aColor = Color( COL_LIGHTBLUE );
break;
case TT_REMOTECMD:
aColor = Color( RGB_COLORDATA( 0x00, 0xB0, 0xB0 ) );
break;
case TT_CONTROL:
case TT_SLOT:
aColor = Color( RGB_COLORDATA( 0x00, 0xB0, 0x00 ) );
break;
case TT_METHOD:
aColor = Color( RGB_COLORDATA( 0x00, 0xB0, 0x00 ) );
break;
case TT_NOMETHOD:
{
aColor = Color( COL_RED );
pTextEngine->SetAttrib( TextAttribSpechial( WEIGHT_BOLD ), nLine, r.nStart, r.nEnd+1 );
}
break;
default:
{
aColor = Color( RGB_COLORDATA( 0xff, 0x80, 0x80 ) );
DBG_ERROR( "Unbekannte Syntax-Farbe?" );
}
}
pTextEngine->SetAttrib( TextAttribFontColor( aColor ), nLine, r.nStart, r.nEnd+1 );
}
// Das Highlighten soll kein Modify setzen
pTextEngine->SetModified( bWasModified );
}
void TextEditImp::DoSyntaxHighlight( ULONG nPara )
{
// Durch das DelayedSyntaxHighlight kann es passieren,
// dass die Zeile nicht mehr existiert!
if ( nPara < pTextEngine->GetParagraphCount() )
{
// leider weis ich nicht, ob genau diese Zeile Modified() ...
// if ( pProgress )
// pProgress->StepProgress();
pTextEngine->RemoveAttribs( nPara );
String aSource( pTextEngine->GetText( nPara ) );
ImpDoHighlight( aSource, nPara );
}
}
void TextEditImp::DoDelayedSyntaxHighlight( xub_StrLen nPara )
{
// Zeile wird nur in 'Liste' aufgenommen, im TimerHdl abgearbeitet.
// => Nicht Absaetze manipulieren, waehrend EditEngine formatiert.
// if ( pProgress )
// pProgress->StepProgress();
if ( !bHighlightning && bDoSyntaxHighlight )
{
if ( bDelayHighlight )
{
aSyntaxLineTable.Insert( nPara, (void*)(ULONG)1 );
aSyntaxIdleTimer.Start();
}
else
DoSyntaxHighlight( nPara );
}
}
IMPL_LINK( TextEditImp, SyntaxTimerHdl, Timer *, EMPTYARG )
{
DBG_ASSERT( pTextView, "Noch keine View, aber Syntax-Highlight ?!" );
pTextEngine->SetUpdateMode( FALSE );
bHighlightning = TRUE;
USHORT nLine;
while ( aSyntaxLineTable.First() && !Application::AnyInput( INPUT_MOUSEANDKEYBOARD ) )
{
nLine = (USHORT)aSyntaxLineTable.GetCurKey();
DoSyntaxHighlight( nLine );
aSyntaxLineTable.Remove( nLine );
/* if ( Application::AnyInput() )
{
aSyntaxIdleTimer.Start(); // Starten, falls wir in einem Dialog landen
pTextView->ShowCursor( TRUE, TRUE );
pTextEngine->SetUpdateMode( TRUE );
bHighlightning = FALSE;
GetpApp()->Reschedule();
bHighlightning = TRUE;
pTextEngine->SetUpdateMode( FALSE );
}*/
}
BOOL bWasModified = pTextEngine->IsModified();
if ( aSyntaxLineTable.Count() > 3 ) // Ohne VDev
{
pTextEngine->SetUpdateMode( TRUE );
pTextView->ShowCursor( TRUE, TRUE );
}
else
pTextEngine->SetUpdateMode( TRUE ); // ! Mit VDev
// pTextView->ForceUpdate();
// SetUpdateMode( TRUE ) soll kein Modify setzen
pTextEngine->SetModified( bWasModified );
// SyntaxTimerHdl wird gerufen, wenn Text-Aenderung
// => gute Gelegenheit, Textbreite zu ermitteln!
// long nPrevTextWidth = nCurTextWidth;
// nCurTextWidth = pTextEngine->CalcTextWidth();
// if ( nCurTextWidth != nPrevTextWidth )
// SetScrollBarRanges();
bHighlightning = FALSE;
if ( aSyntaxLineTable.First() )
aImplSyntaxIdleTimer.Start();
// while ( Application::AnyInput() )
// Application::Reschedule(); // Reschedule, da der UserEvent keine Paints etc. durchlässt
return 0;
}
void TextEditImp::InvalidateSyntaxHighlight()
{
for ( ULONG i = 0; i < pTextEngine->GetParagraphCount(); i++ )
DoDelayedSyntaxHighlight( i );
}
void TextEditImp::SyntaxHighlight( BOOL bNew )
{
if ( ( bNew && bDoSyntaxHighlight ) || ( !bNew && !bDoSyntaxHighlight ) )
return;
bDoSyntaxHighlight = bNew;
if ( !pTextEngine )
return;
if ( bDoSyntaxHighlight )
{
InvalidateSyntaxHighlight();
}
else
{
aSyntaxIdleTimer.Stop();
pTextEngine->SetUpdateMode( FALSE );
for ( ULONG i = 0; i < pTextEngine->GetParagraphCount(); i++ )
pTextEngine->RemoveAttribs( i );
// pTextEngine->QuickFormatDoc();
pTextEngine->SetUpdateMode( TRUE );
pTextView->ShowCursor(TRUE, TRUE );
}
}
void TextEditImp::SetFont( const Font& rNewFont )
{
pTextEngine->SetFont(rNewFont);
}
BOOL TextEditImp::IsModified()
{
return pTextEngine->IsModified();
}
void TextEditImp::KeyInput( const KeyEvent& rKeyEvent )
{
BOOL bWasModified = pTextView->GetTextEngine()->IsModified();
pTextView->GetTextEngine()->SetModified( FALSE );
if ( !pTextView->KeyInput( rKeyEvent ) )
Window::KeyInput( rKeyEvent );
if ( pTextView->GetTextEngine()->IsModified() )
ModifyHdl.Call( NULL );
else
pTextView->GetTextEngine()->SetModified( bWasModified ); // Eventuell wieder setzen
}
void TextEditImp::Paint( const Rectangle& rRect ){ pTextView->Paint( rRect );}
void TextEditImp::MouseButtonUp( const MouseEvent& rMouseEvent ){ pTextView->MouseButtonUp( rMouseEvent );}
//void TextEditImp::MouseButtonDown( const MouseEvent& rMouseEvent ){ pTextView->MouseButtonDown( rMouseEvent );}
//void TextEditImp::MouseMove( const MouseEvent& rMouseEvent ){ pTextView->MouseMove( rMouseEvent );}
//void TextEditImp::Command( const CommandEvent& rCEvt ){ pTextView->Command( rCEvt );}
BOOL TextEditImp::Drop( const DropEvent& rEvt ){ return pTextView->Drop( rEvt );}
BOOL TextEditImp::QueryDrop( DropEvent& rEvt ){ return pTextView->QueryDrop( rEvt );}
void TextEditImp::Command( const CommandEvent& rCEvt )
{
switch( rCEvt.GetCommand() ) {
case COMMAND_CONTEXTMENU:
GetParent()->Command( rCEvt );
break;
default:
pTextView->Command( rCEvt );
}
}
void TextEditImp::MouseButtonDown( const MouseEvent& rMouseEvent )
{
pTextView->MouseButtonDown( rMouseEvent );
HideVarContents( NULL );
ShowTipTimer.Stop();
}
void TextEditImp::MouseMove( const MouseEvent& rMEvt )
{
pTextView->MouseMove( rMEvt );
HideVarContents( NULL );
if ( rMEvt.GetButtons() == 0 )
ShowTipTimer.Start();
if ( rMEvt.IsLeaveWindow() )
ShowTipTimer.Stop();
}
IMPL_LINK( TextEditImp, HideVarContents, void*, EMPTYARG )
{
if ( nTipId )
{
Help::HideTip( nTipId );
nTipId = 0;
aTipWord = String();
}
return 0;
}
static const char cSuffixes[] = "%&!#@$";
SbxBase* TextEditImp::GetSbxAtMousePos( String &aWord )
{
Point aPos = GetPointerPosPixel();
Point aDocPos = pTextView->GetDocPos( aPos );
aWord = pTextEngine->GetWord( pTextEngine->GetPaM( aDocPos ) );
if ( aWord.Len() && !Application::GetAppInternational().IsNumeric( aWord ) )
{
xub_StrLen nLastChar = aWord.Len()-1;
String aSuffixes = CUniString( cSuffixes );
if ( aSuffixes.Search( aWord.GetChar(nLastChar) ) != STRING_NOTFOUND )
aWord.Erase( nLastChar, 1 );
BOOL bWasError = SbxBase::IsError(); // Da eventuell im Testtool ein Fehler geschmissen wird.
SbxBase* pSBX = StarBASIC::FindSBXInCurrentScope( aWord );
if ( !bWasError && SbxBase::IsError() )
SbxBase::ResetError();
return pSBX;
}
return NULL;
}
IMPL_LINK( TextEditImp, ShowVarContents, void*, EMPTYARG )
{
String aWord;
SbxBase* pSBX = GetSbxAtMousePos( aWord );
String aHelpText;
Point aPos = GetPointerPosPixel();
if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) )
{
SbxVariable* pVar = (SbxVariable*)pSBX;
SbxDataType eType = pVar->GetType();
if ( (BYTE)eType == (BYTE)SbxOBJECT )
{
// Kann zu Absturz, z.B. bei Selections-Objekt fuehren
// Type == Object heisst nicht, dass pVar == Object!
if ( pVar->GetObject() && pVar->GetObject()->ISA( SbxObject ) )
aHelpText = ((SbxObject*)(pVar->GetObject()))->GetClassName();
else
aHelpText = CUniString("Object");
}
else if ( eType & SbxARRAY )
aHelpText = CUniString("{...}");
else if ( (BYTE)eType != (BYTE)SbxEMPTY )
{
aHelpText = pVar->GetName();
if ( !aHelpText.Len() ) // Bei Uebergabeparametern wird der Name nicht kopiert
aHelpText = aWord;
aHelpText += '=';
aHelpText += pVar->GetString();
}
}
if ( aHelpText.Len() && aTipPos != aPos && aTipWord != aWord )
{
if ( nTipId )
Help::HideTip( nTipId );
nTipId = Help::ShowTip( this, Rectangle(), aHelpText );
HideTipTimer.Start();
aTipWord = aWord;
aTipPos = aPos;
}
if ( nTipId && aTipPos != aPos )
{
Help::HideTip( nTipId );
nTipId = 0;
aTipWord = String();
}
return 0;
}
void TextEditImp::BuildKontextMenu( PopupMenu *&pMenu )
{
String aWord;
SbxBase* pSBX = GetSbxAtMousePos( aWord );
if ( pSBX && pSBX->ISA( SbxVariable ) && !pSBX->ISA( SbxMethod ) )
{
SbxVariable* pVar = (SbxVariable*)pSBX;
SbxDataType eType = pVar->GetType();
if ( ( eType & ( SbxVECTOR | SbxARRAY | SbxBYREF )) == 0 )
{
/*
Boolean
Currency
Date
Double
Integer
Long
Object
Single
String
Variant(Empty)
*/
switch ( eType )
{
case SbxBOOL:
// case SbxCURRENCY:
// case SbxDATE:
case SbxDOUBLE:
case SbxINTEGER:
case SbxLONG:
// case SbxOBJECT: // kann nicht editiert werden
case SbxSINGLE:
case SbxSTRING:
case SbxVARIANT: // Taucht wohl auch nicht auf. stattdessen SbxEMPTY
case SbxEMPTY:
{
pAppEdit->GetBasicFrame()->SetEditVar( pVar );
if ( !pMenu )
pMenu = new PopupMenu();
else
pMenu->InsertSeparator();
pMenu->InsertItem( RID_POPUPEDITVAR, ((BasicFrame*)GetpApp()->GetAppWindow())->GenRealString( GEN_RES_STR1( IDS_EDIT_VAR, aWord ) ) );
}
break;
}
}
}
}
DBG_NAME(TextEdit)
TextEdit::TextEdit( AppEdit* pParent, const WinBits& aBits )
: aEdit( pParent, aBits | WB_NOHIDESELECTION )
, pBreakpointWindow( NULL )
, bFileWasUTF8( FALSE )
, bSaveAsUTF8( FALSE )
{
DBG_CTOR(TextEdit,0);
Font aFont(System::GetStandardFont(STDFONT_FIXED));
aFont.SetTransparent( FALSE );
SetFont( aFont );
}
TextEdit::~TextEdit()
{DBG_DTOR(TextEdit,0);}
void TextEdit::Highlight( ULONG nLine, xub_StrLen nCol1, xub_StrLen nCol2 )
{
if ( nLine ) // Kann eigentlich nicht vorkommen, außer bei Fehler 'Sub erwartet' in erster Zeile
nLine--;
String s = aEdit.pTextEngine->GetText( nLine );
if( nCol1 == STRING_NOTFOUND )
// Keine Spalte angegeben
nCol1 = 0, nCol2 = STRING_NOTFOUND;
if( nCol2 == STRING_NOTFOUND )
{
nCol2 = s.Len();
}
// Anpassung an den Precompiler | EditText != Compilierter Text
if ( nCol2 > s.Len() )
nCol2 = s.Len();
if ( nCol1 >= nCol2 )
nCol1 = 0;
// Da nCol2 u.U. hinter das aktuelle Statement zeigt
// (weil dort schon das naechste beginnt), muessen
// wird am Ende evtl. Whitespace, einen Doppelpunkt
// und mehr Whitespace entfernen
BOOL bColon = FALSE;
while ( s.GetChar( nCol2 ) == ' ' && nCol2 > nCol1 && !bColon )
{
nCol2--;
if ( s.GetChar( nCol2 ) == ':' )
{
nCol2--;
bColon = TRUE;
}
}
aEdit.pTextView->SetSelection( TextSelection(TextPaM(nLine,nCol2+1)) );
aEdit.pTextView->SetSelection( TextSelection(TextPaM(nLine,nCol2+1), TextPaM(nLine,nCol1)) );
}
void TextEdit::Delete(){ aEdit.pTextView->KeyInput( KeyEvent( 0, KeyCode( KEYFUNC_DELETE ) )); }
void TextEdit::Cut(){ aEdit.pTextView->Cut(); }
void TextEdit::Copy(){ aEdit.pTextView->Copy(); }
void TextEdit::Paste(){ aEdit.pTextView->Paste(); }
void TextEdit::Undo(){ aEdit.pTextView->Undo(); }
void TextEdit::Redo(){ aEdit.pTextView->Redo(); }
String TextEdit::GetSelected(){ return aEdit.pTextView->GetSelected(); }
TextSelection TextEdit::GetSelection() const{ return aEdit.pTextView->GetSelection(); }
void TextEdit::SetSelection( const TextSelection& rSelection ){ aEdit.pTextView->SetSelection( rSelection ); }
USHORT TextEdit::GetLineNr() const
{
return aEdit.pTextView->GetSelection().GetEnd().GetPara()+1;
}
void TextEdit::ReplaceSelected( const String& rStr ){ aEdit.pTextView->InsertText(rStr); }
BOOL TextEdit::IsModified(){ return aEdit.IsModified(); }
String TextEdit::GetText() const
{
return aEdit.pTextEngine->GetText( GetSystemLineEnd() );
}
void TextEdit::SetText( const String& rStr ){ aEdit.pTextEngine->SetText(rStr); aEdit.pTextEngine->SetModified( FALSE ); }
void TextEdit::SetModifyHdl( Link l ){ aEdit.SetModifyHdl(l); }
BOOL TextEdit::HasText() const { return aEdit.pTextEngine->GetTextLen() > 0; }
// Es wird entweder ab Beginn oder ab Markierungsbegin + 1 gesucht.
BOOL TextEdit::Find( const String& s )
{
DBG_CHKTHIS(TextEdit,0);
TextSelection aSelection = aEdit.pTextView->GetSelection();
USHORT nPara = aSelection.GetStart().GetPara();
xub_StrLen nIndex = aSelection.GetStart().GetIndex();
if ( aSelection.HasRange() )
nIndex ++;
while ( nPara <= aEdit.pTextEngine->GetParagraphCount() )
{
String aText = aEdit.pTextEngine->GetText( nPara );
nIndex = aText.Search( s, nIndex );
if( nIndex != STRING_NOTFOUND )
{
aEdit.pTextView->SetSelection( TextSelection( TextPaM( nPara, nIndex ), TextPaM( nPara, nIndex + s.Len() ) ) );
return TRUE;
}
nIndex = 0;
nPara++;
}
return FALSE;
}
BOOL TextEdit::Load( const String& aName )
{
DBG_CHKTHIS(TextEdit,0);
BOOL bOk = TRUE;
SvFileStream aStrm( aName, STREAM_STD_READ );
if( aStrm.IsOpen() )
{
String aText, aLine;
BOOL bIsFirstLine = TRUE;
rtl_TextEncoding aFileEncoding = RTL_TEXTENCODING_IBM_850;
while( !aStrm.IsEof() && bOk )
{
aStrm.ReadByteStringLine( aLine, aFileEncoding );
if ( bIsFirstLine && aLine.EqualsAscii( TT_SIGNATURE_FOR_UNICODE_TEXTFILES ) )
{
aFileEncoding = RTL_TEXTENCODING_UTF8;
bFileWasUTF8 = TRUE;
}
else
{
if ( !bIsFirstLine )
aText += '\n';
aText += aLine;
bIsFirstLine = FALSE;
}
if( aStrm.GetError() != SVSTREAM_OK )
bOk = FALSE;
}
aText.ConvertLineEnd();
SetText( aText );
}
else
bOk = FALSE;
return bOk;
}
BOOL TextEdit::Save( const String& aName )
{
DBG_CHKTHIS(TextEdit,0);
BOOL bOk = TRUE;
SvFileStream aStrm( aName, STREAM_STD_WRITE | STREAM_TRUNC );
rtl_TextEncoding aFileEncoding = RTL_TEXTENCODING_IBM_850;
if( aStrm.IsOpen() )
{
if ( bFileWasUTF8 || bSaveAsUTF8 )
{
aStrm << TT_SIGNATURE_FOR_UNICODE_TEXTFILES;
aStrm << sal_Char(_CR);
aStrm << sal_Char(_LF);
aFileEncoding = RTL_TEXTENCODING_UTF8;
}
String aSave = GetText();
aSave.ConvertLineEnd(LINEEND_CRLF);
aStrm << ByteString( aSave, aFileEncoding ).GetBuffer();
if( aStrm.GetError() != SVSTREAM_OK )
bOk = FALSE;
else
aEdit.pTextEngine->SetModified(FALSE);
} else bOk = FALSE;
return bOk;
}
void TextEdit::BuildKontextMenu( PopupMenu *&pMenu )
{
DataEdit::BuildKontextMenu( pMenu );
aEdit.BuildKontextMenu( pMenu );
}
+178
View File
@@ -0,0 +1,178 @@
/*************************************************************************
*
* $RCSfile: textedit.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _TEXTEDIT_HXX
#define _TEXTEDIT_HXX
class AppEdit;
class TextEngine;
class TextView;
class TextEdit;
class BreakpointWindow;
#ifndef _SV_TIMER_HXX //autogen
#include <vcl/timer.hxx>
#endif
#ifndef _TOOLS_TABLE_HXX //autogen
#include <tools/table.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX //autogen
#include <tools/debug.hxx>
#endif
#ifndef _SFXLSTNER_HXX //autogen
#include <svtools/lstner.hxx>
#endif
#ifdef VCL
#include <svtools/svmedit.hxx>
#endif
#include "dataedit.hxx"
//#include <xtextedt.hxx>
class TextEditImp : public Window, public SfxListener
{
protected:
void DoSyntaxHighlight( ULONG nPara );
private:
AppEdit *pAppEdit;
Link ModifyHdl;
Timer aSyntaxIdleTimer;
Timer aImplSyntaxIdleTimer;
DECL_LINK( SyntaxTimerHdl, Timer * );
Table aSyntaxLineTable;
void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
void ImpDoHighlight( const String& rSource, ULONG nLineOff );
BOOL bHighlightning;
BOOL bDoSyntaxHighlight;
BOOL bDelayHighlight;
SbxBase* GetSbxAtMousePos( String &aWord );
virtual void MouseMove( const MouseEvent& rMEvt );
DECL_LINK( HideVarContents, void* );
DECL_LINK( ShowVarContents, void* );
Point aTipPos;
String aTipWord;
ULONG nTipId;
Timer HideTipTimer;
Timer ShowTipTimer;
public:
TextEditImp( AppEdit *pParent, const WinBits& aBits );
~TextEditImp();
TextEngine *pTextEngine;
TextView *pTextView;
void SetFont( const Font& rNewFont );
BOOL IsModified();
void SetModifyHdl( Link l ){ ModifyHdl = l; }
void KeyInput( const KeyEvent& rKeyEvent );
void Paint( const Rectangle& rRect );
void MouseButtonUp( const MouseEvent& rMouseEvent );
void MouseButtonDown( const MouseEvent& rMouseEvent );
// void MouseMove( const MouseEvent& rMouseEvent );
void Command( const CommandEvent& rCEvt );
BOOL Drop( const DropEvent& rEvt );
BOOL QueryDrop( DropEvent& rEvt );
void DoDelayedSyntaxHighlight( xub_StrLen nPara );
void InvalidateSyntaxHighlight();
void SyntaxHighlight( BOOL bNew );
void BuildKontextMenu( PopupMenu *&pMenu );
};
DBG_NAMEEX(TextEdit)
class TextEdit : public DataEdit {
BreakpointWindow *pBreakpointWindow;
BOOL bFileWasUTF8;
BOOL bSaveAsUTF8;
public:
TextEdit( AppEdit*, const WinBits& );
~TextEdit();
void Highlight( ULONG nLine, xub_StrLen nCol1, xub_StrLen nCol2 );
TextEditImp& GetTextEditImp() { return aEdit; }
void SetBreakpointWindow( BreakpointWindow *pBPWindow ){ pBreakpointWindow = pBPWindow; }
BreakpointWindow *GetBreakpointWindow(){ return pBreakpointWindow; }
DATA_FUNC_DEF( aEdit, TextEditImp )
virtual void BuildKontextMenu( PopupMenu *&pMenu );
void SaveAsUTF8( BOOL bUTF8 ) { bSaveAsUTF8 = bUTF8; }
};
#endif
+66
View File
@@ -0,0 +1,66 @@
/*************************************************************************
*
* $RCSfile: ttbasic.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "mybasic.hxx"
#include "ttbasic.hxx"
MyBasic* TTBasic::CreateMyBasic()
{
return new MyBasic;
+66
View File
@@ -0,0 +1,66 @@
/*************************************************************************
*
* $RCSfile: ttbasic.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
class TTBasic
{
public:
static MyBasic* CreateMyBasic();
};
+659
View File
@@ -0,0 +1,659 @@
/*************************************************************************
*
* $RCSfile: ttmsg.src,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "ttmsg.hrc"
// Hier sind die Messages aus dem Verzeichnis /basic/source/testtool enhalten
///////////////////////////////
// Fehlermeldungen, die in das Resultfile gelangen.
// *********************
// *** !!ACHTUNG!! ***
// *********************
// Die Nummern d黵fen sich NIE! 鋘dern,
// da sie in den Resultfiles gespeichert sind, und bei erneutem Anzeigen
// statdessen die entsprechenden neuen oder garkeine Strings angzeigt werden.
///////////////////////////////
String S_NAME_NOT_THERE
{
Text = "Name nicht vorhanden: #($Arg1)";
Text[ english_us ] = "Name doesn't exist: #($Arg1)";
Text[ portuguese ] = "Nome inexistente: #($Arg1)";
Text[ russian ] = "Name doesn't exist: #($Arg1)";
Text[ greek ] = "Name doesn't exist: #($Arg1)";
Text[ dutch ] = "Naam bestaat niet: #($Arg1)";
Text[ french ] = "Nom inexistant : #($Arg1)";
Text[ spanish ] = "El nombre no existe: #($Arg1)";
Text[ italian ] = "Name doesn't exist: #($Arg1)";
Text[ danish ] = "Name doesn't exist: #($Arg1)";
Text[ swedish ] = "Name doesn't exist: #($Arg1)";
Text[ polish ] = "Nazwa nie istnieje: #($Arg1)";
Text[ portuguese_brazilian ] = "Name nicht vorhanden: #($Arg1)";
Text[ japanese ] = "偙偺柤慜偼懚嵼偟偰偄傑偣傫: #($Arg1)";
Text[ korean ] = "捞抚捞 粮犁窍瘤 臼嚼聪促: #($Arg1)";
Text[ chinese_simplified ] = "名称不存在:#($Arg1)";
Text[ chinese_traditional ] = "�嘿ぃ��� #($Arg1)";
Text[ arabic ] = "Name doesn't exist: #($Arg1)";
Text[ turkish ] = "Name doesn't exist: #($Arg1)";
};
String S_DOUBLE_NAME
{
Text = "Name Doppelt: ($Arg1)";
Text[ english_us ] = "Name double: ($Arg1)";
Text[ portuguese ] = "Nome duplo: ($Arg1)";
Text[ russian ] = "Name double: ($Arg1)";
Text[ greek ] = "Name double: ($Arg1)";
Text[ dutch ] = "Dubbele naam: ($Arg1)";
Text[ french ] = "Nome double : ($Arg1)";
Text[ spanish ] = "Nombre doble: ($Arg1)";
Text[ italian ] = "Name double: ($Arg1)";
Text[ danish ] = "Name double: ($Arg1)";
Text[ swedish ] = "Name double: ($Arg1)";
Text[ polish ] = "Podw骿na nazwa: ($Arg1)";
Text[ portuguese_brazilian ] = "Name Doppelt: ($Arg1)";
Text[ japanese ] = "柤慜偑廳暋偟偰偄傑偡: ($Arg1)";
Text[ korean ] = "捞抚捞 吝汗登菌嚼聪促. : ($Arg1)";
Text[ chinese_simplified ] = "双重名称:($Arg1)";
Text[ chinese_traditional ] = "�嘿蛮��($Arg1)";
Text[ arabic ] = "Name double: ($Arg1)";
Text[ turkish ] = "Name double: ($Arg1)";
};
String S_READING_FILE
{
Text = "Einlesen der Dateien";
Text[ english_us ] = "Reading the files";
Text[ portuguese ] = "Leitura dos ficheiros";
Text[ russian ] = "Reading the files";
Text[ greek ] = "Reading the files";
Text[ dutch ] = "Bestanden lezen";
Text[ french ] = "Lecture des fichiers";
Text[ spanish ] = "Leyendo los archivos";
Text[ italian ] = "Reading the files";
Text[ danish ] = "Reading the files";
Text[ swedish ] = "Reading the files";
Text[ polish ] = "Czytanie plik體";
Text[ portuguese_brazilian ] = "Einlesen der Dateien";
Text[ japanese ] = "抬操偺撉傒崬傒";
Text[ korean ] = "颇老 佬扁";
Text[ chinese_simplified ] = "读取文件";
Text[ chinese_traditional ] = "弄�郎�";
Text[ arabic ] = "Reading the files";
Text[ turkish ] = "Reading the files";
};
String S_CANNOT_OPEN_FILE
{
Text = "Kann Datei nicht 謋fnen: ($Arg1)";
Text[ english_us ] = "File cannot be opened: ($Arg1)";
Text[ portuguese ] = "Imposs韛el abrir ficheiro: ($Arg1)";
Text[ russian ] = "File cannot be opened: ($Arg1)";
Text[ greek ] = "File cannot be opened: ($Arg1)";
Text[ dutch ] = "Kan bestand niet openen: ($Arg1)";
Text[ french ] = "Impossible d'ouvrir le fichier : ($Arg1)";
Text[ spanish ] = "No se puede abrir el archivo: ($Arg1)";
Text[ italian ] = "File cannot be opened: ($Arg1)";
Text[ danish ] = "File cannot be opened: ($Arg1)";
Text[ swedish ] = "File cannot be opened: ($Arg1)";
Text[ polish ] = "Nie mo縠 otworzy� pliku: ($Arg1)";
Text[ portuguese_brazilian ] = "Kann Datei nicht 謋fnen: ($Arg1)";
Text[ japanese ] = "抬操偑奐偗傜傟傑偣傫: ($Arg1)";
Text[ korean ] = "颇老捞 凯府瘤 臼嚼聪促: ($Arg1)";
Text[ chinese_simplified ] = "无法打开文件:($Arg1)";
Text[ chinese_traditional ] = "礚猭秨币郎�� ($Arg1)";
Text[ arabic ] = "File cannot be opened: ($Arg1)";
Text[ turkish ] = "File cannot be opened: ($Arg1)";
};
String S_INVALID_LINE
{
Text = "Zeile \"($Arg1)\" Ist ung黮tig.";
Text[ english_us ] = "Line \"($Arg1)\" is invalid.";
Text[ portuguese ] = "A linha \"($Arg1)\" n鉶 � v醠ida.";
Text[ russian ] = "Line \"($Arg1)\" is invalid.";
Text[ greek ] = "Line \"($Arg1)\" is invalid.";
Text[ dutch ] = "Regel \"($Arg1)\" is ongeldig.";
Text[ french ] = "Ligne \"($Arg1)\" non valable.";
Text[ spanish ] = "La l韓ea \"($Arg1)\" no es v醠ida.";
Text[ italian ] = "Line \"($Arg1)\" is invalid.";
Text[ danish ] = "Line \"($Arg1)\" is invalid.";
Text[ swedish ] = "Line \"($Arg1)\" is invalid.";
Text[ polish ] = "Wiersz \"($Arg1)\" jest niewa縩y.";
Text[ portuguese_brazilian ] = "Zeile \"($Arg1)\" Ist ung黮tig.";
Text[ japanese ] = "峴 \"($Arg1)\" 偼柍岠偱偡丅";
Text[ korean ] = "急 \"($Arg1)\" 篮 蜡瓤窍瘤 臼嚼聪促.";
Text[ chinese_simplified ] = "无效的行“($Arg1)”";
Text[ chinese_traditional ] = "︽ \"($Arg1)\" 礚��";
Text[ arabic ] = "Line \"($Arg1)\" is invalid.";
Text[ turkish ] = "Line \"($Arg1)\" is invalid.";
};
String S_SHORTNAME_UNKNOWN
{
Text = "Kurzname Unbekannt beim Kopieren: ($Arg1)";
Text[ english_us ] = "Short name unknown during copying: ($Arg1)";
Text[ portuguese ] = "Abreviatura desconhecida ao copiar: ($Arg1)";
Text[ russian ] = "Short name unknown during copying: ($Arg1)";
Text[ greek ] = "Short name unknown during copying: ($Arg1)";
Text[ dutch ] = "Afkorting onbekend bij kopi雛en: ($Arg1)";
Text[ french ] = "Abr関iation inconnue lors de la copie : ($Arg1)";
Text[ spanish ] = "Abreviatura desconocida al copiar: ($Arg1)";
Text[ italian ] = "Short name unknown during copying: ($Arg1)";
Text[ danish ] = "Short name unknown during copying: ($Arg1)";
Text[ swedish ] = "Short name unknown during copying: ($Arg1)";
Text[ polish ] = "Skr髏 nazwy nieznany podczas kopiowania: ($Arg1)";
Text[ portuguese_brazilian ] = "Kurzname Unbekannt beim Kopieren: ($Arg1)";
Text[ japanese ] = "Short name unknown during copying: ($Arg1)";
Text[ korean ] = "汗荤登绰 悼救 舅荐 绝绰 陋篮 捞抚: ($Arg1)";
Text[ chinese_simplified ] = "复制时不明的简称:($Arg1)";
Text[ chinese_traditional ] = "蝋��祏�嘿ぃ��($Arg1)";
Text[ arabic ] = "Short name unknown during copying: ($Arg1)";
Text[ turkish ] = "Short name unknown during copying: ($Arg1)";
};
String S_LONGNAME_UNKNOWN
{
Text = "Kurzname Unbekannt beim Kopieren: ($Arg1)";
Text[ english_us ] = "Short name unknown during copying: ($Arg1)";
Text[ portuguese ] = "Abreviatura desconhecida ao copiar: ($Arg1)";
Text[ russian ] = "Short name unknown during copying: ($Arg1)";
Text[ greek ] = "Short name unknown during copying: ($Arg1)";
Text[ dutch ] = "Afkorting onbekend bij kopi雛en: ($Arg1)";
Text[ french ] = "Abr関iation inconnue lors de la copie : ($Arg1)";
Text[ spanish ] = "Abreviatura desconocida al copiar: ($Arg1)";
Text[ italian ] = "Short name unknown during copying: ($Arg1)";
Text[ danish ] = "Short name unknown during copying: ($Arg1)";
Text[ swedish ] = "Short name unknown during copying: ($Arg1)";
Text[ polish ] = "Skr髏 nazwy nieznany podczas kopiowania: ($Arg1)";
Text[ portuguese_brazilian ] = "Kurzname Unbekannt beim Kopieren: ($Arg1)";
Text[ japanese ] = "Short name unknown during copying: ($Arg1)";
Text[ korean ] = "汗荤登绰 悼救 舅荐 绝绰 陋篮 捞抚: ($Arg1)";
Text[ chinese_simplified ] = "复制时不明的简称:($Arg1)";
Text[ chinese_traditional ] = "蝋��祏�嘿ぃ��($Arg1)";
Text[ arabic ] = "Short name unknown during copying: ($Arg1)";
Text[ turkish ] = "Short name unknown during copying: ($Arg1)";
};
String S_FIRST_SHORTNAME_REQ_ASTRX
{
Text = "Erster Kurzname muss mit * beginnen. 躡erspringe.";
Text[ english_us ] = "First short name must start with * . Ignore.";
Text[ portuguese ] = "A primeira abreviatura dever� come鏰r com *. Ignorar.";
Text[ russian ] = "First short name must start with * . Leave out.";
Text[ greek ] = "First short name must start with * . Ignore.";
Text[ dutch ] = "Eerste afkorting moet beginnen met *. Overslaan.";
Text[ french ] = "La premi鑢e abr関iation doit commencer par *. Ignorer.";
Text[ spanish ] = "La primera abreviatura debe comenzar con *. Ignorar.";
Text[ italian ] = "First short name must start with * . Ignore.";
Text[ danish ] = "First short name must start with *. Ignore. ";
Text[ swedish ] = "First short name must start with * . Ignore.";
Text[ polish ] = "Pierwszy skr髏 nazwy musi si� zaczyna� na * . Omi�.";
Text[ portuguese_brazilian ] = "Erster Kurzname mu� mit * beginnen. 躡erspringe.";
Text[ japanese ] = "First short name must start with * . Ignore.";
Text[ korean ] = "霉锅掳 陋篮 捞抚篮 馆靛矫 * . Ignore苞 窃膊 矫累 登绢具 钦聪促.";
Text[ chinese_simplified ] = "第一个简称必须以 * 开头。省略。";
Text[ chinese_traditional ] = "材��祏�嘿ゲ斗� * 秨﹍�┛菠�";
Text[ arabic ] = "First short name must start with * . Leave out.";
Text[ turkish ] = "First short name must start with * . Ignore.";
};
String S_TIMOUT_WAITING
{
Text = "Server Timeout beim Warten auf Antwort. Sequenz Nr: ($Arg1)";
Text[ english_us ] = "Server Timeout while waiting for answer. Sequence No: ($Arg1)";
Text[ portuguese ] = "Server Timeout ao esperar pela resposta. Sequ阯cia n�: ($Arg1)";
Text[ russian ] = "Server Timeout while waiting for answer. Sequence No: ($Arg1)";
Text[ greek ] = "Server Timeout while waiting for answer. Sequence No: ($Arg1)";
Text[ dutch ] = "Server timeout bij het wachten op antwoord. Sequentie nr: ($Arg1)";
Text[ french ] = "Timeout du serveur lors de l'attente de la r閜onse. N� de s閝uence : ($Arg1)";
Text[ spanish ] = "Server Timeout al esperar por respuesta. Secuencia n鷐.: ($Arg1)";
Text[ italian ] = "Server Timeout while waiting for answer. Sequence No: ($Arg1)";
Text[ danish ] = "Server Timeout while waiting for answer. Sequence No: ($Arg1)";
Text[ swedish ] = "Server Timeout while waiting for answer. Sequence No: ($Arg1)";
Text[ polish ] = "Server Timeout podczas czekania na odpowied�. Numer sekwencji: ($Arg1)";
Text[ portuguese_brazilian ] = "Server Timeout beim Warten auf Antwort. Sequenz Nr: ($Arg1)";
Text[ japanese ] = "墳摎懸偪偺嵺偺话兽皞汤惭背膩B及馆絅o.: ($Arg1)";
Text[ korean ] = "览翠阑 扁促府绰 悼救 辑滚 鸥烙 酒眶. 老访 锅龋: ($Arg1)";
Text[ chinese_simplified ] = "在等候答复时服务器超时。序列号:($Arg1)";
Text[ chinese_traditional ] = "�狝竟单�氮蝋禬����腹絏� ($Arg1)";
Text[ arabic ] = "Server Timeout while waiting for answer. Sequence No: ($Arg1)";
Text[ turkish ] = "Server Timeout while waiting for answer. Sequence No: ($Arg1)";
};
String S_APPLICATION_RESTARTED
{
Text = "Applikation wurde neu gestartet.";
Text[ english_us ] = "Application has been restarted.";
Text[ portuguese ] = "A aplica玢o foi reiniciada.";
Text[ russian ] = "Application has been restarted.";
Text[ greek ] = "Application has been restarted.";
Text[ dutch ] = "Applicatie werd opnieuw gestart";
Text[ french ] = "L'application a 閠� red閙arr閑.";
Text[ spanish ] = "Se reinici� la aplicaci髇.";
Text[ italian ] = "Application has been restarted.";
Text[ danish ] = "Application has been restarted.";
Text[ swedish ] = "Application has been restarted.";
Text[ polish ] = "Aplikacja zosta砤 ponownie uruchomiona.";
Text[ portuguese_brazilian ] = "Applikation wurde neu gestartet.";
Text[ japanese ] = "碧哓拱籍輦蛵慕腊膫硞陚軅祩絹B";
Text[ korean ] = "览侩橇肺弊伐捞 促矫 矫累 登菌嚼聪促.";
Text[ chinese_simplified ] = "应用程序已经重新启动。";
Text[ chinese_traditional ] = "�穝币笆�莱ノ祘Α�";
Text[ arabic ] = "Application has been restarted.";
Text[ turkish ] = "Application has been restarted.";
};
String S_APPLICATION_START_FAILED
{
Text = "Applikation \"($Arg1)\" kann nicht gestartet werden. ";
Text[ english_us ] = "Application \"($Arg1)\" cannot be started. ";
Text[ portuguese ] = "Imposs韛el iniciar a aplica玢o \"($Arg1)\". ";
Text[ russian ] = "Application \"($Arg1)\" cannot be started. ";
Text[ greek ] = "Application \"($Arg1)\" cannot be started. ";
Text[ dutch ] = "Applicatie \"($Arg1)\" kan niet worden gestart. ";
Text[ french ] = "Impossible de lancer l'application \"($Arg1)\". ";
Text[ spanish ] = "No se puede iniciar la aplicaci髇 \"($Arg1)\". ";
Text[ italian ] = "Application \"($Arg1)\" cannot be started. ";
Text[ danish ] = "Application \"($Arg1)\" cannot be started. ";
Text[ swedish ] = "Application \"($Arg1)\" cannot be started. ";
Text[ polish ] = "Nie mo縩a uruchomi� aplikacji \"($Arg1)\". ";
Text[ portuguese_brazilian ] = "Applikation \"($Arg1)\" kann nicht gestartet werden. ";
Text[ japanese ] = "碧哓拱籍� \"($Arg1)\" 偼嚼澳偱偒傑偣傫丅 ";
Text[ korean ] = "览侩橇肺弊伐 \"($Arg1)\" 啊 矫累瞪荐 绝嚼聪促. ";
Text[ chinese_simplified ] = "无法启动应用程序“($Arg1)”。 ";
Text[ chinese_traditional ] = "礚猭币笆莱ノ祘Α \"($Arg1)\" � ";
Text[ arabic ] = "Application \"($Arg1)\" cannot be started. ";
Text[ turkish ] = "Application \"($Arg1)\" cannot be started. ";
};
String S_TIMOUT_SENDING
{
Text = "Server Timeout beim Senden. Sequenz Nr: ($Arg1)";
Text[ english_us ] = "Server Timeout while sending. Sequence No: ($Arg1)";
Text[ portuguese ] = "Server Timeout ao enviar. Sequ阯cia n�: ($Arg1)";
Text[ russian ] = "Server Timeout while sending. Sequence No: ($Arg1)";
Text[ greek ] = "Server Timeout while sending. Sequence No: ($Arg1)";
Text[ dutch ] = "Server timeout bij het zenden. Sequentie nr: ($Arg1)";
Text[ french ] = "Timeout du serveur lors de l'envoi. N� de s閝uence : ($Arg1)";
Text[ spanish ] = "Server Timeout al enviar. Secuencia n鷐.: ($Arg1)";
Text[ italian ] = "Server Timeout while sending. Sequence No: ($Arg1)";
Text[ danish ] = "Server Timeout while sending. Sequence No: ($Arg1)";
Text[ swedish ] = "Server Timeout while sending. Sequence No: ($Arg1)";
Text[ polish ] = "Server Timeout podczas wysy砤nia. Numer sekwencji: ($Arg1)";
Text[ portuguese_brazilian ] = "Server Timeout beim Senden. Sequenz Nr: ($Arg1)";
Text[ japanese ] = "憲怣偺嵺偺话兽皞汤惭背膩B及馆絅o.: ($Arg1)";
Text[ korean ] = "焊郴绰 悼救 辑滚 鸥烙 酒眶. 老访 锅龋: ($Arg1)";
Text[ chinese_simplified ] = "在寄发时服务器超时。序列号:($Arg1)";
Text[ chinese_traditional ] = "�狝竟祇癳�禬����腹絏� ($Arg1)";
Text[ arabic ] = "Server Timeout while sending. Sequence No: ($Arg1)";
Text[ turkish ] = "Server Timeout while sending. Sequence No: ($Arg1)";
};
String S_NO_CONNECTION
{
Text = "Keine Verbindung. Sequenz Nr: ($Arg1)";
Text[ english_us ] = "No connection. Sequence No: ($Arg1)";
Text[ portuguese ] = "Sem liga玢o. Sequ阯cia n�: ($Arg1)";
Text[ russian ] = "No connection. Sequence No: ($Arg1)";
Text[ greek ] = "No connection. Sequence No: ($Arg1)";
Text[ dutch ] = "Geen verbinding. Sequentie nr: ($Arg1)";
Text[ french ] = "Aucune connexion. N� de s閝uence : ($Arg1)";
Text[ spanish ] = "Sin conexi髇. Secuencia n鷐.: ($Arg1)";
Text[ italian ] = "No connection. Sequence No: ($Arg1)";
Text[ danish ] = "No connection. Sequence No: ($Arg1)";
Text[ swedish ] = "No connection. Sequence No: ($Arg1)";
Text[ polish ] = "Brak po彻czenia. Numer sekwencji: ($Arg1)";
Text[ portuguese_brazilian ] = "Keine Verbindung. Sequenz Nr: ($Arg1)";
Text[ japanese ] = "愙懕側偟丅及馆絅o.: ($Arg1)";
Text[ korean ] = "立加捞 救登菌嚼聪促. 老访锅龋: ($Arg1)";
Text[ chinese_simplified ] = "没有连接。序列号:($Arg1)";
Text[ chinese_traditional ] = "礚猭硈絬���腹絏�($Arg1)";
Text[ arabic ] = "No connection. Sequence No: ($Arg1)";
Text[ turkish ] = "No connection. Sequence No: ($Arg1)";
};
String S_NO_FILES_FOUND
{
Text = "Keine ($Arg1) Dateien gefunden";
Text[ english_us ] = "No ($Arg1) files found";
Text[ portuguese ] = "N鉶 foram encontrados quaisquer ficheiros ($Arg1)";
Text[ russian ] = "No ($Arg1) files found";
Text[ greek ] = "No ($Arg1) files found";
Text[ dutch ] = "Geen ($Arg1) bestanden gevonden";
Text[ french ] = "Aucun fichier ($Arg1) d閠ect�";
Text[ spanish ] = "No se encontr� ning鷑 archivo ($Arg1)";
Text[ italian ] = "No ($Arg1) files found";
Text[ danish ] = "No ($Arg1) files found";
Text[ swedish ] = "No ($Arg1) files found";
Text[ polish ] = "Nie znaleziono plik體 ($Arg1)";
Text[ portuguese_brazilian ] = "Keine ($Arg1) Dateien gefunden";
Text[ japanese ] = "($Arg1)抬操偼尒偮偐傝傑偣傫丅";
Text[ korean ] = "($Arg1) 颇老捞 惯斑登瘤 臼嚼聪促.";
Text[ chinese_simplified ] = "没有找到 ($Arg1) 文件";
Text[ chinese_traditional ] = "⊿Τт� ($Arg1) 郎�";
Text[ arabic ] = "No ($Arg1) files found";
Text[ turkish ] = "No ($Arg1) files found";
};
String S_ERRORS_DETECTED
{
Text = "** ($Arg1) Fehler aufgetreten";
Text[ english_us ] = "** ($Arg1) errors occurred";
Text[ portuguese ] = "** ($Arg1): erros ocorridos";
Text[ russian ] = "** ($Arg1) errors occurred";
Text[ greek ] = "** ($Arg1) errors occurred";
Text[ dutch ] = "** ($Arg1) fout opgetreden";
Text[ french ] = "** ($Arg1) : Erreurs survenues";
Text[ spanish ] = "** Ha ocurrido el error ($Arg1)";
Text[ italian ] = "** ($Arg1) errors occurred";
Text[ danish ] = "** ($Arg1) errors occurred";
Text[ swedish ] = "** ($Arg1) errors occurred";
Text[ polish ] = "** Wyst筽i硂 ($Arg1) b酬d體";
Text[ portuguese_brazilian ] = "** ($Arg1) Fehler aufgetreten";
Text[ japanese ] = "** ($Arg1) 偺醋皵瓙�";
Text[ korean ] = "** ($Arg1) 坷幅 惯积";
Text[ chinese_simplified ] = "发生了** ($Arg1) 错误";
Text[ chinese_traditional ] = "** ($Arg1) 岿粇";
Text[ arabic ] = "** ($Arg1) errors occurred";
Text[ turkish ] = "** ($Arg1) errors occurred";
};
String S_NO_ERRORS_DETECTED
{
Text = "** Keine Fehler aufgetreten";
Text[ english_us ] = "** No errors have occurred";
Text[ portuguese ] = "**N鉶 ocorreram erros";
Text[ russian ] = "** No errors have occurred";
Text[ greek ] = "** No errors have occurred";
Text[ dutch ] = "** Geen fouten opgetreden";
Text[ french ] = "** Aucune erreur n'est survenue";
Text[ spanish ] = "** No ha ocurrido ning鷑 error";
Text[ italian ] = "** No errors have occurred";
Text[ danish ] = "** No errors have occurred";
Text[ swedish ] = "** No errors have occurred";
Text[ polish ] = "** Nie wyst筽i硑 縜dne b酬dy";
Text[ portuguese_brazilian ] = "** Keine Fehler aufgetreten";
Text[ japanese ] = "** 醋皞葌�";
Text[ korean ] = "** 惯积等 坷幅啊 绝嚼聪促.";
Text[ chinese_simplified ] = "** 没有出现错误";
Text[ chinese_traditional ] = "** ⊿Τ�瞷岿粇";
Text[ arabic ] = "** No errors have occurred";
Text[ turkish ] = "** No errors have occurred";
};
String S_WARNINGS_DETECTED
{
Text = "** ($Arg1) Warnungen aufgetreten";
Text[ english_us ] = "** ($Arg1) warnings occurred";
Text[ portuguese ] = "** ($Arg1): erros ocorridos";
Text[ russian ] = "** ($Arg1) warnings occurred";
Text[ greek ] = "** ($Arg1) warnings occurred";
Text[ dutch ] = "** ($Arg1) waarschuwingen weergegeven";
Text[ french ] = "** ($Arg1) : Avertissements survenus";
Text[ spanish ] = "** Han aparecido las advertencias ($Arg1)";
Text[ italian ] = "** ($Arg1) warnings occurred";
Text[ danish ] = "** ($Arg1) warnings occurred";
Text[ swedish ] = "** ($Arg1) warnings occurred";
Text[ polish ] = "** Wyst筽i硂 ($Arg1) ostrze縠�";
Text[ portuguese_brazilian ] = "** ($Arg1) Warnungen aufgetreten";
Text[ japanese ] = "** ($Arg1) 偺寈崘敪惗";
Text[ korean ] = "** ($Arg1) 版绊 惯积";
Text[ chinese_simplified ] = "发生了** ($Arg1) 警告";
Text[ chinese_traditional ] = "** ($Arg1) 牡�";
Text[ arabic ] = "** ($Arg1) warnings occurred";
Text[ turkish ] = "** ($Arg1) warnings occurred";
};
String S_NO_WARNINGS_DETECTED
{
Text = "** Keine Warnungen aufgetreten";
Text[ english_us ] = "** No warnings have occurred";
Text[ portuguese ] = "**N鉶 ocorreram quaisquer erros";
Text[ russian ] = "** No warnings have occurred";
Text[ greek ] = "** No warnings have occurred";
Text[ dutch ] = "** Geen waarschuwingen weergegeven";
Text[ french ] = "** Aucun avertissement n'est survenu";
Text[ spanish ] = "** No han aparecido advertencias";
Text[ italian ] = "** No warnings have occurred";
Text[ danish ] = "** No warnings have occurred";
Text[ swedish ] = "** No warnings have occurred";
Text[ polish ] = "** Nie wyst筽i硑 縜dne ostrze縠nia";
Text[ portuguese_brazilian ] = "** Keine Warnungen aufgetreten";
Text[ japanese ] = "** 寈崘側偟";
Text[ korean ] = "** 惯积等 版绊啊 绝嚼聪促.";
Text[ chinese_simplified ] = "** 没有出现警告";
Text[ chinese_traditional ] = "** ⊿Τ牡�";
Text[ arabic ] = "** No warnings have occurred";
Text[ turkish ] = "** No warnings have occurred";
};
String S_INCLUDE_FILE_WARNINGS_DETECTED
{
Text = "** ($Arg1) Warnungen bei der Initialisierung aufgetreten";
Text[ english_us ] = "** ($Arg1) warnings occurred";
Text[ portuguese ] = "** ($Arg1): erros ocorridos";
Text[ russian ] = "** ($Arg1) warnings occurred";
Text[ greek ] = "** ($Arg1) warnings occurred";
Text[ dutch ] = "** ($Arg1) waarschuwingen weergegeven";
Text[ french ] = "** ($Arg1) : Avertissements survenus";
Text[ spanish ] = "** Han aparecido las advertencias ($Arg1)";
Text[ italian ] = "** ($Arg1) warnings occurred";
Text[ danish ] = "** ($Arg1) warnings occurred";
Text[ swedish ] = "** ($Arg1) warnings occurred";
Text[ polish ] = "** Wyst筽i硂 ($Arg1) ostrze縠�";
Text[ portuguese_brazilian ] = "** ($Arg1) Warnungen aufgetreten";
Text[ japanese ] = "** ($Arg1) 偺寈崘敪惗";
Text[ korean ] = "** ($Arg1) 版绊 惯积";
Text[ chinese_simplified ] = "发生了** ($Arg1) 警告";
Text[ chinese_traditional ] = "** ($Arg1) 牡�";
Text[ arabic ] = "** ($Arg1) warnings occurred";
Text[ turkish ] = "** ($Arg1) warnings occurred";
};
String S_NO_INCLUDE_FILE_WARNINGS_DETECTED
{
Text = "** Keine Warnungen bei der Initialisierung aufgetreten";
Text[ english_us ] = "** No warnings have occurred";
Text[ portuguese ] = "**N鉶 ocorreram quaisquer erros";
Text[ russian ] = "** No warnings have occurred";
Text[ greek ] = "** No warnings have occurred";
Text[ dutch ] = "** Geen waarschuwingen weergegeven";
Text[ french ] = "** Aucun avertissement n'est survenu";
Text[ spanish ] = "** No han aparecido advertencias";
Text[ italian ] = "** No warnings have occurred";
Text[ danish ] = "** No warnings have occurred";
Text[ swedish ] = "** No warnings have occurred";
Text[ polish ] = "** Nie wyst筽i硑 縜dne ostrze縠nia";
Text[ portuguese_brazilian ] = "** Keine Warnungen aufgetreten";
Text[ japanese ] = "** 寈崘側偟";
Text[ korean ] = "** 惯积等 版绊啊 绝嚼聪促.";
Text[ chinese_simplified ] = "** 没有出现警告";
Text[ chinese_traditional ] = "** ⊿Τ牡�";
Text[ arabic ] = "** No warnings have occurred";
Text[ turkish ] = "** No warnings have occurred";
};
String S_UNKNOWN_SLOT_CONTROL
{
Text = "Slot/Control unbekannt :\"($Arg1)\"";
Text[ english_us ] = "Slot/Control unknown :\"($Arg1)\"";
Text[ portuguese ] = "Slot/Control desconhecido :\"($Arg1)\"";
Text[ russian ] = "Slot/Control unknown :\"($Arg1)\"";
Text[ greek ] = "Slot/Control unknown :\"($Arg1)\"";
Text[ dutch ] = "Slot/Control onbekend :\"($Arg1)\"";
Text[ french ] = "Slot/Control inconnu : \"($Arg1)\"";
Text[ spanish ] = "Slot/Control desconocido :\"($Arg1)\"";
Text[ italian ] = "Slot/Control unknown :\"($Arg1)\"";
Text[ danish ] = "Slot/Control unknown :\"($Arg1)\"";
Text[ swedish ] = "Slot/Control unknown :\"($Arg1)\"";
Text[ polish ] = "Nieznany Slot/Control :\"($Arg1)\"";
Text[ portuguese_brazilian ] = "Slot/Control unbekannt :\"($Arg1)\"";
Text[ japanese ] = "桔�/狠嫩百偑傢偐傝傑偣傫:\"($Arg1)\"";
Text[ korean ] = "舅荐 绝绰 浇吩/牧飘费 :\"($Arg1)\"";
Text[ chinese_simplified ] = "不明的 Slot/Control:\"($Arg1)\"";
Text[ chinese_traditional ] = "Slot/Control ぃ��\"($Arg1)\"";
Text[ arabic ] = "Slot/Control unknown :\"($Arg1)\"";
Text[ turkish ] = "Slot/Control unknown :\"($Arg1)\"";
};
String S_RETURN_SEQUENCE_MISSMATCH
{
Text = "Return Stream mit falscher Sequenz: ($Arg1) statt ($Arg2)";
Text[ english_us ] = "Return Stream has wrong sequence: ($Arg1) instead of ($Arg2)";
Text[ portuguese ] = "Return Stream com sequ阯cia incorrecta: ($Arg1) em lugar de ($Arg2)";
Text[ russian ] = "Return Stream has wrong sequence: ($Arg1) instead of ($Arg2)";
Text[ greek ] = "Return Stream has wrong sequence: ($Arg1) instead of ($Arg2)";
Text[ dutch ] = "Return Stream met verkeerde sequentie: ($Arg1) in plaats van ($Arg2)";
Text[ french ] = "Return Stream avec une s閝uence erron閑 : ($Arg1) au lieu de ($Arg2)";
Text[ spanish ] = "Return Stream con secuencia falsa: ($Arg1) en vez de ($Arg2)";
Text[ italian ] = "Return Stream has wrong sequence: ($Arg1) instead of ($Arg2)";
Text[ danish ] = "Return Stream has wrong sequence: ($Arg1) instead of ($Arg2)";
Text[ swedish ] = "Return Stream has wrong sequence: ($Arg1) instead of ($Arg2)";
Text[ polish ] = "Return Stream o nieprawid硂wej sekwencji: ($Arg1) zamiast ($Arg2)";
Text[ portuguese_brazilian ] = "Return Stream mit falscher Sequenz: ($Arg1) statt ($Arg2)";
Text[ japanese ] = "乩拜侥匕褌碳肮萁偑娫堘偭偰偄傑偡: ($Arg2) 偱側偔 ($Arg1)";
Text[ korean ] = "撇赴 老访 锅龋甫 瘤囱 府畔 胶飘覆: ($Arg2) 措脚 ($Arg1)";
Text[ chinese_simplified ] = "含有错误序列的返回信息流:($Arg1) 代替($Arg2)";
Text[ chinese_traditional ] = "��计誹瑈���岿粇�($Arg1)� 莱赣琌 ($Arg2)";
Text[ arabic ] = "Return Stream has wrong sequence: ($Arg1) instead of ($Arg2)";
Text[ turkish ] = "Return Stream has wrong sequence: ($Arg1) instead of ($Arg2)";
};
String S_RETURNED_VALUE_ID_MISSMATCH
{
Text = "Returnwert Empfangen aber andere Id erwartet";
Text[ english_us ] = "Return value received but different Id expected";
Text[ portuguese ] = "Recebido o valor Return, mas espera-se outro ID";
Text[ russian ] = "Return value received but different Id expected";
Text[ greek ] = "Return value received but different Id expected";
Text[ dutch ] = "Retourwaarde ontvangen echter andere Id verwacht";
Text[ french ] = "Valeur de renvoi re鐄e mais attente d'un autre ID";
Text[ spanish ] = "Recibido Valor Return, pero se esperaba otro Id";
Text[ italian ] = "Return value received but different Id expected";
Text[ danish ] = "Return value received but different Id expected";
Text[ swedish ] = "Return value received but different Id expected";
Text[ polish ] = "Odebrano warto滄 return, ale oczekiwane jest inne ID";
Text[ portuguese_brazilian ] = "Returnwert Empfangen aber andere Id erwartet";
Text[ japanese ] = "乩拜抣傪庴偗庢傝傑偟偨偑丄暿偺Id偑昁梫偱偡丅";
Text[ korean ] = "荐脚狼 府畔蔼捞 促弗 Id甫 扁措窃";
Text[ chinese_simplified ] = "返回值接收期待的是其它的 Id(标识符)";
Text[ chinese_traditional ] = "钡Μ������琌戳�琌ㄤウ Id";
Text[ arabic ] = "Return value received but different Id expected";
Text[ turkish ] = "Return value received but different Id expected";
};
String S_RETURNED_VALUE_NO_RECEIVER
{
Text = "Returnwert Empfangen aber kein Empf鋘ger definiert";
Text[ english_us ] = "Return value received but receiver not defined";
Text[ portuguese ] = "Recebido o valor Return, mas o destinat醨io n鉶 foi definido";
Text[ russian ] = "Return value received but receiver not defined";
Text[ greek ] = "Return value received but receiver not defined";
Text[ dutch ] = "Retourwaarde ontvangen echter geen ontvanger gedefinieerd";
Text[ french ] = "Valeur de renvoi re鐄e mais aucun destinataire d閒ini";
Text[ spanish ] = "Recibido valor Return sin definici髇 de destinatario";
Text[ italian ] = "Return value received but receiver not defined";
Text[ danish ] = "Return value received but receiver not defined";
Text[ swedish ] = "Return value received but receiver not defined";
Text[ polish ] = "Odebrano warto滄 return, ale brak zdefiniowanego odbiorcy";
Text[ portuguese_brazilian ] = "Returnwert Empfangen aber kein Empf鋘ger definiert";
Text[ japanese ] = "乩拜抣傪庴偗庢傝傑偟偨偑丄庴怣幰偑寛掕偱偒傑偣傫丅";
Text[ korean ] = "荐脚狼 府畔蔼俊 荐脚牢捞 沥狼登瘤 臼澜";
Text[ chinese_simplified ] = "返回值接收没有指定接收者";
Text[ chinese_traditional ] = "钡Μ������琌⊿Τ�﹚钡Μヘ夹�";
Text[ arabic ] = "Return value received but receiver not defined";
Text[ turkish ] = "Return value received but receiver not defined";
};
String S_UNKNOWN_METHOD
{
Text = "Unbekannte Methode an Objekt : ($Arg1).($Arg2)";
Text[ english_us ] = "Unknown method on object :($Arg1).($Arg2)";
Text[ portuguese ] = "M閠odo desconhecido ($Arg1) para ($Arg2)";
Text[ russian ] = "Unknown method '($Arg1)' to ($Arg2)";
Text[ greek ] = "Unknown method on object :($Arg1).($Arg2)";
Text[ dutch ] = "Onbekende methode aan object: ($Arg1).($Arg2)";
Text[ french ] = "M閠hode inconnue vers l'objet : ($Arg1).($Arg2)";
Text[ spanish ] = "M閠odo desconocido ($Arg1) a ($Arg2)";
Text[ italian ] = "Unknown method '($Arg1)' to ($Arg2)";
Text[ danish ] = "Unknown method on object: ($Arg1).($Arg2)";
Text[ swedish ] = "Unknown method '($Arg1)' to ($Arg2)";
Text[ polish ] = "Nieznana metoda do obiektu: ($Arg1).($Arg2)";
Text[ portuguese_brazilian ] = "Unbekannte Methode an Objekt : ($Arg1).($Arg2)";
Text[ japanese ] = "Unknown method '($Arg1)' to ($Arg2)";
Text[ korean ] = "俺眉俊 舅荐 绝绰 皋家靛 : ($Arg1).($Arg2)";
Text[ chinese_simplified ] = "Unknown method on object:($Arg1).($Arg2)";
Text[ chinese_traditional ] = "�ンよΑぃ�� ($Arg1).($Arg2)";
Text[ arabic ] = "Unknown method '($Arg1)' to ($Arg2)";
Text[ turkish ] = "Unknown method on object :($Arg1).($Arg2)";
};
/*
String
{
Text = ;
};
String
{
Text = ;
};
String
{
Text = ;
};
String
{
Text = ;
};
String
{
Text = ;
};
String
{
Text = ;
};
String
{
Text = ;
};
String
{
Text = ;
};
*/
+71
View File
@@ -0,0 +1,71 @@
/*************************************************************************
*
* $RCSfile: basmgr.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <basmgr.hxx>
TYPEINIT1( BasicManager, SfxBroadcaster );
DBG_NAME( BasicManager );
BasicManager::~BasicManager()
{
}
+82
View File
@@ -0,0 +1,82 @@
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1.1.1 $
#
# last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library 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 for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJNAME=BASIC
TARGET=basicmgr
# --- Settings -----------------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- Allgemein -----------------------------------------------------------
CXXFILES = basmgr.cxx
SLOFILES= $(SLO)$/basmgr.obj
# --- Targets -------------------------------------------------------------
.INCLUDE : target.mk
+701
View File
@@ -0,0 +1,701 @@
/*************************************************************************
*
* $RCSfile: disas.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdio.h>
#include <string.h>
#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif
#pragma hdrstop
#include <svtools/sbx.hxx>
#include "sb.hxx"
#include "iosys.hxx"
#include "disas.hxx"
// Makro MEMBER()
#include "macfix.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBDISAS, SBDISAS_CODE )
static const char* pOp1[] = {
"NOP",
// Operatoren
// die folgenden Operatoren sind genauso angeordnet
// wie der enum SbxVarOp
"EXP", "MUL", "DIV", "MOD", "PLUS", "MINUS", "NEG",
"EQ", "NE", "LT", "GT", "LE", "GE",
"IDIV", "AND", "OR", "XOR", "EQV", "IMP", "NOT",
"CAT",
// Ende enum SbxVarOp
"LIKE", "IS",
// Laden/speichern
"ARGC", // neuen Argv einrichten
"ARGV", // TOS ==> aktueller Argv
"INPUT", // Input ==> TOS
"LINPUT", // Line Input ==> TOS
"GET", // TOS anfassen
"SET", // Speichern Objekt TOS ==> TOS-1
"PUT", // TOS ==> TOS-1
"CONST", // TOS ==> TOS-1, dann ReadOnly
"DIM", // DIM
"REDIM", // REDIM
"REDIMP", // REDIM PRESERVE
"ERASE", // TOS loeschen
// Verzweigen
"STOP", // Programmende
"INITFOR", // FOR-Variable initialisieren
"NEXT", // FOR-Variable inkrementieren
"CASE", // Anfang CASE
"ENDCASE", // Ende CASE
"STDERR", // Standard-Fehlerbehandlung
"NOERROR", // keine Fehlerbehandlung
"LEAVE", // UP verlassen
// E/A
"CHANNEL", // TOS = Kanalnummer
"PRINT", // print TOS
"PRINTF", // print TOS in field
"WRITE", // write TOS
"RENAME", // Rename Tos+1 to Tos
"PROMPT", // TOS = Prompt for Input
"RESTART", // Restartpunkt definieren
"STDIO", // E/A-Kanal 0 einstellen
// Sonstiges
"EMPTY", // Leeren Ausdruck auf Stack
"ERROR", // TOS = Fehlercode
"LSET", // Speichern Objekt TOS ==> TOS-1
"RSET" // Speichern Objekt TOS ==> TOS-1
};
static const char* pOp2[] = {
"NUMBER", // Laden einer numerischen Konstanten (+ID)
"STRING", // Laden einer Stringkonstanten (+ID)
"CONST", // Immediate Load (+Wert)
"ARGN", // Speichern eines named Args in Argv (+StringID)
"PAD", // String auf feste Laenge bringen (+Laenge)
// Verzweigungen
"JUMP", // Sprung (+Target)
"JUMP.T", // TOS auswerten, bedingter Sprung (+Target)
"JUMP.F", // TOS auswerten, bedingter Sprung (+Target)
"ONJUMP", // TOS auswerten, Sprung in JUMP-Tabelle (+MaxVal)
"GOSUB", // UP-Aufruf (+Target)
"RETURN", // UP-Return (+0 oder Target)
"TESTFOR", // FOR-Variable testen, inkrementieren (+Endlabel)
"CASETO", // Tos+1 <= Case <= Tos, 2xremove (+Target)
"ERRHDL", // Fehler-Handler (+Offset)
"RESUME", // Resume nach Fehlern (+0 or 1 or Label)
// E/A
"CLOSE", // (+Kanal/0)
"PRCHAR", // (+char)
// Objekte
"CLASS", // Klassennamen testen (+StringId)
"LIB", // Libnamen fuer Declare-Procs setzen (+StringId)
// Neues ab Beta 3
"BASED", // TOS wird um BASE erhoeht, BASE davor gepusht
"ARGTYP", // Letzten Parameter in Argv konvertieren (+Typ)
};
static const char* pOp3[] = {
// Alle Opcodes mit zwei Operanden
"RTL", // Laden aus RTL (+StringID+Typ)
"FIND", // Laden (+StringID+Typ)
"ELEM", // Laden Element (+StringID+Typ)
"PARAM", // Parameter (+Offset+Typ)
// Verzweigen
"CALL", // DECLARE-Methode rufen (+StringID+Typ)
"CALL.C", // Cdecl-DECLARE-Methode rufen (+StringID+Typ)
"CASEIS", // Case-Test (+Test-Opcode+False-Target)
"STMNT", // Beginn eines Statements (+Line+Col)
// E/A
"OPEN", // (+SvStreamFlags+Flags)
// Objekte und Variable
"LOCAL", // Lokale Variable (+StringID+Typ)
"PUBLIC", // Modulglobale Variable (+StringID+Typ)
"GLOBAL", // Globale Variable (+StringID+Typ)
"CREATE", // Objekt kreieren (+StringId+StringId)
"STATIC", // Objekt kreieren (+StringId+StringId)
"TCREATE", // User defined Objekt kreieren (+StringId+StringId)
"DCREATE", // User defined Objekt-Array kreieren (+StringId+StringId)
};
static const char** pOps[3] = { pOp1, pOp2, pOp3 };
typedef void( SbiDisas::*Func )( String& ); // Verarbeitungsroutine
static const Func pOperand2[] = {
MEMBER(SbiDisas::StrOp), // Laden einer numerischen Konstanten (+ID)
MEMBER(SbiDisas::StrOp), // Laden einer Stringkonstanten (+ID)
MEMBER(SbiDisas::ImmOp), // Immediate Load (+Wert)
MEMBER(SbiDisas::StrOp), // Speichern eines benannten Arguments(+ID)
MEMBER(SbiDisas::ImmOp), // String auf feste Laenge bringen (+Laenge)
// Verzweigungen
MEMBER(SbiDisas::LblOp), // Sprung (+Target)
MEMBER(SbiDisas::LblOp), // TOS auswerten), bedingter Sprung (+Target)
MEMBER(SbiDisas::LblOp), // TOS auswerten), bedingter Sprung (+Target)
MEMBER(SbiDisas::OnOp), // TOS auswerten), Sprung in JUMP-Tabelle (+MaxVal)
MEMBER(SbiDisas::LblOp), // UP-Aufruf (+Target)
MEMBER(SbiDisas::ReturnOp), // UP-Return (+0 oder Target)
MEMBER(SbiDisas::LblOp), // FOR-Variable testen), inkrementieren (+Endlabel)
MEMBER(SbiDisas::LblOp), // Tos+1 <= Case <= Tos), 2xremove (+Target)
MEMBER(SbiDisas::LblOp), // Fehler-Handler (+Offset)
MEMBER(SbiDisas::ResumeOp), // Resume nach Fehlern (+0 or 1 or Label)
// E/A
MEMBER(SbiDisas::CloseOp), // (+Kanal/0)
MEMBER(SbiDisas::CharOp), // (+char)
// Objekte
MEMBER(SbiDisas::StrOp), // Klassennamen testen (+StringId)
MEMBER(SbiDisas::StrOp), // Libnamen fuer Declare-Procs setzen (+StringId)
MEMBER(SbiDisas::ImmOp), // TOS wird um BASE erhoeht, BASE davor gepusht
MEMBER(SbiDisas::TypeOp), // Letzten Parameter in Argv konvertieren (+Typ)
};
static const Func pOperand3[] = {
// Alle Opcodes mit zwei Operanden
MEMBER(SbiDisas::VarOp), // Laden aus RTL (+StringID+Typ)
MEMBER(SbiDisas::VarOp), // Laden (+StringID+Typ)
MEMBER(SbiDisas::VarOp), // Laden Element (+StringID+Typ)
MEMBER(SbiDisas::OffOp), // Parameter (+Offset+Typ)
// Verzweigen
MEMBER(SbiDisas::VarOp), // DECLARE-Methode rufen (+StringID+Typ)
MEMBER(SbiDisas::VarOp), // CDecl-DECLARE-Methode rufen (+StringID+Typ)
MEMBER(SbiDisas::CaseOp), // Case-Test (+Test-Opcode+False-Target)
MEMBER(SbiDisas::StmntOp), // Statement (+Zeilen+Spalte)
// E/A
MEMBER(SbiDisas::StrmOp), // (+SvStreamFlags+Flags)
// Objekte
MEMBER(SbiDisas::VarDefOp), // Lokale Variable definieren (+StringID+Typ)
MEMBER(SbiDisas::VarDefOp), // Modulglobale Variable definieren (+StringID+Typ)
MEMBER(SbiDisas::VarDefOp), // Globale Variable definieren (+StringID+Typ)
MEMBER(SbiDisas::Str2Op), // Objekt kreieren (+StringId+StringId)
MEMBER(SbiDisas::VarDefOp), // Statische Variable definieren (+StringID+Typ)
MEMBER(SbiDisas::Str2Op), // User defined Objekt kreieren (+StringId+StringId)
MEMBER(SbiDisas::Str2Op), // User defined Objekt-Array kreieren (+StringId+StringId)
};
static const char* _crlf()
{
#if defined (MAC)
return "\n";
#elif defined (UNX) || defined( PM2 )
return "\n";
#else
return "\r\n";
#endif
}
// Diese Methode ist hier, damit die Datei als eigenes Segment geladen werden
// kann.
BOOL SbModule::Disassemble( String& rText )
{
rText.Erase();
if( pImage )
{
SbiDisas aDisas( this, pImage );
aDisas.Disas( rText );
}
return BOOL( rText.Len() != 0 );
}
SbiDisas::SbiDisas( SbModule* p, const SbiImage* q ) : rImg( *q ), pMod( p )
{
memset( cLabels, 0, 8192 );
nLine = nOff = nPC = nOp1 = nOp2 = nParts = 0;
eOp = _NOP;
// Label-Bits setzen
USHORT nPos;
nOff = 0;
while( Fetch() )
{
BOOL bLbl = FALSE;
switch( eOp )
{
case _RESUME: if( nOp1 <= 1 ) break;
case _RETURN: if( !nOp1 ) break;
case _JUMP:
case _JUMPT:
case _JUMPF:
case _GOSUB:
case _TESTFOR:
case _CASEIS:
case _CASETO:
case _ERRHDL: nPos = nOp1; bLbl = TRUE; break;
}
if( bLbl )
cLabels[ nPos >> 3 ] |= ( 1 << ( nPos & 7 ) );
}
nOff = 0;
// Die Publics noch dazu
for( USHORT i = 0; i < pMod->GetMethods()->Count(); i++ )
{
SbMethod* pMeth = PTR_CAST(SbMethod,pMod->GetMethods()->Get( i ));
if( pMeth )
{
nPos = pMeth->GetId();
cLabels[ nPos >> 3 ] |= ( 1 << ( nPos & 7 ) );
}
}
}
// Aktuellen Opcode auslesen
BOOL SbiDisas::Fetch()
{
nPC = nOff;
if( nOff >= rImg.GetCodeSize() )
return FALSE;
const char* p = rImg.GetCode() + nOff;
eOp = (SbiOpcode) ( *p++ & 0xFF );
if( eOp <= SbOP0_END )
{
nOp1 = nOp2 = 0;
nParts = 1;
nOff++;
return TRUE;
}
else if( eOp <= SbOP1_END )
{
nOff += 3;
if( nOff > rImg.GetCodeSize() )
return FALSE;
nOp1 = *p++ & 0xFF; nOp1 |= *p << 8;
nParts = 2;
return TRUE;
}
else if( eOp <= SbOP2_END )
{
nOff += 5;
if( nOff > rImg.GetCodeSize() )
return FALSE;
nOp1 = *p++ & 0xFF; nOp1 |= *p++ << 8;
nOp2 = *p++ & 0xFF; nOp2 |= *p << 8;
nParts = 3;
return TRUE;
}
else
return FALSE;
}
void SbiDisas::Disas( SvStream& r )
{
String aText;
nOff = 0;
while( DisasLine( aText ) )
{
ByteString aByteText( aText, gsl_getSystemTextEncoding() );
r.WriteLine( aByteText );
}
}
void SbiDisas::Disas( String& r )
{
r.Erase();
String aText;
nOff = 0;
while( DisasLine( aText ) )
{
r += aText;
r.AppendAscii( _crlf() );
}
aText.ConvertLineEnd();
}
#ifdef HP9000
const char* SbiDisas_DisasLine_pMask[] = {
"%04X ",
"%04X %02X ",
"%04X %02X %04X ",
"%04X %02X %04X %04X " };
#define pMask SbiDisas_DisasLine_pMask
#endif
BOOL SbiDisas::DisasLine( String& rText )
{
char cBuf[ 30 ];
#ifndef HP9000
const char* pMask[] = {
"%04X ",
"%04X %02X ",
"%04X %02X %04X ",
"%04X %02X %04X %04X " };
#endif
rText.Erase();
if( !Fetch() )
return FALSE;
// Neue Zeile?
if( eOp == _STMNT && (short) nOp1 != nLine )
{
// Zeile raussuchen
USHORT n = 0, l = nLine = nOp1;
while( --l ) {
n = rImg.aSource.SearchAscii( "\n", n );
if( n == STRING_NOTFOUND ) break;
else n++;
}
// Stelle anzeigen
if( n != STRING_NOTFOUND )
{
USHORT n2 = rImg.aSource.SearchAscii( "\n", n );
if( n2 == STRING_NOTFOUND ) n2 = rImg.aSource.Len() - n;
String s( rImg.aSource.Copy( n, n2 - n + 1 ) );
BOOL bDone;
do {
bDone = TRUE;
n = s.Search( '\r' );
if( n != STRING_NOTFOUND ) bDone = FALSE, s.Erase( n, 1 );
n = s.Search( '\n' );
if( n != STRING_NOTFOUND ) bDone = FALSE, s.Erase( n, 1 );
} while( !bDone );
// sprintf( cBuf, pMask[ 0 ], nPC );
// rText += cBuf;
rText.AppendAscii( "; " );
rText += s;
rText.AppendAscii( _crlf() );
}
}
// Label?
const char* p = "";
if( cLabels[ nPC >> 3 ] & ( 1 << ( nPC & 7 ) ) )
{
// Public?
ByteString aByteMethName;
for( USHORT i = 0; i < pMod->GetMethods()->Count(); i++ )
{
SbMethod* pMeth = PTR_CAST(SbMethod,pMod->GetMethods()->Get( i ));
if( pMeth )
{
aByteMethName = ByteString( pMeth->GetName(), gsl_getSystemTextEncoding() );
if( pMeth->GetId() == nPC )
{
p = aByteMethName.GetBuffer();
break;
}
if( pMeth->GetId() >= nPC )
break;
}
}
sprintf( cBuf, pMask[ 0 ], nPC );
rText.AppendAscii( cBuf );
if( p && *p )
{
rText.AppendAscii( p );
}
else
{
sprintf( cBuf, "Lbl%04X", nPC );
rText.AppendAscii( cBuf );
}
rText += ':';
rText.AppendAscii( _crlf() );
}
sprintf( cBuf, pMask[ nParts ], nPC, (USHORT) eOp, nOp1, nOp2 );
rText.AppendAscii( cBuf );
short n = eOp;
if( eOp >= SbOP2_START )
n -= SbOP2_START;
else if( eOp >= SbOP1_START )
n -= SbOP1_START;
rText += '\t';
rText.AppendAscii( pOps[ nParts-1 ][ n ] );
rText += '\t';
switch( nParts )
{
case 2: (this->*( pOperand2[ n ] ) )( rText ); break;
case 3: (this->*( pOperand3[ n ] ) )( rText ); break;
}
return TRUE;
}
#ifdef HP9000
#undef pMask
#endif
// Auslesen aus StringPool
void SbiDisas::StrOp( String& rText )
{
String aStr = rImg.GetString( nOp1 );
const char* p = ByteString( aStr, gsl_getSystemTextEncoding() ).GetBuffer();
if( p )
{
rText += '"';
rText.AppendAscii( p );
rText += '"';
}
else
{
rText.AppendAscii( "?String? " );
rText += nOp1;
}
}
void SbiDisas::Str2Op( String& rText )
{
StrOp( rText );
rText += ',';
String s;
nOp1 = nOp2;
StrOp( s );
rText += s;
}
// Immediate Operand
void SbiDisas::ImmOp( String& rText )
{
rText += nOp1;
}
// OnGoto Operand
void SbiDisas::OnOp( String& rText )
{
rText += nOp1 & 0x7FFF;
if( nOp1 & 0x800 )
rText.AppendAscii( "\t; Gosub" );
}
// Label
void SbiDisas::LblOp( String& rText )
{
char cBuf[ 10 ];
sprintf( cBuf, "Lbl%04X", nOp1 );
rText.AppendAscii( cBuf );
}
// 0 oder Label
void SbiDisas::ReturnOp( String& rText )
{
if( nOp1 )
LblOp( rText );
}
// 0, 1 oder Label
void SbiDisas::ResumeOp( String& rText )
{
switch( nOp1 )
{
case 1: rText.AppendAscii( "NEXT" ); break;
case 2: LblOp( rText );
}
}
// Prompt ausgeben
// FALSE/TRUE
void SbiDisas::PromptOp( String& rText )
{
if( nOp1 )
rText.AppendAscii( "\"? \"" );
}
// 0 oder 1
void SbiDisas::CloseOp( String& rText )
{
rText.AppendAscii( nOp1 ? "Channel" : "All" );
}
// Zeichen ausgeben
void SbiDisas::CharOp( String& rText )
{
const char* p = NULL;
switch( nOp1 )
{
case 7: p = "'\\a'"; break;
case 9: p = "'\\t'"; break;
case 10: p = "'\\n'"; break;
case 12: p = "'\\f'"; break;
case 13: p = "'\\r'"; break;
}
if( p ) rText.AppendAscii( p );
else if( nOp1 >= ' ' )
rText += '\'',
rText += (char) nOp1,
rText += '\'';
else
rText.AppendAscii( "char " ),
rText += nOp1;
}
// Variable ausgeben: String-ID und Typ
void SbiDisas::VarOp( String& rText )
{
rText += rImg.GetString( nOp1 & 0x7FFF );
rText.AppendAscii( "\t; " );
// Der Typ
USHORT n = nOp1;
nOp1 = nOp2;
TypeOp( rText );
if( n & 0x8000 )
rText.AppendAscii( ", Args" );
}
// Variable definieren: String-ID und Typ
void SbiDisas::VarDefOp( String& rText )
{
rText += rImg.GetString( nOp1 );
rText.AppendAscii( "\t; " );
// Der Typ
USHORT n = nOp1;
nOp1 = nOp2;
TypeOp( rText );
}
// Variable ausgeben: Offset und Typ
void SbiDisas::OffOp( String& rText )
{
rText += ( nOp1 & 0x7FFF );
rText.AppendAscii( "\t; " );
// Der Typ
USHORT n = nOp1;
nOp1 = nOp2;
TypeOp( rText );
if( n & 0x8000 )
rText.AppendAscii( ", Args" );
}
// Datentyp
#ifdef HP9000
static char* SbiDisas_TypeOp_pTypes[13] = {
"Empty","Null","Integer","Long","Single","Double",
"Currency","Date","String","Object","Error","Boolean",
"Variant" };
#define pTypes SbiDisas_TypeOp_pTypes
#endif
void SbiDisas::TypeOp( String& rText )
{
// AB 19.1.96: Typ kann Flag für BYVAL enthalten (StepARGTYP)
if( nOp1 & 0x8000 )
{
nOp1 &= 0x7FFF; // Flag wegfiltern
rText.AppendAscii( "BYVAL " );
}
if( nOp1 < 13 )
{
#ifndef HP9000
static char* pTypes[13] = {
"Empty","Null","Integer","Long","Single","Double",
"Currency","Date","String","Object","Error","Boolean",
"Variant" };
#endif
rText.AppendAscii( pTypes[ nOp1 ] );
}
else
{
rText.AppendAscii( "type " );
rText += nOp1;
}
}
#ifdef HP9000
#undef pTypes
#endif
// TRUE-Label, Bedingungs-Opcode
void SbiDisas::CaseOp( String& rText )
{
LblOp( rText );
rText += ',';
rText.AppendAscii( pOp1[ nOp2 - SbxEQ + _EQ ] );
}
// Zeile, Spalte
void SbiDisas::StmntOp( String& rText )
{
rText += nOp1;
rText += ',';
USHORT nCol = nOp2 & 0xFF;
USHORT nFor = nOp2 / 0x100;
rText += nCol;
rText.AppendAscii( " (For-Level: " );
rText += nFor;
rText += ')';
}
// open mode, flags
void SbiDisas::StrmOp( String& rText )
{
char cBuf[ 10 ];
sprintf( cBuf, "%04X", nOp1 );
rText.AppendAscii( cBuf );
if( nOp2 & SBSTRM_INPUT )
rText.AppendAscii( ", Input" );
if( nOp2 & SBSTRM_OUTPUT )
rText.AppendAscii( ", Output" );
if( nOp2 & SBSTRM_APPEND )
rText.AppendAscii( ", Append" );
if( nOp2 & SBSTRM_RANDOM )
rText.AppendAscii( ", Random" );
if( nOp2 & SBSTRM_BINARY )
rText.AppendAscii( ", Binary" );
}
+431
View File
@@ -0,0 +1,431 @@
/*************************************************************************
*
* $RCSfile: image.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif
#pragma hdrstop
#include <svtools/sbx.hxx>
#include "sb.hxx"
#include <string.h> // memset() etc
#include "image.hxx"
#include "filefmt.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBASIC, SBASIC_CODE )
SbiImage::SbiImage()
{
rTypes = new SbxArray;
pStringOff = NULL;
pStrings = NULL;
pCode = NULL;
nFlags =
nStrings =
nStringSize=
nCodeSize =
nDimBase = 0;
bInit =
bError = FALSE;
eCharSet = gsl_getSystemTextEncoding();
}
SbiImage::~SbiImage()
{
Clear();
}
void SbiImage::Clear()
{
delete pStringOff;
delete pStrings;
delete pCode;
pStringOff = NULL;
pStrings = NULL;
pCode = NULL;
nFlags =
nStrings =
nStringSize=
nCodeSize = 0;
eCharSet = gsl_getSystemTextEncoding();
nDimBase = 0;
bError = FALSE;
}
/**************************************************************************
*
* Service-Routinen fuer das Laden und Speichern
*
**************************************************************************/
BOOL SbiGood( SvStream& r )
{
return BOOL( !r.IsEof() && r.GetError() == SVSTREAM_OK );
}
// Oeffnen eines Records
ULONG SbiOpenRecord( SvStream& r, UINT16 nSignature, UINT16 nElem )
{
ULONG nPos = r.Tell();
r << nSignature << (INT32) 0 << nElem;
return nPos;
}
// Schliessen eines Records
void SbiCloseRecord( SvStream& r, ULONG nOff )
{
ULONG nPos = r.Tell();
r.Seek( nOff + 2 );
r << (INT32) ( nPos - nOff - 8 );
r.Seek( nPos );
}
/**************************************************************************
*
* Laden und Speichern
*
**************************************************************************/
// Falls die Versionsnummer nicht passt, werden die binaeren Teile
// nicht geladen, wohl aber Source, Kommentar und Name.
BOOL SbiImage::Load( SvStream& r )
{
UINT16 nSign, nCount;
UINT32 nLen, nOff;
Clear();
ULONG nStart = r.Tell();
// Master-Record einlesen
r >> nSign >> nLen >> nCount;
ULONG nLast = r.Tell() + nLen;
UINT32 nVersion = 0; // Versionsnummer
UINT32 nCharSet; // System-Zeichensatz
UINT32 lDimBase;
UINT16 nReserved1;
UINT32 nReserved2;
UINT32 nReserved3;
BOOL bBadVer = FALSE;
if( nSign == B_MODULE )
{
r >> nVersion >> nCharSet >> lDimBase
>> nFlags >> nReserved1 >> nReserved2 >> nReserved3;
eCharSet = (CharSet) nCharSet;
bBadVer = BOOL( nVersion != B_CURVERSION );
nDimBase = (USHORT) lDimBase;
}
ULONG nNext;
while( ( nNext = r.Tell() ) < nLast )
{
short i;
r >> nSign >> nLen >> nCount;
nNext += nLen + 8;
if( r.GetError() == SVSTREAM_OK )
switch( nSign )
{
case B_NAME:
r.ReadByteString( aName, eCharSet );
//r >> aName;
break;
case B_COMMENT:
r.ReadByteString( aComment, eCharSet );
//r >> aComment;
break;
case B_SOURCE:
r.ReadByteString( aSource, eCharSet );
//r >> aSource;
break;
case B_PCODE:
if( bBadVer ) break;
pCode = new char[ nLen ];
nCodeSize = (USHORT) nLen;
r.Read( pCode, nCodeSize );
break;
case B_PUBLICS:
case B_POOLDIR:
case B_SYMPOOL:
case B_LINERANGES:
break;
case B_STRINGPOOL:
if( bBadVer ) break;
MakeStrings( nCount );
for( i = 0; i < nStrings && SbiGood( r ); i++ )
{
r >> nOff;
pStringOff[ i ] = (USHORT) nOff;
}
r >> nLen;
if( SbiGood( r ) )
{
delete pStrings;
pStrings = new sal_Unicode[ nLen ];
nStringSize = (USHORT) nLen;
char* pByteStrings = new char[ nLen ];
r.Read( pByteStrings, nStringSize );
for( short i = 0; i < nStrings; i++ )
{
USHORT nOff = pStringOff[ i ];
String aStr( pByteStrings + nOff, eCharSet );
memcpy( pStrings + nOff, aStr.GetBuffer(), (aStr.Len() + 1) * sizeof( sal_Unicode ) );
}
delete pByteStrings;
} break;
case B_MODEND:
goto done;
default:
break;
}
else
break;
r.Seek( nNext );
}
done:
r.Seek( nLast );
//if( eCharSet != ::GetSystemCharSet() )
//ConvertStrings();
if( !SbiGood( r ) )
bError = TRUE;
return BOOL( !bError );
}
BOOL SbiImage::Save( SvStream& r )
{
// Erst mal der Header:
ULONG nStart = SbiOpenRecord( r, B_MODULE, 1 );
ULONG nPos;
r << (INT32) B_CURVERSION
<< (INT32) eCharSet
<< (INT32) nDimBase
<< (INT16) nFlags
<< (INT16) 0
<< (INT32) 0
<< (INT32) 0;
// Name?
if( aName.Len() && SbiGood( r ) )
{
nPos = SbiOpenRecord( r, B_NAME, 1 );
r.WriteByteString( aName, eCharSet );
//r << aName;
SbiCloseRecord( r, nPos );
}
// Kommentar?
if( aComment.Len() && SbiGood( r ) )
{
nPos = SbiOpenRecord( r, B_COMMENT, 1 );
r.WriteByteString( aComment, eCharSet );
//r << aComment;
SbiCloseRecord( r, nPos );
}
// Source?
if( aSource.Len() && SbiGood( r ) )
{
nPos = SbiOpenRecord( r, B_SOURCE, 1 );
r.WriteByteString( aSource, eCharSet );
//r << aSource;
SbiCloseRecord( r, nPos );
}
// Binaere Daten?
if( pCode && SbiGood( r ) )
{
nPos = SbiOpenRecord( r, B_PCODE, 1 );
r.Write( pCode, nCodeSize );
SbiCloseRecord( r, nPos );
}
// String-Pool?
if( nStrings )
{
nPos = SbiOpenRecord( r, B_STRINGPOOL, nStrings );
// Fuer jeden String:
// UINT32 Offset des Strings im Stringblock
for( short i = 0; i < nStrings && SbiGood( r ); i++ )
r << (UINT32) pStringOff[ i ];
// Danach der String-Block
char* pByteStrings = new char[ nStringSize ];
for( i = 0; i < nStrings; i++ )
{
USHORT nOff = pStringOff[ i ];
ByteString aStr( pStrings + nOff, eCharSet );
memcpy( pByteStrings + nOff, aStr.GetBuffer(), (aStr.Len() + 1) * sizeof( char ) );
}
r << (UINT32) nStringSize;
r.Write( pByteStrings, nStringSize );
delete pByteStrings;
SbiCloseRecord( r, nPos );
}
// Und die Gesamtlaenge setzen
SbiCloseRecord( r, nStart );
if( !SbiGood( r ) )
bError = TRUE;
return BOOL( !bError );
}
/**************************************************************************
*
* Routinen, die auch vom Compiler gerufen werden
*
**************************************************************************/
void SbiImage::MakeStrings( short nSize )
{
nStrings = nStringIdx = nStringOff = 0;
nStringSize = 1024;
pStrings = new sal_Unicode[ nStringSize ];
pStringOff = new UINT16[ nSize ];
if( pStrings && pStringOff )
{
nStrings = nSize;
memset( pStringOff, 0, nSize * sizeof( UINT16 ) );
memset( pStrings, 0, nStringSize * sizeof( sal_Unicode ) );
}
else
bError = TRUE;
}
// Hinzufuegen eines Strings an den StringPool. Der String-Puffer
// waechst dynamisch in 1K-Schritten
// AB 12.5.2000 Aus Zeitgruenden vorerst weiter auf char-Basis
// TODO: Auch hier auf Unicode umstellen, d.h. sal_Unicode-Array
void SbiImage::AddString( const String& r )
{
if( nStringIdx >= nStrings )
bError = TRUE;
if( !bError )
{
UINT16 len = r.Len() + 1;
long needed = (long) nStringOff + len;
if( needed > 0xFF00L )
bError = TRUE; // out of mem!
else if( (USHORT) needed > nStringSize )
{
sal_Unicode* p = new sal_Unicode[ nStringSize + 1024 ];
if( p )
{
memcpy( p, pStrings, nStringSize * sizeof( sal_Unicode ) );
delete pStrings;
pStrings = p;
nStringSize += 1024;
}
else
bError = TRUE;
}
if( !bError )
{
pStringOff[ nStringIdx++ ] = nStringOff;
//ByteString aByteStr( r, eCharSet );
memcpy( pStrings + nStringOff, r.GetBuffer(), len * sizeof( sal_Unicode ) );
nStringOff += len;
// war das der letzte String? Dann die Groesse
// des Puffers aktualisieren
if( nStringIdx >= nStrings )
nStringSize = nStringOff;
}
}
}
// Codeblock hinzufuegen
// Der Block wurde vom Compiler aus der Klasse SbBuffer herausgeholt
// und ist bereits per new angelegt. Ausserdem enthaelt er alle Integers
// im Big Endian-Format, kann also direkt gelesen/geschrieben werden.
void SbiImage::AddCode( char* p, USHORT s )
{
pCode = p;
nCodeSize = s;
}
void SbiImage::AddType(SbxObject* pObject) // User-Type mit aufnehmen
{
SbxObject *pCopyObject = new SbxObject(*pObject);
rTypes->Insert (pCopyObject,rTypes->Count());
}
/**************************************************************************
*
* Zugriffe auf das Image
*
**************************************************************************/
// IDs zaehlen ab 1!!
String SbiImage::GetString( short nId ) const
{
if( nId && nId <= nStrings )
{
USHORT nOff = pStringOff[ --nId ];
String aStr( pStrings + nOff );
return aStr;
}
return String();
}
const SbxObject* SbiImage::FindType (String aTypeName) const
{
return (SbxObject *)rTypes->Find(aTypeName,SbxCLASS_OBJECT);
}
+93
View File
@@ -0,0 +1,93 @@
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1.1.1 $
#
# last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library 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 for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJNAME=BASIC
TARGET=classes
# --- Settings -----------------------------------------------------------
ENABLE_EXCEPTIONS=TRUE
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
# --- Allgemein -----------------------------------------------------------
SLOFILES= \
$(SLO)$/sb.obj \
$(SLO)$/sbxmod.obj \
$(SLO)$/image.obj \
$(SLO)$/sbintern.obj \
$(SLO)$/sbunoobj.obj \
$(SLO)$/propacc.obj \
$(SLO)$/disas.obj
SRCFILES= sb.src
# --- Targets -------------------------------------------------------------
.INCLUDE : target.mk
+435
View File
@@ -0,0 +1,435 @@
/*************************************************************************
*
* $RCSfile: propacc.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:09 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "propacc.hxx"
#include <tools/urlobj.hxx>
#include <tools/errcode.hxx>
#include <svtools/svarray.hxx>
#include <svtools/sbx.hxx>
#include <sbstar.hxx>
#include <sbunoobj.hxx>
using namespace com::sun::star::uno;
using namespace com::sun::star::lang;
using namespace com::sun::star::beans;
using namespace cppu;
using namespace rtl;
//========================================================================
// Deklaration Konvertierung von Sbx nach Uno mit bekannter Zielklasse
Any sbxToUnoValue( SbxVariable* pVar, const Reference< XIdlClass >& xIdlTargetClass );
Reference<XIdlClass> TypeToIdlClass( const Type& rType );
//========================================================================
#ifdef WNT
#define CDECL _cdecl
#endif
#ifdef OS2
#define CDECL _Optlink
#endif
#if defined(UNX) || defined(MAC)
#define CDECL
#endif
int CDECL SbCompare_PropertyValues_Impl( const void *arg1, const void *arg2 )
{
return ((PropertyValue*)arg1)->Name.compareTo( ((PropertyValue*)arg2)->Name );
}
int CDECL SbCompare_UString_PropertyValue_Impl( const void *arg1, const void *arg2 )
{
const OUString *pArg1 = (OUString*) arg1;
const PropertyValue **pArg2 = (const PropertyValue**) arg2;
return pArg1->compareTo( (*pArg2)->Name );
}
int CDECL SbCompare_Properties_Impl( const void *arg1, const void *arg2 )
{
return ((Property*)arg1)->Name.compareTo( ((Property*)arg2)->Name );
}
int CDECL SbCompare_UString_Property_Impl( const void *arg1, const void *arg2 )
{
const OUString *pArg1 = (OUString*) arg1;
const Property *pArg2 = (Property*) arg2;
return pArg1->compareTo( pArg2->Name );
}
//----------------------------------------------------------------------------
SbPropertyValues::SbPropertyValues()
{
}
//----------------------------------------------------------------------------
SbPropertyValues::~SbPropertyValues()
{
_xInfo = Reference< XPropertySetInfo >();
for ( USHORT n = 0; n < _aPropVals.Count(); ++n )
delete _aPropVals.GetObject( n );
}
//----------------------------------------------------------------------------
Reference< XPropertySetInfo > SbPropertyValues::getPropertySetInfo(void) throw( RuntimeException )
{
// create on demand?
if ( !_xInfo.is() )
{
SbPropertySetInfo *pInfo = new SbPropertySetInfo( _aPropVals );
((SbPropertyValues*)this)->_xInfo = (XPropertySetInfo*)pInfo;
}
return _xInfo;
}
//-------------------------------------------------------------------------
INT32 SbPropertyValues::GetIndex_Impl( const OUString &rPropName ) const
{
PropertyValue **ppPV;
ppPV = (PropertyValue **)
bsearch( &rPropName, _aPropVals.GetData(), _aPropVals.Count(),
sizeof( PropertyValue* ),
SbCompare_UString_PropertyValue_Impl );
return ppPV ? ( (ppPV-_aPropVals.GetData()) / sizeof(ppPV) ) : USHRT_MAX;
}
//----------------------------------------------------------------------------
void SbPropertyValues::setPropertyValue(
const OUString& aPropertyName,
const Any& aValue)
{
USHORT nIndex = GetIndex_Impl( aPropertyName );
PropertyValue *pPropVal = _aPropVals.GetObject(nIndex);
pPropVal->Value = aValue;
}
//----------------------------------------------------------------------------
Any SbPropertyValues::getPropertyValue(
const OUString& aPropertyName) throw( UnknownPropertyException, WrappedTargetException, RuntimeException )
{
USHORT nIndex = GetIndex_Impl( aPropertyName );
if ( nIndex != USHRT_MAX )
return _aPropVals.GetObject(nIndex)->Value;
return Any();
}
//----------------------------------------------------------------------------
void SbPropertyValues::addPropertyChangeListener(
const OUString& aPropertyName,
const Reference< XPropertyChangeListener >& )
{
}
//----------------------------------------------------------------------------
void SbPropertyValues::removePropertyChangeListener(
const OUString& aPropertyName,
const Reference< XPropertyChangeListener >& )
{
}
//----------------------------------------------------------------------------
void SbPropertyValues::addVetoableChangeListener(
const OUString& aPropertyName,
const Reference< XVetoableChangeListener >& )
{
}
//----------------------------------------------------------------------------
void SbPropertyValues::removeVetoableChangeListener(
const OUString& aPropertyName,
const Reference< XVetoableChangeListener >& )
{
}
//----------------------------------------------------------------------------
Sequence< PropertyValue > SbPropertyValues::getPropertyValues(void)
{
Sequence<PropertyValue> aRet( _aPropVals.Count());
for ( USHORT n = 0; n < _aPropVals.Count(); ++n )
aRet.getArray()[n] = *_aPropVals.GetObject(n);
return aRet;
}
//----------------------------------------------------------------------------
void SbPropertyValues::setPropertyValues(const Sequence< PropertyValue >& rPropertyValues )
{
if ( _aPropVals.Count() )
throw PropertyExistException();
const PropertyValue *pPropVals = rPropertyValues.getConstArray();
for ( sal_Int16 n = 0; n < rPropertyValues.getLength(); ++n )
{
PropertyValue *pPropVal = new PropertyValue(pPropVals[n]);
_aPropVals.Insert( pPropVal, n );
}
}
//============================================================================
//PropertySetInfoImpl
PropertySetInfoImpl::PropertySetInfoImpl()
{
}
INT32 PropertySetInfoImpl::GetIndex_Impl( const OUString &rPropName ) const
{
Property *pP;
pP = (Property*)
bsearch( &rPropName, _aProps.getConstArray(), _aProps.getLength(),
sizeof( Property ),
SbCompare_UString_Property_Impl );
return pP ? ( (pP-_aProps.getConstArray()) / sizeof(pP) ) : -1;
}
Sequence< Property > PropertySetInfoImpl::getProperties(void)
{
return _aProps;
}
Property PropertySetInfoImpl::getPropertyByName(const OUString& Name) throw( RuntimeException )
{
USHORT nIndex = GetIndex_Impl( Name );
if( USHRT_MAX != nIndex )
return _aProps.getConstArray()[ nIndex ];
return Property();
}
sal_Bool PropertySetInfoImpl::hasPropertyByName(const OUString& Name) throw( RuntimeException )
{
USHORT nIndex = GetIndex_Impl( Name );
return USHRT_MAX != nIndex;
}
//============================================================================
SbPropertySetInfo::SbPropertySetInfo()
{
}
//----------------------------------------------------------------------------
SbPropertySetInfo::SbPropertySetInfo( const SbPropertyValueArr_Impl &rPropVals )
{
aImpl._aProps.realloc( rPropVals.Count() );
for ( USHORT n = 0; n < rPropVals.Count(); ++n )
{
Property &rProp = aImpl._aProps.getArray()[n];
const PropertyValue &rPropVal = *rPropVals.GetObject(n);
rProp.Name = rPropVal.Name;
rProp.Handle = rPropVal.Handle;
rProp.Type = getCppuVoidType();
rProp.Attributes = 0;
}
}
//----------------------------------------------------------------------------
SbPropertySetInfo::~SbPropertySetInfo()
{
}
//-------------------------------------------------------------------------
Sequence< Property > SbPropertySetInfo::getProperties(void) throw( RuntimeException )
{
return aImpl.getProperties();
}
Property SbPropertySetInfo::getPropertyByName(const OUString& Name)
throw( RuntimeException )
{
return aImpl.getPropertyByName( Name );
}
BOOL SbPropertySetInfo::hasPropertyByName(const OUString& Name)
throw( RuntimeException )
{
return aImpl.hasPropertyByName( Name );
}
//----------------------------------------------------------------------------
SbPropertyContainer::SbPropertyContainer()
{
}
//----------------------------------------------------------------------------
SbPropertyContainer::~SbPropertyContainer()
{
}
//----------------------------------------------------------------------------
void SbPropertyContainer::addProperty(const OUString& Name,
INT16 Attributes,
const Any& DefaultValue)
throw( PropertyExistException, IllegalTypeException,
IllegalArgumentException, RuntimeException )
{
}
//----------------------------------------------------------------------------
void SbPropertyContainer::removeProperty(const OUString& Name)
throw( UnknownPropertyException, RuntimeException )
{
}
//----------------------------------------------------------------------------
// XPropertySetInfo
Sequence< Property > SbPropertyContainer::getProperties(void)
{
return aImpl.getProperties();
}
Property SbPropertyContainer::getPropertyByName(const OUString& Name)
throw( RuntimeException )
{
return aImpl.getPropertyByName( Name );
}
BOOL SbPropertyContainer::hasPropertyByName(const OUString& Name)
throw( RuntimeException )
{
return aImpl.hasPropertyByName( Name );
}
//----------------------------------------------------------------------------
Sequence< PropertyValue > SbPropertyContainer::getPropertyValues(void)
{
return Sequence<PropertyValue>();
}
//----------------------------------------------------------------------------
void SbPropertyContainer::setPropertyValues(const Sequence< PropertyValue >& PropertyValues_)
{
}
//----------------------------------------------------------------------------
void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite )
{
// Wir brauchen mindestens 1 Parameter
if ( rPar.Count() < 2 )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
return;
}
// Klassen-Name der struct holen
String aServiceName( RTL_CONSTASCII_USTRINGPARAM("stardiv.uno.beans.PropertySet") );
#if 0
// Service suchen und instanzieren
Reference< XMultiServiceFactory > xServiceManager = getProcessServiceFactory();
Reference< XInterface > xInterface;
if( xProv.is() )
xInterface = xProv->newInstance();
#else
Reference< XInterface > xInterface = (OWeakObject*) new SbPropertyValues();
#endif
SbxVariableRef refVar = rPar.Get(0);
if( xInterface.is() )
{
// PropertyValues setzen
Any aArgAsAny = sbxToUnoValue( rPar.Get(1),
TypeToIdlClass( getCppuType( (Sequence<PropertyValue>*)0 ) ) );
Sequence<PropertyValue> *pArg =
(Sequence<PropertyValue>*) aArgAsAny.getValue();
Reference< XPropertyAccess > xPropAcc = Reference< XPropertyAccess >::query( xInterface );
xPropAcc->setPropertyValues( *pArg );
// SbUnoObject daraus basteln und zurueckliefern
Any aAny;
aAny <<= xInterface;
SbUnoObjectRef xUnoObj = new SbUnoObject( aServiceName, aAny );
if( xUnoObj->getUnoAny().getValueType().getTypeClass() != TypeClass_VOID )
{
// Objekt zurueckliefern
refVar->PutObject( (SbUnoObject*)xUnoObj );
return;
}
}
// Objekt konnte nicht erzeugt werden
refVar->PutObject( NULL );
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+109
View File
@@ -0,0 +1,109 @@
/*************************************************************************
*
* $RCSfile: sbintern.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SHL_HXX //autogen
#include <tools/shl.hxx>
#endif
#include "sbintern.hxx"
#include "sbunoobj.hxx"
#include "token.hxx" // Tokenizer
#include "symtbl.hxx" // Symbolverwaltung
#include "parser.hxx" // Parser
#include "codegen.hxx" // Code-Generator
#pragma hdrstop
SV_IMPL_PTRARR(SbErrorStack, SbErrorStackEntry*)
SbiGlobals* GetSbData()
{
SbiGlobals** pp = (SbiGlobals**) ::GetAppData( SHL_SBC );
SbiGlobals* p = *pp;
if( !p )
p = *pp = new SbiGlobals;
return p;
}
SbiGlobals::SbiGlobals()
{
pInst = NULL;
pMod = NULL;
pSbFac= NULL;
pUnoFac = NULL;
pCompMod = NULL; // JSM
nInst = 0;
nCode = 0;
nLine = 0;
nCol1 = nCol2 = 0;
bCompiler = FALSE;
bCompWait = FALSE;
bGlobalInitErr = FALSE;
bRunInit = FALSE;
eLanguageMode = SB_LANG_BASIC;
pErrStack = NULL;
}
SbiGlobals::~SbiGlobals()
{
delete pErrStack;
delete pSbFac;
delete pUnoFac;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+253
View File
@@ -0,0 +1,253 @@
/*************************************************************************
*
* $RCSfile: buffer.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "sbcomp.hxx"
#pragma hdrstop
#include "buffer.hxx"
#include <string.h>
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
// Der SbiBuffer wird in Inkrements von mindestens 16 Bytes erweitert.
// Dies ist notwendig, da viele Klassen von einer Pufferlaenge
// von x*16 Bytes ausgehen.
SbiBuffer::SbiBuffer( SbiParser* p, short n )
{
pParser = p;
n = ( (n + 15 ) / 16 ) * 16;
if( !n ) n = 16;
pBuf = NULL;
pCur = NULL;
nInc = n;
nSize =
nOff = 0;
}
SbiBuffer::~SbiBuffer()
{
delete pBuf;
}
// Rausreichen des Puffers
// Dies fuehrt zur Loeschung des Puffers!
char* SbiBuffer::GetBuffer()
{
char* p = pBuf;
pBuf = NULL;
pCur = NULL;
return p;
}
// Test, ob der Puffer n Bytes aufnehmen kann.
// Im Zweifelsfall wird er vergroessert
BOOL SbiBuffer::Check( USHORT n )
{
if( !n ) return TRUE;
if( ((long) nOff + n ) > (long) nSize )
{
USHORT nn = 0;
while( nn < n ) nn += nInc;
char* p;
if( ((long) nSize + nn ) > 0xFF00L ) p = NULL;
else p = new char [nSize + nn];
if( !p )
{
pParser->Error( SbERR_PROG_TOO_LARGE );
nInc = 0;
delete pBuf; pBuf = NULL;
return FALSE;
}
else
{
if( nSize ) memcpy( p, pBuf, nSize );
delete pBuf;
pBuf = p;
pCur = pBuf + nOff;
nSize += nn;
}
}
return TRUE;
}
// Angleich des Puffers auf die uebergebene Byte-Grenze
void SbiBuffer::Align( short n )
{
if( nOff % n ) {
USHORT nn =( ( nOff + n ) / n ) * n;
if( nn <= 0xFF00 )
{
nn -= nOff;
if( Check( nn ) )
{
memset( pCur, 0, nn );
pCur += nn;
nOff += nn;
}
}
}
}
// Patch einer Location
void SbiBuffer::Patch( USHORT off, UINT16 val )
{
if( ( off + sizeof( UINT16 ) ) < nOff )
{
BYTE* p = (BYTE*) pBuf + off;
*p++ = (char) ( val & 0xFF );
*p = (char) ( val >> 8 );
}
}
// Forward References auf Labels und Prozeduren
// bauen eine Kette auf. Der Anfang der Kette ist beim uebergebenen
// Parameter, das Ende der Kette ist 0.
void SbiBuffer::Chain( USHORT off )
{
if( off && pBuf )
{
BYTE *ip;
USHORT i = off;
USHORT val = nOff;
do
{
ip = (BYTE*) pBuf + i;
i = ( *ip ) | ( *(ip+1) << 8 );
if( i >= nOff )
{
pParser->Error( SbERR_INTERNAL_ERROR, "BACKCHAIN" );
break;
}
*ip++ = (char) ( val & 0xFF );
*ip = (char) ( val >> 8 );
} while( i );
}
}
BOOL SbiBuffer::operator +=( INT8 n )
{
if( Check( 1 ) )
{
*pCur++ = (char) n; nOff++; return TRUE;
} else return FALSE;
}
BOOL SbiBuffer::operator +=( UINT8 n )
{
if( Check( 1 ) )
{
*pCur++ = (char) n; nOff++; return TRUE;
} else return FALSE;
}
BOOL SbiBuffer::operator +=( INT16 n )
{
if( Check( 2 ) )
{
*pCur++ = (char) ( n & 0xFF );
*pCur++ = (char) ( n >> 8 );
nOff += 2; return TRUE;
} else return FALSE;
}
BOOL SbiBuffer::operator +=( UINT16 n )
{
if( Check( 2 ) )
{
*pCur++ = (char) ( n & 0xFF );
*pCur++ = (char) ( n >> 8 );
nOff += 2; return TRUE;
} else return FALSE;
}
BOOL SbiBuffer::operator +=( const String& n )
{
USHORT l = n.Len() + 1;
if( Check( l ) )
{
ByteString aByteStr( n, gsl_getSystemTextEncoding() );
memcpy( pCur, aByteStr.GetBuffer(), l );
pCur += l;
nOff += l;
return TRUE;
}
else return FALSE;
}
BOOL SbiBuffer::Add( const void* p, USHORT len )
{
if( Check( len ) )
{
memcpy( pCur, p, len );
pCur += len;
nOff += len;
return TRUE;
} else return FALSE;
}
+241
View File
@@ -0,0 +1,241 @@
/*************************************************************************
*
* $RCSfile: codegen.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <svtools/sbx.hxx>
#include "sbcomp.hxx"
#pragma hdrstop
#include "image.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
// nInc ist die Inkrementgroesse der Puffer
SbiCodeGen::SbiCodeGen( SbModule& r, SbiParser* p, short nInc )
: rMod( r ), aCode( p, nInc )
{
pParser = p;
bStmnt = FALSE;
nLine = 0;
nCol = 0;
nForLevel = 0;
}
USHORT SbiCodeGen::GetPC()
{
return aCode.GetSize();
}
// Statement merken
void SbiCodeGen::Statement()
{
bStmnt = TRUE;
nLine = pParser->GetLine();
nCol = pParser->GetCol1();
// #29955 Information der for-Schleifen-Ebene
// in oberen Byte der Spalte speichern
nCol = (nCol & 0xff) + 0x100 * nForLevel;
}
// Anfang eines Statements markieren
void SbiCodeGen::GenStmnt()
{
if( bStmnt )
{
bStmnt = FALSE;
Gen( _STMNT, nLine, nCol );
}
}
// Die Gen-Routinen returnen den Offset des 1. Operanden,
// damit Jumps dort ihr Backchain versenken koennen
USHORT SbiCodeGen::Gen( SbiOpcode eOpcode )
{
#ifndef PRODUCT
if( eOpcode < SbOP0_START || eOpcode > SbOP0_END )
pParser->Error( SbERR_INTERNAL_ERROR, "OPCODE1" );
#endif
GenStmnt();
aCode += (UINT8) eOpcode;
return GetPC();
}
USHORT SbiCodeGen::Gen( SbiOpcode eOpcode, UINT16 nOpnd )
{
#ifndef PRODUCT
if( eOpcode < SbOP1_START || eOpcode > SbOP1_END )
pParser->Error( SbERR_INTERNAL_ERROR, "OPCODE2" );
#endif
GenStmnt();
aCode += (UINT8) eOpcode;
USHORT n = GetPC();
aCode += nOpnd;
return n;
}
USHORT SbiCodeGen::Gen( SbiOpcode eOpcode, UINT16 nOpnd1, UINT16 nOpnd2 )
{
#ifndef PRODUCT
if( eOpcode < SbOP2_START || eOpcode > SbOP2_END )
pParser->Error( SbERR_INTERNAL_ERROR, "OPCODE3" );
#endif
GenStmnt();
aCode += (UINT8) eOpcode;
USHORT n = GetPC();
aCode += nOpnd1;
aCode += nOpnd2;
return n;
}
// Abspeichern des erzeugten Images im Modul
void SbiCodeGen::Save()
{
SbiImage* p = new SbiImage;
if( !p )
{
SbERR_NO_MEMORY; return;
}
rMod.StartDefinitions();
// OPTION BASE-Wert:
p->nDimBase = pParser->nBase;
// OPTION EXPLICIT-Flag uebernehmen
if( pParser->bExplicit )
p->SetFlag( SBIMG_EXPLICIT );
if( pParser->bText )
p->SetFlag( SBIMG_COMPARETEXT );
// GlobalCode-Flag
if( pParser->HasGlobalCode() )
p->SetFlag( SBIMG_INITCODE );
// Die Entrypoints:
for( SbiSymDef* pDef = pParser->aPublics.First(); pDef;
pDef = pParser->aPublics.Next() )
{
SbiProcDef* pProc = pDef->GetProcDef();
if( pProc && pProc->IsPublic() && pProc->IsDefined() )
{
SbMethod* pMeth = rMod.GetMethod( pProc->GetName(), pProc->GetType() );
pMeth->nStart = pProc->GetAddr();
pMeth->nLine1 = pProc->GetLine1();
pMeth->nLine2 = pProc->GetLine2();
// Die Parameter:
SbxInfo* pInfo = pMeth->GetInfo();
String aHelpFile, aComment;
ULONG nHelpId = 0;
if( pInfo )
{
// Die Zusatzdaten retten
aHelpFile = pInfo->GetHelpFile();
aComment = pInfo->GetComment();
nHelpId = pInfo->GetHelpId();
}
// Und die Parameterliste neu aufbauen
pInfo = new SbxInfo( aHelpFile, nHelpId );
pInfo->SetComment( aComment );
SbiSymPool* pPool = &pProc->GetParams();
// Das erste Element ist immer der Funktionswert!
for( USHORT i = 1; i < pPool->GetSize(); i++ )
{
SbiSymDef* pPar = pPool->Get( i );
SbxDataType t = pPar->GetType();
if( !pPar->IsByVal() )
t = (SbxDataType) ( t | SbxBYREF );
if( pPar->GetDims() )
t = (SbxDataType) ( t | SbxARRAY );
// #33677 Optional-Info durchreichen
USHORT nFlags = SBX_READ;
if( pPar->IsOptional() )
nFlags |= SBX_OPTIONAL;
pInfo->AddParam( pPar->GetName(), t, nFlags );
}
pMeth->SetInfo( pInfo );
}
}
// Der Code
p->AddCode( aCode.GetBuffer(), aCode.GetSize() );
// Der globale StringPool. 0 ist nicht belegt.
SbiStringPool* pPool = &pParser->aGblStrings;
USHORT nSize = pPool->GetSize();
p->MakeStrings( nSize );
USHORT i;
for( i = 1; i <= nSize; i++ )
p->AddString( pPool->Find( i ) );
// Typen einfuegen
USHORT nCount = pParser->rTypeArray->Count();
for (i = 0; i < nCount; i++)
p->AddType((SbxObject *)pParser->rTypeArray->Get(i));
if( !p->IsError() )
rMod.pImage = p;
else
delete p;
rMod.EndDefinitions();
}
+792
View File
@@ -0,0 +1,792 @@
/*************************************************************************
*
* $RCSfile: dim.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <svtools/sbx.hxx>
#include "sbcomp.hxx"
#pragma hdrstop
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
// Deklaration einer Variablen
// Bei Fehlern wird bis zum Komma oder Newline geparst.
// Returnwert: eine neue Instanz, die eingefuegt und dann geloescht wird.
// Array-Indexe werden als SbiDimList zurueckgegeben
SbiSymDef* SbiParser::VarDecl( SbiDimList** ppDim, BOOL bStatic, BOOL bConst )
{
if( !TestSymbol() ) return NULL;
SbxDataType t = eScanType;
SbiSymDef* pDef = bConst ? new SbiConstDef( aSym ) : new SbiSymDef( aSym );
SbiDimList* pDim = NULL;
// Klammern?
if( Peek() == LPAREN )
pDim = new SbiDimList( this );
pDef->SetType( t );
if( bStatic )
pDef->SetStatic();
TypeDecl( *pDef );
if( !ppDim && pDim )
{
if(pDim->GetDims() )
Error( SbERR_EXPECTED, "()" );
delete pDim;
}
else if( ppDim )
*ppDim = pDim;
return pDef;
}
// Aufloesen einer AS-Typdeklaration
// Der Datentyp wird in die uebergebene Variable eingetragen
void SbiParser::TypeDecl( SbiSymDef& rDef )
{
SbxDataType eType = rDef.GetType();
short nSize = 0;
if( Peek() == AS )
{
#ifdef VBSCRIPT_TEST
Error( ERRCODE_BASIC_NOT_IN_VBSCRIPT );
#endif
Next();
rDef.SetDefinedAs();
String aType;
SbiToken eTok = Next();
if( eTok == NEW )
{
rDef.SetNew();
eTok = Next();
}
switch( eTok )
{
case ANY:
if( rDef.IsNew() )
Error( SbERR_SYNTAX );
eType = SbxVARIANT; break;
case TINTEGER:
case TLONG:
case TSINGLE:
case TDOUBLE:
case TCURRENCY:
case TDATE:
case TSTRING:
case TOBJECT:
case _ERROR_:
case TBOOLEAN:
case TVARIANT:
if( rDef.IsNew() )
Error( SbERR_SYNTAX );
eType = SbxDataType( eTok - TINTEGER + SbxINTEGER );
if( eType == SbxSTRING )
{
// STRING*n ?
if( Peek() == MUL )
{ // fixed size!
Next();
SbiConstExpression aSize( this );
nSize = aSize.GetShortValue();
if( nSize < 0 )
Error( SbERR_OUT_OF_RANGE );
}
}
break;
case SYMBOL: // kann nur ein TYPE oder eine Objektklasse sein!
if( eScanType != SbxVARIANT )
Error( SbERR_SYNTAX );
else
{
String aCompleteName = aSym;
// #52709 DIM AS NEW fuer Uno mit voll-qualifizierten Namen
if( Peek() == DOT )
{
String aDotStr( '.' );
while( Peek() == DOT )
{
aCompleteName += aDotStr;
Next();
if( Peek() == SYMBOL )
{
Next();
aCompleteName += aSym;
}
else
{
Next();
Error( SbERR_UNEXPECTED, SYMBOL );
break;
}
}
}
// In den String-Pool uebernehmen
rDef.SetTypeId( aGblStrings.Add( aCompleteName ) );
}
eType = SbxOBJECT;
break;
default:
Error( SbERR_UNEXPECTED, eTok );
Next();
}
// Die Variable koennte mit Suffix deklariert sein
if( rDef.GetType() != SbxVARIANT )
{
if( rDef.GetType() != eType )
Error( SbERR_VAR_DEFINED, rDef.GetName() );
else if( eType == SbxSTRING && rDef.GetLen() != nSize )
Error( SbERR_VAR_DEFINED, rDef.GetName() );
}
rDef.SetType( eType );
rDef.SetLen( nSize );
}
}
// Hier werden Variable, Arrays und Strukturen definiert.
// DIM/PRIVATE/PUBLIC/GLOBAL
void SbiParser::Dim()
{
DefVar( _DIM, FALSE );
}
void SbiParser::DefVar( SbiOpcode eOp, BOOL bStatic )
{
SbiSymPool* pOldPool = pPool;
BOOL bSwitchPool = FALSE;
if( pProc && ( eCurTok == GLOBAL || eCurTok == PUBLIC || eCurTok == PRIVATE ) )
Error( SbERR_NOT_IN_SUBR, eCurTok );
if( eCurTok == PUBLIC || eCurTok == GLOBAL )
bSwitchPool = TRUE; // im richtigen Moment auf globalen Pool schalten
//pPool = &aGlobals;
// PRIVATE ist Synonym fuer DIM
// _CONST_?
BOOL bConst = FALSE;
if( eCurTok == _CONST_ )
bConst = TRUE;
else if( Peek() == _CONST_ )
Next(), bConst = TRUE;
#ifdef SHARED
#define tmpSHARED
#undef SHARED
#endif
// SHARED wird ignoriert
if( Peek() == SHARED ) Next();
#ifdef tmpSHARED
#define SHARED
#undef tmpSHARED
#endif
// PRESERVE nur bei REDIM
if( Peek() == PRESERVE )
{
Next();
if( eOp == _REDIM )
eOp = _REDIMP;
else
Error( SbERR_UNEXPECTED, eCurTok );
}
SbiSymDef* pDef;
SbiDimList* pDim;
// AB 9.7.97, #40689, Statics -> Modul-Initialisierung, in Sub ueberspringen
USHORT nEndOfStaticLbl;
if( bStatic )
{
nEndOfStaticLbl = aGen.Gen( _JUMP, 0 );
aGen.Statement(); // bei static hier nachholen
}
BOOL bDefined = FALSE;
while( ( pDef = VarDecl( &pDim, bStatic, bConst ) ) != NULL )
{
EnableErrors();
// Variable suchen:
if( bSwitchPool )
pPool = &aGlobals;
SbiSymDef* pOld = pPool->Find( pDef->GetName() );
// AB 31.3.1996, #25651#, auch in Runtime-Library suchen
BOOL bRtlSym = FALSE;
if( !pOld )
{
pOld = CheckRTLForSym( pDef->GetName(), SbxVARIANT );
if( pOld )
bRtlSym = TRUE;
}
if( pOld )
{
bDefined = TRUE;
// Bei RTL-Symbol immer Fehler
if( !bRtlSym && (eOp == _REDIM || eOp == _REDIMP) )
{
// Bei REDIM die Attribute vergleichen
if( pOld->IsStatic() || pOld->GetType() != pDef->GetType() )
Error( SbERR_VAR_DEFINED, pDef->GetName() );
}
else
Error( SbERR_VAR_DEFINED, pDef->GetName() );
delete pDef; pDef = pOld;
}
else
pPool->Add( pDef );
// #36374: Variable vor Unterscheidung IsNew() anlegen
// Sonst Error bei Dim Identifier As New Type und option explicit
if( !bDefined && ( !bConst || pDef->GetScope() == SbGLOBAL ) )
{
// Variable oder globale Konstante deklarieren
SbiOpcode eOp;
switch ( pDef->GetScope() )
{
case SbGLOBAL: eOp = _GLOBAL; goto global;
case SbPUBLIC: eOp = _PUBLIC;
// AB 9.7.97, #40689, kein eigener Opcode mehr
/*
if( bStatic )
{
eOp = _STATIC;
break;
}
*/
global: aGen.BackChain( nGblChain );
nGblChain = 0;
bGblDefs = bNewGblDefs = TRUE;
break;
default: eOp = _LOCAL;
}
aGen.Gen( eOp, pDef->GetId(), pDef->GetType() );
}
// Initialisierung fuer selbstdefinierte Datentypen
// und per NEW angelegte Variable
if( pDef->GetType() == SbxOBJECT
&& pDef->GetTypeId()
&& pDef->IsNew() )
// && ( pDef->IsNew() || pDef->HabIchAlsTypeDefiniert() ) )
{
if( bConst )
{
Error( SbERR_SYNTAX );
}
if( pDim )
{
pDef->SetDims( pDim->GetDims() );
SbiExpression aExpr( this, *pDef, pDim );
aExpr.Gen();
aGen.Gen( _DCREATE, pDef->GetId(), pDef->GetTypeId() );
}
else
{
SbiExpression aExpr( this, *pDef );
aExpr.Gen();
SbiOpcode eOp = pDef->IsNew() ? _CREATE : _TCREATE;
aGen.Gen( eOp, pDef->GetId(), pDef->GetTypeId() );
aGen.Gen( _SET );
}
}
else
{
if( bConst )
{
// Konstanten-Definition
if( pDim )
{
Error( SbERR_SYNTAX );
delete pDim;
}
SbiExpression aVar( this, *pDef );
if( !TestToken( EQ ) )
goto MyBreak; // AB 24.6.1996 (s.u.)
SbiConstExpression aExpr( this );
if( !bDefined && aExpr.IsValid() )
{
if( pDef->GetScope() == SbGLOBAL )
{
// Nur Code fuer globale Konstante erzeugen!
aVar.Gen();
aExpr.Gen();
aGen.Gen( _PUTC );
}
SbiConstDef* pConst = pDef->GetConstDef();
if( aExpr.GetType() == SbxSTRING )
pConst->Set( aExpr.GetString() );
else
pConst->Set( aExpr.GetValue(), aExpr.GetType() );
}
}
else if( pDim )
{
// Die Variable dimensionieren
// Bei REDIM die Var vorher loeschen
if( eOp == _REDIM )
{
SbiExpression aExpr( this, *pDef, NULL );
aExpr.Gen();
aGen.Gen( _ERASE );
}
pDef->SetDims( pDim->GetDims() );
SbiExpression aExpr( this, *pDef, pDim );
aExpr.Gen();
aGen.Gen( (eOp == _STATIC) ? _DIM : eOp );
}
}
if( !TestComma() )
goto MyBreak; // AB 24.6.1996 (s.u.)
// #27963# AB, 24.6.1996
// Einfuehrung bSwitchPool (s.o.): pPool darf beim VarDecl-Aufruf
// noch nicht auf &aGlobals gesetzt sein.
// Ansonsten soll das Verhalten aber absolut identisch bleiben,
// d.h. pPool muss immer am Schleifen-Ende zurueckgesetzt werden.
// auch bei break
pPool = pOldPool;
continue; // MyBreak überspingen
MyBreak:
pPool = pOldPool;
break;
}
// AB 9.7.97, #40689, Sprung ueber Statics-Deklaration abschliessen
if( bStatic )
{
// globalen Chain pflegen
nGblChain = aGen.Gen( _JUMP, 0 );
bGblDefs = bNewGblDefs = TRUE;
// fuer Sub Sprung auf Ende der statics eintragen
aGen.BackChain( nEndOfStaticLbl );
}
//pPool = pOldPool;
}
// Hier werden Arrays redimensioniert.
void SbiParser::ReDim()
{
DefVar( _REDIM, FALSE );
}
// ERASE array, ...
void SbiParser::Erase()
{
while( !bAbort )
{
if( !TestSymbol() ) return;
String aName( aSym );
SbxDataType eType = eScanType;
SbiSymDef* pDef = pPool->Find( aName );
if( !pDef )
{
if( bExplicit )
Error( SbERR_UNDEF_VAR, aName );
pDef = pPool->AddSym( aName );
pDef->SetType( eType );
}
SbiExpression aExpr( this, *pDef );
aExpr.Gen();
aGen.Gen( _ERASE );
if( !TestComma() ) break;
}
}
// Deklaration eines Datentyps
void SbiParser::Type()
{
// Neues Token lesen, es muss ein Symbol sein
if (!TestSymbol())
return;
if (rTypeArray->Find(aSym,SbxCLASS_OBJECT))
{
Error( SbERR_VAR_DEFINED, aSym );
return;
}
SbxObject *pType = new SbxObject(aSym);
SbiSymDef* pElem;
SbiDimList* pDim;
BOOL bDone = FALSE;
while( !bDone && !IsEof() )
{
switch (Next())
{
case ENDTYPE :
pElem = NULL;
bDone = TRUE;
break;
case EOLN :
pElem = NULL;
break;
default:
pDim = NULL;
pElem = VarDecl(&pDim,FALSE,FALSE);
if( pDim )
{
// HOT FIX, to be updated
delete pDim;
Error( SbERR_NO_STRINGS_ARRAYS );
}
}
if( pElem )
{
SbxArray *pTypeMembers = pType -> GetProperties();
if (pTypeMembers -> Find (pElem->GetName(),SbxCLASS_DONTCARE))
Error (SbERR_VAR_DEFINED);
else
{
SbxProperty *pTypeElem = new SbxProperty (pElem->GetName(),pElem->GetType());
pTypeMembers -> Insert (pTypeElem,pTypeMembers->Count());
}
delete pElem;
}
}
rTypeArray->Insert (pType,rTypeArray->Count());
}
/**********************************************************
// Variablennamen einlesen:
if( !TestSymbol() ) return;
String aName( aSym );
if( pDEFS->Find( aName ) )
{
Error( SbERR_VAR_DEFINED, aName ); return;
}
SbTypeDef* pDef = pDEFS->AddTypeDef( aName );
TestEoln();
// Deklarationen parsen:
SbiSymDef* pElem;
SbiDimList* pDim;
BOOL bDone = FALSE;
while( !IsEof() && !bDone )
{
switch( Next() )
{
case SUB:
case FUNCTION:
pElem = ProcDecl( TRUE ); break;
case END:
pElem = NULL;
bDone = TRUE;
if( Next() != TYPE )
Error( SbERR_EXPECTED, TYPE );
break;
default:
pElem = VarDecl( &pDim );
if( pDim )
{
// HOT FIX, to be updated
delete pDim;
Error( SbERR_NO_STRINGS_ARRAYS );
}
}
if( pElem )
pDef->GetPool().Add( *pElem );
delete pElem;
}
}
************************************************/
// Prozedur-Deklaration
// das erste Token ist bereits eingelesen (SUB/FUNCTION)
// xxx Name [LIB "name"[ALIAS "name"]][(Parameter)][AS TYPE]
SbiProcDef* SbiParser::ProcDecl( BOOL bDecl )
{
BOOL bFunc = BOOL( eCurTok == FUNCTION );
if( !TestSymbol() ) return NULL;
String aName( aSym );
SbxDataType eType = eScanType;
SbiProcDef* pDef = new SbiProcDef( this, aName );
pDef->SetType( eType );
if( Peek() == _CDECL_ )
{
Next(); pDef->SetCdecl();
}
if( Peek() == LIB )
{
Next();
if( Next() == FIXSTRING )
pDef->GetLib() = aSym;
else
Error( SbERR_SYNTAX );
}
if( Peek() == ALIAS )
{
Next();
if( Next() == FIXSTRING )
pDef->GetAlias() = aSym;
else
Error( SbERR_SYNTAX );
}
if( !bDecl )
{
// CDECL, LIB und ALIAS sind unzulaessig
if( pDef->GetLib().Len() )
Error( SbERR_UNEXPECTED, LIB );
if( pDef->GetAlias().Len() )
Error( SbERR_UNEXPECTED, ALIAS );
if( pDef->IsCdecl() )
Error( SbERR_UNEXPECTED, _CDECL_ );
pDef->SetCdecl( FALSE );
pDef->GetLib().Erase();
pDef->GetAlias().Erase();
}
else if( !pDef->GetLib().Len() )
{
// ALIAS und CDECL nur zusammen mit LIB
if( pDef->GetAlias().Len() )
Error( SbERR_UNEXPECTED, ALIAS );
if( pDef->IsCdecl() )
Error( SbERR_UNEXPECTED, _CDECL_ );
pDef->SetCdecl( FALSE );
pDef->GetAlias().Erase();
}
// Klammern?
if( Peek() == LPAREN )
{
Next();
if( Peek() == RPAREN )
Next();
else
for(;;) {
BOOL bByVal = FALSE;
BOOL bOptional = FALSE;
while( Peek() == BYVAL || Peek() == _OPTIONAL_ )
{
if ( Peek() == BYVAL ) Next(), bByVal = TRUE;
else if ( Peek() == _OPTIONAL_ ) Next(), bOptional = TRUE;
}
SbiSymDef* pPar = VarDecl( NULL, FALSE, FALSE );
if( !pPar )
break;
if( bByVal )
pPar->SetByVal();
if( bOptional )
pPar->SetOptional();
pDef->GetParams().Add( pPar );
SbiToken eTok = Next();
if( eTok != COMMA && eTok != RPAREN )
{
Error( SbERR_EXPECTED, RPAREN );
break;
}
if( eTok == RPAREN )
break;
}
}
TypeDecl( *pDef );
if( eType != SbxVARIANT && pDef->GetType() != eType )
Error( SbERR_BAD_DECLARATION, aName );
// if( pDef->GetType() == SbxOBJECT )
// pDef->SetType( SbxVARIANT ),
// Error( SbERR_SYNTAX );
if( pDef->GetType() == SbxVARIANT && !bFunc )
pDef->SetType( SbxEMPTY );
return pDef;
}
// DECLARE
void SbiParser::Declare()
{
Next();
if( eCurTok != SUB && eCurTok != FUNCTION )
Error( SbERR_UNEXPECTED, eCurTok );
else
{
SbiProcDef* pDef = ProcDecl( TRUE );
if( pDef )
{
if( !pDef->GetLib().Len() )
Error( SbERR_EXPECTED, LIB );
// gibts den schon?
SbiSymDef* pOld = aPublics.Find( pDef->GetName() );
if( pOld )
{
SbiProcDef* p = pOld->GetProcDef();
if( !p )
{
// Als Variable deklariert
Error( SbERR_BAD_DECLARATION, pDef->GetName() );
delete pDef;
}
else
pDef->Match( p );
}
else
aPublics.Add( pDef );
}
}
}
// Aufruf einer SUB oder FUNCTION
void SbiParser::Call()
{
String aName( aSym );
SbiExpression aVar( this, SbSYMBOL );
aVar.Gen();
aGen.Gen( _GET );
}
// SUB/FUNCTION
void SbiParser::SubFunc()
{
DefProc( FALSE );
}
// Einlesen einer Prozedur
void SbiParser::DefProc( BOOL bStatic )
{
USHORT l1 = nLine, l2 = nLine;
BOOL bSub = BOOL( eCurTok == SUB );
SbiToken eExit = eCurTok;
SbiProcDef* pDef = ProcDecl( FALSE );
if( !pDef )
return;
// Ist die Proc bereits deklariert?
SbiSymDef* pOld = aPublics.Find( pDef->GetName() );
if( pOld )
{
pProc = pOld->GetProcDef();
if( !pProc )
{
// Als Variable deklariert
Error( SbERR_BAD_DECLARATION, pDef->GetName() );
delete pDef;
pProc = NULL;
}
else
{
pDef->Match( pProc );
pProc = pDef;
}
}
else
aPublics.Add( pDef ), pProc = pDef;
if( !pProc )
return;
// Nun setzen wir die Suchhierarchie fuer Symbole sowie die aktuelle
// Prozedur.
aPublics.SetProcId( pProc->GetId() );
pProc->GetParams().SetParent( &aPublics );
if( !bStatic )
{
// Normalfall: Lokale Variable->Parameter->Globale Variable
pProc->GetLocals().SetParent( &pProc->GetParams() );
pPool = &pProc->GetLocals();
}
else
{
Error( SbERR_NOT_IMPLEMENTED ); // STATIC SUB ...
}
pProc->Define();
OpenBlock( eExit );
StmntBlock( bSub ? ENDSUB : ENDFUNC );
l2 = nLine;
pProc->SetLine1( l1 );
pProc->SetLine2( l2 );
pPool = &aPublics;
aPublics.SetProcId( 0 );
// Offene Labels?
pProc->GetLabels().CheckRefs();
CloseBlock();
aGen.Gen( _LEAVE );
pProc = NULL;
}
// STATIC variable|procedure
void SbiParser::Static()
{
switch( Peek() )
{
case SUB:
case FUNCTION:
Next();
DefProc( TRUE );
break;
default: {
if( !pProc )
Error( SbERR_NOT_IN_SUBR );
// Pool umsetzen, damit STATIC-Deklarationen im globalen
// Pool landen
SbiSymPool* p = pPool; pPool = &aPublics;
DefVar( _STATIC, TRUE );
pPool = p;
} break;
}
}
+273
View File
@@ -0,0 +1,273 @@
/*************************************************************************
*
* $RCSfile: exprgen.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "sbcomp.hxx"
#pragma hdrstop
#include "expr.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCEXPR, SBCOMP_CODE )
// Umsetztabelle fuer Token-Operatoren und Opcodes
typedef struct {
SbiToken eTok; // Token
SbiOpcode eOp; // Opcode
} OpTable;
static OpTable aOpTable [] = {
{ EXPON,_EXP },
{ MUL, _MUL },
{ DIV, _DIV },
{ IDIV, _IDIV },
{ MOD, _MOD },
{ PLUS, _PLUS },
{ MINUS,_MINUS },
{ EQ, _EQ },
{ NE, _NE },
{ LE, _LE },
{ GE, _GE },
{ LT, _LT },
{ GT, _GT },
{ AND, _AND },
{ OR, _OR },
{ XOR, _XOR },
{ EQV, _EQV },
{ IMP, _IMP },
{ NOT, _NOT },
{ NEG, _NEG },
{ CAT, _CAT },
{ LIKE, _LIKE },
{ IS, _IS },
{ NIL, _NOP }};
// Ausgabe eines Elements
void SbiExprNode::Gen()
{
if( IsConstant() )
{
switch( GetType() )
{
case SbxEMPTY: pGen->Gen( _EMPTY ); break;
case SbxINTEGER: pGen->Gen( _CONST, (short) nVal ); break;
case SbxSTRING: pGen->Gen( _SCONST, nStringId ); break;
default:
nStringId = pGen->GetParser()->aGblStrings.Add( nVal, eType );
pGen->Gen( _NUMBER, nStringId );
}
}
else if( IsOperand() )
{
SbiOpcode eOp;
if( aVar.pDef->GetScope() == SbPARAM )
eOp = _PARAM;
// AB: 17.12.1995, Spezialbehandlung fuer WITH
else if( IsPartOfWith() )
{
eOp = _ELEM; // .-Ausdruck in WITH
}
else
{
SbiProcDef* pProc = aVar.pDef->GetProcDef();
// per DECLARE definiert?
if( pProc && pProc->GetLib().Len() )
eOp = pProc->IsCdecl() ? _CALLC : _CALL;
else
eOp = ( aVar.pDef->GetScope() == SbRTL ) ? _RTL : _FIND;
}
for( SbiExprNode* p = this; p; p = p->aVar.pNext )
{
if( p->IsPartOfWith() )
pGen->GetParser()->GetWithVar()->Gen();
p->GenElement( eOp );
eOp = _ELEM;
}
}
else
{
pLeft->Gen();
if( pRight )
pRight->Gen();
for( OpTable* p = aOpTable; p->eTok != NIL; p++ )
{
if( p->eTok == eTok )
{
pGen->Gen( p->eOp ); break;
}
}
}
}
// Ausgabe eines Operanden-Elements
void SbiExprNode::GenElement( SbiOpcode eOp )
{
#ifndef PRODUCT
if( eOp < _RTL || eOp > _CALLC )
pGen->GetParser()->Error( SbERR_INTERNAL_ERROR, "Opcode" );
#endif
SbiSymDef* pDef = aVar.pDef;
// Das ID ist entweder die Position oder das String-ID
// Falls das Bit 0x8000 gesetzt ist, hat die Variable
// eine Parameterliste.
USHORT nId = ( eOp == _PARAM ) ? pDef->GetPos() : pDef->GetId();
// Parameterliste aufbauen
if( aVar.pPar && aVar.pPar->GetSize() )
{
nId |= 0x8000;
aVar.pPar->Gen();
}
SbiProcDef* pProc = aVar.pDef->GetProcDef();
// per DECLARE definiert?
if( pProc )
{
// Dann evtl. einen LIB-Befehl erzeugen
if( pProc->GetLib().Len() )
pGen->Gen( _LIB, pGen->GetParser()->aGblStrings.Add( pProc->GetLib() ) );
// und den Aliasnamen nehmen
if( pProc->GetAlias().Len() )
nId = ( nId & 0x8000 ) | pGen->GetParser()->aGblStrings.Add( pProc->GetAlias() );
}
pGen->Gen( eOp, nId, GetType() );
}
// Erzeugen einer Argv-Tabelle
// Das erste Element bleibt immer frei fuer Returnwerte etc.
// Siehe auch SbiProcDef::SbiProcDef() in symtbl.cxx
void SbiExprList::Gen()
{
if( pFirst )
{
pParser->aGen.Gen( _ARGC );
// AB 10.1.96: Typ-Anpassung bei DECLARE
USHORT nCount = 1, nParAnz = 0;
SbiSymPool* pPool;
if( pProc )
{
pPool = &pProc->GetParams();
nParAnz = pPool->GetSize();
}
for( SbiExpression* pExpr = pFirst; pExpr; pExpr = pExpr->pNext,nCount++ )
{
pExpr->Gen();
if( pExpr->GetName().Len() )
{
// named arg
USHORT nSid = pParser->aGblStrings.Add( pExpr->GetName() );
pParser->aGen.Gen( _ARGN, nSid );
// AB 10.1.96: Typanpassung bei named -> passenden Parameter suchen
if( pProc )
{
// Vorerst: Error ausloesen
pParser->Error( SbERR_NO_NAMED_ARGS );
// Spaeter, wenn Named Args bei DECLARE moeglich
/*
for( USHORT i = 1 ; i < nParAnz ; i++ )
{
SbiSymDef* pDef = pPool->Get( i );
const String& rName = pDef->GetName();
if( rName.Len() )
{
if( pExpr->GetName().ICompare( rName )
== COMPARE_EQUAL )
{
pParser->aGen.Gen( _ARGTYP, pDef->GetType() );
break;
}
}
}
*/
}
}
else
{
pParser->aGen.Gen( _ARGV );
// Funktion mit DECLARE -> Typ-Anpassung
if( pProc && nCount < nParAnz )
{
SbiSymDef* pDef = pPool->Get( nCount );
USHORT nTyp = pDef->GetType();
// Zusätzliches Flag für BYVAL einbauen
if( pDef->IsByVal() )
nTyp |= 0x8000;
pParser->aGen.Gen( _ARGTYP, nTyp );
}
}
}
}
}
void SbiExpression::Gen()
{
// AB: 17.12.1995, Spezialbehandlung fuer WITH
// Wenn pExpr == .-Ausdruck in With, zunaechst Gen fuer Basis-Objekt
pExpr->Gen();
if( bBased )
pParser->aGen.Gen( _BASED, pParser->nBase ),
pParser->aGen.Gen( _ARGV );
}
+497
View File
@@ -0,0 +1,497 @@
/*************************************************************************
*
* $RCSfile: exprnode.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#define _NTSDK // wg. HUGE_VAL MH
#define HUGE_VAL HUGE
#include <math.h>
#include "sbcomp.hxx"
#pragma hdrstop
#include "expr.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCEXPR, SBCOMP_CODE )
//////////////////////////////////////////////////////////////////////////
SbiExprNode::SbiExprNode( SbiParser* p, SbiExprNode* l, SbiToken t, SbiExprNode* r )
{
BaseInit( p );
pLeft = l;
pRight = r;
eTok = t;
nVal = 0;
eType = SbxVARIANT; // Nodes sind immer Variant
eNodeType = SbxNODE;
bComposite= TRUE;
}
SbiExprNode::SbiExprNode( SbiParser* p, double n, SbxDataType t )
{
BaseInit( p );
eType = t;
eNodeType = SbxNUMVAL;
nVal = n;
}
SbiExprNode::SbiExprNode( SbiParser* p, const String& rVal )
{
BaseInit( p );
eType = SbxSTRING;
eNodeType = SbxSTRVAL;
nStringId = p->aGblStrings.Add( rVal, TRUE );
}
SbiExprNode::SbiExprNode( SbiParser* p, const SbiSymDef& r, SbxDataType t, SbiExprList* l )
{
BaseInit( p );
eType = ( t == SbxVARIANT ) ? r.GetType() : t;
eNodeType = SbxVARVAL;
aVar.pDef = (SbiSymDef*) &r;
aVar.pPar = l;
aVar.pNext= NULL;
// Funktionsergebnisse sind nie starr
bComposite= BOOL( aVar.pDef->GetProcDef() != NULL );
}
// AB: 17.12.95, Hilfsfunktion fuer Ctor fuer einheitliche Initialisierung
void SbiExprNode::BaseInit( SbiParser* p )
{
pGen = &p->aGen;
eTok = NIL;
pLeft = NULL;
pRight = NULL;
bComposite = FALSE;
bPartOfWith = FALSE;
bError = FALSE;
}
SbiExprNode::~SbiExprNode()
{
delete pLeft;
delete pRight;
if( IsVariable() )
{
delete aVar.pPar;
delete aVar.pNext;
}
}
SbiSymDef* SbiExprNode::GetVar()
{
if( eNodeType == SbxVARVAL )
return aVar.pDef;
else
return NULL;
}
SbiSymDef* SbiExprNode::GetRealVar()
{
SbiExprNode* p = GetRealNode();
if( p )
return p->GetVar();
else
return NULL;
}
// AB: 18.12.95
SbiExprNode* SbiExprNode::GetRealNode()
{
if( eNodeType == SbxVARVAL )
{
SbiExprNode* p = this;
while( p->aVar.pNext )
p = p->aVar.pNext;
return p;
}
else
return NULL;
}
BOOL SbiExprNode::IsOperand()
{
return BOOL( eNodeType != SbxNODE );
}
BOOL SbiExprNode::IsConstant()
{
return BOOL( eNodeType == SbxSTRVAL || eNodeType == SbxNUMVAL );
}
// Diese Methode setzt den Typ um, falls er in den Integer-Bereich hineinpasst
BOOL SbiExprNode::IsIntConst()
{
if( eNodeType == SbxNUMVAL )
{
if( eType >= SbxINTEGER && eType <= SbxDOUBLE )
{
#if defined(MAC) && !defined(__powerc)
long double n;
#else
double n;
#endif
if( nVal >= SbxMININT && nVal <= SbxMAXINT && modf( nVal, &n ) == 0 )
{
nVal = (double) (short) nVal;
eType = SbxINTEGER;
return TRUE;
}
}
}
return FALSE;
}
BOOL SbiExprNode::IsNumber()
{
return BOOL( eNodeType == SbxNUMVAL );
}
BOOL SbiExprNode::IsString()
{
return BOOL( eNodeType == SbxSTRVAL );
}
BOOL SbiExprNode::IsVariable()
{
return BOOL( eNodeType == SbxVARVAL );
}
BOOL SbiExprNode::IsLvalue()
{
return IsVariable();
}
// Ermitteln der Tiefe eines Baumes
short SbiExprNode::GetDepth()
{
if( IsOperand() ) return 0;
else
{
SbiExprNode* p = (SbiExprNode*) this;
short d1 = pLeft->GetDepth();
short d2 = pRight->GetDepth();
return( (d1 < d2 ) ? d2 : d1 ) + 1;
}
}
const String& SbiExprNode::GetString()
{
USHORT n = ( eType == SbxSTRING ) ? nStringId : 0;
return pGen->GetParser()->aGblStrings.Find( n );
}
// Abgleich eines Baumes:
// 1. Constant Folding
// 2. Typabgleich
// 3. Umwandlung der Operanden in Strings
// 4. Hochziehen der Composite- und Error-Bits
void SbiExprNode::Optimize()
{
FoldConstants();
CollectBits();
}
// Hochziehen der Composite- und Fehlerbits
void SbiExprNode::CollectBits()
{
if( pLeft )
{
pLeft->CollectBits();
bError |= pLeft->bError;
bComposite |= pLeft->bComposite;
}
if( pRight )
{
pRight->CollectBits();
bError |= pRight->bError;
bComposite |= pRight->bComposite;
}
}
// Kann ein Zweig umgeformt werden, wird TRUE zurueckgeliefert. In diesem
// Fall ist das Ergebnis im linken Zweig.
void SbiExprNode::FoldConstants()
{
if( IsOperand() ) return;
pLeft->FoldConstants();
if( pRight )
{
pRight->FoldConstants();
if( pLeft->IsConstant() && pRight->IsConstant()
&& pLeft->eNodeType == pRight->eNodeType )
{
CollectBits();
if( eTok == CAT )
// CAT verbindet auch zwei Zahlen miteinander!
eType = SbxSTRING;
if( pLeft->eType == SbxSTRING )
// Kein Type Mismatch!
eType = SbxSTRING;
if( eType == SbxSTRING )
{
String rl( pLeft->GetString() );
String rr( pRight->GetString() );
delete pLeft; pLeft = NULL;
delete pRight; pRight = NULL;
eType = SbxDOUBLE;
eNodeType = SbxNUMVAL;
bComposite = FALSE;
StringCompare eRes = rr.CompareTo( rl );
//StringCompare eRes = rl.Compare( rr );
String s;
switch( eTok )
{
case PLUS:
case CAT:
eTok = CAT;
// Verkettung:
s = rl;
s += rr;
nStringId = pGen->GetParser()->aGblStrings.Add( s, TRUE );
eType = SbxSTRING;
eNodeType = SbxSTRVAL;
break;
case EQ:
nVal = ( eRes == COMPARE_EQUAL ) ? SbxTRUE : SbxFALSE;
break;
case NE:
nVal = ( eRes != COMPARE_EQUAL ) ? SbxTRUE : SbxFALSE;
break;
case LT:
nVal = ( eRes == COMPARE_LESS ) ? SbxTRUE : SbxFALSE;
break;
case GT:
nVal = ( eRes == COMPARE_GREATER ) ? SbxTRUE : SbxFALSE;
break;
case LE:
nVal = ( eRes != COMPARE_GREATER ) ? SbxTRUE : SbxFALSE;
break;
case GE:
nVal = ( eRes != COMPARE_LESS ) ? SbxTRUE : SbxFALSE;
break;
default:
pGen->GetParser()->Error( SbERR_CONVERSION );
bError = TRUE;
}
}
else
{
double nl = pLeft->nVal;
double nr = pRight->nVal;
long ll, lr;
if( ( eTok >= AND && eTok <= EQV )
|| eTok == IDIV || eTok == MOD )
{
// Integer-Operationen
BOOL err = FALSE;
if( nl > SbxMAXLNG ) err = TRUE, nl = SbxMAXLNG;
else
if( nl < SbxMINLNG ) err = TRUE, nl = SbxMINLNG;
if( nr > SbxMAXLNG ) err = TRUE, nr = SbxMAXLNG;
else
if( nr < SbxMINLNG ) err = TRUE, nr = SbxMINLNG;
ll = (long) nl; lr = (long) nr;
if( err )
{
pGen->GetParser()->Error( SbERR_MATH_OVERFLOW );
bError = TRUE;
}
}
BOOL bBothInt = BOOL( pLeft->eType < SbxSINGLE
&& pRight->eType < SbxSINGLE );
delete pLeft; pLeft = NULL;
delete pRight; pRight = NULL;
nVal = 0;
eType = SbxDOUBLE;
eNodeType = SbxNUMVAL;
bComposite = FALSE;
BOOL bCheckType = FALSE;
switch( eTok )
{
case EXPON:
nVal = pow( nl, nr ); break;
case MUL:
bCheckType = TRUE;
nVal = nl * nr; break;
case DIV:
if( !nr )
{
pGen->GetParser()->Error( SbERR_ZERODIV ); nVal = HUGE_VAL;
bError = TRUE;
} else nVal = nl / nr;
break;
case PLUS:
bCheckType = TRUE;
nVal = nl + nr; break;
case MINUS:
bCheckType = TRUE;
nVal = nl - nr; break;
case EQ:
nVal = ( nl == nr ) ? SbxTRUE : SbxFALSE;
eType = SbxINTEGER; break;
case NE:
nVal = ( nl != nr ) ? SbxTRUE : SbxFALSE;
eType = SbxINTEGER; break;
case LT:
nVal = ( nl < nr ) ? SbxTRUE : SbxFALSE;
eType = SbxINTEGER; break;
case GT:
nVal = ( nl > nr ) ? SbxTRUE : SbxFALSE;
eType = SbxINTEGER; break;
case LE:
nVal = ( nl <= nr ) ? SbxTRUE : SbxFALSE;
eType = SbxINTEGER; break;
case GE:
nVal = ( nl >= nr ) ? SbxTRUE : SbxFALSE;
eType = SbxINTEGER; break;
case IDIV:
if( !lr )
{
pGen->GetParser()->Error( SbERR_ZERODIV ); nVal = HUGE_VAL;
bError = TRUE;
} else nVal = ll / lr;
eType = SbxLONG; break;
case MOD:
if( !lr )
{
pGen->GetParser()->Error( SbERR_ZERODIV ); nVal = HUGE_VAL;
bError = TRUE;
} else nVal = ll % lr;
eType = SbxLONG; break;
case AND:
nVal = (double) ( ll & lr ); eType = SbxLONG; break;
case OR:
nVal = (double) ( ll | lr ); eType = SbxLONG; break;
case XOR:
nVal = (double) ( ll ^ lr ); eType = SbxLONG; break;
case EQV:
nVal = (double) ( ~ll ^ lr ); eType = SbxLONG; break;
case IMP:
nVal = (double) ( ~ll | lr ); eType = SbxLONG; break;
}
// Den Datentyp wiederherstellen, um Rundungsfehler
// zu killen
if( bCheckType && bBothInt
&& nVal >= SbxMINLNG && nVal <= SbxMAXLNG )
{
// NK-Stellen weg
long n = (long) nVal;
nVal = n;
eType = ( n >= SbxMININT && n <= SbxMAXINT )
? SbxINTEGER : SbxLONG;
}
}
}
}
else if( pLeft->IsNumber() )
{
nVal = pLeft->nVal;
delete pLeft;
pLeft = NULL;
eType = SbxDOUBLE;
eNodeType = SbxNUMVAL;
bComposite = FALSE;
switch( eTok )
{
case NEG:
nVal = -nVal; break;
case NOT: {
// Integer-Operation!
BOOL err = FALSE;
if( nVal > SbxMAXLNG ) err = TRUE, nVal = SbxMAXLNG;
else
if( nVal < SbxMINLNG ) err = TRUE, nVal = SbxMINLNG;
if( err )
{
pGen->GetParser()->Error( SbERR_MATH_OVERFLOW );
bError = TRUE;
}
nVal = (double) ~((long) nVal);
eType = SbxLONG;
} break;
}
}
if( eNodeType == SbxNUMVAL )
{
// Evtl auf INTEGER falten (wg. besserem Opcode)?
if( eType == SbxSINGLE || eType == SbxDOUBLE )
{
double x;
if( nVal >= SbxMINLNG && nVal <= SbxMAXLNG
&& !modf( nVal, &x ) )
eType = SbxLONG;
}
if( eType == SbxLONG && nVal >= SbxMININT && nVal <= SbxMAXINT )
eType = SbxINTEGER;
}
}
+971
View File
@@ -0,0 +1,971 @@
/*************************************************************************
*
* $RCSfile: exprtree.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "sbcomp.hxx"
#pragma hdrstop
#include <svtools/sbx.hxx> // w.g. ...IMPL_REF(...sbxvariable)
#include "expr.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCEXPR, SBCOMP_CODE )
/***************************************************************************
|*
|* SbiExpression
|*
***************************************************************************/
SbiExpression::SbiExpression( SbiParser* p, SbiExprType t )
{
pParser = p;
bError = bByVal = bBased = FALSE;
eCurExpr = t;
pNext = NULL;
pExpr = (t != SbSTDEXPR ) ? Term() : Boolean();
if( t != SbSYMBOL )
pExpr->Optimize();
if( t == SbLVALUE && !pExpr->IsLvalue() )
p->Error( SbERR_LVALUE_EXPECTED );
if( t == SbOPERAND && !IsVariable() )
p->Error( SbERR_VAR_EXPECTED );
}
SbiExpression::SbiExpression( SbiParser* p, double n, SbxDataType t )
{
pParser = p;
eCurExpr = SbOPERAND;
pNext = NULL;
bError = bByVal = bBased = FALSE;
pExpr = new SbiExprNode( pParser, n, t );
pExpr->Optimize();
}
SbiExpression::SbiExpression( SbiParser* p, const String& r )
{
pParser = p;
pNext = NULL;
bError = bByVal = bBased = FALSE;
eCurExpr = SbOPERAND;
pExpr = new SbiExprNode( pParser, r );
}
SbiExpression::SbiExpression( SbiParser* p, const SbiSymDef& r, SbiExprList* pPar )
{
pParser = p;
pNext = NULL;
bError = bByVal = bBased = FALSE;
eCurExpr = SbOPERAND;
pExpr = new SbiExprNode( pParser, r, SbxVARIANT, pPar );
}
SbiExpression::SbiExpression( SbiParser* p, SbiToken t )
{
pParser = p;
pNext = NULL;
bError = bByVal = bBased = FALSE;
eCurExpr = SbOPERAND;
pExpr = new SbiExprNode( pParser, NULL, t, NULL );
}
SbiExpression::~SbiExpression()
{
delete pExpr;
}
// Einlesen eines kompletten Bezeichners
// Ein Bezeichner hat folgende Form:
// name[(Parameter)][.Name[(parameter)]]...
// Strukturelemente werden ueber das Element pNext verkoppelt,
// damit sie nicht im Baum stehen.
// Folgen Parameter ohne Klammer? Dies kann eine Zahl, ein String,
// ein Symbol oder auch ein Komma sein (wenn der 1. Parameter fehlt)
static BOOL DoParametersFollow( SbiParser* p, SbiExprType eCurExpr, SbiToken eTok )
{
if( eTok == LPAREN )
return TRUE;
// Aber nur, wenn CALL-aehnlich!
if( !p->WhiteSpace() || eCurExpr != SbSYMBOL )
return FALSE;
return BOOL(
eTok == NUMBER || eTok == FIXSTRING
|| eTok == SYMBOL || eTok == COMMA || eTok == DOT );
}
// Definition eines neuen Symbols
static SbiSymDef* AddSym
( SbiToken eTok, SbiSymPool& rPool, SbiExprType eCurExpr,
const String& rName, SbxDataType eType, SbiParameters* pPar )
{
SbiSymDef* pDef;
// A= ist keine Prozedur
BOOL bHasType = BOOL( eTok == EQ || eTok == DOT );
if( ( !bHasType && eCurExpr == SbSYMBOL ) || pPar )
{
// Dies ist also eine Prozedur
// da suche man doch den richtigen Pool raus, da Procs
// immer in einem Public-Pool landen muessen
SbiSymPool* pPool = &rPool;
if( pPool->GetScope() != SbPUBLIC )
pPool = &rPool.GetParser()->aPublics;
SbiProcDef* pProc = pPool->AddProc( rName );
// Sonderbehandlung fuer Colls wie Documents(1)
if( eCurExpr == SbSTDEXPR )
bHasType = TRUE;
pDef = pProc;
pDef->SetType( bHasType ? eType : SbxEMPTY );
if( pPar )
{
// Dummy-Parameter generieren
USHORT n = 1;
for( short i = 0; i < pPar->GetSize(); i++ )
{
String aPar = String::CreateFromAscii( "PAR" );
aPar += ++n;
pProc->GetParams().AddSym( aPar );
}
}
}
else
{
// oder ein normales Symbol
pDef = rPool.AddSym( rName );
pDef->SetType( eType );
}
return pDef;
}
// Zur Zeit sind sogar Keywords zugelassen (wg. gleichnamiger Dflt-Properties)
SbiExprNode* SbiExpression::Term()
{
if( pParser->Peek() == DOT )
{
// eine WITH-Variable
SbiExprNode* pWithVar = pParser->GetWithVar();
// #26608: Ans Ende der Node-Kette gehen, um richtiges Objekt zu uebergeben
SbiSymDef* pDef = pWithVar ? pWithVar->GetRealVar() : NULL;
SbiExprNode* pNd = NULL;
if( !pDef )
{
pParser->Next();
}
else
{
pNd = ObjTerm( *pDef );
if( pNd )
pNd->SetPartOfWith( TRUE );
}
if( !pNd )
{
pParser->Error( SbERR_UNEXPECTED, DOT );
pNd = new SbiExprNode( pParser, 1.0, SbxDOUBLE );
}
return pNd;
}
SbiToken eTok = pParser->Next();
// Anfang des Parsings merken
pParser->LockColumn();
String aSym( pParser->GetSym() );
SbxDataType eType = pParser->GetType();
SbiParameters* pPar = NULL;
// Folgen Parameter?
SbiToken eNextTok = pParser->Peek();
// Ist es ein benannter Parameter?
// Dann einfach eine Stringkonstante erzeugen. Diese wird
// im SbiParameters-ctor erkannt und weiterverarbeitet
if( eNextTok == ASSIGN )
{
pParser->UnlockColumn();
return new SbiExprNode( pParser, aSym );
}
// ab hier sind keine Keywords zugelassen!
if( pParser->IsKwd( eTok ) )
{
pParser->Error( SbERR_SYNTAX );
bError = TRUE;
}
if( DoParametersFollow( pParser, eCurExpr, eTok = eNextTok ) )
{
pPar = new SbiParameters( pParser );
bError |= !pPar->IsValid();
eTok = pParser->Peek();
}
// Es koennte ein Objektteil sein, wenn . oder ! folgt
// Bei . muss aber die Variable bereits definiert sein; wenn pDef
// nach der Suche NULL ist, isses ein Objekt!
BOOL bObj = BOOL( ( eTok == DOT || eTok == EXCLAM )
&& !pParser->WhiteSpace() );
if( bObj )
{
if( eType == SbxVARIANT )
eType = SbxOBJECT;
else
{
// Name%. geht wirklich nicht!
pParser->Error( SbERR_BAD_DECLARATION, aSym );
bError = TRUE;
}
}
// Suche:
SbiSymDef* pDef = pParser->pPool->Find( aSym );
if( !pDef )
{
// Teil der Runtime-Library?
// AB 31.3.1996: In Parser-Methode ausgelagert
// (wird auch in SbiParser::DefVar() in DIM.CXX benoetigt)
pDef = pParser->CheckRTLForSym( aSym, eType );
}
if( !pDef )
{
// Falls ein Punkt angegeben war, isses Teil eines Objekts,
// also muss der Returnwert ein Objekt sein
if( bObj )
eType = SbxOBJECT;
pDef = AddSym( eTok, *pParser->pPool, eCurExpr, aSym, eType, pPar );
}
else
{
// Symbol ist bereits definiert.
// Ist es eine Konstante?
SbiConstDef* pConst = pDef->GetConstDef();
if( pConst )
{
if( pConst->GetType() == SbxSTRING )
return new SbiExprNode( pParser, pConst->GetString() );
else
return new SbiExprNode( pParser, pConst->GetValue(), pConst->GetType() );
}
// Hat es Dimensionen,
// und sind auch Parameter angegeben?
// (Wobei 0 Parameter () entsprechen)
if( pDef->GetDims() )
{
if( !pPar
|| ( pPar->GetSize() && pPar->GetSize() != pDef->GetDims() ) )
pParser->Error( SbERR_WRONG_DIMS );
}
if( pDef->IsDefinedAs() )
{
if( eType >= SbxINTEGER && eType <= SbxSTRING )
{
// Wie? Erst mit AS definieren und dann einen Suffix nehmen?
pParser->Error( SbERR_BAD_DECLARATION, aSym );
bError = TRUE;
}
else if ( eType == SbxVARIANT )
// Falls nix angegeben, den Typ des Eintrags nehmen
// aber nur, wenn die Var nicht mit AS XXX definiert ist
// damit erwischen wir n% = 5 : print n
eType = pDef->GetType();
}
// Funktion?
if( pDef->GetProcDef() )
{
SbiProcDef* pProc = pDef->GetProcDef();
if( pPar && pProc->GetLib().Len() ) // DECLARE benutzt?
pPar->SetProc( pProc );
// Wenn keine Pars, vorerst nichts machen
// Pruefung auf Typ-Anzahl waere denkbar
}
// Typcheck bei Variablen:
// ist explizit im Scanner etwas anderes angegeben?
// Bei Methoden ist dies OK!
if( eType != SbxVARIANT && // Variant nimmt alles
eType != pDef->GetType() &&
!pDef->GetProcDef() )
{
// Es kann sein, dass pDef ein Objekt beschreibt, das bisher
// nur als SbxVARIANT erkannt wurde, dann Typ von pDef aendern
// AB, 16.12.95 (Vielleicht noch aehnliche Faelle moeglich ?!?)
if( eType == SbxOBJECT && pDef->GetType() == SbxVARIANT )
{
pDef->SetType( SbxOBJECT );
}
else
{
pParser->Error( SbERR_BAD_DECLARATION, aSym );
bError = TRUE;
}
}
}
SbiExprNode* pNd = new SbiExprNode( pParser, *pDef, eType );
if( !pPar )
pPar = new SbiParameters( pParser,FALSE,FALSE );
pNd->aVar.pPar = pPar;
if( bObj )
{
// AB, 8.1.95: Objekt kann auch vom Typ SbxVARIANT sein
if( pDef->GetType() == SbxVARIANT )
pDef->SetType( SbxOBJECT );
// Falls wir etwas mit Punkt einscannen, muss der
// Typ SbxOBJECT sein
if( pDef->GetType() != SbxOBJECT && pDef->GetType() != SbxVARIANT )
{
pParser->Error( SbERR_BAD_DECLARATION, aSym );
bError = TRUE;
}
if( !bError )
pNd->aVar.pNext = ObjTerm( *pDef );
}
// Merken der Spalte 1 wieder freigeben
pParser->UnlockColumn();
return pNd;
}
// Aufbau eines Objekt-Terms. Ein derartiger Term ist Teil
// eines Ausdrucks, der mit einer Objektvariablen beginnt.
SbiExprNode* SbiExpression::ObjTerm( SbiSymDef& rObj )
{
pParser->Next();
SbiToken eTok = pParser->Next();
if( eTok != SYMBOL && !pParser->IsKwd( eTok ) && !pParser->IsExtra( eTok ) )
{
// #66745 Einige Operatoren koennen in diesem Kontext auch
// als Identifier zugelassen werden, wichtig fuer StarOne
if( eTok != MOD && eTok != NOT && eTok != AND && eTok != OR &&
eTok != XOR && eTok != EQV && eTok != IMP && eTok != IS )
{
pParser->Error( SbERR_VAR_EXPECTED );
bError = TRUE;
}
}
else
{
if( pParser->GetType() != SbxVARIANT )
pParser->Error( SbERR_SYNTAX ), bError = TRUE;
}
if( bError )
return NULL;
String aSym( pParser->GetSym() );
SbxDataType eType = pParser->GetType();
SbiParameters* pPar = NULL;
eTok = pParser->Peek();
// Parameter?
if( DoParametersFollow( pParser, eCurExpr, eTok ) )
{
pPar = new SbiParameters( pParser );
bError |= !pPar->IsValid();
eTok = pParser->Peek();
}
BOOL bObj = BOOL( ( eTok == DOT || eTok == EXCLAM ) && !pParser->WhiteSpace() );
if( bObj )
{
if( eType == SbxVARIANT )
eType = SbxOBJECT;
else
{
// Name%. geht wirklich nicht!
pParser->Error( SbERR_BAD_DECLARATION, aSym );
bError = TRUE;
}
}
// Der Symbol-Pool eines Objekts ist immer PUBLIC
SbiSymPool& rPool = rObj.GetPool();
rPool.SetScope( SbPUBLIC );
SbiSymDef* pDef = rPool.Find( aSym );
if( !pDef )
{
pDef = AddSym( eTok, rPool, eCurExpr, aSym, eType, pPar );
pDef->SetType( eType );
}
SbiExprNode* pNd = new SbiExprNode( pParser, *pDef, eType );
pNd->aVar.pPar = pPar;
if( bObj )
{
// Falls wir etwas mit Punkt einscannen, muss der
// Typ SbxOBJECT sein
// AB, 3.1.96
// Es kann sein, dass pDef ein Objekt beschreibt, das bisher
// nur als SbxVARIANT erkannt wurde, dann Typ von pDef aendern
if( pDef->GetType() == SbxVARIANT )
pDef->SetType( SbxOBJECT );
if( pDef->GetType() != SbxOBJECT )
{
pParser->Error( SbERR_BAD_DECLARATION, aSym );
bError = TRUE;
}
if( !bError )
{
pNd->aVar.pNext = ObjTerm( *pDef );
pNd->eType = eType;
}
}
return pNd;
}
// Als Operanden kommen in Betracht:
// Konstante
// skalare Variable
// Strukturelemente
// Array-Elemente
// Funktionen
// geklammerte Ausdruecke
SbiExprNode* SbiExpression::Operand()
{
SbiExprNode *pRes;
SbiToken eTok;
// Operand testen:
switch( eTok = pParser->Peek() )
{
case SYMBOL:
case DOT: // .with
pRes = Term(); break;
case NUMBER:
pParser->Next();
pRes = new SbiExprNode( pParser, pParser->GetDbl(), pParser->GetType() );
break;
case FIXSTRING:
pParser->Next();
pRes = new SbiExprNode( pParser, pParser->GetSym() ); break;
case LPAREN:
pParser->Next();
pRes = Boolean();
if( pParser->Peek() != RPAREN )
pParser->Error( SbERR_BAD_BRACKETS );
else pParser->Next();
pRes->bComposite = TRUE;
break;
default:
// Zur Zeit sind Keywords hier OK!
if( pParser->IsKwd( eTok ) )
pRes = Term();
else
{
pParser->Next();
pRes = new SbiExprNode( pParser, 1.0, SbxDOUBLE ); // bei Fehlern
pParser->Error( SbERR_UNEXPECTED, eTok );
}
}
return pRes;
}
SbiExprNode* SbiExpression::Unary()
{
SbiExprNode* pNd;
SbiToken eTok = pParser->Peek();
switch( eTok )
{
case MINUS:
eTok = NEG;
case NOT:
pParser->Next();
pNd = new SbiExprNode( pParser, Unary(), eTok, NULL );
break;
case PLUS:
pParser->Next();
pNd = Unary();
break;
default:
pNd = Operand();
}
return pNd;
}
SbiExprNode* SbiExpression::Exp()
{
SbiExprNode* pNd = Unary();
while( pParser->Peek() == EXPON ) {
SbiToken eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Unary() );
}
return pNd;
}
SbiExprNode* SbiExpression::MulDiv()
{
SbiExprNode* pNd = Exp();
for( ;; )
{
SbiToken eTok = pParser->Peek();
if( eTok != MUL && eTok != DIV )
break;
eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Exp() );
}
return pNd;
}
SbiExprNode* SbiExpression::IntDiv()
{
SbiExprNode* pNd = MulDiv();
while( pParser->Peek() == IDIV ) {
SbiToken eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, MulDiv() );
}
return pNd;
}
SbiExprNode* SbiExpression::Mod()
{
SbiExprNode* pNd = IntDiv();
while( pParser->Peek() == MOD ) {
SbiToken eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, IntDiv() );
}
return pNd;
}
SbiExprNode* SbiExpression::AddSub()
{
SbiExprNode* pNd = Mod();
for( ;; )
{
SbiToken eTok = pParser->Peek();
if( eTok != PLUS && eTok != MINUS )
break;
eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Mod() );
}
return pNd;
}
SbiExprNode* SbiExpression::Cat()
{
SbiExprNode* pNd = AddSub();
for( ;; )
{
SbiToken eTok = pParser->Peek();
if( eTok != CAT )
break;
eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, AddSub() );
}
return pNd;
}
SbiExprNode* SbiExpression::Comp()
{
SbiExprNode* pNd = Cat();
short nCount = 0;
for( ;; )
{
SbiToken eTok = pParser->Peek();
if( eTok != EQ && eTok != NE && eTok != LT
&& eTok != GT && eTok != LE && eTok != GE )
break;
eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Cat() );
nCount++;
}
// Mehrere Operatoren hintereinander gehen nicht
if( nCount > 1 )
{
pParser->Error( SbERR_SYNTAX );
bError = TRUE;
}
return pNd;
}
SbiExprNode* SbiExpression::Like()
{
SbiExprNode* pNd = Comp();
short nCount = 0;
while( pParser->Peek() == LIKE ) {
SbiToken eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Comp() ), nCount++;
}
// Mehrere Operatoren hintereinander gehen nicht
if( nCount > 1 )
{
pParser->Error( SbERR_SYNTAX );
bError = TRUE;
}
return pNd;
}
SbiExprNode* SbiExpression::Boolean()
{
SbiExprNode* pNd = Like();
for( ;; )
{
SbiToken eTok = pParser->Peek();
if( eTok != AND && eTok != OR && eTok != XOR
&& eTok != EQV && eTok != IMP && eTok != IS )
break;
eTok = pParser->Next();
pNd = new SbiExprNode( pParser, pNd, eTok, Like() );
}
return pNd;
}
/***************************************************************************
|*
|* SbiConstExpression
|*
***************************************************************************/
// Parsing einer Expression, die sich zu einer numerischen
// Konstanten verarbeiten laesst.
SbiConstExpression::SbiConstExpression( SbiParser* p ) : SbiExpression( p )
{
if( pExpr->IsConstant() )
{
eType = pExpr->GetType();
if( pExpr->IsNumber() )
nVal = pExpr->nVal;
else
nVal = 0, aVal = pParser->aGblStrings.Find( pExpr->nStringId );
}
else
{
// #40204 Spezialbehandlung fuer BOOL-Konstanten
BOOL bIsBool = FALSE;
if( pExpr->eNodeType == SbxVARVAL )
{
SbiSymDef* pVarDef = pExpr->GetVar();
// Ist es eine BOOL-Konstante?
BOOL bBoolVal;
if( pVarDef->GetName().EqualsIgnoreCaseAscii( "true" ) )
//if( pVarDef->GetName().ICompare( "true" ) == COMPARE_EQUAL )
{
bIsBool = TRUE;
bBoolVal = TRUE;
}
else if( pVarDef->GetName().EqualsIgnoreCaseAscii( "false" ) )
//else if( pVarDef->GetName().ICompare( "false" ) == COMPARE_EQUAL )
{
bIsBool = TRUE;
bBoolVal = FALSE;
}
// Wenn es ein BOOL ist, Node austauschen
if( bIsBool )
{
delete pExpr;
pExpr = new SbiExprNode( pParser, (bBoolVal ? SbxTRUE : SbxFALSE), SbxINTEGER );
eType = pExpr->GetType();
nVal = pExpr->nVal;
}
}
if( !bIsBool )
{
pParser->Error( SbERR_SYNTAX );
eType = SbxDOUBLE;
nVal = 0;
}
}
}
short SbiConstExpression::GetShortValue()
{
if( eType == SbxSTRING )
{
SbxVariableRef refConv = new SbxVariable;
refConv->PutString( aVal );
return refConv->GetInteger();
}
else
{
double n = nVal;
if( n > 0 ) n += .5; else n -= .5;
if( n > SbxMAXINT ) n = SbxMAXINT, pParser->Error( SbERR_OUT_OF_RANGE );
else
if( n < SbxMININT ) n = SbxMININT, pParser->Error( SbERR_OUT_OF_RANGE );
return (short) n;
}
}
/***************************************************************************
|*
|* SbiExprList
|*
***************************************************************************/
SbiExprList::SbiExprList( SbiParser* p )
{
pParser = p;
pFirst = NULL;
pProc = NULL;
nExpr =
nDim = 0;
bError =
bBracket = FALSE;
}
SbiExprList::~SbiExprList()
{
SbiExpression* p = pFirst;
while( p )
{
SbiExpression* q = p->pNext;
delete p;
p = q;
}
}
// Parameter anfordern (ab 0)
SbiExpression* SbiExprList::Get( short n )
{
SbiExpression* p = pFirst;
while( n-- && p )
p = p->pNext;
return p;
}
/***************************************************************************
|*
|* SbiParameters
|*
***************************************************************************/
// Parsender Konstruktor:
// Die Parameterliste wird komplett geparst.
// "Prozedurname()" ist OK.
// Dann handelt es sich um eine Funktion ohne Parameter
// respektive um die Angabe eines Arrays als Prozedurparameter.
SbiParameters::SbiParameters( SbiParser* p, BOOL bConst, BOOL bPar) :
SbiExprList( p )
{
if (bPar)
{
SbiExpression *pExpr;
SbiToken eTok = pParser->Peek();
// evtl. Klammer auf weg:
if( eTok == LPAREN )
{
bBracket = TRUE; pParser->Next(); eTok = pParser->Peek();
}
// Ende-Test
if( ( bBracket && eTok == RPAREN ) || pParser->IsEoln( eTok ) )
{
if( eTok == RPAREN )
pParser->Next();
return;
}
// Parametertabelle einlesen und in richtiger Folge ablegen!
SbiExpression* pLast = NULL;
String aName;
while( !bError )
{
aName.Erase();
// Fehlendes Argument
if( eTok == COMMA )
{
pExpr = new SbiExpression( pParser, 0, SbxEMPTY );
if( bConst )
pParser->Error( SbERR_SYNTAX ), bError = TRUE;
}
// Benannte Argumente: entweder .name= oder name:=
else
{
if( eTok == DOT )
{
// VB mode: .name=
pParser->Next();
pParser->TestSymbol( TRUE ); // Keywords sind OK
aName = pParser->GetSym();
pParser->TestToken( EQ );
pExpr = bConst ? new SbiConstExpression( pParser )
: new SbiExpression( pParser );
}
else
{
pExpr = bConst ? new SbiConstExpression( pParser )
: new SbiExpression( pParser );
if( pParser->Peek() == ASSIGN )
{
// VBA mode: name:=
// SbiExpression::Term() hat einen String daraus gemacht
aName = pExpr->GetString();
delete pExpr;
pParser->Next();
pExpr = new SbiExpression( pParser );
if( bConst )
pParser->Error( SbERR_SYNTAX ), bError = TRUE;
}
}
pExpr->GetName() = aName;
}
pExpr->pNext = NULL;
if( !pLast )
pFirst = pLast = pExpr;
else
pLast->pNext = pExpr, pLast = pExpr;
nExpr++;
bError |= !pExpr->IsValid();
// Naechstes Element?
eTok = pParser->Peek();
if( eTok != COMMA )
{
if( ( bBracket && eTok == RPAREN ) || pParser->IsEoln( eTok ) )
break;
pParser->Error( bBracket
? SbERR_BAD_BRACKETS
: SbERR_EXPECTED, COMMA );
bError = TRUE;
}
else
{
pParser->Next();
eTok = pParser->Peek();
if( ( bBracket && eTok == RPAREN ) || pParser->IsEoln( eTok ) )
break;
}
}
// Schliessende Klammer
if( eTok == RPAREN )
{
pParser->Next();
pParser->Peek();
if( !bBracket )
{
pParser->Error( SbERR_BAD_BRACKETS );
bError = TRUE;
}
}
nDim = nExpr;
}
}
/***************************************************************************
|*
|* SbiDimList
|*
***************************************************************************/
// Parsender Konstruktor:
// Eine Liste von Array-Dimensionen wird geparst. Die Ausdruecke werden
// auf numerisch getestet. Das bCONST-Bit wird gesetzt, wenn alle Ausdruecke
// Integer-Konstanten sind.
SbiDimList::SbiDimList( SbiParser* p ) : SbiExprList( p )
{
bConst = TRUE;
if( pParser->Next() != LPAREN )
{
pParser->Error( SbERR_EXPECTED, LPAREN );
bError = TRUE; return;
}
if( pParser->Peek() != RPAREN )
{
SbiExpression *pExpr1, *pExpr2, *pLast = NULL;
SbiToken eTok;
for( ;; )
{
pExpr1 = new SbiExpression( pParser );
eTok = pParser->Next();
if( eTok == TO )
{
pExpr2 = new SbiExpression( pParser );
eTok = pParser->Next();
bConst &= pExpr1->IsIntConstant() & pExpr2->IsIntConstant();
bError |= !pExpr1->IsValid();
bError |= !pExpr2->IsValid();
pExpr1->pNext = pExpr2;
if( !pLast )
pFirst = pExpr1;
else
pLast->pNext = pExpr1;
pLast = pExpr2;
nExpr += 2;
}
else
{
// Nur eine Dim-Angabe
pExpr1->SetBased();
pExpr1->pNext = NULL;
bConst &= pExpr1->IsIntConstant();
bError |= !pExpr1->IsValid();
if( !pLast )
pFirst = pLast = pExpr1;
else
pLast->pNext = pExpr1, pLast = pExpr1;
nExpr++;
}
nDim++;
if( eTok == RPAREN ) break;
if( eTok != COMMA )
{
pParser->Error( SbERR_BAD_BRACKETS );
pParser->Next();
break;
}
}
}
else pParser->Next();
}
+353
View File
@@ -0,0 +1,353 @@
/*************************************************************************
*
* $RCSfile: io.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif
#include "sbcomp.hxx"
#pragma hdrstop
#include "iosys.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
// Test, ob ein I/O-Channel angegeben wurde
BOOL SbiParser::Channel( BOOL bAlways )
{
BOOL bRes = FALSE;
Peek();
if( IsHash() )
{
SbiExpression aExpr( this );
if( Peek() == COMMA ) Next();
aExpr.Gen();
aGen.Gen( _CHANNEL );
bRes = TRUE;
}
else if( bAlways )
Error( SbERR_EXPECTED, "#" );
return bRes;
}
// Fuer PRINT und WRITE wird bei Objektvariablen versucht,
// die Default-Property anzusprechen.
// PRINT
void SbiParser::Print()
{
BOOL bChan = Channel();
// Die Ausdruecke zum Drucken:
while( !bAbort )
{
if( !IsEoln( Peek() ) )
{
SbiExpression* pExpr = new SbiExpression( this );
pExpr->Gen();
delete pExpr;
Peek();
aGen.Gen( eCurTok == COMMA ? _PRINTF : _BPRINT );
}
if( eCurTok == COMMA || eCurTok == SEMICOLON )
{
Next();
if( IsEoln( Peek() ) ) break;
}
else
{
aGen.Gen( _PRCHAR, '\n' );
break;
}
}
if( bChan )
aGen.Gen( _CHAN0 );
}
// WRITE #chan, expr, ...
void SbiParser::Write()
{
BOOL bChan = Channel();
// Die Ausdruecke zum Drucken:
while( !bAbort )
{
SbiExpression* pExpr = new SbiExpression( this );
pExpr->Gen();
delete pExpr;
aGen.Gen( _BWRITE );
if( Peek() == COMMA )
{
aGen.Gen( _PRCHAR, ',' );
Next();
if( IsEoln( Peek() ) ) break;
}
else
{
aGen.Gen( _PRCHAR, '\n' );
break;
}
}
if( bChan )
aGen.Gen( _CHAN0 );
}
// LINE INPUT [prompt], var$
void SbiParser::LineInput()
{
Channel( TRUE );
// BOOL bChan = Channel( TRUE );
SbiExpression* pExpr = new SbiExpression( this, SbOPERAND );
/* AB 15.1.96: Keinen allgemeinen Ausdruck mehr zulassen
SbiExpression* pExpr = new SbiExpression( this );
if( !pExpr->IsVariable() )
{
SbiToken eTok = Peek();
if( eTok == COMMA || eTok == SEMICOLON ) Next();
else Error( SbERR_EXPECTED, COMMA );
// mit Prompt
if( !bChan )
{
pExpr->Gen();
aGen.Gen( _PROMPT );
}
else
Error( SbERR_VAR_EXPECTED );
delete pExpr;
pExpr = new SbiExpression( this, SbOPERAND );
}
*/
if( !pExpr->IsVariable() )
Error( SbERR_VAR_EXPECTED );
if( pExpr->GetType() != SbxVARIANT && pExpr->GetType() != SbxSTRING )
Error( SbERR_CONVERSION );
pExpr->Gen();
aGen.Gen( _LINPUT );
delete pExpr;
aGen.Gen( _CHAN0 ); // ResetChannel() nicht mehr in StepLINPUT()
}
// INPUT
void SbiParser::Input()
{
aGen.Gen( _RESTART );
Channel( TRUE );
// BOOL bChan = Channel( TRUE );
SbiExpression* pExpr = new SbiExpression( this, SbOPERAND );
/* ALT: Jetzt keinen allgemeinen Ausdruck mehr zulassen
SbiExpression* pExpr = new SbiExpression( this );
...
siehe LineInput
*/
while( !bAbort )
{
if( !pExpr->IsVariable() )
Error( SbERR_VAR_EXPECTED );
pExpr->Gen();
aGen.Gen( _INPUT );
if( Peek() == COMMA )
{
Next();
delete pExpr;
pExpr = new SbiExpression( this, SbOPERAND );
}
else break;
}
delete pExpr;
aGen.Gen( _CHAN0 ); // ResetChannel() nicht mehr in StepINPUT()
}
// OPEN stringexpr FOR mode ACCCESS access mode AS Channel [Len=n]
void SbiParser::Open()
{
SbiExpression aFileName( this );
SbiToken eTok;
TestToken( FOR );
short nMode = 0;
short nFlags = 0;
switch( Next() )
{
case INPUT:
nMode = STREAM_READ; nFlags |= SBSTRM_INPUT; break;
case OUTPUT:
nMode = STREAM_WRITE | STREAM_TRUNC; nFlags |= SBSTRM_OUTPUT; break;
case APPEND:
nMode = STREAM_WRITE; nFlags |= SBSTRM_APPEND; break;
case RANDOM:
nMode = STREAM_READ | STREAM_WRITE; nFlags |= SBSTRM_RANDOM; break;
case BINARY:
nMode = STREAM_READ | STREAM_WRITE; nFlags |= SBSTRM_BINARY; break;
default:
Error( SbERR_SYNTAX );
}
if( Peek() == ACCESS )
{
Next();
eTok = Next();
// #27964# Nur STREAM_READ,STREAM_WRITE-Flags in nMode beeinflussen
nMode &= ~(STREAM_READ | STREAM_WRITE); // loeschen
if( eTok == READ )
{
if( Peek() == WRITE )
{
Next();
nMode |= (STREAM_READ | STREAM_WRITE);
}
else
nMode |= STREAM_READ;
}
else if( eTok == WRITE )
nMode |= STREAM_WRITE;
else
Error( SbERR_SYNTAX );
}
switch( Peek() )
{
#ifdef SHARED
#undef SHARED
#define tmpSHARED
#endif
case SHARED:
Next(); nMode |= STREAM_SHARE_DENYNONE; break;
#ifdef tmpSHARED
#define SHARED
#undef tmpSHARED
#endif
case LOCK:
Next();
eTok = Next();
if( eTok == READ )
{
if( Peek() == WRITE ) Next(), nMode |= STREAM_SHARE_DENYALL;
else nMode |= STREAM_SHARE_DENYREAD;
}
else if( eTok == WRITE )
nMode |= STREAM_SHARE_DENYWRITE;
else
Error( SbERR_SYNTAX );
break;
}
TestToken( AS );
// Die Kanalnummer
SbiExpression* pChan = new SbiExpression( this );
if( !pChan )
Error( SbERR_SYNTAX );
SbiExpression* pLen = NULL;
if( Peek() == SYMBOL )
{
Next();
String aLen( aSym );
if( aLen.EqualsIgnoreCaseAscii( "LEN" ) )
{
TestToken( EQ );
pLen = new SbiExpression( this );
}
}
if( !pLen ) pLen = new SbiExpression( this, 128, SbxINTEGER );
// Der Stack fuer den OPEN-Befehl sieht wie folgt aus:
// Blocklaenge
// Kanalnummer
// Dateiname
pLen->Gen();
if( pChan )
pChan->Gen();
aFileName.Gen();
aGen.Gen( _OPEN, nMode, nFlags );
delete pLen;
delete pChan;
}
// NAME file AS file
void SbiParser::Name()
{
SbiExpression aExpr1( this );
TestToken( AS );
SbiExpression aExpr2( this );
aExpr1.Gen();
aExpr2.Gen();
aGen.Gen( _RENAME );
}
// CLOSE [n,...]
void SbiParser::Close()
{
Peek();
if( IsEoln( eCurTok ) )
aGen.Gen( _CLOSE, 0 );
else
for( ;; )
{
if( Channel( TRUE ) )
aGen.Gen( _CLOSE, 1 );
else
break;
if( IsEoln( Peek() ) )
break;
}
}
+561
View File
@@ -0,0 +1,561 @@
/*************************************************************************
*
* $RCSfile: loops.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "sbcomp.hxx"
#pragma hdrstop
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
// Single-line IF und Multiline IF
void SbiParser::If()
{
USHORT nEndLbl;
SbiToken eTok;
// Ende-Tokens ignorieren:
SbiExpression aCond( this );
aCond.Gen();
TestToken( THEN );
if( IsEoln( Next() ) )
{
// AB 13.5.1996: #27720# Am Ende jeden Blocks muss ein Jump zu ENDIF
// eingefuegt werden, damit bei ELSEIF nicht erneut die Bedingung
// ausgewertet wird. Die Tabelle nimmt alle Absprungstellen auf.
#define JMP_TABLE_SIZE 100
USHORT pnJmpToEndLbl[JMP_TABLE_SIZE]; // 100 ELSEIFs zulaessig
USHORT iJmp = 0; // aktueller Tabellen-Index
// multiline IF
nEndLbl = aGen.Gen( _JUMPF, 0 );
while( !bAbort && Parse() )
{
eTok = Peek();
if( eTok == ELSEIF || eTok == ELSE || eTok == ENDIF )
break;
if( IsEof() )
{
Error( SbERR_BAD_BLOCK, IF ); bAbort = TRUE; return;
}
}
// ELSEIF?
while( eTok == ELSEIF )
{
// #27720# Bei erfolgreichem IF/ELSEIF auf ENDIF springen
if( iJmp >= JMP_TABLE_SIZE )
{
Error( SbERR_PROG_TOO_LARGE ); bAbort = TRUE; return;
}
pnJmpToEndLbl[iJmp++] = aGen.Gen( _JUMP, 0 );
Next();
aGen.BackChain( nEndLbl );
SbiExpression* pCond = new SbiExpression( this );
pCond->Gen();
nEndLbl = aGen.Gen( _JUMPF, 0 );
delete pCond;
TestToken( THEN );
while( !bAbort && Parse() )
{
eTok = Peek();
if( eTok == ELSEIF || eTok == ELSE || eTok == ENDIF )
break;
if( IsEof() )
{
Error( SbERR_BAD_BLOCK, ELSEIF ); bAbort = TRUE; return;
}
}
}
if( eTok == ELSE )
{
Next();
USHORT nElseLbl = nEndLbl;
nEndLbl = aGen.Gen( _JUMP, 0 );
aGen.BackChain( nElseLbl );
StmntBlock( ENDIF );
}
else if( eTok == ENDIF )
Next();
// #27720# Jmp-Tabelle abarbeiten
while( iJmp > 0 )
{
iJmp--;
aGen.BackChain( pnJmpToEndLbl[iJmp] );
}
}
else
{
// single line IF
bSingleLineIf = TRUE;
nEndLbl = aGen.Gen( _JUMPF, 0 );
Push( eCurTok );
while( !bAbort )
{
if( !Parse() ) break;
eTok = Peek();
if( eTok == ELSE || eTok == EOLN || eTok == REM )
break;
}
if( eTok == ELSE )
{
Next();
USHORT nElseLbl = nEndLbl;
nEndLbl = aGen.Gen( _JUMP, 0 );
aGen.BackChain( nElseLbl );
while( !bAbort )
{
if( !Parse() ) break;
eTok = Peek();
if( eTok == EOLN )
break;
}
}
bSingleLineIf = FALSE;
}
aGen.BackChain( nEndLbl );
}
// ELSE/ELSEIF/ENDIF ohne IF
void SbiParser::NoIf()
{
Error( SbERR_NO_IF );
StmntBlock( ENDIF );
}
// DO WHILE...LOOP
// DO ... LOOP WHILE
void SbiParser::DoLoop()
{
USHORT nStartLbl = aGen.GetPC();
USHORT nEndChain = 0;
OpenBlock( DO );
SbiToken eTok = Next();
if( IsEoln( eTok ) )
{
// DO ... LOOP [WHILE|UNTIL expr]
StmntBlock( LOOP );
eTok = Next();
if( eTok == UNTIL || eTok == WHILE )
{
SbiExpression aExpr( this );
aExpr.Gen();
aGen.Gen( eTok == UNTIL ? _JUMPF : _JUMPT, nStartLbl );
} else
if (eTok == EOLN || eTok == REM)
aGen.Gen (_JUMP, nStartLbl);
else
Error( SbERR_EXPECTED, WHILE );
}
else
{
// DO [WHILE|UNTIL expr] ... LOOP
if( eTok == UNTIL || eTok == WHILE )
{
SbiExpression aCond( this );
aCond.Gen();
}
USHORT nEndLbl = aGen.Gen( eTok == UNTIL ? _JUMPT : _JUMPF, 0 );
StmntBlock( LOOP );
TestEoln();
aGen.Gen( _JUMP, nStartLbl );
aGen.BackChain( nEndLbl );
}
CloseBlock();
}
// WHILE ... WEND
void SbiParser::While()
{
SbiExpression aCond( this );
USHORT nStartLbl = aGen.GetPC();
aCond.Gen();
USHORT nEndLbl = aGen.Gen( _JUMPF, 0 );
StmntBlock( WEND );
aGen.Gen( _JUMP, nStartLbl );
aGen.BackChain( nEndLbl );
}
// FOR var = expr TO expr STEP
void SbiParser::For()
{
SbiExpression aLvalue( this, SbOPERAND );
aLvalue.Gen(); // Variable auf dem Stack
TestToken( EQ );
SbiExpression aStartExpr( this );
aStartExpr.Gen(); // Startausdruck auf dem Stack
TestToken( TO );
SbiExpression aStopExpr( this );
aStopExpr.Gen(); // Endausdruck auf dem Stack
if( Peek() == STEP )
{
Next();
SbiExpression aStepExpr( this );
aStepExpr.Gen();
}
else
{
SbiExpression aOne( this, 1, SbxINTEGER );
aOne.Gen();
}
TestEoln();
// Der Stack hat jetzt 4 Elemente: Variable, Start, Ende, Inkrement
// Startwert binden
aGen.Gen( _INITFOR );
USHORT nLoop = aGen.GetPC();
// Test durchfuehren, evtl. Stack freigeben
USHORT nEndTarget = aGen.Gen( _TESTFOR, 0 );
OpenBlock( FOR );
StmntBlock( NEXT );
aGen.Gen( _NEXT );
aGen.Gen( _JUMP, nLoop );
// Kommen Variable nach NEXT?
if( Peek() == SYMBOL )
{
SbiExpression aVar( this, SbOPERAND );
if( aVar.GetRealVar() != aLvalue.GetRealVar() )
Error( SbERR_EXPECTED, aVar.GetRealVar()->GetName() );
}
aGen.BackChain( nEndTarget );
CloseBlock();
}
// WITH .. END WITH
void SbiParser::With()
{
SbiExpression aVar( this, SbOPERAND );
// Letzten Knoten in der Objekt-Kette ueberpruefen
SbiExprNode *pNode = aVar.GetExprNode()->GetRealNode();
SbiSymDef* pDef = pNode->GetVar();
// Variant, AB 27.6.1997, #41090: bzw. empty -> muß Object sein
if( pDef->GetType() == SbxVARIANT || pDef->GetType() == SbxEMPTY )
pDef->SetType( SbxOBJECT );
else if( pDef->GetType() != SbxOBJECT )
Error( SbERR_NEEDS_OBJECT );
// Knoten auch auf SbxOBJECT setzen, damit spaeter Gen() klappt
pNode->SetType( SbxOBJECT );
OpenBlock( NIL, aVar.GetExprNode() );
StmntBlock( ENDWITH );
CloseBlock();
}
// LOOP/NEXT/WEND ohne Konstrukt
void SbiParser::BadBlock()
{
if( eEndTok )
Error( SbERR_BAD_BLOCK, eEndTok );
else
Error( SbERR_BAD_BLOCK, "Loop/Next/Wend" );
}
// On expr Goto/Gosub n,n,n...
void SbiParser::OnGoto()
{
SbiExpression aCond( this );
aCond.Gen();
USHORT nLabelsTarget = aGen.Gen( _ONJUMP, 0 );
SbiToken eTok = Next();
if( eTok != GOTO && eTok != GOSUB )
{
Error( SbERR_EXPECTED, "GoTo/GoSub" );
eTok = GOTO;
}
// Label-Tabelle einlesen:
short nLbl = 0;
do
{
SbiToken eTok2 = Next(); // Label holen
if( MayBeLabel() )
{
USHORT nOff = pProc->GetLabels().Reference( aSym );
aGen.Gen( _JUMP, nOff );
nLbl++;
}
else Error( SbERR_LABEL_EXPECTED );
}
while( !bAbort && TestComma() );
if( eTok == GOSUB )
nLbl |= 0x8000;
aGen.Patch( nLabelsTarget, nLbl );
}
// GOTO/GOSUB
void SbiParser::Goto()
{
SbiOpcode eOp = eCurTok == GOTO ? _JUMP : _GOSUB;
Next();
if( MayBeLabel() )
{
USHORT nOff = pProc->GetLabels().Reference( aSym );
aGen.Gen( eOp, nOff );
}
else Error( SbERR_LABEL_EXPECTED );
}
// RETURN [label]
void SbiParser::Return()
{
Next();
if( MayBeLabel() )
{
USHORT nOff = pProc->GetLabels().Reference( aSym );
aGen.Gen( _RETURN, nOff );
}
else aGen.Gen( _RETURN, 0 );
}
// SELECT CASE
void SbiParser::Select()
{
TestToken( CASE );
SbiExpression aCase( this );
SbiToken eTok;
aCase.Gen();
aGen.Gen( _CASE );
TestEoln();
USHORT nNextTarget = 0;
USHORT nDoneTarget = 0;
BOOL bElse = FALSE;
// Die Cases einlesen:
while( !bAbort )
{
eTok = Next();
if( eTok == CASE )
{
if( nNextTarget )
aGen.BackChain( nNextTarget ), nNextTarget = 0;
aGen.Statement();
// Jeden Case einlesen
BOOL bDone = FALSE;
USHORT nTrueTarget = 0;
if( Peek() == ELSE )
{
// CASE ELSE
Next();
bElse = TRUE;
}
else while( !bDone )
{
if( bElse )
Error( SbERR_SYNTAX );
SbiToken eTok = Peek();
if( eTok == IS || ( eTok >= EQ && eTok <= GE ) )
{ // CASE [IS] operator expr
if( eTok == IS )
Next();
eTok = Peek();
if( eTok < EQ || eTok > GE )
Error( SbERR_SYNTAX );
else Next();
SbiExpression aCompare( this );
aCompare.Gen();
nTrueTarget = aGen.Gen( _CASEIS, nTrueTarget,
SbxEQ + ( eTok - EQ ) );
}
else
{ // CASE expr | expr TO expr
SbiExpression aCase1( this );
aCase1.Gen();
if( Peek() == TO )
{
// CASE a TO b
Next();
SbiExpression aCase2( this );
aCase2.Gen();
nTrueTarget = aGen.Gen( _CASETO, nTrueTarget );
}
else
// CASE a
nTrueTarget = aGen.Gen( _CASEIS, nTrueTarget, SbxEQ );
}
if( Peek() == COMMA ) Next();
else TestEoln(), bDone = TRUE;
}
// Alle Cases abgearbeitet
if( !bElse )
{
nNextTarget = aGen.Gen( _JUMP, nNextTarget );
aGen.BackChain( nTrueTarget );
}
// den Statement-Rumpf bauen
while( !bAbort )
{
eTok = Peek();
if( eTok == CASE || eTok == ENDSELECT )
break;
if( !Parse() ) goto done;
eTok = Peek();
if( eTok == CASE || eTok == ENDSELECT )
break;
}
if( !bElse )
nDoneTarget = aGen.Gen( _JUMP, nDoneTarget );
}
else if( !IsEoln( eTok ) )
break;
}
done:
if( eTok != ENDSELECT )
Error( SbERR_EXPECTED, ENDSELECT );
if( nNextTarget )
aGen.BackChain( nNextTarget );
aGen.BackChain( nDoneTarget );
aGen.Gen( _ENDCASE );
}
// ON Error/Variable
#ifdef _MSC_VER
#pragma optimize("",off)
#endif
void SbiParser::On()
{
SbiToken eTok = Peek();
String aString = SbiTokenizer::Symbol(eTok);
if (aString.EqualsIgnoreCaseAscii("ERROR"))
//if (!aString.ICompare("ERROR"))
eTok = _ERROR_; // Error kommt als SYMBOL
if( eTok != _ERROR_ && eTok != LOCAL ) OnGoto();
else
{
if( eTok == LOCAL ) Next();
Next (); // Kein TestToken mehr, da es sonst einen Fehler gibt
Next(); // Token nach Error holen
if( eCurTok == GOTO )
{
// ON ERROR GOTO label|0
Next();
if( MayBeLabel() )
{
if( eCurTok == NUMBER && !nVal )
aGen.Gen( _STDERROR );
else
{
USHORT nOff = pProc->GetLabels().Reference( aSym );
aGen.Gen( _ERRHDL, nOff );
}
}
else Error( SbERR_LABEL_EXPECTED );
}
else if( eCurTok == RESUME )
{
TestToken( NEXT );
aGen.Gen( _NOERROR );
}
else Error( SbERR_EXPECTED, "GoTo/Resume" );
}
}
#ifdef _MSC_VER
#pragma optimize("",off)
#endif
// RESUME [0]|NEXT|label
void SbiParser::Resume()
{
USHORT nLbl;
switch( Next() )
{
case EOS:
case EOLN:
aGen.Gen( _RESUME, 0 );
break;
case NEXT:
aGen.Gen( _RESUME, 1 );
Next();
break;
case NUMBER:
if( !nVal )
{
aGen.Gen( _RESUME, 0 );
break;
} // fall thru
case SYMBOL:
if( MayBeLabel() )
{
nLbl = pProc->GetLabels().Reference( aSym );
aGen.Gen( _RESUME, nLbl );
Next();
break;
} // fall thru
default:
Error( SbERR_LABEL_EXPECTED );
}
}
+106
View File
@@ -0,0 +1,106 @@
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1.1.1 $
#
# last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library 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 for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..
PRJNAME=BASIC
TARGET=comp
# --- Settings ------------------------------------------------------------
.INCLUDE : svpre.mk
.INCLUDE : settings.mk
.INCLUDE : sv.mk
CXXFILES= \
sbcomp.cxx \
dim.cxx \
exprtree.cxx \
exprnode.cxx \
exprgen.cxx \
codegen.cxx \
io.cxx \
loops.cxx \
parser.cxx \
scanner.cxx \
token.cxx \
symtbl.cxx \
buffer.cxx
SLOFILES= \
$(SLO)$/sbcomp.obj \
$(SLO)$/dim.obj \
$(SLO)$/exprtree.obj \
$(SLO)$/exprnode.obj \
$(SLO)$/exprgen.obj \
$(SLO)$/codegen.obj \
$(SLO)$/io.obj \
$(SLO)$/loops.obj \
$(SLO)$/parser.obj \
$(SLO)$/scanner.obj \
$(SLO)$/token.obj \
$(SLO)$/symtbl.obj \
$(SLO)$/buffer.obj
# --- Targets --------------------------------------------------------------
.INCLUDE : target.mk
+774
View File
@@ -0,0 +1,774 @@
/*************************************************************************
*
* $RCSfile: parser.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#if SUPD >= 375
#ifndef _SBXCLASS_HXX //autogen
#include <svtools/sbx.hxx>
#endif
#else
#include <svmem.hxx>
#include <sbx.hxx>
#endif
#include "sbcomp.hxx"
#pragma hdrstop
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
struct SbiParseStack { // "Stack" fuer Statement-Blocks
SbiParseStack* pNext; // Chain
SbiExprNode* pWithVar; // Variable fuer WITH
SbiToken eExitTok; // Exit-Token
USHORT nChain; // JUMP-Chain
};
struct SbiStatement {
SbiToken eTok;
void( SbiParser::*Func )(); // Verarbeitungsroutine
BOOL bMain; // TRUE: ausserhalb SUBs OK
BOOL bSubr; // TRUE: in SUBs OK
BOOL bVBScript; // TRUE: in OK
};
#define Y TRUE
#define N FALSE
static SbiStatement StmntTable [] = {
{ CALL, &SbiParser::Call, N, Y, Y, }, // CALL
{ CLOSE, &SbiParser::Close, N, Y, Y, }, // CLOSE
{ _CONST_, &SbiParser::Dim, Y, Y, Y, }, // CONST
{ DECLARE, &SbiParser::Declare, Y, N, N, }, // DECLARE
{ DEFBOOL, &SbiParser::DefXXX, Y, N, N, }, // DEFBOOL
{ DEFCUR, &SbiParser::DefXXX, Y, N, N, }, // DEFCUR
{ DEFDATE, &SbiParser::DefXXX, Y, N, N, }, // DEFDATE
{ DEFDBL, &SbiParser::DefXXX, Y, N, N, }, // DEFDBL
{ DEFERR, &SbiParser::DefXXX, Y, N, N, }, // DEFERR
{ DEFINT, &SbiParser::DefXXX, Y, N, N, }, // DEFINT
{ DEFLNG, &SbiParser::DefXXX, Y, N, N, }, // DEFLNG
{ DEFOBJ, &SbiParser::DefXXX, Y, N, N, }, // DEFOBJ
{ DEFSNG, &SbiParser::DefXXX, Y, N, N, }, // DEFSNG
{ DEFSTR, &SbiParser::DefXXX, Y, N, N, }, // DEFSTR
{ DEFVAR, &SbiParser::DefXXX, Y, N, N, }, // DEFVAR
{ DIM, &SbiParser::Dim, Y, Y, Y, }, // DIM
{ DO, &SbiParser::DoLoop, N, Y, Y, }, // DO
{ ELSE, &SbiParser::NoIf, N, Y, Y, }, // ELSE
{ ELSEIF, &SbiParser::NoIf, N, Y, Y, }, // ELSEIF
{ ENDIF, &SbiParser::NoIf, N, Y, Y, }, // ENDIF
{ END, &SbiParser::Stop, N, Y, N, }, // END
{ ERASE, &SbiParser::Erase, N, Y, Y, }, // ERASE
{ _ERROR_, &SbiParser::ErrorStmnt, N, Y, Y, }, // ERROR
{ EXIT, &SbiParser::Exit, N, Y, N, }, // EXIT
{ FOR, &SbiParser::For, N, Y, Y, }, // FOR
{ FUNCTION, &SbiParser::SubFunc, Y, N, Y, }, // FUNCTION
{ GOSUB, &SbiParser::Goto, N, Y, N, }, // GOSUB
{ GLOBAL, &SbiParser::Dim, Y, N, Y, }, // GLOBAL
{ GOTO, &SbiParser::Goto, N, Y, N, }, // GOTO
{ IF, &SbiParser::If, N, Y, Y, }, // IF
{ INPUT, &SbiParser::Input, N, Y, Y, }, // INPUT
{ LET, &SbiParser::Assign, N, Y, Y, }, // LET
{ LINEINPUT,&SbiParser::LineInput, N, Y, Y, }, // LINE INPUT
{ LOOP, &SbiParser::BadBlock, N, Y, Y, }, // LOOP
{ LSET, &SbiParser::LSet, N, Y, N, }, // LSET
{ NAME, &SbiParser::Name, N, Y, Y, }, // NAME
{ NEXT, &SbiParser::BadBlock, N, Y, Y, }, // NEXT
{ ON, &SbiParser::On, N, Y, N, }, // ON
{ OPEN, &SbiParser::Open, N, Y, Y, }, // OPEN
{ OPTION, &SbiParser::Option, Y, N, N, }, // OPTION
{ PRINT, &SbiParser::Print, N, Y, Y, }, // PRINT
{ PRIVATE, &SbiParser::Dim, Y, N, Y, }, // PRIVATE
{ PUBLIC, &SbiParser::Dim, Y, N, Y, }, // PUBLIC
{ REDIM, &SbiParser::ReDim, N, Y, Y, }, // DIM
{ RESUME, &SbiParser::Resume, N, Y, N, }, // RESUME
{ RETURN, &SbiParser::Return, N, Y, N, }, // RETURN
{ RSET, &SbiParser::RSet, N, Y, N, }, // RSET
{ SELECT, &SbiParser::Select, N, Y, N, }, // SELECT
{ SET, &SbiParser::Set, N, Y, Y, }, // SET
{ STATIC, &SbiParser::Static, Y, Y, Y, }, // STATIC
{ STOP, &SbiParser::Stop, N, Y, N, }, // STOP
{ SUB, &SbiParser::SubFunc, Y, N, Y, }, // SUB
{ TYPE, &SbiParser::Type, Y, N, Y, }, // TYPE
{ UNTIL, &SbiParser::BadBlock, N, Y, Y, }, // UNTIL
{ WHILE, &SbiParser::While, N, Y, Y, }, // WHILE
{ WEND, &SbiParser::BadBlock, N, Y, Y, }, // WEND
{ WITH, &SbiParser::With, N, Y, N, }, // WITH
{ WRITE, &SbiParser::Write, N, Y, Y, }, // WRITE
{ NIL }
};
#ifdef MSC
// 'this' : used in base member initializer list
#pragma warning( disable: 4355 )
#endif
SbiParser::SbiParser( StarBASIC* pb, SbModule* pm )
: SbiTokenizer( pm->GetSource(), pb ),
aGblStrings( this ),
aLclStrings( this ),
aPublics( aGblStrings, SbPUBLIC ),
aGlobals( aGblStrings, SbGLOBAL ),
aRtlSyms( aGblStrings, SbRTL ),
aGen( *pm, this, 1024 )
{
pBasic = pb;
eCurExpr = SbSYMBOL;
eEndTok = NIL;
pProc = NULL;
pStack = NULL;
pWithVar = NULL;
nBase = 0;
bText =
bGblDefs =
bNewGblDefs =
bSingleLineIf =
bExplicit = FALSE;
pPool = &aPublics;
for( short i = 0; i < 26; i++ )
eDefTypes[ i ] = SbxVARIANT; // Kein expliziter Defaulttyp
aPublics.SetParent( &aGlobals );
aGlobals.SetParent( &aRtlSyms );
// Die globale Chainkette faengt bei Adresse 0 an:
nGblChain = aGen.Gen( _JUMP, 0 );
rTypeArray = new SbxArray; // Array fuer Benutzerdefinierte Typen
}
// Ist Teil der Runtime-Library?
SbiSymDef* SbiParser::CheckRTLForSym( const String& rSym, SbxDataType eType )
{
SbxVariable* pVar = GetBasic()->GetRtl()->Find( rSym, SbxCLASS_DONTCARE );
SbiSymDef* pDef = NULL;
if( pVar )
{
if( pVar->IsA( TYPE(SbxMethod) ) )
{
SbiProcDef* pProc = aRtlSyms.AddProc( rSym );
pProc->SetType( pVar->GetType() );
pDef = pProc;
}
else
{
pDef = aRtlSyms.AddSym( rSym );
pDef->SetType( eType );
}
}
return pDef;
}
// Globale Chainkette schliessen
BOOL SbiParser::HasGlobalCode()
{
if( bGblDefs && nGblChain )
{
aGen.BackChain( nGblChain );
aGen.Gen( _LEAVE );
// aGen.Gen( _STOP );
nGblChain = 0;
}
return bGblDefs;
}
void SbiParser::OpenBlock( SbiToken eTok, SbiExprNode* pVar )
{
SbiParseStack* p = new SbiParseStack;
p->eExitTok = eTok;
p->nChain = 0;
p->pWithVar = pWithVar;
p->pNext = pStack;
pStack = p;
pWithVar = pVar;
// #29955 for-Schleifen-Ebene pflegen
if( eTok == FOR )
aGen.IncForLevel();
}
void SbiParser::CloseBlock()
{
if( pStack )
{
SbiParseStack* p = pStack;
// #29955 for-Schleifen-Ebene pflegen
if( p->eExitTok == FOR )
aGen.DecForLevel();
aGen.BackChain( p->nChain );
pStack = p->pNext;
pWithVar = p->pWithVar;
delete p;
}
}
// EXIT ...
void SbiParser::Exit()
{
SbiToken eTok = Next();
for( SbiParseStack* p = pStack; p; p = p->pNext )
{
if( eTok == p->eExitTok )
{
p->nChain = aGen.Gen( _JUMP, p->nChain );
return;
}
}
if( pStack )
Error( SbERR_EXPECTED, pStack->eExitTok );
else
Error( SbERR_BAD_EXIT );
}
BOOL SbiParser::TestSymbol( BOOL bKwdOk )
{
Peek();
if( eCurTok == SYMBOL || ( bKwdOk && IsKwd( eCurTok ) ) )
{
Next(); return TRUE;
}
Error( SbERR_SYMBOL_EXPECTED );
return FALSE;
}
// Testen auf ein bestimmtes Token
BOOL SbiParser::TestToken( SbiToken t )
{
if( Peek() == t )
{
Next(); return TRUE;
}
else
{
Error( SbERR_EXPECTED, t );
return FALSE;
}
}
// Testen auf Komma oder EOLN
BOOL SbiParser::TestComma()
{
SbiToken eTok = Peek();
if( IsEoln( eTok ) )
{
Next();
return FALSE;
}
else if( eTok != COMMA )
{
Error( SbERR_EXPECTED, COMMA );
return FALSE;
}
Next();
return TRUE;
}
// Testen, ob EOLN vorliegt
void SbiParser::TestEoln()
{
if( !IsEoln( Next() ) )
{
Error( SbERR_EXPECTED, EOLN );
while( !IsEoln( Next() ) ) {}
}
}
// Parsing eines Statement-Blocks
// Das Parsing laeuft bis zum Ende-Token.
void SbiParser::StmntBlock( SbiToken eEnd )
{
SbiToken xe = eEndTok;
eEndTok = eEnd;
while( !bAbort && Parse() ) {}
eEndTok = xe;
if( IsEof() )
{
Error( SbERR_BAD_BLOCK, eEnd );
bAbort = TRUE;
}
}
// Die Hauptroutine. Durch wiederholten Aufrufs dieser Routine wird
// die Quelle geparst. Returnwert FALSE bei Ende/Fehlern.
BOOL SbiParser::Parse()
{
if( bAbort ) return FALSE;
EnableErrors();
Peek();
// Dateiende?
if( IsEof() )
{
// AB #33133: Falls keine Sub angelegt wurde, muss hier
// der globale Chain abgeschlossen werden!
// AB #40689: Durch die neue static-Behandlung kann noch
// ein nGblChain vorhanden sein, daher vorher abfragen
if( bNewGblDefs && nGblChain == 0 )
nGblChain = aGen.Gen( _JUMP, 0 );
return FALSE;
}
// Leerstatement?
if( IsEoln( eCurTok ) )
{
Next(); return TRUE;
}
if( !bSingleLineIf && MayBeLabel( TRUE ) )
{
// Ist ein Label
if( !pProc )
Error( SbERR_NOT_IN_MAIN, aSym );
else
pProc->GetLabels().Define( aSym );
Next(); Peek();
// Leerstatement?
if( IsEoln( eCurTok ) )
{
Next(); return TRUE;
}
}
// Ende des Parsings?
if( eCurTok == eEndTok )
{
Next();
if( eCurTok != NIL )
aGen.Statement();
return FALSE;
}
// Kommentar?
if( eCurTok == REM )
{
Next(); return TRUE;
}
// Kommt ein Symbol, ist es entweder eine Variable( LET )
// oder eine SUB-Prozedur( CALL ohne Klammern )
// DOT fuer Zuweisungen im WITH-Block: .A=5
if( eCurTok == SYMBOL || eCurTok == DOT )
{
#ifndef VBSCRIPT_TEST
if( !pProc )
Error( SbERR_EXPECTED, SUB );
else
#endif
{
// Damit Zeile & Spalte stimmen...
Next();
Push( eCurTok );
aGen.Statement();
Symbol();
}
}
else
{
Next();
// Hier folgen nun die Statement-Parser.
SbiStatement* p;
for( p = StmntTable; p->eTok != NIL; p++ )
if( p->eTok == eCurTok )
break;
if( p->eTok != NIL )
{
#ifdef VBSCRIPT_TEST
if( !p->bVBScript )
Error( ERRCODE_BASIC_NOT_IN_VBSCRIPT );
else
#endif
#ifndef VBSCRIPT_TEST
if( !pProc && !p->bMain )
Error( SbERR_NOT_IN_MAIN, eCurTok );
else
#endif
if( pProc && !p->bSubr )
Error( SbERR_NOT_IN_SUBR, eCurTok );
else
{
// globalen Chain pflegen
// AB #41606/#40689: Durch die neue static-Behandlung kann noch
// ein nGblChain vorhanden sein, daher vorher abfragen
if( bNewGblDefs && ( eCurTok == SUB || eCurTok == FUNCTION ) && nGblChain == 0 )
{
nGblChain = aGen.Gen( _JUMP, 0 );
bNewGblDefs = FALSE;
}
// Statement-Opcode bitte auch am Anfang einer Sub
if( ( p->bSubr && (eCurTok != STATIC || Peek() == SUB || Peek() == FUNCTION ) ) ||
eCurTok == SUB || eCurTok == FUNCTION )
aGen.Statement();
(this->*( p->Func ) )();
SbxError nSbxErr = SbxBase::GetError();
if( nSbxErr )
SbxBase::ResetError(), Error( (SbError)nSbxErr );
}
}
else
Error( SbERR_UNEXPECTED, eCurTok );
}
// Test auf Ende des Statements:
// Kann auch ein ELSE sein, da vor dem ELSE kein : stehen muss!
if( !IsEos() )
{
Peek();
if( !IsEos() && eCurTok != ELSE )
{
// falls das Parsing abgebrochen wurde, bis zum ":" vorgehen:
Error( SbERR_UNEXPECTED, eCurTok );
while( !IsEos() ) Next();
}
}
// Der Parser bricht am Ende ab, das naechste Token ist noch nicht
// geholt!
return TRUE;
}
// Innerste With-Variable liefern
SbiExprNode* SbiParser::GetWithVar()
{
if( pWithVar )
return pWithVar;
// Sonst im Stack suchen
SbiParseStack* p = pStack;
while( p )
{
// LoopVar kann zur Zeit nur fuer with sein
if( p->pWithVar )
return p->pWithVar;
p = p->pNext;
}
return NULL;
}
// Zuweisung oder Subroutine Call
void SbiParser::Symbol()
{
SbiExpression aVar( this, SbSYMBOL );
aVar.Gen();
if( Peek() != EQ )
{
aGen.Gen( _GET );
}
else
{
// Dann muss es eine Zuweisung sein. Was anderes gibts nicht!
if( !aVar.IsLvalue() )
Error( SbERR_LVALUE_EXPECTED );
TestToken( EQ );
SbiExpression aExpr( this );
aExpr.Gen();
SbiOpcode eOp = _PUT;
SbiSymDef* pDef = aVar.GetRealVar();
if( pDef )
{
if( pDef->GetConstDef() )
Error( SbERR_DUPLICATE_DEF, pDef->GetName() );
if( pDef->GetType() == SbxOBJECT )
{
eOp = _SET;
if( pDef->GetTypeId() )
// if( pDef->GetTypeId() && !pDef->HabIchAlsTypeDefiniert() )
aGen.Gen( _CLASS, pDef->GetTypeId() );
// x = Objektfunktion (ohne Set) is nich drin
// Error( SbERR_SYNTAX );
}
}
aGen.Gen( eOp );
}
}
// Zuweisungen
void SbiParser::Assign()
{
SbiExpression aLvalue( this, SbLVALUE );
TestToken( EQ );
SbiExpression aExpr( this );
aLvalue.Gen();
aExpr.Gen();
USHORT nLen = 0;
SbiSymDef* pDef = aLvalue.GetRealVar();
{
if( pDef->GetConstDef() )
Error( SbERR_DUPLICATE_DEF, pDef->GetName() );
nLen = aLvalue.GetRealVar()->GetLen();
}
if( nLen )
aGen.Gen( _PAD, nLen );
aGen.Gen( _PUT );
}
// Zuweisungen einer Objektvariablen
void SbiParser::Set()
{
SbiExpression aLvalue( this, SbLVALUE );
if( aLvalue.GetType() != SbxOBJECT )
Error( SbERR_INVALID_OBJECT );
TestToken( EQ );
SbiSymDef* pDef = aLvalue.GetRealVar();
if( pDef && pDef->GetConstDef() )
Error( SbERR_DUPLICATE_DEF, pDef->GetName() );
SbiExpression aExpr( this );
aLvalue.Gen();
aExpr.Gen();
if( pDef->GetTypeId() )
// if( pDef->GetTypeId() && !pDef->HabIchAlsTypeDefiniert() )
aGen.Gen( _CLASS, pDef->GetTypeId() );
aGen.Gen( _SET );
}
// JSM 07.10.95
void SbiParser::LSet()
{
SbiExpression aLvalue( this, SbLVALUE );
if( aLvalue.GetType() != SbxSTRING )
Error( SbERR_INVALID_OBJECT );
TestToken( EQ );
SbiSymDef* pDef = aLvalue.GetRealVar();
if( pDef && pDef->GetConstDef() )
Error( SbERR_DUPLICATE_DEF, pDef->GetName() );
SbiExpression aExpr( this );
aLvalue.Gen();
aExpr.Gen();
aGen.Gen( _LSET );
}
// JSM 07.10.95
void SbiParser::RSet()
{
SbiExpression aLvalue( this, SbLVALUE );
if( aLvalue.GetType() != SbxSTRING )
Error( SbERR_INVALID_OBJECT );
TestToken( EQ );
SbiSymDef* pDef = aLvalue.GetRealVar();
if( pDef && pDef->GetConstDef() )
Error( SbERR_DUPLICATE_DEF, pDef->GetName() );
SbiExpression aExpr( this );
aLvalue.Gen();
aExpr.Gen();
aGen.Gen( _RSET );
}
// DEFINT, DEFLNG, DEFSNG, DEFDBL, DEFSTR und so weiter
void SbiParser::DefXXX()
{
sal_Unicode ch1, ch2;
SbxDataType t = SbxDataType( eCurTok - DEFINT + SbxINTEGER );
while( !bAbort )
{
if( Next() != SYMBOL ) break;
ch1 = aSym.ToUpperAscii().GetBuffer()[0];
ch2 = 0;
if( Peek() == MINUS )
{
Next();
if( Next() != SYMBOL ) Error( SbERR_SYMBOL_EXPECTED );
else
{
ch2 = aSym.ToUpperAscii().GetBuffer()[0];
//ch2 = aSym.Upper();
if( ch2 < ch1 ) Error( SbERR_SYNTAX ), ch2 = 0;
}
}
if (!ch2) ch2 = ch1;
ch1 -= 'A'; ch2 -= 'A';
for (; ch1 <= ch2; ch1++) eDefTypes[ ch1 ] = t;
if( !TestComma() ) break;
}
}
// STOP/SYSTEM
void SbiParser::Stop()
{
aGen.Gen( _STOP );
Peek(); // #35694: Nur Peek(), damit EOL in Single-Line-If erkannt wird
}
// OPTION
void SbiParser::Option()
{
switch( Next() )
{
case EXPLICIT:
bExplicit = TRUE; break;
case BASE:
if( Next() == NUMBER )
{
if( nVal == 0 || nVal == 1 )
{
nBase = (short) nVal;
break;
}
}
Error( SbERR_EXPECTED, "0/1" );
break;
case PRIVATE:
{
String aString = SbiTokenizer::Symbol(Next());
if( !aString.EqualsIgnoreCaseAscii("Module") )
Error( SbERR_EXPECTED, "Module" );
break;
}
case COMPARE:
switch( Next() )
{
case TEXT: bText = TRUE; return;
case BINARY: bText = FALSE; return;
default:;
} // Fall thru!
default:
Error( SbERR_BAD_OPTION, eCurTok );
}
}
// ERROR n
void SbiParser::ErrorStmnt()
{
SbiExpression aPar( this );
aPar.Gen();
aGen.Gen( _ERROR );
}
// AB 22.5.1996
// JavaScript-Parsing zunaechst provisorisch hier implementiert
void SbiParser::OpenJavaBlock( SbiToken, SbiExprNode* )
{
}
void SbiParser::CloseJavaBlock()
{
}
void SbiParser::JavaStmntBlock( SbiToken )
{
}
void SbiParser::JavaBreak()
{
}
void SbiParser::JavaContinue()
{
}
void SbiParser::JavaFor()
{
}
void SbiParser::JavaFunction()
{
}
void SbiParser::JavaIf()
{
}
void SbiParser::JavaNew()
{
}
void SbiParser::JavaReturn()
{
}
void SbiParser::JavaThis()
{
}
void SbiParser::JavaVar()
{
}
void SbiParser::JavaWhile()
{
}
void SbiParser::JavaWith()
{
}
+138
View File
@@ -0,0 +1,138 @@
/*************************************************************************
*
* $RCSfile: sbcomp.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SV_SVAPP_HXX //autogen
#include <vcl/svapp.hxx>
#endif
#pragma hdrstop
#include <svtools/sbx.hxx>
#include "sbcomp.hxx"
#include "image.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
// Diese Routine ist hier definiert, damit der Compiler als eigenes Segment
// geladen werden kann.
BOOL SbModule::Compile()
{
if( pImage )
return TRUE;
StarBASIC* pBasic = PTR_CAST(StarBASIC,GetParent());
if( !pBasic )
return FALSE;
SbxBase::ResetError();
// Aktuelles Modul!
SbModule* pOld = pCMOD;
pCMOD = this;
// #45741# Anderes Wait-Cursor-Handling
GetSbData()->bCompWait = BOOL( aSource.Len() > 2048 );
if( GetSbData()->bCompWait )
Application::EnterWait();
SbiParser* pParser = new SbiParser( (StarBASIC*) GetParent(), this );
while( pParser->Parse() ) {}
if( !pParser->GetErrors() )
pParser->aGen.Save();
delete pParser;
// fuer den Disassembler
if( pImage )
pImage->aSource = aSource;
// #45741# Falls der Wait-Cursor gesetzt ist, jetzt zuruecksetzen
if( GetSbData()->bCompWait )
{
Application::LeaveWait();
GetSbData()->bCompWait = FALSE;
}
pCMOD = pOld;
// Beim Compilieren eines Moduls werden die Modul-globalen
// Variablen aller Module ungueltig
BOOL bRet = IsCompiled();
if( bRet )
{
pBasic->ClearAllModuleVars();
SbxObject* pParent = pBasic->GetParent();
if( pParent )
pBasic = PTR_CAST(StarBASIC,pParent);
if( pBasic )
pBasic->ClearAllModuleVars();
}
return bRet;
}
/**************************************************************************
*
* Syntax-Highlighting
*
**************************************************************************/
void StarBASIC::Highlight( const String& rSrc, SbTextPortions& rList )
{
SbiTokenizer aTok( rSrc );
aTok.Hilite( rList );
}
+501
View File
@@ -0,0 +1,501 @@
/*************************************************************************
*
* $RCSfile: scanner.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "sbcomp.hxx"
#pragma hdrstop
#include <ctype.h>
#include <stdio.h> // sprintf()
#include <string.h>
#if defined (ICC) || defined (WTC) || defined(__powerc) || defined ( MAC ) || defined UNX
#include <stdlib.h>
#else
#include <math.h> // atof()
#endif
#ifndef _SOLMATH_HXX //autogen wg. SolarMath
#include <tools/solmath.hxx>
#endif
#ifndef _TOOLS_INTN_HXX
#include <tools/intn.hxx>
#endif
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
SbiScanner::SbiScanner( const String& rBuf, StarBASIC* p ) : aBuf( rBuf )
{
pBasic = p;
pLine = NULL;
nVal = 0;
eScanType = SbxVARIANT;
nErrors =
nBufPos =
nCurCol1 =
nSavedCol1 =
nColLock =
nLine =
nCol1 =
nCol2 =
nCol = 0;
bError =
bAbort =
bSpaces =
bNumber =
bSymbol =
bUsedForHilite = FALSE;
bHash =
bErrors = TRUE;
}
SbiScanner::~SbiScanner()
{}
void SbiScanner::LockColumn()
{
if( !nColLock++ )
nSavedCol1 = nCol1;
}
void SbiScanner::UnlockColumn()
{
if( nColLock )
nColLock--;
}
void SbiScanner::GenError( SbError code )
{
if( !bError && bErrors )
{
BOOL bRes = TRUE;
// Nur einen Fehler pro Statement reporten
bError = TRUE;
if( pBasic )
{
// Falls EXPECTED oder UNEXPECTED kommen sollte, bezieht es sich
// immer auf das letzte Token, also die Col1 uebernehmen
USHORT nc = nColLock ? nSavedCol1 : nCol1;
switch( code )
{
case SbERR_EXPECTED:
case SbERR_UNEXPECTED:
case SbERR_SYMBOL_EXPECTED:
case SbERR_LABEL_EXPECTED:
nc = nCol1;
if( nc > nCol2 ) nCol2 = nc;
break;
}
bRes = pBasic->CError( code, aError, nLine, nc, nCol2 );
}
bAbort |= !bRes |
( code == SbERR_NO_MEMORY || code == SbERR_PROG_TOO_LARGE );
}
if( bErrors )
nErrors++;
}
// Falls sofort ein Doppelpunkt folgt, wird TRUE zurueckgeliefert.
// Wird von SbiTokenizer::MayBeLabel() verwendet, um einen Label zu erkennen
BOOL SbiScanner::DoesColonFollow()
{
if( pLine && *pLine == ':' )
{
pLine++; nCol++; return TRUE;
}
else return FALSE;
}
// Testen auf ein legales Suffix
static SbxDataType GetSuffixType( sal_Unicode c )
{
static String aSuffixesStr = String::CreateFromAscii( "%&!#@ $" );
if( c )
{
sal_uInt32 n = aSuffixesStr.Search( c );
if( STRING_NOTFOUND != n && c != ' ' )
return SbxDataType( (USHORT) n + SbxINTEGER );
}
return SbxVARIANT;
}
// Einlesen des naechsten Symbols in die Variablen aSym, nVal und eType
// Returnwert ist FALSE bei EOF oder Fehlern
#define BUF_SIZE 80
BOOL SbiScanner::NextSym()
{
static International aEnglischIntn( LANGUAGE_ENGLISH_US, LANGUAGE_ENGLISH_US );
// Fuer den EOLN-Fall merken
USHORT nOldLine = nLine;
USHORT nOldCol1 = nCol1;
USHORT nOldCol2 = nCol2;
sal_Unicode buf[ BUF_SIZE ], *p = buf;
bHash = FALSE;
eScanType = SbxVARIANT;
aSym.Erase();
bSymbol =
bNumber = bSpaces = FALSE;
// Zeile einlesen?
if( !pLine )
{
USHORT n = nBufPos;
USHORT nLen = aBuf.Len();
if( nBufPos >= nLen )
return FALSE;
const sal_Unicode* p = aBuf.GetBuffer();
p += n;
while( ( n < nLen ) && ( *p != '\n' ) && ( *p != '\r' ) )
p++, n++;
aLine = aBuf.Copy( nBufPos, n - nBufPos );
if( ( n < nLen ) && *p == '\r' && *( p+1 ) == '\n' )
n += 2;
else
n++;
nBufPos = n;
pLine = aLine.GetBuffer();
nOldLine = ++nLine;
nCol = nCol1 = nCol2 = nOldCol1 = nOldCol2 = 0;
nColLock = 0;
}
// Leerstellen weg:
while( *pLine && ( *pLine == ' ' ) || ( *pLine == '\t' ) || ( *pLine == '\f' ) )
pLine++, nCol++, bSpaces = TRUE;
nCol1 = nCol;
// nur Leerzeile?
if( !*pLine ) goto eoln;
if( *pLine == '#' ) pLine++, nCol++, bHash = TRUE;
// Symbol? Dann Zeichen kopieren.
if( isalpha( *pLine & 0xFF ) || *pLine == '_' )
{
// Wenn nach '_' nichts kommt, ist es ein Zeilenabschluss!
if( *pLine == '_' && !*(pLine+1) )
{ pLine++;
goto eoln; }
bSymbol = TRUE;
short n = nCol;
for ( ; (isalnum( *pLine & 0xFF ) || ( *pLine == '_' ) ); pLine++ )
nCol++;
aSym = aLine.Copy( n, nCol - n );
// Abschliessendes '_' durch Space ersetzen, wenn Zeilenende folgt
// (sonst falsche Zeilenfortsetzung)
if( !bUsedForHilite && !*pLine && *(pLine-1) == '_' )
*((sal_Unicode*)(pLine-1)) = ' '; // cast wegen const
// Typkennung?
// Das Ausrufezeichen bitte nicht testen, wenn
// danach noch ein Symbol anschliesst
else if( *pLine != '!' || !isalpha( pLine[ 1 ] & 0xFF ) )
{
SbxDataType t = GetSuffixType( *pLine );
if( t != SbxVARIANT )
{
eScanType = t;
pLine++;
nCol++;
#ifdef VBSCRIPT_TEST
nCol2 = nCol;
GenError( ERRCODE_BASIC_NOT_IN_VBSCRIPT );
#endif
}
}
}
// Zahl? Dann einlesen und konvertieren.
else if( isdigit( *pLine & 0xFF )
|| ( *pLine == '.' && isdigit( *(pLine+1) & 0xFF ) ) )
{
short exp = 0;
short comma = 0;
short ndig = 0;
short ncdig = 0;
eScanType = SbxDOUBLE;
BOOL bBufOverflow = FALSE;
while( strchr( "0123456789.DEde", *pLine ) && *pLine )
{
// AB 4.1.1996: Buffer voll? -> leer weiter scannen
if( (p-buf) == (BUF_SIZE-1) )
{
bBufOverflow = TRUE;
pLine++, nCol++;
continue;
}
// Komma oder Exponent?
if( *pLine == '.' )
{
if( ++comma > 1 )
{
pLine++; nCol++; continue;
}
else *p++ = *pLine++, nCol++;
}
else if( strchr( "DdEe", *pLine ) )
{
if (++exp > 1)
{
pLine++; nCol++; continue;
}
// if( toupper( *pLine ) == 'D' )
// eScanType = SbxDOUBLE;
*p++ = 'E'; pLine++; nCol++;
// Vorzeichen hinter Exponent?
if( *pLine == '+' )
pLine++, nCol++;
else
if( *pLine == '-' )
*p++ = *pLine++, nCol++;
}
else
{
*p++ = *pLine++, nCol++;
if( comma && !exp ) ncdig++;
}
if (!exp) ndig++;
}
*p = 0;
aSym = p; bNumber = TRUE;
// Komma, Exponent mehrfach vorhanden?
if( comma > 1 || exp > 1 )
{ aError = '.';
GenError( SbERR_BAD_CHAR_IN_NUMBER ); }
// #57844 Lokalisierte Funktion benutzen
int nErrno;
nVal = SolarMath::StringToDouble( buf, aEnglischIntn, nErrno );
// ATL: nVal = atof( buf );
ndig -= comma;
if( !comma && !exp )
{
if( nVal >= SbxMININT && nVal <= SbxMAXINT )
eScanType = SbxINTEGER;
else
if( nVal >= SbxMINLNG && nVal <= SbxMAXLNG )
eScanType = SbxLONG;
}
if( bBufOverflow )
GenError( SbERR_MATH_OVERFLOW );
// zu viele Zahlen fuer SINGLE?
// if (ndig > 15 || ncdig > 6)
// eScanType = SbxDOUBLE;
// else
// if( nVal > SbxMAXSNG || nVal < SbxMINSNG )
// eScanType = SbxDOUBLE;
// Typkennung?
SbxDataType t = GetSuffixType( *pLine );
if( t != SbxVARIANT )
{
eScanType = t;
pLine++;
nCol++;
#ifdef VBSCRIPT_TEST
nCol2 = nCol;
GenError( ERRCODE_BASIC_NOT_IN_VBSCRIPT );
#endif
}
}
// Hex/Oktalzahl? Einlesen und konvertieren:
else if( *pLine == '&' )
{
pLine++; nCol++;
sal_Unicode cmp1[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };
sal_Unicode cmp2[] = { '0', '1', '2', '3', '4', '5', '6', '7' };
sal_Unicode *cmp = cmp1;
//char *cmp = "0123456789ABCDEF";
sal_Unicode base = 16;
sal_Unicode ndig = 8;
sal_Unicode xch = *pLine++ & 0xFF; nCol++;
switch( toupper( xch ) )
{
case 'O':
cmp = cmp2; base = 8; ndig = 11; break;
//cmp = "01234567"; base = 8; ndig = 11; break;
case 'H':
break;
default :
// Wird als Operator angesehen
pLine--; nCol--; nCol1 = nCol-1; aSym = '&'; return SYMBOL;
}
bNumber = TRUE;
long l = 0;
int i;
BOOL bBufOverflow = FALSE;
while( isalnum( *pLine & 0xFF ) )
{
sal_Unicode ch = toupper( *pLine & 0xFF );
pLine++; nCol++;
// AB 4.1.1996: Buffer voll, leer weiter scannen
if( (p-buf) == (BUF_SIZE-1) )
bBufOverflow = TRUE;
else if( String( cmp ).Search( ch ) != STRING_NOTFOUND )
//else if( strchr( cmp, ch ) )
*p++ = ch;
else
{
aError = ch;
GenError( SbERR_BAD_CHAR_IN_NUMBER );
}
}
*p = 0;
for( p = buf; *p; p++ )
{
i = (*p & 0xFF) - '0';
if( i > 9 ) i -= 7;
l = ( l * base ) + i;
if( !ndig-- )
{
GenError( SbERR_MATH_OVERFLOW ); break;
}
}
if( *pLine == '&' ) pLine++, nCol++;
nVal = (double) l;
eScanType = ( l >= SbxMININT && l <= SbxMAXINT ) ? SbxINTEGER : SbxLONG;
if( bBufOverflow )
GenError( SbERR_MATH_OVERFLOW );
}
// Strings:
else if( *pLine == '"' || *pLine == '[' )
{
sal_Unicode cSep = *pLine;
if( cSep == '[' )
bSymbol = TRUE, cSep = ']';
short n = nCol+1;
while( *pLine )
{
do pLine++, nCol++;
while( *pLine && ( *pLine != cSep ) );
if( *pLine == cSep )
{
pLine++; nCol++;
if( *pLine != cSep || cSep == ']' ) break;
} else aError = cSep, GenError( SbERR_EXPECTED );
}
aSym = aLine.Copy( n, nCol - n - 1 );
// Doppelte Stringbegrenzer raus
String s( cSep );
s += cSep;
USHORT nIdx;
do {
nIdx = aSym.Search( s );
aSym.Erase( nIdx, 1 );
} while( nIdx != STRING_NOTFOUND );
if( cSep != ']' )
eScanType = ( cSep == '#' ) ? SbxDATE : SbxSTRING;
}
// ungueltige Zeichen:
else if( ( *pLine & 0xFF ) >= 0x7F )
{
GenError( SbERR_SYNTAX ); pLine++; nCol++;
}
// andere Gruppen:
else
{
short n = 1;
switch( *pLine++ )
{
case '<': if( *pLine == '>' || *pLine == '=' ) n = 2; break;
case '>': if( *pLine == '=' ) n = 2; break;
case ':': if( *pLine == '=' ) n = 2; break;
}
aSym = aLine.Copy( nCol, n );
pLine += n-1; nCol += n;
}
nCol2 = nCol-1;
// Kommentar?
if( eScanType != SbxSTRING &&
( aSym.GetBuffer()[0] == '\'' || aSym.EqualsIgnoreCaseAscii( "REM" ) ) )
{
aSym = String::CreateFromAscii( "REM" );
nCol2 += String( pLine ).Len();
pLine = NULL;
}
return TRUE;
// Sonst Zeilen-Ende: aber bitte auf '_' testen, ob die
// Zeile nicht weitergeht!
eoln:
if( nCol && *--pLine == '_' )
{
pLine = NULL; return NextSym();
}
else
{
pLine = NULL;
nLine = nOldLine;
nCol1 = nOldCol1;
nCol2 = nOldCol2;
aSym = '\n';
nColLock = 0;
return TRUE;
}
}
+528
View File
@@ -0,0 +1,528 @@
/*************************************************************************
*
* $RCSfile: symtbl.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include "sbcomp.hxx"
#pragma hdrstop
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
SV_IMPL_PTRARR(SbiStrings,String*)
SV_IMPL_PTRARR(SbiSymbols,SbiSymDef*)
// Alle Symbolnamen werden im Stringpool des Symbol-Pools abgelegt, damit
// alle Symbole im gleichen Case verarbeitet werden. Beim Speichern des
// Code-Images wird der globale Stringpool mit den entsprechenden Sympools
// gespeichert. Der lokale Stringpool nimmt alle Symbole auf, die nicht
// ins Image wandern (Labels, Konstantennamen etc).
/***************************************************************************
|*
|* SbiStringPool
|*
***************************************************************************/
SbiStringPool::SbiStringPool( SbiParser* p )
{
pParser = p;
}
SbiStringPool::~SbiStringPool()
{}
// Suchen
const String& SbiStringPool::Find( USHORT n ) const
{
if( !n || n > aData.Count() )
return aEmpty;
else
return *aData.GetObject( n-1 );
}
// Hinzufuegen eines Strings. Der String wird Case-Insensitiv
// verglichen.
short SbiStringPool::Add( const String& rVal, BOOL bNoCase )
{
USHORT n = aData.Count();
for( USHORT i = 0; i < n; i++ )
{
String* p = aData.GetObject( i );
if( ( bNoCase && p->Equals( rVal ) )
|| ( !bNoCase && p->EqualsIgnoreCaseAscii( rVal ) ) )
return i+1;
}
const String* pNew = new String( rVal );
aData.Insert( pNew, n++ );
return (short) n;
}
short SbiStringPool::Add( double n, SbxDataType t )
{
char buf[ 40 ];
switch( t )
{
case SbxINTEGER: sprintf( buf, "%d", (short) n ); break;
case SbxLONG: sprintf( buf, "%ld", (long) n ); break;
case SbxSINGLE: sprintf( buf, "%.6g", (float) n ); break;
case SbxDOUBLE: sprintf( buf, "%.16g", n ); break;
}
return Add( String::CreateFromAscii( buf ) );
}
/***************************************************************************
|*
|* SbiSymPool
|*
***************************************************************************/
SbiSymPool::SbiSymPool( SbiStringPool& r, SbiSymScope s ) : rStrings( r )
{
pParser = r.GetParser();
eScope = s;
pParent = NULL;
nCur =
nProcId = 0;
}
SbiSymPool::~SbiSymPool()
{}
// Inhalt loeschen
void SbiSymPool::Clear()
{
aData.DeleteAndDestroy( 0, aData.Count() );
}
SbiSymDef* SbiSymPool::First()
{
nCur = (USHORT) -1;
return Next();
}
SbiSymDef* SbiSymPool::Next()
{
if( ++nCur >= aData.Count() )
return NULL;
else
return aData.GetObject( nCur );
}
// Hinzufuegen eines Symbols
SbiSymDef* SbiSymPool::AddSym( const String& rName )
{
SbiSymDef* p = new SbiSymDef( rName );
p->nPos = aData.Count();
p->nId = rStrings.Add( rName );
p->nProcId = nProcId;
p->pIn = this;
const SbiSymDef* q = p;
aData.Insert( q, q->nPos );
return p;
}
SbiProcDef* SbiSymPool::AddProc( const String& rName )
{
SbiProcDef* p = new SbiProcDef( pParser, rName );
p->nPos = aData.Count();
p->nId = rStrings.Add( rName );
// Procs sind immer global
p->nProcId = 0;
p->pIn = this;
const SbiSymDef* q = p;
aData.Insert( q, q->nPos );
return p;
}
// Hinzufuegen einer extern aufgebauten Symboldefinition
void SbiSymPool::Add( SbiSymDef* pDef )
{
if( pDef && pDef->pIn != this )
{
if( pDef->pIn )
{
#ifndef PRODUCT
// schon in einem anderen Pool drin!
pParser->Error( SbERR_INTERNAL_ERROR, "Dbl Pool" );
#endif
return;
}
pDef->nPos = aData.Count();
if( !pDef->nId )
{
// Bei statischen Variablen muss ein eindeutiger Name
// im Stringpool erzeugt werden (Form ProcName:VarName)
String aName( pDef->aName );
if( pDef->IsStatic() )
{
aName = pParser->aGblStrings.Find( nProcId );
aName += ':';
aName += pDef->aName;
}
pDef->nId = rStrings.Add( aName );
}
// Procs sind immer global
if( !pDef->GetProcDef() )
pDef->nProcId = nProcId;
pDef->pIn = this;
const SbiSymDef* q = pDef;
aData.Insert( q, q->nPos );
}
}
// Suchen eines Eintrags ueber den Namen. Es wird auch im Parent gesucht.
SbiSymDef* SbiSymPool::Find( const String& rName ) const
{
for( USHORT i = 0; i < aData.Count(); i++ )
{
SbiSymDef* p = aData.GetObject( i );
if( ( !p->nProcId || ( p->nProcId == nProcId ) )
&& ( p->aName.EqualsIgnoreCaseAscii( rName ) ) )
return p;
}
if( pParent )
return pParent->Find( rName );
else
return NULL;
}
// Suchen ueber ID-Nummer
SbiSymDef* SbiSymPool::FindId( USHORT n ) const
{
for( USHORT i = 0; i < aData.Count(); i++ )
{
SbiSymDef* p = aData.GetObject( i );
if( p->nId == n && ( !p->nProcId || ( p->nProcId == nProcId ) ) )
return p;
}
if( pParent )
return pParent->FindId( n );
else
return NULL;
}
// Suchen ueber Position (ab 0)
SbiSymDef* SbiSymPool::Get( USHORT n ) const
{
if( n >= aData.Count() )
return NULL;
else
return aData.GetObject( n );
}
USHORT SbiSymPool::Define( const String& rName )
{
SbiSymDef* p = Find( rName );
if( p )
{ if( p->IsDefined() )
pParser->Error( SbERR_LABEL_DEFINED, rName );
}
else
p = AddSym( rName );
return p->Define();
}
USHORT SbiSymPool::Reference( const String& rName )
{
SbiSymDef* p = Find( rName );
if( !p )
p = AddSym( rName );
//Sicherheitshalber
pParser->aGen.GenStmnt();
return p->Reference();
}
// Alle offenen Referenzen anmaulen
void SbiSymPool::CheckRefs()
{
for( USHORT i = 0; i < aData.Count(); i++ )
{
SbiSymDef* p = aData.GetObject( i );
if( !p->IsDefined() )
pParser->Error( SbERR_UNDEF_LABEL, p->GetName() );
}
}
/***************************************************************************
|*
|* Symbol-Definitionen
|*
***************************************************************************/
SbiSymDef::SbiSymDef( const String& rName ) : aName( rName )
{
eType = SbxEMPTY;
nDims =
nTypeId =
nProcId =
nId =
nPos =
nLen =
nChain = 0;
bAs =
bNew =
bStatic =
bOpt =
bByVal =
bChained = FALSE;
pIn =
pPool = NULL;
}
SbiSymDef::~SbiSymDef()
{
delete pPool;
}
SbiProcDef* SbiSymDef::GetProcDef()
{
return NULL;
}
SbiConstDef* SbiSymDef::GetConstDef()
{
return NULL;
}
// Wenn der Name benoetigt wird, den aktuellen Namen
// aus dem Stringpool nehmen
const String& SbiSymDef::GetName()
{
if( pIn )
aName = pIn->rStrings.Find( nId );
return aName;
}
// Eintragen eines Datentyps
void SbiSymDef::SetType( SbxDataType t )
{
if( t == SbxVARIANT && pIn )
{
char ch = (char)aName.GetBuffer()[0];
if( ch == '_' ) ch = 'Z';
ch = toupper( ch );
t = pIn->pParser->eDefTypes[ ch - 'A' ];
}
eType = t;
}
// Aufbau einer Backchain, falls noch nicht definiert
// Es wird der Wert zurueckgeliefert, der als Operand gespeichert
// werden soll.
USHORT SbiSymDef::Reference()
{
if( !bChained )
{
USHORT n = nChain;
nChain = pIn->pParser->aGen.GetOffset();
return n;
}
else return nChain;
}
// Definition eines Symbols.
// Hier wird der Backchain aufgeloest, falls vorhanden
USHORT SbiSymDef::Define()
{
USHORT n = pIn->pParser->aGen.GetPC();
pIn->pParser->aGen.GenStmnt();
if( nChain ) pIn->pParser->aGen.BackChain( nChain );
nChain = n;
bChained = TRUE;
return nChain;
}
// Eine Symboldefinition kann einen eigenen Pool haben. Dies ist
// der Fall bei Objekten und Prozeduren (lokale Variable)
SbiSymPool& SbiSymDef::GetPool()
{
if( !pPool )
pPool = new SbiSymPool( pIn->pParser->aGblStrings, SbLOCAL ); // wird gedumpt
return *pPool;
}
SbiSymScope SbiSymDef::GetScope() const
{
return pIn ? pIn->GetScope() : SbLOCAL;
}
////////////////////////////////////////////////////////////////////////////
// Die Prozedur-Definition hat drei Pools:
// 1) aParams: wird durch die Definition gefuellt. Enthaelt die Namen
// der Parameter, wie sie innerhalb des Rumpfes verwendet werden.
// Das erste Element ist der Returnwert.
// 2) pPool: saemtliche lokale Variable
// 3) aLabels: Labels
SbiProcDef::SbiProcDef( SbiParser* pParser, const String& rName )
: SbiSymDef( rName ),
aParams( pParser->aGblStrings, SbPARAM ), // wird gedumpt
aLabels( pParser->aLclStrings, SbLOCAL ) // wird nicht gedumpt
{
aParams.SetParent( &pParser->aPublics );
pPool = new SbiSymPool( pParser->aGblStrings, SbLOCAL ); // Locals
pPool->SetParent( &aParams );
nLine1 =
nLine2 = 0;
bPublic = TRUE;
bCdecl = FALSE;
// Fuer Returnwerte ist das erste Element der Parameterliste
// immer mit dem Namen und dem Typ der Proc definiert
aParams.AddSym( aName );
}
SbiProcDef::~SbiProcDef()
{}
SbiProcDef* SbiProcDef::GetProcDef()
{
return this;
}
void SbiProcDef::SetType( SbxDataType t )
{
SbiSymDef::SetType( t );
aParams.Get( 0 )->SetType( eType );
}
// Match mit einer Forward-Deklaration
// Falls der Match OK ist, wird pOld durch this im Pool ersetzt
// pOld wird immer geloescht!
void SbiProcDef::Match( SbiProcDef* pOld )
{
SbiSymDef* po, *pn;
// Parameter 0 ist der Funktionsname
USHORT i;
for( i = 1; i < aParams.GetSize(); i++ )
{
po = pOld->aParams.Get( i );
pn = aParams.Get( i );
// Kein Typabgleich; das wird beim Laufen erledigt
// aber ist sie evtl. mit zu wenigen Parametern aufgerufen
// worden?
if( !po && !pn->IsOptional() )
break;
po = pOld->aParams.Next();
}
// Wurden zu viele Parameter angegeben?
if( pn && i < aParams.GetSize() && pOld->pIn )
{
// Die ganze Zeile markieren
pOld->pIn->GetParser()->SetCol1( 0 );
pOld->pIn->GetParser()->Error( SbERR_BAD_DECLARATION, aName );
}
if( !pIn && pOld->pIn )
{
// Alten Eintrag durch neuen ersetzen
SbiSymDef** pData = (SbiSymDef**) pOld->pIn->aData.GetData();
pData[ pOld->nPos ] = this;
nPos = pOld->nPos;
nId = pOld->nId;
pIn = pOld->pIn;
}
delete pOld;
}
//////////////////////////////////////////////////////////////////////////
SbiConstDef::SbiConstDef( const String& rName )
: SbiSymDef( rName )
{
nVal = 0; eType = SbxINTEGER;
}
void SbiConstDef::Set( double n, SbxDataType t )
{
aVal.Erase(); nVal = n; eType = t;
}
void SbiConstDef::Set( const String& n )
{
aVal = n; nVal = 0; eType = SbxSTRING;
}
SbiConstDef::~SbiConstDef()
{}
SbiConstDef* SbiConstDef::GetConstDef()
{
return this;
}
+689
View File
@@ -0,0 +1,689 @@
/*************************************************************************
*
* $RCSfile: token.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <ctype.h>
#include "sbcomp.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBCOMP, SBCOMP_CODE )
struct TokenTable { SbiToken t; const char *s; };
static short nToken; // Anzahl der Tokens
static TokenTable* pTokTable;
static TokenTable aTokTable_Basic [] = { // Token-Tabelle:
{ CAT, "&" },
{ MUL, "*" },
{ PLUS, "+" },
{ MINUS, "-" },
{ DIV, "/" },
{ EOS, ":" },
{ ASSIGN, ":=" },
{ LT, "<" },
{ LE, "<=" },
{ NE, "<>" },
{ EQ, "=" },
{ GT, ">" },
{ GE, ">=" },
{ ACCESS, "Access" },
{ ALIAS, "Alias" },
{ AND, "And" },
{ ANY, "Any" },
{ APPEND, "Append" },
{ AS, "As" },
{ BASE, "Base" },
{ BINARY, "Binary" },
{ TBOOLEAN, "Boolean" },
{ BYVAL, "ByVal", },
{ CALL, "Call" },
{ CASE, "Case" },
{ _CDECL_, "Cdecl" },
{ CLOSE, "Close" },
{ COMPARE, "Compare" },
{ _CONST_, "Const" },
{ TCURRENCY,"Currency" },
{ TDATE, "Date" },
{ DECLARE, "Declare" },
{ DEFBOOL, "DefBool" },
{ DEFCUR, "DefCur" },
{ DEFDATE, "DefDate" },
{ DEFDBL, "DefDbl" },
{ DEFERR, "DefErr" },
{ DEFINT, "DefInt" },
{ DEFLNG, "DefLng" },
{ DEFOBJ, "DefObj" },
{ DEFSNG, "DefSng" },
{ DEFSTR, "DefStr" },
{ DEFVAR, "DefVar" },
{ DIM, "Dim" },
{ DO, "Do" },
{ TDOUBLE, "Double" },
{ EACH, "Each" },
{ ELSE, "Else" },
{ ELSEIF, "ElseIf" },
{ END, "End" },
{ ENDFUNC, "End Function" },
{ ENDIF, "End If" },
{ ENDSELECT,"End Select" },
{ ENDSUB, "End Sub" },
{ ENDTYPE, "End Type" },
{ ENDIF, "EndIf" },
{ EQV, "Eqv" },
{ ERASE, "Erase" },
{ _ERROR_, "Error" },
{ EXIT, "Exit" },
{ EXPLICIT, "Explicit" },
{ FOR, "For" },
{ FUNCTION, "Function" },
{ GLOBAL, "Global" },
{ GOSUB, "GoSub" },
{ GOTO, "GoTo" },
{ IF, "If" },
{ IMP, "Imp" },
{ _IN_, "In" },
{ INPUT, "Input" }, // auch INPUT #
{ TINTEGER, "Integer" },
{ IS, "Is" },
{ LET, "Let" },
{ LIB, "Lib" },
{ LINE, "Line" },
{ LINEINPUT,"Line Input" },
{ LOCAL, "Local" },
{ LOCK, "Lock" },
{ TLONG, "Long" },
{ LOOP, "Loop" },
{ LPRINT, "LPrint" },
{ LSET, "LSet" }, // JSM
{ MOD, "Mod" },
{ NAME, "Name" },
{ NEW, "New" },
{ NEXT, "Next" },
{ NOT, "Not" },
{ TOBJECT, "Object" },
{ ON, "On" },
{ OPEN, "Open" },
{ OPTION, "Option" },
{ _OPTIONAL_, "Optional" },
{ OR, "Or" },
{ OUTPUT, "Output" },
{ PRESERVE, "Preserve" },
{ PRINT, "Print" },
{ PRIVATE, "Private" },
{ PUBLIC, "Public" },
{ RANDOM, "Random" },
{ READ, "Read" },
{ REDIM, "ReDim" },
{ REM, "Rem" },
{ RESUME, "Resume" },
{ RETURN, "Return" },
{ RSET, "RSet" }, // JSM
{ SELECT, "Select" },
{ SET, "Set" },
#ifdef SHARED
#undef SHARED
#define tmpSHARED
#endif
{ SHARED, "Shared" },
#ifdef tmpSHARED
#define SHARED
#undef tmpSHARED
#endif
{ TSINGLE, "Single" },
{ STATIC, "Static" },
{ STEP, "Step" },
{ STOP, "Stop" },
{ TSTRING, "String" },
{ SUB, "Sub" },
{ STOP, "System" },
{ TEXT, "Text" },
{ THEN, "Then" },
{ TO, "To", },
{ TYPE, "Type" },
{ UNTIL, "Until" },
{ TVARIANT, "Variant" },
{ WEND, "Wend" },
{ WHILE, "While" },
{ WITH, "With" },
{ WRITE, "Write" }, // auch WRITE #
{ XOR, "Xor" },
{ NIL }
};
/*
TokenTable aTokTable_Java [] = { // Token-Tabelle:
{ JS_LOG_NOT, "!" },
{ JS_NE, "!=" },
{ JS_MOD, "%" },
{ JS_ASS_MOD, "%=" },
{ JS_BIT_AND, "&" },
{ JS_LOG_AND, "&&" },
{ JS_ASS_AND, "&=" },
{ JS_LPAREN, "(" },
{ JS_RPAREN, ")" },
{ JS_MUL, "*" },
{ JS_ASS_MUL, "*=" },
{ JS_PLUS, "+" },
{ JS_INC, "++" },
{ JS_ASS_PLUS, "+=" },
{ JS_COMMA, "," },
{ JS_MINUS, "-" },
{ JS_DEC, "--" },
{ JS_ASS_MINUS, "-=" },
{ JS_DIV, "/" },
{ JS_ASS_DIV, "/=" },
{ JS_COND_SEL, ":" },
{ JS_LT, "<" },
{ JS_LSHIFT, "<<" },
{ JS_ASS_LSHIFT,"<<=" },
{ JS_LE, "<=" },
{ JS_NE, "<>" },
{ JS_ASSIGNMENT,"=" },
{ JS_EQ, "==" },
{ JS_GT, ">" },
{ JS_RSHIFT, ">>" },
{ JS_ASS_RSHIFT,">>=" },
{ JS_RSHIFT_Z, ">>>" },
{ JS_ASS_RSHIFT_Z,">>>=" },
{ JS_GE, ">=" },
{ JS_COND_QUEST,"?" },
{ ACCESS, "Access" },
{ ALIAS, "Alias" },
{ AND, "And" },
{ ANY, "Any" },
{ APPEND, "Append" },
{ AS, "As" },
{ BASE, "Base" },
{ BINARY, "Binary" },
{ TBOOLEAN, "Boolean" },
{ BYVAL, "ByVal", },
{ CALL, "Call" },
{ CASE, "Case" },
{ _CDECL_, "Cdecl" },
{ CLOSE, "Close" },
{ COMPARE, "Compare" },
{ _CONST_, "Const" },
{ TCURRENCY,"Currency" },
{ TDATE, "Date" },
{ DECLARE, "Declare" },
{ DEFBOOL, "DefBool" },
{ DEFCUR, "DefCur" },
{ DEFDATE, "DefDate" },
{ DEFDBL, "DefDbl" },
{ DEFERR, "DefErr" },
{ DEFINT, "DefInt" },
{ DEFLNG, "DefLng" },
{ DEFOBJ, "DefObj" },
{ DEFSNG, "DefSng" },
{ DEFSTR, "DefStr" },
{ DEFVAR, "DefVar" },
{ DIM, "Dim" },
{ DO, "Do" },
{ TDOUBLE, "Double" },
{ EACH, "Each" },
{ ELSE, "Else" },
{ ELSEIF, "ElseIf" },
{ END, "End" },
{ ENDFUNC, "End Function" },
{ ENDIF, "End If" },
{ ENDSELECT,"End Select" },
{ ENDSUB, "End Sub" },
{ ENDTYPE, "End Type" },
{ ENDIF, "EndIf" },
{ EQV, "Eqv" },
{ ERASE, "Erase" },
{ _ERROR_, "Error" },
{ EXIT, "Exit" },
{ EXPLICIT, "Explicit" },
{ FOR, "For" },
{ FUNCTION, "Function" },
{ GLOBAL, "Global" },
{ GOSUB, "GoSub" },
{ GOTO, "GoTo" },
{ IF, "If" },
{ IMP, "Imp" },
{ _IN_, "In" },
{ INPUT, "Input" }, // auch INPUT #
{ TINTEGER, "Integer" },
{ IS, "Is" },
{ LET, "Let" },
{ LIB, "Lib" },
{ LINE, "Line" },
{ LINEINPUT,"Line Input" },
{ LOCAL, "Local" },
{ LOCK, "Lock" },
{ TLONG, "Long" },
{ LOOP, "Loop" },
{ LPRINT, "LPrint" },
{ LSET, "LSet" }, // JSM
{ MOD, "Mod" },
{ NAME, "Name" },
{ NEW, "New" },
{ NEXT, "Next" },
{ NOT, "Not" },
{ TOBJECT, "Object" },
{ ON, "On" },
{ OPEN, "Open" },
{ OPTION, "Option" },
{ _OPTIONAL_, "Optional" },
{ OR, "Or" },
{ OUTPUT, "Output" },
{ PRESERVE, "Preserve" },
{ PRINT, "Print" },
{ PRIVATE, "Private" },
{ PUBLIC, "Public" },
{ RANDOM, "Random" },
{ READ, "Read" },
{ REDIM, "ReDim" },
{ REM, "Rem" },
{ RESUME, "Resume" },
{ RETURN, "Return" },
{ RSET, "RSet" }, // JSM
{ SELECT, "Select" },
{ SET, "Set" },
{ SHARED, "Shared" },
{ TSINGLE, "Single" },
{ STATIC, "Static" },
{ STEP, "Step" },
{ STOP, "Stop" },
{ TSTRING, "String" },
{ SUB, "Sub" },
{ STOP, "System" },
{ TEXT, "Text" },
{ THEN, "Then" },
{ TO, "To", },
{ TYPE, "Type" },
{ UNTIL, "Until" },
{ TVARIANT, "Variant" },
{ WEND, "Wend" },
{ WHILE, "While" },
{ WITH, "With" },
{ WRITE, "Write" }, // auch WRITE #
{ XOR, "Xor" },
{ JS_LINDEX, "[" },
{ JS_RINDEX, "]" },
{ JS_BIT_XOR, "^" },
{ JS_ASS_XOR, "^=" },
{ JS_BIT_OR, "|" },
{ JS_ASS_OR, "|=" },
{ JS_LOG_OR, "||" },
{ JS_BIT_NOT, "~" },
{ NIL }
};
*/
// Der Konstruktor ermittelt die Laenge der Token-Tabelle.
SbiTokenizer::SbiTokenizer( const String& rSrc, StarBASIC* pb )
: SbiScanner( rSrc, pb )
{
pTokTable = aTokTable_Basic;
//if( StarBASIC::GetGlobalLanguageMode() == SB_LANG_JAVASCRIPT )
// pTokTable = aTokTable_Java;
TokenTable *tp;
bEof = bAs = FALSE;
eCurTok = NIL;
ePush = NIL;
bEos = bKeywords = TRUE;
if( !nToken )
for( nToken = 0, tp = pTokTable; tp->t; nToken++, tp++ ) {}
}
SbiTokenizer::~SbiTokenizer()
{}
// Wiederablage (Pushback) eines Tokens. (Bis zu 2 Tokens)
void SbiTokenizer::Push( SbiToken t )
{
if( ePush != NIL )
Error( SbERR_INTERNAL_ERROR, "PUSH" );
else ePush = t;
}
void SbiTokenizer::Error( SbError code, const char* pMsg )
{
aError = String::CreateFromAscii( pMsg );
Error( code );
}
void SbiTokenizer::Error( SbError code, String aMsg )
{
aError = aMsg;
Error( code );
}
void SbiTokenizer::Error( SbError code, SbiToken tok )
{
aError = Symbol( tok );
Error( code );
}
// Einlesen des naechsten Tokens, ohne dass das Token geschluckt wird
SbiToken SbiTokenizer::Peek()
{
if( ePush == NIL )
{
USHORT nOldLine = nLine;
USHORT nOldCol1 = nCol1;
USHORT nOldCol2 = nCol2;
ePush = Next();
nPLine = nLine; nLine = nOldLine;
nPCol1 = nCol1; nCol1 = nOldCol1;
nPCol2 = nCol2; nCol2 = nOldCol2;
}
return eCurTok = ePush;
}
// Dies ist fuer die Decompilation.
// Zahlen und Symbole liefern einen Leerstring zurueck.
const String& SbiTokenizer::Symbol( SbiToken t )
{
// Zeichen-Token?
if( t < FIRSTKWD )
{
aSym = (char) t;
return aSym;
}
switch( t )
{
case NEG : aSym = '-'; return aSym;
case EOS : aSym = String::CreateFromAscii( ":/CRLF" ); return aSym;
case EOLN : aSym = String::CreateFromAscii( "CRLF" ); return aSym;
}
TokenTable* tp = pTokTable;
for( short i = 0; i < nToken; i++, tp++ )
{
if( tp->t == t )
{
aSym = String::CreateFromAscii( tp->s );
return aSym;
}
}
const sal_Unicode *p = aSym.GetBuffer();
if (*p <= ' ') aSym = String::CreateFromAscii( "???" );
return aSym;
}
// Einlesen des naechsten Tokens und Ablage desselben
// Tokens, die nicht in der Token-Tabelle vorkommen, werden
// direkt als Zeichen zurueckgeliefert.
// Einige Worte werden gesondert behandelt.
SbiToken SbiTokenizer::Next()
{
if (bEof) return EOLN;
// Schon eines eingelesen?
if( ePush != NIL )
{
eCurTok = ePush;
ePush = NIL;
nLine = nPLine;
nCol1 = nPCol1;
nCol2 = nPCol2;
bEos = IsEoln( eCurTok );
return eCurTok;
}
TokenTable *tp;
// Sonst einlesen:
if( !NextSym() )
{
bEof = bEos = TRUE;
return eCurTok = EOLN;
}
// Zeilenende?
if( aSym.GetBuffer()[0] == '\n' )
{
bEos = TRUE; return eCurTok = EOLN;
}
bEos = FALSE;
// Zahl?
if( bNumber )
return eCurTok = NUMBER;
// String?
else if( ( eScanType == SbxDATE || eScanType == SbxSTRING ) && !bSymbol )
return eCurTok = FIXSTRING;
// Sonderfaelle von Zeichen, die zwischen "Z" und "a" liegen. ICompare()
// wertet die Position dieser Zeichen unterschiedlich aus.
else if( aSym.GetBuffer()[0] == '^' )
return eCurTok = EXPON;
else if( aSym.GetBuffer()[0] == '\\' )
return eCurTok = IDIV;
else
{
// Mit Typkennung oder ein Symbol und keine Keyword-Erkennung?
// Dann kein Token-Test
if( eScanType != SbxVARIANT
|| ( !bKeywords && bSymbol ) )
return eCurTok = SYMBOL;
// Gueltiges Token?
short lb = 0;
short ub = nToken-1;
short delta;
do
{
delta = (ub - lb) >> 1;
tp = &pTokTable[ lb + delta ];
StringCompare res = aSym.CompareIgnoreCaseToAscii( tp->s );
// Gefunden?
if( res == COMPARE_EQUAL ) goto special;
// Groesser? Dann untere Haelfte
if( res == COMPARE_LESS )
{
if ((ub - lb) == 2) ub = lb;
else ub -= delta;
}
// Kleiner? Dann obere Haelfte
else
{
if ((ub -lb) == 2) lb = ub;
else lb += delta;
}
} while( delta );
// Symbol? Wenn nicht >= Token
sal_Unicode ch = aSym.GetBuffer()[0];
if( !isalpha( ch ) && !bSymbol )
return eCurTok = (SbiToken) (ch & 0x00FF);
return eCurTok = SYMBOL;
}
special:
// LINE INPUT
if( tp->t == LINE )
{
short nC1 = nCol1;
eCurTok = Peek();
if( eCurTok == INPUT )
{
Next();
nCol1 = nC1;
return eCurTok = LINEINPUT;
}
else
return eCurTok = LINE;
}
// END IF, CASE, SUB, DEF, FUNCTION, TYPE, CLASS, WITH
if( tp->t == END )
{
// AB, 15.3.96, Spezialbehandlung fuer END, beim Peek() geht die
// aktuelle Zeile verloren, daher alles merken und danach restaurieren
USHORT nOldLine = nLine;
USHORT nOldCol = nCol;
USHORT nOldCol1 = nCol1;
USHORT nOldCol2 = nCol2;
String aOldSym = aSym;
SaveLine(); // pLine im Scanner sichern
eCurTok = Peek();
switch( eCurTok )
{
case IF: Next(); eCurTok = ENDIF; break;
case SELECT: Next(); eCurTok = ENDSELECT; break;
case SUB: Next(); eCurTok = ENDSUB; break;
case FUNCTION: Next(); eCurTok = ENDFUNC; break;
case TYPE: Next(); eCurTok = ENDTYPE; break;
case WITH: Next(); eCurTok = ENDWITH; break;
default : eCurTok = END;
}
nCol1 = nOldCol1;
if( eCurTok == END )
{
// Alles zuruecksetzen, damit Token nach END ganz neu gelesen wird
ePush = NIL;
nLine = nOldLine;
nCol = nOldCol;
nCol2 = nOldCol2;
aSym = aOldSym;
RestoreLine(); // pLine im Scanner restaurieren
}
return eCurTok;
}
// Sind Datentypen Keywords?
// Nur nach AS, sonst sind es Symbole!
// Es gibt ja ERROR(), DATA(), STRING() etc.
eCurTok = tp->t;
// AS: Datentypen sind Keywords
if( tp->t == AS )
bAs = TRUE;
else
{
if( bAs )
bAs = FALSE;
else if( eCurTok >= DATATYPE1 && eCurTok <= DATATYPE2 )
eCurTok = SYMBOL;
}
bEos = IsEoln( eCurTok );
return eCurTok;
}
#ifdef _MSC_VER
#pragma optimize("",off)
#endif
// Kann das aktuell eingelesene Token ein Label sein?
BOOL SbiTokenizer::MayBeLabel( BOOL bNeedsColon )
{
if( eCurTok == SYMBOL )
return bNeedsColon ? DoesColonFollow() : TRUE;
else
return BOOL( eCurTok == NUMBER
&& eScanType == SbxINTEGER
&& nVal >= 0 );
}
#ifdef _MSC_VER
#pragma optimize("",off)
#endif
void SbiTokenizer::Hilite( SbTextPortions& rList )
{
bErrors = FALSE;
bUsedForHilite = TRUE;
SbiToken eLastTok = NIL;
for( ;; )
{
Next();
if( IsEof() )
break;
SbTextPortion aRes;
aRes.nLine = nLine;
aRes.nStart = nCol1;
aRes.nEnd = nCol2;
sal_Unicode ch = aSym.GetBuffer()[0];
switch( eCurTok )
{
case REM:
aRes.eType = SB_COMMENT; break;
case SYMBOL:
aRes.eType = SB_SYMBOL; break;
case FIXSTRING:
aRes.eType = SB_STRING; break;
case NUMBER:
aRes.eType = SB_NUMBER; break;
default:
if( ( eCurTok >= FIRSTKWD && eCurTok <= LASTKWD )
|| (eCurTok >= _CDECL_ ) )
aRes.eType = SB_KEYWORD;
else
aRes.eType = SB_PUNCTUATION;
}
// Die Folge xxx.Keyword sollte nicht als Kwd geflagt werden
if( aRes.eType == SB_KEYWORD
&& ( eLastTok == DOT|| eLastTok == EXCLAM ) )
aRes.eType = SB_SYMBOL;
if( eCurTok != EOLN && aRes.nStart <= aRes.nEnd )
rList.Insert( aRes, rList.Count() );
if( aRes.eType == SB_COMMENT )
break;
eLastTok = eCurTok;
}
bUsedForHilite = FALSE;
}
+98
View File
@@ -0,0 +1,98 @@
/*************************************************************************
*
* $RCSfile: buffer.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _BUFFER_HXX
#define _BUFFER_HXX
#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
#ifndef _STRING_HXX //autogen
#include <tools/string.hxx>
#endif
class SbiParser;
class SbiBuffer { // Code/Konstanten-Puffer:
SbiParser* pParser; // fuer Fehlermeldungen
char* pBuf; // Puffer-Pointer
char* pCur; // aktueller Puffer-Pointer
USHORT nOff; // aktuelles Offset
USHORT nSize; // aktuelle Groesse
short nInc; // Inkrement
BOOL Check( USHORT ); // Buffergroesse testen
public:
SbiBuffer( SbiParser*, short ); // Inkrement
~SbiBuffer();
void Patch( USHORT, USHORT ); // Patchen
void Chain( USHORT ); // Back-Chain
void Align( short ); // Alignment
BOOL Add( const void*, USHORT );// Element anfuegen
BOOL operator += (const String&);// Basic-String speichern
BOOL operator += (INT8); // Zeichen speichern
BOOL operator += (INT16); // Integer speichern
BOOL operator += (UINT8); // Zeichen speichern
BOOL operator += (UINT16); // Integer speichern
char* GetBuffer(); // Puffer rausgeben (selbst loeschen!)
USHORT GetSize() { return nOff; }
};
#endif
+101
View File
@@ -0,0 +1,101 @@
/*************************************************************************
*
* $RCSfile: codegen.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _CODEGEN_HXX
#define _CODEGEN_HXX
class SbiImage;
class SbiParser;
class SbModule;
#ifndef _OPCODES_HXX
#include "opcodes.hxx"
#endif
#ifndef _BUFFER_HXX
#include "buffer.hxx"
#endif
class SbiCodeGen { // Code-Erzeugung:
SbiParser* pParser; // fuer Fehlermeldungen, Line, Column etc.
SbModule& rMod; // aktuelles Modul
SbiBuffer aCode; // Code-Puffer
short nLine, nCol; // Zeile, Spalte fuer Stmnt-Befehl
short nForLevel; // #29955 for-Schleifen-Ebene
BOOL bStmnt; // TRUE: Statement-Opcode liegt an
public:
SbiCodeGen( SbModule&, SbiParser*, short );
SbiParser* GetParser() { return pParser; }
USHORT Gen( SbiOpcode );
USHORT Gen( SbiOpcode, UINT16 );
USHORT Gen( SbiOpcode, UINT16, UINT16 );
void Patch( USHORT o, USHORT v ){ aCode.Patch( o, v ); }
void BackChain( USHORT off ) { aCode.Chain( off ); }
void Statement();
void GenStmnt(); // evtl. Statement-Opcode erzeugen
USHORT GetPC();
USHORT GetOffset() { return GetPC() + 1; }
void Save();
// #29955 for-Schleifen-Ebene pflegen
void IncForLevel( void ) { nForLevel++; }
void DecForLevel( void ) { nForLevel--; }
};
#endif
+83
View File
@@ -0,0 +1,83 @@
/*************************************************************************
*
* $RCSfile: collelem.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SAMPLE_COLLELEM_HXX
#define _SAMPLE_COLLELEM_HXX
#ifndef _SBX_SBXOBJECT_HXX //autogen
#include <svtools/sbxobj.hxx>
#endif
// Das Sample-Element ist ein kleines Objekt, das die Properties
// Name und Value enth„lt sowie die Methode Say, die den �bergebenen
// Text mit dem eigenen Namen verkoppelt. Der Name ist von aussen setzbar.
// Die Implementation arbeitet ausschliesslich mit dynamischen Elementen.
class SampleElement : public SbxObject
{
// Broadcaster Notification
virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
const SfxHint& rHint, const TypeId& rHintType );
public:
SampleElement( const String& );
};
#endif
+106
View File
@@ -0,0 +1,106 @@
/*************************************************************************
*
* $RCSfile: disas.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _DISAS_HXX
#define _DISAS_HXX
#include "image.hxx"
#include "opcodes.hxx"
class SvStream;
class SbiDisas {
const SbiImage& rImg;
SbModule* pMod;
char cLabels[ 8192 ]; // Bitvektor fuer Labels
USHORT nOff; // aktuelle Position
USHORT nPC; // Position des Opcodes
SbiOpcode eOp; // Opcode
USHORT nOp1, nOp2; // Operanden
short nParts; // 1, 2 oder 3
short nLine; // aktuelle Zeile
BOOL DisasLine( String& );
BOOL Fetch(); // naechster Opcode
public:
SbiDisas( SbModule*, const SbiImage* );
void Disas( SvStream& );
void Disas( String& );
// NICHT AUFRUFEN
void StrOp( String& );
void Str2Op( String& );
void ImmOp( String& );
void OnOp( String& );
void LblOp( String& );
void ReturnOp( String& );
void ResumeOp( String& );
void PromptOp( String& );
void CloseOp( String& );
void CharOp( String& );
void VarOp( String& );
void VarDefOp( String& );
void OffOp( String& );
void TypeOp( String& );
void CaseOp( String& );
void StmntOp( String& );
void StrmOp( String& );
};
#endif
+255
View File
@@ -0,0 +1,255 @@
/*************************************************************************
*
* $RCSfile: expr.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _EXPR_HXX
#define _EXPR_HXX
#ifndef _OPCODES_HXX
#include "opcodes.hxx"
#endif
#ifndef _TOKEN_HXX
#include "token.hxx"
#endif
class SbiExprNode;
class SbiExpression;
class SbiExprList;
class SbiDimList;
class SbiParameters;
class SbiParser;
class SbiCodeGen;
class SbiSymDef;
class SbiProcDef;
struct SbVar { // Variablen-Element:
SbiExprNode* pNext; // Weiteres Element (bei Strukturen)
SbiSymDef* pDef; // Symboldefinition
SbiExprList* pPar; // optionale Parameter (wird geloescht)
};
enum SbiExprType { // Expression-Typen:
SbSTDEXPR, // normaler Ausdruck
SbLVALUE, // beliebiger lValue
SbSYMBOL, // beliebiges zusammengesetztes Symbol
SbOPERAND // Variable/Funktion
};
enum SbiNodeType {
SbxNUMVAL, // nVal = Wert
SbxSTRVAL, // nStringId = Wert
SbxVARVAL, // aVar = Wert
SbxNODE // Node
};
class SbiExprNode { // Operatoren (und Operanden)
friend class SbiExpression;
friend class SbiConstExpression;
union {
USHORT nStringId; // gepoolter String-ID
double nVal; // numerischer Wert
SbVar aVar; // oder Variable
};
SbiExprNode* pLeft; // linker Zweig
SbiExprNode* pRight; // rechter Zweig (NULL bei unaeren Ops)
SbiCodeGen* pGen; // Code-Generator
SbiNodeType eNodeType; // Art des Nodes
SbxDataType eType; // aktueller Datentyp
SbiToken eTok; // Token des Operators
BOOL bComposite; // TRUE: Zusammengesetzter Ausdruck
BOOL bError; // TRUE: Fehlerhaft
BOOL bPartOfWith; // TRUE: .-Anweisung in with-Block
void FoldConstants(); // Constant Folding durchfuehren
void CollectBits(); // Umwandeln von Zahlen in Strings
BOOL IsOperand(); // TRUE, wenn Operand
BOOL IsNumber(); // TRUE bei Zahlen
BOOL IsString(); // TRUE bei Strings
BOOL IsLvalue(); // TRUE, falls als Lvalue verwendbar
void GenElement( SbiOpcode ); // Element
void BaseInit( SbiParser* p ); // Hilfsfunktion fuer Ctor, AB 17.12.95
public:
SbiExprNode( SbiParser*, double, SbxDataType );
SbiExprNode( SbiParser*, const String& );
SbiExprNode( SbiParser*, const SbiSymDef&, SbxDataType, SbiExprList* = NULL );
SbiExprNode( SbiParser*, SbiExprNode*, SbiToken, SbiExprNode* );
virtual ~SbiExprNode();
BOOL IsValid() { return BOOL( !bError ); }
BOOL IsConstant(); // TRUE bei konstantem Operanden
BOOL IsIntConst(); // TRUE bei Integer-Konstanten
BOOL IsVariable(); // TRUE, wenn Variable
BOOL IsPartOfWith() { return bPartOfWith; }
void SetPartOfWith( BOOL b ) { bPartOfWith = b; }
SbxDataType GetType() { return eType; }
void SetType( SbxDataType eTp ) { eType = eTp; }
SbiNodeType GetNodeType() { return eNodeType; }
SbiSymDef* GetVar(); // Variable (falls vorhanden)
SbiSymDef* GetRealVar(); // letzte Variable in x.y.z
SbiExprNode* GetRealNode(); // letzter Knoten in x.y.z
short GetDepth(); // Tiefe eines Baumes berechnen
const String& GetString(); // String liefern
void Optimize(); // Baumabgleich
void Gen(); // Ausgabe eines Nodes
};
class SbiExpression { // der Ausdruck:
friend class SbiExprList;
friend class SbiParameters;
friend class SbiDimList;
protected:
String aArgName; // Name fuer bananntes Argument
SbiParser* pParser; // fuer Fehlermeldungen, Parsing
SbiExpression* pNext; // Link bei Parameterlisten
SbiExprNode* pExpr; // Der Expression-Baum
SbiExprType eCurExpr; // Art des Ausdrucks
BOOL bBased; // TRUE: einfacher DIM-Teil (+BASE)
BOOL bError; // TRUE: Fehler
BOOL bByVal; // TRUE: ByVal-Parameter
SbiExprNode* Term();
SbiExprNode* ObjTerm( SbiSymDef& );
SbiExprNode* Operand();
SbiExprNode* Unary();
SbiExprNode* Exp();
SbiExprNode* MulDiv();
SbiExprNode* IntDiv();
SbiExprNode* Mod();
SbiExprNode* AddSub();
SbiExprNode* Cat();
SbiExprNode* Like();
SbiExprNode* Comp();
SbiExprNode* Boolean();
public:
SbiExpression( SbiParser*, SbiExprType = SbSTDEXPR ); // Parsender Ctor
SbiExpression( SbiParser*, const String& );
SbiExpression( SbiParser*, double, SbxDataType = SbxDOUBLE );
SbiExpression( SbiParser*, const SbiSymDef&, SbiExprList* = NULL );
SbiExpression( SbiParser*, SbiToken ); // Spezial-Expr mit Spezial-Tokens
~SbiExpression();
String& GetName() { return aArgName; }
void SetBased() { bBased = TRUE; }
BOOL IsBased() { return bBased; }
void SetByVal() { bByVal = TRUE; }
BOOL IsByVal() { return bByVal; }
BOOL IsValid() { return pExpr->IsValid(); }
BOOL IsConstant() { return pExpr->IsConstant(); }
BOOL IsVariable() { return pExpr->IsVariable(); }
BOOL IsLvalue() { return pExpr->IsLvalue(); }
BOOL IsIntConstant() { return pExpr->IsIntConst(); }
const String& GetString() { return pExpr->GetString(); }
SbiSymDef* GetVar() { return pExpr->GetVar(); }
SbiSymDef* GetRealVar() { return pExpr->GetRealVar(); }
SbiExprNode* GetExprNode() { return pExpr; }
SbxDataType GetType() { return pExpr->GetType(); }
void SetType( SbxDataType eType){ pExpr->eType = eType; }
void Gen();
};
class SbiConstExpression : public SbiExpression {
double nVal;
String aVal;
SbxDataType eType;
public: // numerische Konstante
SbiConstExpression( SbiParser* );
SbxDataType GetType() { return eType; }
const String& GetString() { return aVal; }
double GetValue() { return nVal; }
short GetShortValue();
};
class SbiExprList { // Basisklasse fuer Parameter und Dims
protected:
SbiParser* pParser; // Parser
SbiExpression* pFirst; // Expressions
SbiProcDef* pProc; // DECLARE-Funktion (Parameter-Anpassung)
short nExpr; // Anzahl Expressions
short nDim; // Anzahl Dimensionen
BOOL bError; // TRUE: Fehler
BOOL bBracket; // TRUE: Klammern
public:
SbiExprList( SbiParser* );
virtual ~SbiExprList();
BOOL IsBracket() { return bBracket; }
BOOL IsValid() { return BOOL( !bError ); }
short GetSize() { return nExpr; }
short GetDims() { return nDim; }
SbiExpression* Get( short );
BOOL Test( const SbiProcDef& ); // Parameter-Checks
void Gen(); // Code-Erzeugung
// Setzen einer Funktionsdefinition zum Abgleich der Parameter
void SetProc( SbiProcDef* p ) { pProc = p; }
};
class SbiParameters : public SbiExprList {
public:
SbiParameters( SbiParser*, BOOL bConst = FALSE, BOOL bPar = TRUE);// parsender Ctor
};
class SbiDimList : public SbiExprList {
BOOL bConst; // TRUE: Alles sind Integer-Konstanten
public:
SbiDimList( SbiParser* ); // Parsender Ctor
BOOL IsConstant() { return bConst; }
};
#endif
+207
View File
@@ -0,0 +1,207 @@
/*************************************************************************
*
* $RCSfile: filefmt.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SB_FILEFMT_HXX
#define _SB_FILEFMT_HXX
#ifndef _SOLAR_H
#include <tools/solar.h>
#endif
class SvStream;
// Version 2: Datentyp des Returnwerts fuer Publics
// Version 3: neue Opcodes
// Version 4: neue Opcodes
// Version 5: Bug (Ansprung von STATIC-Variablen im Init-Code)
// Version 6: Neue Opcodes und Bug (Globals anlegen, ohne BASIC zu beenden)
// Version 7: Korrektur im WITH-Parsing
// Version 8: Korrektur im IF-Parsing
// Version 9: Init-Code auch mit LEAVE beenden, wenn keine SUB/FUNCTION folgt
// Version A: #36374 Bei DIM AS NEW... auch Variablen anlegen
// Version B: #40689 Static umgestellt
// Version C: #41606 Bug bei Static
// Version D: #42678 Bug bei RTL-Function spc
// Version E: #56204 DCREATE, um auch bei DIM AS NEW Arrays anzulegen
// Version F: #57844 Einfuehrung von SvNumberformat::StringToDouble
// Version 10: #29955 For-Schleifen-Level in Statement-PCodes generieren
// Version 11: #29955 Wegen Build-Inkonsistenzen Neu-Compilieren erzwingen
#define B_CURVERSION 0x00000011L
// Eine Datei enthaelt entweder einen Modul- oder einen Library-Record.
// Diese Records enthalten wiederum weitere Records. Jeder Record hat
// den folgenden Header:
// UINT16 Kennung
// UINT32 Laenge des Records ohne Header
// UINT16 Anzahl Unterelemente
// Alle Datei-Offsets in Records sind relativ zum Start des Moduls!
#define B_LIBRARY 0x4C42 // BL Library Record
#define B_MODULE 0x4D42 // BM Module Record
#define B_NAME 0x4E4D // MN module name
#define B_COMMENT 0x434D // MC comment
#define B_SOURCE 0x4353 // SC source code
#define B_PCODE 0x4350 // PC p-code
#define B_OLDPUBLICS 0x7550 // Pu publics
#define B_PUBLICS 0x5550 // PU publics
#define B_POOLDIR 0x4450 // PD symbol pool directory
#define B_SYMPOOL 0x5953 // SY symbol pool
#define B_STRINGPOOL 0x5453 // ST symbol pool
#define B_LINERANGES 0x524C // LR line ranges for publics
#define B_MODEND 0x454D // ME module end
#define B_SBXOBJECTS 0x5853 // SX SBX objects
// Ein Library Record enthaelt nur Module Records
// UINT16 Kennung BL
// UINT32 Laenge des Records
// UINT16 Anzahl Module
// Ein Modul-Record enthaelt alle anderen Recordtypen
// UINT16 Kennung BM
// UINT32 Laenge des Records
// UINT16 1
// Daten:
// UINT32 Versionsnummer
// UINT32 Zeichensatz
// UINT32 Startadresse Initialisierungscode
// UINT32 Startadresse Sub Main
// UINT32 Reserviert
// UINT32 Reserviert
// Modulname, Kommentar und Quellcode:
// UINT16 Kennung MN, MC oder SC
// UINT32 Laenge des Records
// UINT16 1
// Daten:
// String-Instanz
// P-Code:
// UINT16 Kennung PC
// UINT32 Laenge des Records
// UINT16 1
// Daten:
// Der P-Code als Bytesack
// Alle Symbole und Strings werden in einem String-Pool gehalten.
// Verweise auf diese Strings sind in Form eines Indexes in diesen Pool.
// Liste aller Publics:
// UINT16 Kennung PU oder Pu
// UINT32 Laenge des Records
// UINT16 Anzahl der Publics
// Daten fuer jeden Public-Eintrag:
// UINT16 String-Index
// UINT32 Startadresse im P-Code-Image (UINT16 fuer alte Publics)
// UINT16 Datentyp des Returnwertes (ab Version 2)
// Verzeichnis der Symbol-Tabellen:
// UINT16 Kennung SP
// UINT32 Laenge des Records
// UINT16 Anzahl der Symboltabellen
// Daten fuer jede Symboltabelle:
// UINT16 Stringindex des Namens
// UINT16 Anzahl Symbole
// UINT16 Scope-Kennung
// Symboltabelle:
// UINT16 Kennung SY
// UINT32 Laenge des Records
// UINT16 Anzahl der Symbole
// Daten:
// UINT16 Stringindex des Namens
// UINT16 Anzahl Symbole
// Daten fuer jedes Symbol:
// UINT16 Stringindex des Namens
// UINT16 Datentyp
// UINT16 Laenge bei STRING*n-Symbolen (0x8000: STATIC-Variable)
// Stringpool:
// UINT16 Kennung ST
// UINT32 Laenge des Records
// UINT16 Anzahl der Strings
// Daten fuer jeden String:
// UINT32 Offset in den Block aller Strings
// Danach folgt der Block aller Strings, die dort als ASCIIZ-Strings liegen.
// Line Ranges:
// UINT16 Kennung LR
// UINT32 Laenge des Records
// UINT16 Anzahl der Strings
// Daten fuer jedes Public:
// UINT16 1. Zeile (Sub XXX)
// UINT16 2. Zeile (End Sub)
// SBX-Objekte:
// UINT16 Anzahl Objekte
// .... Objektdaten
////////////////////////////////////////////////////////////////////////////
// Service-Routinen (in IMAGE.CXX)
BOOL SbGood( SvStream& r );
ULONG SbOpenRecord( SvStream&, UINT16 nSignature, UINT16 nElem );
void SbCloseRecord( SvStream&, ULONG );
#endif
+123
View File
@@ -0,0 +1,123 @@
/*************************************************************************
*
* $RCSfile: image.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SBIMAGE_HXX
#define _SBIMAGE_HXX
#include "sbintern.hxx"
// Diese Klasse liest das vom Compiler erzeugte Image ein und verwaltet
// den Zugriff auf die einzelnen Elemente.
struct SbPublicEntry;
class SbiImage {
friend class SbiCodeGen; // Compiler-Klassen, die die private-
SbxArrayRef rTypes; //
UINT16* pStringOff; // StringId-Offsets
sal_Unicode* pStrings; // StringPool
char* pCode; // Code-Image
BOOL bError; // TRUE: Fehler
USHORT nFlags; // Flags (s.u.)
short nStrings; // Anzahl Strings
UINT16 nStringSize; // Groesse des String-Puffers
UINT16 nCodeSize; // Groesse des Code-Blocks
UINT16 nDimBase; // OPTION BASE-Wert
rtl_TextEncoding eCharSet; // Zeichensatz fuer Strings
// temporaere Verwaltungs-Variable:
short nStringIdx; // aktueller String-Index
UINT16 nStringOff; // aktuelle Pos im Stringpuffer
// Routinen fuer Compiler:
void MakeStrings( short ); // StringPool einrichten
void AddString( const String& );// String zufuegen
void AddCode( char*, USHORT ); // Codeblock dazu
void AddType(SbxObject *); // User-Type mit aufnehmen
public:
String aName; // Makroname
String aSource; // Quellcode
String aComment; // Kommentar
BOOL bInit; // TRUE: Init-Code ist gelaufen
SbiImage();
~SbiImage();
void Clear(); // Inhalt loeschen
BOOL Load( SvStream& );
BOOL Save( SvStream& );
BOOL IsError() { return bError; }
const char* GetCode() const { return pCode; }
USHORT GetCodeSize() const { return nCodeSize; }
String& GetSource() { return aSource; }
USHORT GetBase() const { return nDimBase; }
String GetString( short nId ) const;
//const char* GetString( short nId ) const;
const SbxObject* FindType (String aTypeName) const;
void SetFlag( USHORT n ) { nFlags |= n; }
USHORT GetFlag( USHORT n ) const { return nFlags & n; }
};
#define SBIMG_EXPLICIT 0x0001 // OPTION EXPLICIT ist aktiv
#define SBIMG_COMPARETEXT 0x0002 // OPTION COMPARE TEXT ist aktiv
#define SBIMG_INITCODE 0x0004 // Init-Code vorhanden
#endif
+149
View File
@@ -0,0 +1,149 @@
/*************************************************************************
*
* $RCSfile: iosys.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SBIOSYS_HXX
#define _SBIOSYS_HXX
#ifndef _STREAM_HXX //autogen
#include <tools/stream.hxx>
#endif
#ifndef _SBERRORS_HXX
#include "sberrors.hxx"
#endif
class SvStream;
// Zur Zeit sind globale Dateien (Kanalnummern 256 bis 511)
// nicht implementiert.
#define CHANNELS 256
#define CONSOLE 0
#define SBSTRM_INPUT 0x0001 // Input
#define SBSTRM_OUTPUT 0x0002 // Output
#define SBSTRM_RANDOM 0x0004 // Random
#define SBSTRM_APPEND 0x0008 // Append
#define SBSTRM_BINARY 0x0010 // Binary
class SbiStream {
SvStream* pStrm; // der Stream
ULONG nExpandOnWriteTo; // bei Schreibzugriff, den Stream
// bis zu dieser Groesse aufblasen
ByteString aLine; // aktuelle Zeile
ULONG nLine; // aktuelle Zeilennummer
short nLen; // Pufferlaenge
short nMode; // Bits:
short nChan; // aktueller Kanal
SbError nError; // letzter Fehlercode
void MapError(); // Fehlercode mappen
public:
SbiStream();
~SbiStream();
SbError Open( short, const ByteString&, short, short, short );
SbError Close();
SbError Read( ByteString&, USHORT = 0 );
SbError Read( char& );
SbError Write( const ByteString&, USHORT = 0 );
BOOL IsText() const { return !(nMode & SBSTRM_BINARY); }
BOOL IsRandom() const { return (nMode & SBSTRM_RANDOM); }
BOOL IsBinary() const { return (nMode & SBSTRM_BINARY); }
BOOL IsSeq() const { return !(nMode & SBSTRM_RANDOM); }
BOOL IsAppend() const { return (nMode & SBSTRM_APPEND); }
short GetBlockLen() const { return nLen; }
short GetMode() const { return nMode; }
ULONG GetLine() const { return nLine; }
void SetExpandOnWriteTo( ULONG n ) { nExpandOnWriteTo = n; }
void ExpandFile();
SvStream* GetStrm() { return pStrm; }
};
class SbiIoSystem {
SbiStream* pChan[ CHANNELS ];
ByteString aPrompt; // Input-Prompt
ByteString aIn, aOut; // Console-Buffer
short nChan; // aktueller Kanal
SbError nError; // letzter Fehlercode
void ReadCon( ByteString& );
void WriteCon( const ByteString& );
public:
SbiIoSystem();
~SbiIoSystem();
SbError GetError();
void Shutdown();
void SetPrompt( const ByteString& r ) { aPrompt = r; }
void SetChannel( short n ) { nChan = n; }
short GetChannel() const { return nChan;}
void ResetChannel() { nChan = 0; }
void Open( short, const ByteString&, short, short, short );
void Close();
void Read( ByteString&, short = 0 );
char Read();
void Write( const ByteString&, short = 0 );
short NextChannel();
// 0 == bad channel or no SvStream (nChannel=0..CHANNELS-1)
SbiStream* GetStream( short nChannel ) const;
void CloseAll(); // JSM
};
#endif
+137
View File
@@ -0,0 +1,137 @@
/*************************************************************************
*
* $RCSfile: object.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SAMPLE_OBJECT_HXX
#define _SAMPLE_OBJECT_HXX
#ifndef __SBX_SBX_FACTORY_HXX //autogen
#include <svtools/sbxfac.hxx>
#endif
#ifndef __SBX_SBXVARIABLE_HXX //autogen
#include <svtools/sbxvar.hxx>
#endif
#ifndef _SBX_SBXOBJECT_HXX //autogen
#include <svtools/sbxobj.hxx>
#endif
// 1) Properties:
// Name der Name, R/O
// Value ein double-Wert, R/W
// 2) Methoden:
// Display Ausgabe eines Textes
// Square Argument * Argument
// Event Aufruf eines Basic-Programms
// 3) Unterobjekte:
// eine Collection names "Elements". Der Zugriff ist sowohl als
// Property (fuer das gesamte Objekt) als auch als Methode (fuer
// einzelne Elemente, wird durchgereicht) implementiert.
// Diese Implementation ist ein Beispiel fuer eine tabellengesteuerte
// Version, die sehr viele Elemente enthalten kann.
// Die Collection findet sich in COLLECTN.*, die in der Collection
// enthaltenen Objekte in COLLELEM.*
class SampleObject : public SbxObject
{
// Definition eines Tabelleneintrags. Dies wird hier gemacht,
// da dadurch die Methoden und Properties als private deklariert
// werden koennen.
#if defined ( ICC ) || defined ( HPUX ) || defined ( C50 )
public:
#endif
typedef void( SampleObject::*pMeth )
( SbxVariable* pThis, SbxArray* pArgs, BOOL bWrite );
#if defined ( ICC ) || defined ( HPUX )
private:
#endif
struct Methods {
const char* pName; // Name des Eintrags
SbxDataType eType; // Datentyp
short nArgs; // Argumente und Flags
pMeth pFunc; // Function Pointer
};
static Methods aMethods[]; // Methodentabelle
// Methoden
void Display( SbxVariable*, SbxArray*, BOOL );
void Event( SbxVariable*, SbxArray*, BOOL );
void Square( SbxVariable*, SbxArray*, BOOL );
void Create( SbxVariable*, SbxArray*, BOOL );
// Infoblock auffuellen
SbxInfo* GetInfo( short nIdx );
// Broadcaster Notification
virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
const SfxHint& rHint, const TypeId& rHintType );
public:
SampleObject( const String& );
// Suchen eines Elements
virtual SbxVariable* Find( const String&, SbxClassType );
};
// Die dazugehoerige Factory:
class SampleObjectFac : public SbxFactory
{
public:
virtual SbxObject* CreateObject( const String& );
};
#endif
+191
View File
@@ -0,0 +1,191 @@
/*************************************************************************
*
* $RCSfile: opcodes.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _OPCODES_HXX
#define _OPCODES_HXX
#include "sbintern.hxx"
#ifdef MTW
#undef _NUMBER
#endif
// Ein Opcode ist entweder 1, 3 oder 5 Bytes lang, je nach numerischen
// Wert des Opcodes (s.u.).
enum SbiOpcode {
// Alle Opcodes ohne Operanden
_NOP = 0,
SbOP0_START = _NOP,
// Operatoren
// die folgenden Operatoren sind genauso angeordnet
// wie der enum SbxVarOp
_EXP, _MUL, _DIV, _MOD, _PLUS, _MINUS, _NEG,
_EQ, _NE, _LT, _GT, _LE, _GE,
_IDIV, _AND, _OR, _XOR, _EQV, _IMP, _NOT,
_CAT,
// Ende enum SbxVarOp
_LIKE, _IS,
// Laden/speichern
_ARGC, // neuen Argv einrichten
_ARGV, // TOS ==> aktueller Argv
_INPUT, // Input ==> TOS
_LINPUT, // Line Input ==> TOS
_GET, // TOS anfassen
_SET, // Speichern Objekt TOS ==> TOS-1
_PUT, // TOS ==> TOS-1
_PUTC, // TOS ==> TOS-1, dann ReadOnly
_DIM, // DIM
_REDIM, // REDIM
_REDIMP, // REDIM PRESERVE
_ERASE, // TOS loeschen
// Verzweigen
_STOP, // Programmende
_INITFOR, // FOR-Variable initialisieren
_NEXT, // FOR-Variable inkrementieren
_CASE, // Anfang CASE
_ENDCASE, // Ende CASE
_STDERROR, // Standard-Fehlerbehandlung
_NOERROR, // keine Fehlerbehandlung
_LEAVE, // UP verlassen
// E/A
_CHANNEL, // TOS = Kanalnummer
_BPRINT, // print TOS
_PRINTF, // print TOS in field
_BWRITE, // write TOS
_RENAME, // Rename Tos+1 to Tos
_PROMPT, // TOS = Prompt for Input
_RESTART, // Restartpunkt definieren
_CHAN0, // I/O-Kanal 0
// Sonstiges
_EMPTY, // Leeren Ausdruck auf Stack
_ERROR, // TOS = Fehlercode
_LSET, // Speichern Objekt TOS ==> TOS-1
_RSET, // Speichern Objekt TOS ==> TOS-1
SbOP0_END,
// Alle Opcodes mit einem Operanden
_NUMBER = 0x40, // Laden einer numerischen Konstanten (+ID)
SbOP1_START = _NUMBER,
_SCONST, // Laden einer Stringkonstanten (+ID)
_CONST, // Immediate Load (+Wert)
_ARGN, // Speichern eines named Args in Argv (+StringID)
_PAD, // String auf feste Laenge bringen (+Laenge)
// Verzweigungen
_JUMP, // Sprung (+Target)
_JUMPT, // TOS auswerten, bedingter Sprung (+Target)
_JUMPF, // TOS auswerten, bedingter Sprung (+Target)
_ONJUMP, // TOS auswerten, Sprung in JUMP-Tabelle (+MaxVal)
_GOSUB, // UP-Aufruf (+Target)
_RETURN, // UP-Return (+0 oder Target)
_TESTFOR, // FOR-Variable testen, inkrementieren (+Endlabel)
_CASETO, // Tos+1 <= Case <= Tos, 2xremove (+Target)
_ERRHDL, // Fehler-Handler (+Offset)
_RESUME, // Resume nach Fehlern (+0 or 1 or Label)
// E/A
_CLOSE, // (+Kanal/0)
_PRCHAR, // (+char)
// Verwaltung
_CLASS, // Klassennamen testen (+StringId)
_LIB, // Libnamen fuer Declare-Procs setzen (+StringId)
_BASED, // TOS wird um BASE erhoeht, BASE davor gepusht (+base)
// Typanpassung im Argv
_ARGTYP, // Letzten Parameter in Argv konvertieren (+Typ)
SbOP1_END,
// Alle Opcodes mit zwei Operanden
_RTL = 0x80, // Laden aus RTL (+StringID+Typ)
SbOP2_START = _RTL,
_FIND, // Laden (+StringID+Typ)
_ELEM, // Laden Element (+StringID+Typ)
_PARAM, // Parameter (+Offset+Typ)
// Verzweigen
_CALL, // DECLARE-Methode rufen (+StringID+Typ)
_CALLC, // Cdecl-DECLARE-Methode rufen (+StringID+Typ)
_CASEIS, // Case-Test (+Test-Opcode+True-Target)
// Verwaltung
_STMNT, // Beginn eines Statements (+Line+Col)
// E/A
_OPEN, // (+SvStreamFlags+Flags)
// Objekte
_LOCAL, // Lokale Variable definieren (+StringID+Typ)
_PUBLIC, // Modulglobale Variable (+StringID+Typ)
_GLOBAL, // Globale Variable definieren (+StringID+Typ)
_CREATE, // Objekt kreieren (+StringId+StringID)
_STATIC, // Statische Variabl (+StringID+Typ) JSM
_TCREATE, // User Defined Objekt kreieren
_DCREATE, // Objekt-Array kreieren (+StringId+StringID)
SbOP2_END
};
#endif
+192
View File
@@ -0,0 +1,192 @@
/*************************************************************************
*
* $RCSfile: parser.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _PARSER_HXX
#define _PARSER_HXX
#ifndef _EXPR_HXX
#include "expr.hxx"
#endif
#ifndef _CODEGEN_HXX
#include "codegen.hxx"
#endif
#ifndef _SYMTBL_HXX
#include "symtbl.hxx"
#endif
struct SbiParseStack;
class SbiParser : public SbiTokenizer
{
SbiParseStack* pStack; // Block-Stack
SbiProcDef* pProc; // aktuelle Prozedur
SbiExprNode* pWithVar; // aktuelle With-Variable
SbiToken eEndTok; // das Ende-Token
USHORT nGblChain; // Chainkette fuer globale DIMs
BOOL bGblDefs; // TRUE globale Definitionen allgemein
BOOL bNewGblDefs; // TRUE globale Definitionen vor Sub
BOOL bSingleLineIf; // TRUE einzeiliges if-Statement
SbiSymDef* VarDecl( SbiDimList**,BOOL,BOOL );// Variablen-Deklaration
SbiProcDef* ProcDecl(BOOL bDecl);// Prozedur-Deklaration
void DefProc( BOOL bStatic ); // Prozedur einlesen
void DefVar( SbiOpcode eOp, BOOL bStatic ); // DIM/REDIM einlesen
void TypeDecl( SbiSymDef& ); // AS-Deklaration
void OpenBlock( SbiToken, SbiExprNode* = NULL ); // Block oeffnen
void CloseBlock(); // Block aufloesen
BOOL Channel( BOOL=FALSE ); // Kanalnummer parsen
void StmntBlock( SbiToken ); // Statement-Block abarbeiten
public:
SbxArrayRef rTypeArray; // das Type-Array
SbiStringPool aGblStrings; // der String-Pool
SbiStringPool aLclStrings; // der String-Pool
SbiSymPool aGlobals; // globale Variable
SbiSymPool aPublics; // modulglobale Variable
SbiSymPool aRtlSyms; // Runtime-Library
SbiCodeGen aGen; // Code-Generator
StarBASIC* pBasic; // StarBASIC-Instanz
SbiSymPool* pPool; // aktueller Pool
SbiExprType eCurExpr; // aktueller Expr-Typ
short nBase; // OPTION BASE-Wert
BOOL bText; // OPTION COMPARE TEXT
BOOL bExplicit; // TRUE: OPTION EXPLICIT
SbxDataType eDefTypes[26]; // DEFxxx-Datentypen
SbiParser( StarBASIC*, SbModule* );
BOOL Parse(); // die Aktion
SbiExprNode* GetWithVar(); // Innerste With-Variable liefern
// AB 31.3.1996, Symbol in Runtime-Library suchen
SbiSymDef* CheckRTLForSym( const String& rSym, SbxDataType eType );
BOOL HasGlobalCode(); // Globaler Code definiert?
BOOL TestToken( SbiToken ); // bestimmtes TOken?
BOOL TestSymbol( BOOL=FALSE ); // Symbol?
BOOL TestComma(); // Komma oder EOLN?
void TestEoln(); // EOLN?
void Symbol(); // Let oder Call
void ErrorStmnt(); // ERROR n
void NotImp(); // nicht implementiert
void BadBlock(); // LOOP/WEND/NEXT
void BadSyntax(); // Falsches SbiToken
void NoIf(); // ELSE/ELSE IF ohne IF
void Assign(); // LET
void Call(); // CALL
void Close(); // CLOSE
void Declare(); // DECLARE
void DefXXX(); // DEFxxx
void Dim(); // DIM
void ReDim(); // ReDim();
void Erase(); // ERASE
void Exit(); // EXIT
void For(); // FOR...NEXT
void Goto(); // GOTO / GOSUB
void If(); // IF
void Input(); // INPUT, INPUT #
void LineInput(); // LINE INPUT, LINE INPUT #
void LSet(); // LSET
void Name(); // NAME .. AS ..
void On(); // ON ERROR/variable
void OnGoto(); // ON...GOTO / GOSUB
void Open(); // OPEN
void Option(); // OPTION
void Print(); // PRINT, PRINT #
void SubFunc(); // SUB / FUNCTION
void Resume(); // RESUME
void Return(); // RETURN
void RSet(); // RSET
void DoLoop(); // DO...LOOP
void Select(); // SELECT ... CASE
void Set(); // SET
void Static(); // STATIC
void Stop(); // STOP/SYSTEM
void Type(); // TYPE...AS...END TYPE
void While(); // WHILE/WEND
void With(); // WITH
void Write(); // WRITE
// JavaScript-Parsing
void OpenJavaBlock( SbiToken, SbiExprNode* = NULL ); // Block oeffnen
void CloseJavaBlock(); // Block aufloesen
void JavaStmntBlock( SbiToken ); // Statement-Block abarbeiten
void JavaBreak();
void JavaContinue();
void JavaFor();
void JavaFunction();
void JavaIf();
void JavaNew();
void JavaReturn();
void JavaThis();
void JavaVar();
void JavaWhile();
void JavaWith();
};
#endif
+235
View File
@@ -0,0 +1,235 @@
/*************************************************************************
*
* $RCSfile: propacc.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SFX_PROPBAG_HXX
#define _SFX_PROPBAG_HXX
#ifndef _SVARRAY_HXX
#include <svtools/svarray.hxx>
#endif
#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HXX_
#include <com/sun/star/beans/PropertyValue.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HXX_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSETINFO_HXX_
#include <com/sun/star/beans/XPropertySetInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYACCESS_HXX_
#include <com/sun/star/beans/XPropertyAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYCONTAINER_HXX_
#include <com/sun/star/beans/XPropertyContainer.hpp>
#endif
#ifndef _CPPUHELPER_IMPLBASE1_HXX_
#include <cppuhelper/implbase1.hxx>
#endif
#ifndef _CPPUHELPER_IMPLBASE2_HXX_
#include <cppuhelper/implbase2.hxx>
#endif
#define NS_BEANS ::com::sun::star::beans
#define NS_LANG ::com::sun::star::lang
#define NS_UNO ::com::sun::star::uno
typedef NS_BEANS::PropertyValue* SbPropertyValuePtr;
SV_DECL_PTRARR( SbPropertyValueArr_Impl, SbPropertyValuePtr, 4, 4 );
typedef ::cppu::WeakImplHelper2< NS_BEANS::XPropertySet,
NS_BEANS::XPropertyAccess > SbPropertyValuesHelper;
//==========================================================================
class SbPropertyValues: public SbPropertyValuesHelper
{
SbPropertyValueArr_Impl _aPropVals;
NS_UNO::Reference< ::com::sun::star::beans::XPropertySetInfo > _xInfo;
private:
INT32 GetIndex_Impl( const ::rtl::OUString &rPropName ) const;
public:
SbPropertyValues();
virtual ~SbPropertyValues();
// XPropertySet
virtual NS_UNO::Reference< NS_BEANS::XPropertySetInfo > SAL_CALL
getPropertySetInfo(void) throw( NS_UNO::RuntimeException );
virtual void SAL_CALL setPropertyValue(
const ::rtl::OUString& aPropertyName,
const NS_UNO::Any& aValue);
virtual NS_UNO::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName )
throw( NS_BEANS::UnknownPropertyException,
NS_LANG::WrappedTargetException,
NS_UNO::RuntimeException);
virtual void SAL_CALL addPropertyChangeListener(
const ::rtl::OUString& aPropertyName,
const NS_UNO::Reference< NS_BEANS::XPropertyChangeListener >& );
virtual void SAL_CALL removePropertyChangeListener(
const ::rtl::OUString& aPropertyName,
const NS_UNO::Reference< NS_BEANS::XPropertyChangeListener >& );
virtual void SAL_CALL addVetoableChangeListener(
const ::rtl::OUString& aPropertyName,
const NS_UNO::Reference< NS_BEANS::XVetoableChangeListener >& );
virtual void SAL_CALL removeVetoableChangeListener(
const ::rtl::OUString& aPropertyName,
const NS_UNO::Reference< NS_BEANS::XVetoableChangeListener >& );
// XPropertyAccess
virtual NS_UNO::Sequence< NS_BEANS::PropertyValue > SAL_CALL getPropertyValues(void);
virtual void SAL_CALL setPropertyValues(const NS_UNO::Sequence< NS_BEANS::PropertyValue >& PropertyValues_);
};
//==========================================================================
typedef ::cppu::WeakImplHelper1< NS_BEANS::XPropertySetInfo > SbPropertySetInfoHelper;
// AB 20.3.2000 Help Class for XPropertySetInfo implementation
class PropertySetInfoImpl
{
friend class SbPropertySetInfo;
friend class SbPropertyContainer;
NS_UNO::Sequence< NS_BEANS::Property > _aProps;
sal_Int32 GetIndex_Impl( const ::rtl::OUString &rPropName ) const;
public:
PropertySetInfoImpl();
PropertySetInfoImpl( NS_UNO::Sequence< NS_BEANS::Property >& rProps );
// XPropertySetInfo
NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void);
NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
throw( NS_UNO::RuntimeException );
sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
throw ( NS_UNO::RuntimeException );
};
class SbPropertySetInfo: public SbPropertySetInfoHelper
{
PropertySetInfoImpl aImpl;
public:
SbPropertySetInfo();
SbPropertySetInfo( const SbPropertyValueArr_Impl &rPropVals );
virtual ~SbPropertySetInfo();
// XPropertySetInfo
virtual NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void)
throw( NS_UNO::RuntimeException );
virtual NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
throw( NS_UNO::RuntimeException );
virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
throw( NS_UNO::RuntimeException );
};
//==========================================================================
typedef ::cppu::WeakImplHelper2< NS_BEANS::XPropertySetInfo, NS_BEANS::XPropertyContainer > SbPropertyContainerHelper;
class SbPropertyContainer: public SbPropertyContainerHelper
{
PropertySetInfoImpl aImpl;
public:
SbPropertyContainer();
virtual ~SbPropertyContainer();
// XPropertyContainer
virtual void SAL_CALL addProperty( const ::rtl::OUString& Name,
INT16 Attributes,
const NS_UNO::Any& DefaultValue)
throw( NS_BEANS::PropertyExistException, NS_BEANS::IllegalTypeException,
NS_LANG::IllegalArgumentException, NS_UNO::RuntimeException );
virtual void SAL_CALL removeProperty(const ::rtl::OUString& Name)
throw( NS_BEANS::UnknownPropertyException, NS_UNO::RuntimeException );
// XPropertySetInfo
virtual NS_UNO::Sequence< NS_BEANS::Property > SAL_CALL getProperties(void);
virtual NS_BEANS::Property SAL_CALL getPropertyByName(const ::rtl::OUString& Name)
throw( NS_UNO::RuntimeException );
virtual sal_Bool SAL_CALL hasPropertyByName(const ::rtl::OUString& Name)
throw( NS_UNO::RuntimeException );
// XPropertyAccess
virtual NS_UNO::Sequence< NS_BEANS::PropertyValue > SAL_CALL getPropertyValues(void);
virtual void SAL_CALL setPropertyValues(const NS_UNO::Sequence< NS_BEANS::PropertyValue >& PropertyValues_);
};
//=========================================================================
class StarBASIC;
class SbxArray;
void RTL_Impl_CreatePropertySet( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
#undef NS_BEANS
#undef NS_LANG
#undef NS_UNO
#endif
+473
View File
@@ -0,0 +1,473 @@
/*************************************************************************
*
* $RCSfile: runtime.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SBRUNTIME_HXX
#define _SBRUNTIME_HXX
#include "sb.hxx"
// Define activates class UCBStream in iosys.cxx
#define _USE_UNO
#ifdef _USE_UNO
#include <rtl/ustring>
#include <com/sun/star/uno/Sequence.hxx>
using namespace rtl;
using namespace com::sun::star::uno;
//#include <sal/types.h>
//#include <rtl/byteseq.hxx>
//#include <rtl/ustring>
namespace basicEncoder
{
// TODO: Use exported functionality (code is copied from deamons2/ucb)
class AsciiEncoder
{
public:
static ::rtl::OUString decodeUnoUrlParamValue(const rtl::OUString & rSource);
//static ::rtl::OUString encodeUnoUrlParamValue(const rtl::OUString & rSource);
//static ::rtl::ByteSequence decode(const ::rtl::OUString & string);
//static ::rtl::OUString encode(const ::rtl::ByteSequence & bytes);
//static void test();
};
}
#endif /* _USE_UNO */
class SbiInstance; // aktiver StarBASIC-Prozess
class SbiRuntime; // aktive StarBASIC-Prozedur-Instanz
struct SbiArgvStack; // Argv stack element
struct SbiGosubStack; // GOSUB stack element
class SbiImage; // Code-Image
class SbiIoSystem; // Dateisystem
class SbiDdeControl; // DDE-Steuerung
class SbiDllMgr; // Aufrufe in DLLs
class SvNumberFormatter; // Zeit/Datumsfunktionen
struct SbiForStack { // for/next stack:
SbiForStack* pNext; // Chain
SbxVariableRef refVar; // loop variable
SbxVariableRef refEnd; // end expression
SbxVariableRef refInc; // increment expression
};
#define MAXRECURSION 500 // max. 500 Rekursionen
#define Sb_ATTR_NORMAL 0x0000
#define Sb_ATTR_HIDDEN 0x0002
#define Sb_ATTR_SYSTEM 0x0004
#define Sb_ATTR_VOLUME 0x0008
#define Sb_ATTR_DIRECTORY 0x0010
#define Sb_ATTR_ARCHIVE 0x0020
class Dir;
class SbiRTLData
{
public:
Dir* pDir;
INT16 nDirFlags;
USHORT nCurDirPos;
#ifdef _USE_UNO
Sequence< OUString > aDirSeq;
#endif /* _USE_UNO */
SbiRTLData();
~SbiRTLData();
};
// Die Instanz entspricht einem laufenden StarBASIC. Mehrere gleichzeitig
// laufende BASICs werden ueber verkettete Instanzen verwaltet. Hier liegen
// alle Daten, die nur leben, wenn BASIC auch lebt, wie z.B. das I/O-System.
class SbiInstance
{
friend class SbiRuntime;
SbiRTLData aRTLData;
SbiIoSystem* pIosys; // Dateisystem
SbiDdeControl* pDdeCtrl; // DDE
SbiDllMgr* pDllMgr; // DLL-Calls (DECLARE)
StarBASIC* pBasic;
SvNumberFormatter* pNumberFormatter;
ULONG nStdDateIdx, nStdTimeIdx, nStdDateTimeIdx;
SbError nErr; // aktueller Fehlercode
String aErrorMsg; // letzte Error-Message fuer $ARG
USHORT nErl; // aktuelle Fehlerzeile
BOOL bReschedule; // Flag: TRUE = Reschedule in Hauptschleife
public:
SbiRuntime* pRun; // Call-Stack
SbiInstance* pNext; // Instanzen-Chain
// #31460 Neues Konzept fuer StepInto/Over/Out,
// Erklaerung siehe runtime.cxx bei SbiInstance::CalcBreakCallLevel()
USHORT nCallLvl; // Call-Level (wg. Rekursion)
USHORT nBreakCallLvl; // Call-Level zum Anhalten
void CalcBreakCallLevel( USHORT nFlags ); // Gemaess Flags setzen
SbiInstance( StarBASIC* );
~SbiInstance();
void Error( SbError ); // trappable Error
void Error( SbError, const String& rMsg ); // trappable Error mit Message
void FatalError( SbError ); // non-trappable Error
void Abort(); // Abbruch mit aktuellem Fehlercode
void Stop();
SbError GetErr() { return nErr; }
String GetErrorMsg() { return aErrorMsg; }
xub_StrLen GetErl() { return nErl; }
void EnableReschedule( BOOL bEnable ) { bReschedule = bEnable; }
BOOL IsReschedule( void ) { return bReschedule; }
SbMethod* GetCaller( USHORT );
SbModule* GetActiveModule();
SbxArray* GetLocals( SbMethod* );
SbiIoSystem* GetIoSystem() { return pIosys; }
SbiDdeControl* GetDdeControl() { return pDdeCtrl; }
SbiDllMgr* GetDllMgr();
SbiRTLData* GetRTLData() const { return (SbiRTLData*)&aRTLData; }
SvNumberFormatter* GetNumberFormatter();
ULONG GetStdDateIdx() const { return nStdDateIdx; }
ULONG GetStdTimeIdx() const { return nStdTimeIdx; }
ULONG GetStdDateTimeIdx() const { return nStdDateTimeIdx; }
// #39629# NumberFormatter auch statisch anbieten
static void PrepareNumberFormatter( SvNumberFormatter*& rpNumberFormatter,
ULONG &rnStdDateIdx, ULONG &rnStdTimeIdx, ULONG &rnStdDateTimeIdx );
};
SbiIoSystem* SbGetIoSystem(); // das aktuelle I/O-System
// Verkettbare Items, um Referenzen temporaer zu halten
struct RefSaveItem
{
SbxVariableRef xRef;
RefSaveItem* pNext;
RefSaveItem() { pNext = NULL; }
};
// #72488 Spezielle SbxVariable, die beim get das Verhalten
// einer nicht initialisierten Variable simuliert. Wenn als
// Typ SbxOBJECT verlangt wird, geht das jedoch nicht.
class UnoClassSbxVariable : public SbxVariable
{
SbxDataType meOrgType;
BOOL mbOverWritten;
const SbiImage* mpImg;
SbiRuntime* mpRuntime;
public:
UnoClassSbxVariable( SbxDataType eType, const SbiImage* pImg_, SbiRuntime* pRuntime_ )
: SbxVariable( SbxVARIANT ), mpImg( pImg_ ), mpRuntime( pRuntime_ )
{
meOrgType = eType;
mbOverWritten = FALSE;
}
UnoClassSbxVariable( const UnoClassSbxVariable& r )
: SbxVariable( r ), meOrgType( r.meOrgType), mbOverWritten( r.mbOverWritten),
mpImg( r.mpImg ), mpRuntime( r.mpRuntime )
{}
virtual BOOL Get( SbxValues& ) const;
virtual BOOL Put( const SbxValues& );
TYPEINFO();
};
// #72732 Spezielle SbxVariable, die beim put/get prueft,
// ob der Kontext fuer eine UnoClass sinnvoll ist. Sonst
// liegt eventuell ein Schreibfehler im Basic-Source vor.
class UnoClassMemberVariable : public SbxVariable
{
SbiRuntime* mpRuntime;
BOOL bInternalUse;
public:
UnoClassMemberVariable( SbiRuntime* pRuntime_, const SbxObjectRef& xWrapper )
: SbxVariable( SbxVARIANT ), mpRuntime( pRuntime_ )
{
bInternalUse = TRUE;
PutObject( xWrapper );
bInternalUse = FALSE;
}
virtual BOOL Get( SbxValues& ) const;
virtual BOOL Put( const SbxValues& );
TYPEINFO();
};
// Eine Instanz dieser Klasse wird fuer jedes ausgefuehrte Unterprogramm
// aufgesetzt. Diese Instanz ist das Herz der BASIC-Maschine und enthaelt
// nur lokale Daten.
class SbiRuntime
{
typedef void( SbiRuntime::*pStep0 )();
typedef void( SbiRuntime::*pStep1 )( USHORT nOp1 );
typedef void( SbiRuntime::*pStep2 )( USHORT nOp1, USHORT nOp2 );
static pStep0 aStep0[]; // Opcode-Tabelle Gruppe 0
static pStep1 aStep1[]; // Opcode-Tabelle Gruppe 1
static pStep2 aStep2[]; // Opcode-Tabelle Gruppe 2
StarBASIC& rBasic; // StarBASIC-Instanz
SbiInstance* pInst; // aktiver Thread
SbModule* pMod; // aktuelles Modul
SbMethod* pMeth; // Methoden-Instanz
SbiIoSystem* pIosys; // I/O-System
const SbiImage* pImg; // Code-Image
SbxArrayRef refExprStk; // expression stack
SbxArrayRef refCaseStk; // CASE expression stack
SbxVariableRef xDummyVar; // Ersatz fuer nicht gefundene Variablen
SbiArgvStack* pArgvStk; // ARGV-Stack
SbiGosubStack* pGosubStk; // GOSUB stack
SbiForStack* pForStk; // FOR/NEXT-Stack
USHORT nExprLvl; // Tiefe des Expr-Stacks
USHORT nGosubLvl; // Zum Vermeiden von Tot-Rekursionen
const BYTE* pCode; // aktueller Code-Pointer
const BYTE* pStmnt; // Beginn des lezten Statements
const BYTE* pError; // Adresse des aktuellen Error-Handlers
const BYTE* pRestart; // Restart-Adresse
const BYTE* pErrCode; // Restart-Adresse RESUME NEXT
const BYTE* pErrStmnt; // Restart-Adresse RESUMT 0
String aLibName; // Lib-Name fuer Declare-Call
SbxArrayRef refParams; // aktuelle Prozedur-Parameter
SbxArrayRef refLocals; // lokale Variable
SbxArrayRef refArgv; // aktueller Argv
// AB, 28.3.2000 #74254, Ein refSaveObj reicht nicht! Neu: pRefSaveList (s.u.)
//SbxVariableRef refSaveObj; // #56368 Bei StepElem Referenz sichern
short nArgc; // aktueller Argc
BOOL bRun; // TRUE: Programm ist aktiv
BOOL bError; // TRUE: Fehler behandeln
BOOL bInError; // TRUE: in einem Fehler-Handler
USHORT nFlags; // Debugging-Flags
SbError nError; // letzter Fehler
USHORT nOps; // Opcode-Zaehler
RefSaveItem* pRefSaveList; // #74254 Temporaere Referenzen sichern
RefSaveItem* pItemStoreList; // Unbenutzte Items aufbewahren
void SaveRef( SbxVariable* pVar )
{
RefSaveItem* pItem = pItemStoreList;
if( pItem )
pItemStoreList = pItem->pNext;
else
pItem = new RefSaveItem();
pItem->pNext = pRefSaveList;
pItem->xRef = pVar;
pRefSaveList = pItem;
}
void ClearRefs( void )
{
while( pRefSaveList )
{
RefSaveItem* pToClearItem = pRefSaveList;
pRefSaveList = pToClearItem->pNext;
pToClearItem->xRef = NULL;
pToClearItem->pNext = pItemStoreList;
pItemStoreList = pToClearItem;
}
}
SbxVariable* FindElement
( SbxObject* pObj, USHORT nOp1, USHORT nOp2, SbError, BOOL );
void SetupArgs( SbxVariable*, USHORT );
SbxVariable* CheckArray( SbxVariable* );
void PushVar( SbxVariable* ); // Variable push
SbxVariableRef PopVar(); // Variable pop
SbxVariable* GetTOS( short=0 ); // Variable vom TOS holen
void TOSMakeTemp(); // TOS in temp. Variable wandeln
BOOL ClearExprStack(); // Expr-Stack freigeben
void PushGosub( const BYTE* ); // GOSUB-Element push
void PopGosub(); // GOSUB-Element pop
void ClearGosubStack(); // GOSUB-Stack freigeben
void PushArgv(); // Argv-Element push
void PopArgv(); // Argv-Element pop
void ClearArgvStack(); // Argv-Stack freigeben
void PushFor(); // For-Element push
void PopFor(); // For-Element pop
void ClearForStack(); // For-Stack freigeben
void StepArith( SbxOperator ); // arithmetische Verknuepfungen
void StepUnary( SbxOperator ); // unaere Verknuepfungen
void StepCompare( SbxOperator );// Vergleiche
void SetParameters( SbxArray* );// Parameter uebernehmen
// MUSS NOCH IMPLEMENTIERT WERDEN
void DllCall( const String&, const String&, SbxArray*, SbxDataType, BOOL );
// #56204 DIM-Funktionalitaet in Hilfsmethode auslagern (step0.cxx)
void DimImpl( SbxVariableRef refVar );
// Die nachfolgenden Routinen werden vom Single Stepper
// gerufen und implementieren die einzelnen Opcodes
void StepNOP(), StepEXP(), StepMUL(), StepDIV();
void StepMOD(), StepPLUS(), StepMINUS(), StepNEG();
void StepEQ(), StepNE(), StepLT(), StepGT();
void StepLE(), StepGE(), StepIDIV(), StepAND();
void StepOR(), StepXOR(), StepEQV(), StepIMP();
void StepNOT(), StepCAT(), StepLIKE(), StepIS();
void StepCLONE(), StepOLDBASED(), StepARGC();
void StepARGV(), StepINPUT(), StepLINPUT(), StepSTOP();
void StepGET(), StepSET(), StepPUT(), StepPUTC();
void StepDIM(), StepREDIM(), StepREDIMP(), StepERASE();
void StepINITFOR(), StepNEXT(), StepERROR();
void StepCASE(), StepENDCASE(), StepSTDERROR();
void StepNOERROR(), StepCHANNEL(), StepCHANNEL0(), StepPRINT();
void StepPRINTF(), StepWRITE(), StepRENAME(), StepPROMPT();
void StepRESTART(), StepEMPTY(), StepLEAVE();
void StepLSET(), StepRSET();
// Alle Opcodes mit einem Operanden
void StepLOADNC( USHORT ), StepLOADSC( USHORT ), StepLOADI( USHORT );
void StepARGN( USHORT ), StepBASED( USHORT ), StepPAD( USHORT );
void StepJUMP( USHORT ), StepJUMPT( USHORT );
void StepJUMPF( USHORT ), StepONJUMP( USHORT );
void StepGOSUB( USHORT ), StepRETURN( USHORT );
void StepTESTFOR( USHORT ), StepCASETO( USHORT ), StepERRHDL( USHORT );
void StepRESUME( USHORT ), StepCLASS( USHORT ), StepLIB( USHORT );
void StepCLOSE( USHORT ), StepPRCHAR( USHORT ), StepARGTYP( USHORT );
// Alle Opcodes mit zwei Operanden
void StepRTL( USHORT, USHORT ), StepPUBLIC( USHORT, USHORT );
void StepFIND( USHORT, USHORT ), StepELEM( USHORT, USHORT );
void StepGLOBAL( USHORT, USHORT ), StepLOCAL( USHORT, USHORT );
void StepPARAM( USHORT, USHORT), StepCREATE( USHORT, USHORT );
void StepCALL( USHORT, USHORT ), StepCALLC( USHORT, USHORT );
void StepCASEIS( USHORT, USHORT ), StepSTMNT( USHORT, USHORT );
void StepOPEN( USHORT, USHORT ), StepSTATIC( USHORT, USHORT );
void StepTCREATE(USHORT,USHORT), StepDCREATE(USHORT,USHORT);
public:
xub_StrLen nLine,nCol1,nCol2; // aktuelle Zeile, Spaltenbereich
SbiRuntime* pNext; // Stack-Chain
SbiRuntime( SbModule*, SbMethod*, USHORT );
~SbiRuntime();
void Error( SbError ); // Fehler setzen, falls != 0
void FatalError( SbError ); // Fehlerbehandlung=Standard, Fehler setzen
BOOL Step(); // Einzelschritt (ein Opcode)
void Stop() { bRun = FALSE; }
SbMethod* GetMethod() { return pMeth; }
SbModule* GetModule() { return pMod; }
USHORT GetDebugFlags() { return nFlags; }
void SetDebugFlags( USHORT nFl ) { nFlags = nFl; }
SbMethod* GetCaller();
SbxArray* GetLocals();
SbxArray* GetParams();
SbxBase* FindElementExtern( const String& rName );
};
// Hilfsfunktion, um aktives Basic zu finden
StarBASIC* GetCurrentBasic( StarBASIC* pRTBasic );
// Get information if security restrictions should be
// used (File IO based on UCB, no RTL function SHELL
// no DDE functionality, no DLLCALL) in basic because
// of portal "virtual" users (portal user != UNIX user)
// (Implemented in iosys.cxx)
BOOL needSecurityRestrictions( void );
// Returns TRUE if UNO is available, otherwise the old
// file system implementation has to be used
// (Implemented in iosys.cxx)
BOOL hasUno( void );
// Converts possibly relative paths to absolute paths
// according to the setting done by ChDir/ChDrive
// (Implemented in methods.cxx)
String getFullPath( const String& aRelPath );
// Sets (virtual) current path for UCB file access
void implChDir( const String& aDir );
// Sets (virtual) current drive for UCB file access
void implChDrive( const String& aDrive );
// Returns (virtual) current path for UCB file access
String implGetCurDir( void );
// Implementation of StepRENAME with UCB
// (Implemented in methods.cxx, so step0.cxx
// has not to be infected with UNO)
void implStepRenameUCB( const String& aSource, const String& aDest );
#endif
+72
View File
@@ -0,0 +1,72 @@
/*************************************************************************
*
* $RCSfile: sbcomp.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SBCOMP_HXX
#define _SBCOMP_HXX
// das folgende habe ich der neuen Datei von MD entnommen! (MT)
#include "sbintern.hxx"
#include "token.hxx" // Tokenizer
#include "symtbl.hxx" // Symbolverwaltung
#include "parser.hxx" // Parser
#include "codegen.hxx" // Code-Generator
#endif
+131
View File
@@ -0,0 +1,131 @@
/*************************************************************************
*
* $RCSfile: sbintern.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SB_INTERN_HXX
#define _SB_INTERN_HXX
#include <svtools/sbxfac.hxx>
#include "sb.hxx"
class SbUnoFactory;
class SbiInstance;
class SbModule;
class SbiFactory : public SbxFactory
{
public:
virtual SbxBase* Create( UINT16 nSbxId, UINT32 = SBXCR_SBX );
virtual SbxObject* CreateObject( const String& );
};
// Stack fuer die im Fehlerfall abgebaute SbiRuntime Kette
class SbErrorStackEntry
{
public:
SbErrorStackEntry(SbMethodRef aM, xub_StrLen nL, xub_StrLen nC1, xub_StrLen nC2)
: aMethod(aM), nLine(nL), nCol1(nC1), nCol2(nC2) {}
SbMethodRef aMethod;
xub_StrLen nLine;
xub_StrLen nCol1, nCol2;
};
SV_DECL_PTRARR_DEL(SbErrorStack, SbErrorStackEntry*, 1, 1)
struct SbiGlobals
{
SbiInstance* pInst; // alle aktiven Runtime-Instanzen
SbiFactory* pSbFac; // StarBASIC-Factory
SbUnoFactory* pUnoFac; // Factory fuer Uno-Structs bei DIM AS NEW
SbModule* pMod; // aktuell aktives Modul
SbModule* pCompMod; // aktuell compiliertes Modul
short nInst; // Anzahl BASICs
Link aErrHdl; // globaler Error-Handler
Link aBreakHdl; // globaler Break-Handler
SbError nCode; // aktueller Fehlercode
xub_StrLen nLine; // aktuelle Zeile
xub_StrLen nCol1,nCol2; // aktuelle Spalten (von,bis)
BOOL bCompiler; // Flag fuer Compiler-Error
BOOL bCompWait; // Flag, beim Compilieren WaitCursor eingeschaltet ist
BOOL bGlobalInitErr; // Beim GlobalInit trat ein Compiler-Fehler auf
BOOL bRunInit; // TRUE, wenn RunInit vom Basic aktiv ist
String aErrMsg; // Puffer fuer GetErrorText()
SbLanguageMode eLanguageMode; // Flag fuer Visual-Basic-Script-Modus
SbErrorStack* pErrStack; // Stack fuer die im Fehlerfall abgebaute SbiRuntime Kette
SbiGlobals();
~SbiGlobals();
};
// Utility-Makros und -Routinen
SbiGlobals* GetSbData();
#define pINST GetSbData()->pInst
#define pMOD GetSbData()->pMod
#define pCMOD GetSbData()->pCompMod
#define pSBFAC GetSbData()->pSbFac
#define pUNOFAC GetSbData()->pUnoFac
#endif
+89
View File
@@ -0,0 +1,89 @@
/*************************************************************************
*
* $RCSfile: sbjsmeth.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SB_SBJSMETH_HXX
#define _SB_SBJSMETH_HXX
#ifndef _SB_SBMETH_HXX
#include <sbmeth.hxx>
#endif
// Basic-Modul fuer JavaScript-Sourcen.
// Alle Basic-spezifischen Methoden muessen virtuell ueberladen und deaktiviert
// werden. Die Unterscheidung von normalen Modulen erfolgt uebr RTTI.
class SbJScriptMethod : public SbMethod
{
public:
SbJScriptMethod( const String&, SbxDataType, SbModule* );
virtual ~SbJScriptMethod();
SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_JSCRIPTMETH,2);
TYPEINFO();
};
#ifndef __SB_SBJSCRIPTMETHODREF_HXX
#define __SB_SBJSCRIPTMETHODREF_HXX
SV_DECL_IMPL_REF(SbJScriptMethod)
#endif
#endif
+84
View File
@@ -0,0 +1,84 @@
/*************************************************************************
*
* $RCSfile: sbjsmod.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SB_SBJSMOD_HXX
#define _SB_SBJSMOD_HXX
#include <sbmod.hxx>
// Basic-Modul fuer JavaScript-Sourcen.
// Alle Basic-spezifischen Methoden muessen virtuell ueberladen und deaktiviert
// werden. Die Unterscheidung von normalen Modulen erfolgt uebr RTTI.
class SbJScriptModule : public SbModule
{
virtual BOOL LoadData( SvStream&, USHORT );
virtual BOOL StoreData( SvStream& ) const;
public:
SBX_DECL_PERSIST_NODATA(SBXCR_SBX,SBXID_JSCRIPTMOD,1);
TYPEINFO();
SbJScriptModule( const String& ); // DURCHREICHEN
};
#endif
+226
View File
@@ -0,0 +1,226 @@
/*************************************************************************
*
* $RCSfile: sbunoobj.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef SB_UNO_OBJ
#define SB_UNO_OBJ
#ifndef _SBX_SBXOBJECT_HXX //autogen
#include <svtools/sbxobj.hxx>
#endif
#ifndef __SBX_SBXMETHOD_HXX //autogen
#include <svtools/sbxmeth.hxx>
#endif
#ifndef __SBX_SBXPROPERTY_HXX //autogen
#include <svtools/sbxprop.hxx>
#endif
#ifndef __SBX_SBX_FACTORY_HXX //autogen
#include <svtools/sbxfac.hxx>
#endif
#ifndef _COM_SUN_STAR_BEANS_XMATERIALHOLDER_HPP_
#include <com/sun/star/beans/XMaterialHolder.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XEXACTNAME_HPP_
#include <com/sun/star/beans/XExactName.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XINTROSPECTIONACCESS_HPP_
#include <com/sun/star/beans/XIntrospectionAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XINTROSPECTION_HPP_
#include <com/sun/star/beans/XIntrospection.hpp>
#endif
#ifndef _COM_SUN_STAR_SCRIPT_XINVOCATION_HPP_
#include <com/sun/star/script/XInvocation.hpp>
#endif
#ifndef _COM_SUN_STAR_REFLECTION_XIDLCLASS_HPP_
#include <com/sun/star/reflection/XIdlClass.hpp>
#endif
using namespace com::sun::star::uno;
using namespace com::sun::star::beans;
using namespace com::sun::star::script;
using namespace com::sun::star::reflection;
class SbUnoObject: public SbxObject
{
Reference< XIntrospectionAccess > mxUnoAccess;
Reference< XMaterialHolder > mxMaterialHolder;
Reference< XInvocation > mxInvocation;
Reference< XExactName > mxExactName;
BOOL bNeedIntrospection;
Any maTmpUnoObj; // Only to save obj for doIntrospection!
// Hilfs-Methode zum Anlegen der dbg_-Properties
void implCreateDbgProperties( void );
// Hilfs-Methode zum Anlegen aller Properties und Methoden
// (Beim on-demand-Mechanismus erforderlich fuer die dbg_-Properties)
void implCreateAll( void );
public:
TYPEINFO();
SbUnoObject( const String& aName, const Any& aUnoObj_ );
~SbUnoObject();
// #76470 Introspection on Demand durchfuehren
void doIntrospection( void );
// Find ueberladen, um z.B. NameAccess zu unterstuetzen
virtual SbxVariable* Find( const String&, SbxClassType );
// Wert rausgeben
Any getUnoAny( void );
Reference< XIntrospectionAccess > getIntrospectionAccess( void ) { return mxUnoAccess; }
Reference< XInvocation > getInvocation( void ) { return mxInvocation; }
void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
};
SV_DECL_IMPL_REF(SbUnoObject);
// #67781 Rueckgabewerte der Uno-Methoden loeschen
void clearUnoMethods( void );
class SbUnoMethod : public SbxMethod
{
friend class SbUnoObject;
friend void clearUnoMethods( void );
Reference< XIdlMethod > m_xUnoMethod;
Sequence<ParamInfo>* pParamInfoSeq;
// #67781 Verweis auf vorige und naechste Methode in der Methoden-Liste
SbUnoMethod* pPrev;
SbUnoMethod* pNext;
public:
TYPEINFO();
SbUnoMethod( const String& aName, SbxDataType eSbxType, Reference< XIdlMethod > xUnoMethod_ );
virtual ~SbUnoMethod();
//virtual SbxInfo* GetInfo() { return NULL; }
const Sequence<ParamInfo>& getParamInfos( void );
};
class SbUnoProperty : public SbxProperty
{
friend class SbUnoObject;
// Daten der Uno-Property
Property aUnoProp;
UINT32 nId;
virtual ~SbUnoProperty();
public:
TYPEINFO();
SbUnoProperty( const String& aName, SbxDataType eSbxType,
const Property& aUnoProp_, UINT32 nId_ );
};
// Factory-Klasse fuer das Anlegen von Uno-Structs per DIM AS NEW
class SbUnoFactory : public SbxFactory
{
public:
virtual SbxBase* Create( UINT16 nSbxId, UINT32 = SBXCR_SBX );
virtual SbxObject* CreateObject( const String& );
};
// Wrapper fuer eine Uno-Klasse
class SbUnoClass: public SbxObject
{
const Reference< XIdlClass > m_xClass;
public:
TYPEINFO();
SbUnoClass( const String& aName, const Reference< XIdlClass >& xClass_ )
: SbxObject( aName ), m_xClass( xClass_ ) {}
//~SbUnoClass();
// Find ueberladen, um Elemente on Demand anzulegen
virtual SbxVariable* Find( const String&, SbxClassType );
// Wert rausgeben
const Reference< XIdlClass >& getUnoClass( void ) { return m_xClass; }
//void SFX_NOTIFY( SfxBroadcaster&, const TypeId&, const SfxHint& rHint, const TypeId& );
};
SV_DECL_IMPL_REF(SbUnoClass);
// Funktion, um einen globalen Bezeichner im
// UnoScope zu suchen und fuer Sbx zu wrappen
SbxVariable* findUnoClass( const String& rName );
class StarBASIC;
// Impl-Methoden fuer RTL
void RTL_Impl_CreateUnoStruct( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
void RTL_Impl_CreateUnoService( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
void RTL_Impl_GetProcessServiceManager( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
void RTL_Impl_HasInterfaces( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
void RTL_Impl_IsUnoStruct( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
void RTL_Impl_EqualUnoObjects( StarBASIC* pBasic, SbxArray& rPar, BOOL bWrite );
#endif
+136
View File
@@ -0,0 +1,136 @@
/*************************************************************************
*
* $RCSfile: scanner.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SCANNER_HXX
#define _SCANNER_HXX
#ifndef _STRING_HXX //autogen
#include <tools/string.hxx>
#endif
#ifndef _SBERRORS_HXX
#include "sberrors.hxx"
#endif
// Der Scanner ist stand-alone, d.h. er kann von ueberallher verwendet
// werden. Eine BASIC-Instanz ist fuer Fehlermeldungen notwendig. Ohne
// BASIC werden die Fehler nur gezaehlt. Auch ist Basic notwendig, wenn
// eine erweiterte SBX-Variable zur Erkennung von Datentypen etc. verwendet
// werden soll.
class StarBASIC;
class SbiScanner
{
String aBuf; // Input-Puffer
String aLine; // aktuelle Zeile
const sal_Unicode* pLine; // Pointer
const sal_Unicode* pSaveLine; // Merker fuer Line
protected:
String aSym; // Symbolpuffer
String aError; // Fehler-String
SbxDataType eScanType; // evtl. Datentyp
StarBASIC* pBasic; // Instanz fuer Fehler-Callbacks
double nVal; // numerischer Wert
short nCurCol1; // aktuelle Spalte 1
short nSavedCol1; // gerettete Spalte 1
short nCol; // aktuelle Spaltennummer
short nErrors; // Anzahl Fehler
short nColLock; // Lock-Zaehler fuer Col1
USHORT nBufPos; // aktuelle Buffer-Pos
USHORT nLine; // aktuelle Zeile
USHORT nCol1, nCol2; // aktuelle 1. und 2. Spalte
BOOL bSymbol; // TRUE: Symbol gescannt
BOOL bNumber; // TRUE: Zahl gescannt
BOOL bSpaces; // TRUE: Whitespace vor Token
BOOL bErrors; // TRUE: Fehler generieren
BOOL bAbort; // TRUE: abbrechen
BOOL bHash; // TRUE: # eingelesen
BOOL bError; // TRUE: Fehler generieren
BOOL bUsedForHilite; // TRUE: Nutzung fuer Highlighting
void GenError( SbError );
public:
SbiScanner( const String&, StarBASIC* = NULL );
~SbiScanner();
void EnableErrors() { bError = FALSE; }
BOOL IsHash() { return bHash; }
BOOL WhiteSpace() { return bSpaces; }
short GetErrors() { return nErrors; }
short GetLine() { return nLine; }
short GetCol1() { return nCol1; }
short GetCol2() { return nCol2; }
void SetCol1( short n ) { nCol1 = n; }
StarBASIC* GetBasic() { return pBasic; }
void SaveLine(void) { pSaveLine = pLine; }
void RestoreLine(void) { pLine = pSaveLine; }
void LockColumn();
void UnlockColumn();
BOOL DoesColonFollow();
BOOL NextSym(); // naechstes Symbol lesen
const String& GetSym() { return aSym; }
SbxDataType GetType() { return eScanType; }
double GetDbl() { return nVal; }
};
#endif
+86
View File
@@ -0,0 +1,86 @@
/*************************************************************************
*
* $RCSfile: stdobj.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SBSTDOBJ_HXX
#define _SBSTDOBJ_HXX
#ifndef _SBX_SBXOBJECT_HXX //autogen
#include <svtools/sbxobj.hxx>
#endif
class StarBASIC;
class SbStdFactory;
class SbiStdObject : public SbxObject
{
SbStdFactory* pStdFactory;
~SbiStdObject();
SbxInfo* GetInfo( short );
virtual void SFX_NOTIFY( SfxBroadcaster& rBC, const TypeId& rBCType,
const SfxHint& rHint, const TypeId& rHintType );
public:
SbiStdObject( const String&, StarBASIC* );
virtual SbxVariable* Find( const String&, SbxClassType );
virtual void SetModified( BOOL );
};
#endif
+266
View File
@@ -0,0 +1,266 @@
/*************************************************************************
*
* $RCSfile: symtbl.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SYMTBL_HXX
#define _SYMTBL_HXX
#ifndef _SVARRAY_HXX //autogen
#include <svtools/svarray.hxx>
#endif
#ifndef _STRING_HXX //autogen
#include <tools/string.hxx>
#endif
#ifndef _SBXDEF_HXX //autogen
#include <svtools/sbxdef.hxx>
#endif
class SbiSymDef; // Basisklasse
class SbiProcDef; // Prozedur
class SbiConstDef; // Konstante
class SbiSymPool; // Symbol-Pool
class SbiStringPool; // gepoolte Strings
class SvStream;
class SbiParser;
enum SbiSymScope { SbLOCAL, SbPARAM, SbPUBLIC, SbGLOBAL, SbRTL };
///////////////////////////////////////////////////////////////////////////
// Der String-Pool nimmt String-Eintraege auf und sorgt dafuer,
// dass sie nicht doppelt vorkommen.
SV_DECL_PTRARR_DEL(SbiStrings,String*,5,5)
class SbiStringPool { // String-Pool
SbiStrings aData; // Daten
String aEmpty; // for convenience
SbiParser* pParser; // der Parser
public:
SbiStringPool( SbiParser* );
~SbiStringPool();
USHORT GetSize() const { return aData.Count(); }
// AB 8.4.1999, Default wegen #64236 auf TRUE geaendert
// Wenn der Bug sauber behoben ist, wieder auf FALSE aendern.
short Add( const String&, BOOL=TRUE );
short Add( double, SbxDataType );
const String& Find( USHORT ) const;
SbiParser* GetParser() { return pParser; }
};
///////////////////////////////////////////////////////////////////////////
SV_DECL_PTRARR_DEL(SbiSymbols,SbiSymDef*,5,5)
class SbiSymPool { // Symbol-Pool
friend class SbiSymDef;
friend class SbiProcDef;
protected:
SbiStringPool& rStrings; // verwendeter Stringpool
SbiSymbols aData; // Daten
SbiSymPool* pParent; // uebergeordneter Symbol-Pool
SbiParser* pParser; // der Parser
SbiSymScope eScope; // Scope des Pools
USHORT nProcId; // aktuelles ProcId fuer STATIC-Variable
USHORT nCur; // Iterator
public:
SbiSymPool( SbiStringPool&, SbiSymScope );
~SbiSymPool();
void Clear();
void SetParent( SbiSymPool* p ) { pParent = p; }
void SetProcId( short n ) { nProcId = n; }
USHORT GetSize() const { return aData.Count(); }
SbiSymScope GetScope() const { return eScope; }
void SetScope( SbiSymScope s ) { eScope = s; }
SbiParser* GetParser() { return pParser; }
SbiSymDef* AddSym( const String& ); // Symbol hinzufuegen
SbiProcDef* AddProc( const String& );// Prozedur hinzufuegen
void Add( SbiSymDef* ); // Symbol uebernehmen
SbiSymDef* Find( const String& ) const;// Variablenname
SbiSymDef* FindId( USHORT ) const; // Variable per ID suchen
SbiSymDef* Get( USHORT ) const; // Variable per Position suchen
SbiSymDef* First(), *Next(); // Iteratoren
USHORT Define( const String& ); // Label definieren
USHORT Reference( const String& ); // Label referenzieren
void CheckRefs(); // offene Referenzen suchen
};
///////////////////////////////////////////////////////////////////////////
class SbiSymDef { // Allgemeiner Symboleintrag
friend class SbiSymPool;
protected:
String aName; // Name des Eintrags
SbxDataType eType; // Typ des Eintrags
SbiSymPool* pIn; // Parent-Pool
SbiSymPool* pPool; // Pool fuer Unterelemente
short nLen; // Stringlaenge bei STRING*n
short nDims; // Array-Dimensionen
USHORT nId; // Symbol-Nummer
USHORT nTypeId; // String-ID des Datentyps (Dim X AS Dytentyp)
USHORT nProcId; // aktuelles ProcId fuer STATIC-Variable
USHORT nPos; // Positions-Nummer
USHORT nChain; // Backchain-Kette
BOOL bNew : 1; // TRUE: Dim As New...
BOOL bChained : 1; // TRUE: Symbol ist in Code definiert
BOOL bByVal : 1; // TRUE: ByVal-Parameter
BOOL bOpt : 1; // TRUE: optionaler Parameter
BOOL bStatic : 1; // TRUE: STATIC-Variable
BOOL bAs : 1; // TRUE: Datentyp per AS XXX definiert
public:
SbiSymDef( const String& );
virtual ~SbiSymDef();
virtual SbiProcDef* GetProcDef();
virtual SbiConstDef* GetConstDef();
SbxDataType GetType() const { return eType; }
virtual void SetType( SbxDataType );
const String& GetName();
SbiSymScope GetScope() const;
USHORT GetProcId() const{ return nProcId; }
USHORT GetAddr() const { return nChain; }
USHORT GetId() const { return nId; }
USHORT GetTypeId() const{ return nTypeId; }
void SetTypeId( USHORT n ) { nTypeId = n; eType = SbxOBJECT; }
USHORT GetPos() const { return nPos; }
void SetLen( short n ){ nLen = n; }
short GetLen() const { return nLen; }
void SetDims( short n ) { nDims = n; }
short GetDims() const { return nDims; }
BOOL IsDefined() const{ return bChained; }
void SetOptional() { bOpt = TRUE; }
void SetByVal() { bByVal = TRUE; }
void SetStatic() { bStatic = TRUE; }
void SetNew() { bNew = TRUE; }
void SetDefinedAs() { bAs = TRUE; }
BOOL IsOptional() const{ return bOpt; }
BOOL IsByVal() const { return bByVal; }
BOOL IsStatic() const { return bStatic; }
BOOL IsNew() const { return bNew; }
BOOL IsDefinedAs() const { return bAs; }
SbiSymPool& GetPool();
USHORT Define(); // Symbol in Code definieren
USHORT Reference(); // Symbol in Code referenzieren
private:
SbiSymDef( const SbiSymDef& );
};
class SbiProcDef : public SbiSymDef { // Prozedur-Definition (aus Basic):
SbiSymPool aParams; // Parameter
SbiSymPool aLabels; // lokale Sprungziele
String aLibName; // LIB "name"
String aAlias; // ALIAS "name"
USHORT nLine1, nLine2; // Zeilenbereich
BOOL bCdecl : 1; // TRUE: CDECL angegeben
BOOL bPublic : 1; // TRUE: proc ist PUBLIC
public:
SbiProcDef( SbiParser*, const String& ); // Name
virtual ~SbiProcDef();
virtual SbiProcDef* GetProcDef();
virtual void SetType( SbxDataType );
SbiSymPool& GetParams() { return aParams; }
SbiSymPool& GetLabels() { return aLabels; }
SbiSymPool& GetLocals() { return GetPool();}
String& GetLib() { return aLibName; }
String& GetAlias() { return aAlias; }
void SetPublic( BOOL b ) { bPublic = b; }
BOOL IsPublic() const { return bPublic; }
void SetCdecl( BOOL b = TRUE) { bCdecl = b; }
BOOL IsCdecl() const { return bCdecl; }
void SetLine1( USHORT n ) { nLine1 = n; }
USHORT GetLine1() const { return nLine1; }
void SetLine2( USHORT n ) { nLine2 = n; }
USHORT GetLine2() const { return nLine2; }
// Match mit einer Forward-Deklaration. Die Parameternamen
// werden abgeglichen und die Forward-Deklaration wird
// durch this ersetzt
void Match( SbiProcDef* pForward );
private:
SbiProcDef( const SbiProcDef& );
};
class SbiConstDef : public SbiSymDef
{
double nVal;
String aVal;
public:
SbiConstDef( const String& );
virtual ~SbiConstDef();
virtual SbiConstDef* GetConstDef();
void Set( double, SbxDataType );
void Set( const String& );
double GetValue() { return nVal; }
const String& GetString() { return aVal; }
};
#endif
+199
View File
@@ -0,0 +1,199 @@
/*************************************************************************
*
* $RCSfile: token.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _TOKEN_HXX
#define _TOKEN_HXX
#ifndef _SCANNER_HXX
#include "scanner.hxx"
#endif
#ifndef _SBDEF_HXX
#include "sbdef.hxx"
#endif
#if defined( SHARED )
#define SbiTokenSHAREDTMPUNDEF
#undef SHARED
#endif
// Der Tokenizer ist stand-alone, d.h. er kann von ueberallher verwendet
// werden. Eine BASIC-Instanz ist fuer Fehlermeldungen notwendig. Ohne
// BASIC werden die Fehler nur gezaehlt. Auch ist Basic notwendig, wenn
// eine erweiterte SBX-Variable zur Erkennung von Datentypen etc. verwendet
// werden soll.
enum SbiToken {
NIL = 0,
// Token zwischen 0x20 und 0x3F sind Literale:
LPAREN = '(', RPAREN = ')', COMMA = ',', DOT = '.', EXCLAM = '!',
HASH = '#', SEMICOLON = ';',
// Anweisungen:
FIRSTKWD = 0x40,
AS = FIRSTKWD, ALIAS, ASSIGN,
CALL, CASE, CLOSE, COMPARE, _CONST_,
DECLARE, DIM, DO,
// in der Reihenfolge der Datentyp-Enums!
DEFINT, DEFLNG, DEFSNG, DEFDBL, DEFCUR, DEFDATE, DEFSTR, DEFOBJ,
DEFERR, DEFBOOL, DEFVAR,
// in der Reihenfolge der Datentyp-Enums!
DATATYPE1,
TINTEGER = DATATYPE1,
TLONG, TSINGLE, TDOUBLE, TCURRENCY, TDATE, TSTRING, TOBJECT,
_ERROR_, TBOOLEAN, TVARIANT,
DATATYPE2 = TVARIANT,
EACH, ELSE, ELSEIF, END, ERASE, EXIT,
FOR, FUNCTION,
GLOBAL, GOSUB, GOTO,
IF, _IN_, INPUT,
LET, LINE, LINEINPUT, LOCAL, LOOP, LPRINT, LSET,
NAME, NEW, NEXT,
ON, OPEN, OPTION,
PRINT, PRIVATE, PUBLIC,
REDIM, REM, RESUME, RETURN, RSET,
SELECT, SET, SHARED, STATIC, STEP, STOP, SUB,
TEXT, THEN, TO, TYPE,
UNTIL,
WEND, WHILE, WITH, WRITE,
ENDIF, ENDFUNC, ENDSUB, ENDTYPE, ENDSELECT, ENDWITH,
// Ende aller Keywords
LASTKWD = ENDWITH,
// Statement-Ende
EOS, EOLN,
// Operatoren:
EXPON, NEG, MUL,
DIV, IDIV, MOD, PLUS, MINUS,
EQ, NE, LT, GT, LE, GE,
NOT, AND, OR, XOR, EQV,
IMP, CAT, LIKE, IS,
// Sonstiges:
FIRSTEXTRA,
NUMBER=FIRSTEXTRA, FIXSTRING, SYMBOL, _CDECL_, BYVAL,
OUTPUT, RANDOM, APPEND, BINARY, ACCESS,
LOCK, READ, PRESERVE, BASE, ANY, LIB, _OPTIONAL_,
EXPLICIT,
// Ab hier kommen JavaScript-Tokens (gleiches enum, damit gleicher Typ)
FIRSTJAVA,
JS_BREAK=FIRSTJAVA, JS_CONTINUE, JS_FOR, JS_FUNCTION, JS_IF, JS_NEW,
JS_RETURN, JS_THIS, JS_VAR, JS_WHILE, JS_WITH,
// JavaScript-Operatoren
// _ASS_ = Assignment
JS_COMMA, JS_ASSIGNMENT, JS_ASS_PLUS, JS_ASS_MINUS, JS_ASS_MUL,
JS_ASS_DIV, JS_ASS_MOD, JS_ASS_LSHIFT, JS_ASS_RSHIFT, JS_ASS_RSHIFT_Z,
JS_ASS_AND, JS_ASS_XOR, JS_ASS_OR,
JS_COND_QUEST, JS_COND_SEL, JS_LOG_OR, JS_LOG_AND, JS_BIT_OR,
JS_BIT_XOR, JS_BIT_AND, JS_EQ, JS_NE, JS_LT, JS_LE,
JS_GT, JS_GE, JS_LSHIFT, JS_RSHIFT, JS_RSHIFT_Z,
JS_PLUS, JS_MINUS, JS_MUL, JS_DIV, JS_MOD, JS_LOG_NOT, JS_BIT_NOT,
JS_INC, JS_DEC, JS_LPAREN, JS_RPAREN, JS_LINDEX, JS_RINDEX
};
#ifdef SbiTokenSHAREDTMPUNDEF
#define SHARED
#undef SbiTokenSHAREDTMPUNDEF
#endif
class SbiTokenizer : public SbiScanner {
protected:
SbiToken eCurTok; // aktuelles Token
SbiToken ePush; // Pushback-Token
USHORT nPLine, nPCol1, nPCol2; // Pushback-Location
BOOL bEof; // TRUE bei Dateiende
BOOL bEos; // TRUE bei Statement-Ende
BOOL bKeywords; // TRUE, falls Keywords geparst werden
BOOL bAs; // letztes Keyword war AS
public:
SbiTokenizer( const String&, StarBASIC* = NULL );
~SbiTokenizer();
inline BOOL IsEof() { return bEof; }
inline BOOL IsEos() { return bEos; }
void Push( SbiToken ); // Pushback eines Tokens
const String& Symbol( SbiToken );// Rueckumwandlung
SbiToken Peek(); // das naechste Token lesen
SbiToken Next(); // Ein Token lesen
BOOL MayBeLabel( BOOL= FALSE ); // Kann es ein Label sein?
void Hilite( SbTextPortions& ); // Syntax-Highlighting
void Error( SbError c ) { GenError( c ); }
void Error( SbError, SbiToken );
void Error( SbError, const char* );
void Error( SbError, String );
void Keywords( BOOL b ) { bKeywords = b; }
static BOOL IsEoln( SbiToken t )
{ return BOOL( t == EOS || t == EOLN || t == REM ); }
static BOOL IsKwd( SbiToken t )
{ return BOOL( t >= FIRSTKWD && t <= LASTKWD ); }
static BOOL IsExtra( SbiToken t )
{ return BOOL( t >= FIRSTEXTRA ); }
};
#endif
+141
View File
@@ -0,0 +1,141 @@
/*************************************************************************
*
* $RCSfile: basrdll.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _SHL_HXX //autogen
#include <tools/shl.hxx>
#endif
#ifndef _SV_SVAPP_HXX //autogen
#include <vcl/svapp.hxx>
#endif
#ifndef _SOLAR_HRC
#include <svtools/solar.hrc>
#endif
#ifndef _INTN_HXX //autogen
#include <tools/intn.hxx>
#endif
#ifndef _TOOLS_DEBUG_HXX //autogen
#include <tools/debug.hxx>
#endif
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#include <sbstar.hxx>
#include <basrdll.hxx>
#include <basrid.hxx>
#include <sb.hrc>
BasicResId::BasicResId( USHORT nId ):
ResId( nId, (*(BasicDLL**)GetAppData(SHL_BASIC))->GetResMgr() )
{
}
BasicDLL::BasicDLL()
{
*(BasicDLL**)GetAppData(SHL_BASIC) = this;
pResMgr = NULL;
bDebugMode = FALSE;
bBreakEnabled = TRUE;
}
BasicDLL::~BasicDLL()
{
delete pResMgr;
}
void BasicDLL::EnableBreak( BOOL bEnable )
{
BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC);
DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" );
if ( pThis )
pThis->bBreakEnabled = bEnable;
}
void BasicDLL::SetDebugMode( BOOL bDebugMode )
{
BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC);
DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" );
if ( pThis )
pThis->bDebugMode = bDebugMode;
}
void BasicDLL::BasicBreak()
{
//bJustStopping: Wenn jemand wie wild x-mal STOP drueckt, aber das Basic
// nicht schnell genug anhaelt, kommt die Box ggf. oefters...
static BOOL bJustStopping = FALSE;
BasicDLL* pThis = *(BasicDLL**)GetAppData(SHL_BASIC);
DBG_ASSERT( pThis, "BasicDLL::EnableBreak: Noch keine Instanz!" );
if ( pThis )
{
if ( StarBASIC::IsRunning() && !bJustStopping && ( pThis->bBreakEnabled || pThis->bDebugMode ) )
{
bJustStopping = TRUE;
StarBASIC::Stop();
String aMessageStr( BasicResId( IDS_SBERR_TERMINATED ) );
InfoBox( 0, aMessageStr ).Execute();
bJustStopping = FALSE;
}
}
}
+232
View File
@@ -0,0 +1,232 @@
/*************************************************************************
*
* $RCSfile: ddectrl.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _ERRCODE_HXX //autogen
#include <tools/errcode.hxx>
#endif
#ifndef _SVDDE_HXX //autogen
#include <svtools/svdde.hxx>
#endif
#pragma hdrstop
#include "ddectrl.hxx"
#ifndef _SBERRORS_HXX
#include <sberrors.hxx>
#endif
//#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBRUNTIME, SBRUNTIME_CODE )
#define DDE_FREECHANNEL ((DdeConnection*)0xffffffff)
#define DDE_FIRSTERR 0x4000
#define DDE_LASTERR 0x4011
static const SbError nDdeErrMap[] =
{
/* DMLERR_ADVACKTIMEOUT */ 0x4000, SbERR_DDE_TIMEOUT,
/* DMLERR_BUSY */ 0x4001, SbERR_DDE_BUSY,
/* DMLERR_DATAACKTIMEOUT */ 0x4002, SbERR_DDE_TIMEOUT,
/* DMLERR_DLL_NOT_INITIALIZED */ 0x4003, SbERR_DDE_ERROR,
/* DMLERR_DLL_USAGE */ 0x4004, SbERR_DDE_ERROR,
/* DMLERR_EXECACKTIMEOUT */ 0x4005, SbERR_DDE_TIMEOUT,
/* DMLERR_INVALIDPARAMETER */ 0x4006, SbERR_DDE_ERROR,
/* DMLERR_LOW_MEMORY */ 0x4007, SbERR_DDE_ERROR,
/* DMLERR_MEMORY_ERROR */ 0x4008, SbERR_DDE_ERROR,
/* DMLERR_NOTPROCESSED */ 0x4009, SbERR_DDE_NOTPROCESSED,
/* DMLERR_NO_CONV_ESTABLISHED */ 0x400a, SbERR_DDE_NO_CHANNEL,
/* DMLERR_POKEACKTIMEOUT */ 0x400b, SbERR_DDE_TIMEOUT,
/* DMLERR_POSTMSG_FAILED */ 0x400c, SbERR_DDE_QUEUE_OVERFLOW,
/* DMLERR_REENTRANCY */ 0x400d, SbERR_DDE_ERROR,
/* DMLERR_SERVER_DIED */ 0x400e, SbERR_DDE_PARTNER_QUIT,
/* DMLERR_SYS_ERROR */ 0x400f, SbERR_DDE_ERROR,
/* DMLERR_UNADVACKTIMEOUT */ 0x4010, SbERR_DDE_TIMEOUT,
/* DMLERR_UNFOUND_QUEUE_ID */ 0x4011, SbERR_DDE_NO_CHANNEL
};
SbError SbiDdeControl::GetLastErr( DdeConnection* pConv )
{
if( !pConv )
return 0;
long nErr = pConv->GetError();
if( !nErr )
return 0;
if( nErr < DDE_FIRSTERR || nErr > DDE_LASTERR )
return SbERR_DDE_ERROR;
return nDdeErrMap[ 2*(nErr - DDE_FIRSTERR) + 1 ];
}
IMPL_LINK_INLINE( SbiDdeControl,Data , DdeData*, pData,
{
aData = String::CreateFromAscii( (char*)(const void*)*pData );
return 1;
}
)
SbiDdeControl::SbiDdeControl()
{
pConvList = new DdeConnections;
DdeConnection* pPtr = DDE_FREECHANNEL;
pConvList->Insert( pPtr );
}
SbiDdeControl::~SbiDdeControl()
{
TerminateAll();
delete pConvList;
}
INT16 SbiDdeControl::GetFreeChannel()
{
INT16 nListSize = (INT16)pConvList->Count();
DdeConnection* pPtr = pConvList->First();
pPtr = pConvList->Next(); // nullten eintrag ueberspringen
INT16 nChannel;
for( nChannel = 1; nChannel < nListSize; nChannel++ )
{
if( pPtr == DDE_FREECHANNEL )
return nChannel;
pPtr = pConvList->Next();
}
pPtr = DDE_FREECHANNEL;
pConvList->Insert( pPtr, LIST_APPEND );
return nChannel;
}
SbError SbiDdeControl::Initiate( const String& rService, const String& rTopic,
INT16& rnHandle )
{
SbError nErr;
DdeConnection* pConv = new DdeConnection( rService, rTopic );
nErr = GetLastErr( pConv );
if( nErr )
{
delete pConv;
rnHandle = 0;
}
else
{
INT16 nChannel = GetFreeChannel();
pConvList->Replace( pConv, (ULONG)nChannel );
rnHandle = nChannel;
}
return 0;
}
SbError SbiDdeControl::Terminate( INT16 nChannel )
{
DdeConnection* pConv = pConvList->GetObject( (ULONG)nChannel );
if( !nChannel || !pConv || pConv == DDE_FREECHANNEL )
return SbERR_DDE_NO_CHANNEL;
pConvList->Replace( DDE_FREECHANNEL, (ULONG)nChannel );
delete pConv;
return 0L;
}
SbError SbiDdeControl::TerminateAll()
{
INT16 nChannel = (INT16)pConvList->Count();
while( nChannel )
{
nChannel--;
Terminate( nChannel );
}
pConvList->Clear();
DdeConnection* pPtr = DDE_FREECHANNEL;
pConvList->Insert( pPtr );
return 0;
}
SbError SbiDdeControl::Request( INT16 nChannel, const String& rItem, String& rResult )
{
DdeConnection* pConv = pConvList->GetObject( (ULONG)nChannel );
if( !nChannel || !pConv || pConv == DDE_FREECHANNEL )
return SbERR_DDE_NO_CHANNEL;
DdeRequest aRequest( *pConv, rItem, 30000 );
aRequest.SetDataHdl( LINK( this, SbiDdeControl, Data ) );
aRequest.Execute();
rResult = aData;
return GetLastErr( pConv );
}
SbError SbiDdeControl::Execute( INT16 nChannel, const String& rCommand )
{
DdeConnection* pConv = pConvList->GetObject( (ULONG)nChannel );
if( !nChannel || !pConv || pConv == DDE_FREECHANNEL )
return SbERR_DDE_NO_CHANNEL;
DdeExecute aRequest( *pConv, rCommand, 30000 );
aRequest.Execute();
return GetLastErr( pConv );
}
SbError SbiDdeControl::Poke( INT16 nChannel, const String& rItem, const String& rData )
{
DdeConnection* pConv = pConvList->GetObject( (ULONG)nChannel );
if( !nChannel || !pConv || pConv == DDE_FREECHANNEL )
return SbERR_DDE_NO_CHANNEL;
DdePoke aRequest( *pConv, rItem, DdeData(rData), 30000 );
aRequest.Execute();
return GetLastErr( pConv );
}
+102
View File
@@ -0,0 +1,102 @@
/*************************************************************************
*
* $RCSfile: ddectrl.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _DDECTRL_HXX
#define _DDECTRL_HXX
#ifndef _LINK_HXX //autogen
#include <tools/link.hxx>
#endif
#ifndef _SBERRORS_HXX
#include "sberrors.hxx"
#endif
#ifndef _STRING_HXX //autogen
#include <tools/string.hxx>
#endif
class DdeConnection;
class DdeConnections;
class DdeData;
class SbiDdeControl
{
private:
DECL_LINK( Data, DdeData* );
SbError GetLastErr( DdeConnection* );
INT16 GetFreeChannel();
DdeConnections* pConvList;
String aData;
public:
SbiDdeControl();
~SbiDdeControl();
SbError Initiate( const String& rService, const String& rTopic,
INT16& rnHandle );
SbError Terminate( INT16 nChannel );
SbError TerminateAll();
SbError Request( INT16 nChannel, const String& rItem, String& rResult );
SbError Execute( INT16 nChannel, const String& rCommand );
SbError Poke( INT16 nChannel, const String& rItem, const String& rData );
};
#endif
+702
View File
@@ -0,0 +1,702 @@
/*************************************************************************
*
* $RCSfile: dllmgr.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#include <stdlib.h>
#ifdef OS2
#define INCL_DOSMODULEMGR
#include <tools/svpm.h>
#endif
#if defined( WIN ) || defined( WNT )
#ifndef _SVWIN_H
#include <tools/svwin.h>
#endif
#endif
#ifndef _TOOLS_DEBUG_HXX //autogen
#include <tools/debug.hxx>
#endif
#ifndef _STRING_HXX //autogen
#include <tools/string.hxx>
#endif
#ifndef _ERRCODE_HXX //autogen
#include <tools/errcode.hxx>
#endif
#ifndef _SBXVAR_HXX //autogen
#include <svtools/sbxvar.hxx>
#endif
#ifndef _SBXCLASS_HXX //autogen
#include <svtools/sbx.hxx>
#endif
#if defined(WIN)
typedef HINSTANCE SbiDllHandle;
typedef FARPROC SbiDllProc;
#elif defined(WNT)
typedef HMODULE SbiDllHandle;
typedef int(*SbiDllProc)();
#elif defined(OS2)
typedef HMODULE SbiDllHandle;
typedef PFN SbiDllProc;
#else
typedef void* SbiDllHandle;
typedef void* SbiDllProc;
#endif
#define _DLLMGR_CXX
#include "dllmgr.hxx"
#include <sberrors.hxx>
#ifndef CDECL
#ifdef WNT
//#define CDECL __cdecl
#define CDECL
#else
#ifdef WTC
#define CDECL cdecl
#else
#if defined(ICC) && defined(OS2)
#define CDECL _System
#else
#define CDECL
#endif
#endif
#endif
#endif
extern "C" {
#if defined(INTEL) && (defined(WIN) || defined(WNT) || defined(OS2))
extern INT16 CDECL CallINT( SbiDllProc, char *stack, short nstack);
extern INT32 CDECL CallLNG( SbiDllProc, char *stack, short nstack);
#ifndef WNT
extern float CDECL CallSNG( SbiDllProc, char *stack, short nstack);
#endif
extern double CDECL CallDBL( SbiDllProc, char *stack, short nstack);
extern char* CDECL CallSTR( SbiDllProc, char *stack, short nstack);
// extern CallFIX( SbiDllProc, char *stack, short nstack);
#else
INT16 CallINT( SbiDllProc, char *, short ) { return 0; }
INT32 CallLNG( SbiDllProc, char *, short ) { return 0; }
float CallSNG( SbiDllProc, char *, short ) { return 0; }
double CallDBL( SbiDllProc, char *, short) { return 0; }
char* CallSTR( SbiDllProc, char *, short ) { return 0; }
#endif
}
SV_IMPL_OP_PTRARR_SORT(ImplDllArr,ByteStringPtr)
/* mit Optimierung An stuerzt unter Win95 folgendes Makro ab:
declare Sub MessageBeep Lib "user32" (ByVal long)
sub main
MessageBeep( 1 )
end sub
*/
#if defined (WNT) && defined (MSC)
//#pragma optimize ("", off)
#endif
//
// ***********************************************************************
//
class ImplSbiProc : public ByteString
{
SbiDllProc pProc;
ImplSbiProc();
ImplSbiProc( const ImplSbiProc& );
public:
ImplSbiProc( const ByteString& rName, SbiDllProc pFunc )
: ByteString( rName ) { pProc = pFunc; }
SbiDllProc GetProc() const { return pProc; }
};
//
// ***********************************************************************
//
class ImplSbiDll : public ByteString
{
ImplDllArr aProcArr;
SbiDllHandle hDLL;
ImplSbiDll( const ImplSbiDll& );
public:
ImplSbiDll( const ByteString& rName, SbiDllHandle hHandle )
: ByteString( rName ) { hDLL = hHandle; }
~ImplSbiDll();
SbiDllHandle GetHandle() const { return hDLL; }
SbiDllProc GetProc( const ByteString& rName ) const;
void InsertProc( const ByteString& rName, SbiDllProc pProc );
};
ImplSbiDll::~ImplSbiDll()
{
USHORT nCount = aProcArr.Count();
for( USHORT nCur = 0; nCur < nCount; nCur++ )
{
ImplSbiProc* pProc = (ImplSbiProc*)aProcArr.GetObject( nCur );
delete pProc;
}
}
SbiDllProc ImplSbiDll::GetProc( const ByteString& rName ) const
{
USHORT nPos;
BOOL bRet = aProcArr.Seek_Entry( (ByteStringPtr)&rName, &nPos );
if( bRet )
{
ImplSbiProc* pImplProc = (ImplSbiProc*)aProcArr.GetObject(nPos);
return pImplProc->GetProc();
}
return (SbiDllProc)0;
}
void ImplSbiDll::InsertProc( const ByteString& rName, SbiDllProc pProc )
{
DBG_ASSERT(aProcArr.Seek_Entry((ByteStringPtr)&rName,0)==0,"InsertProc: Already in table");
ImplSbiProc* pImplProc = new ImplSbiProc( rName, pProc );
aProcArr.Insert( (ByteStringPtr)pImplProc );
}
//
// ***********************************************************************
//
SbiDllMgr::SbiDllMgr( const SbiDllMgr& )
{
}
SbiDllMgr::SbiDllMgr()
{
}
SbiDllMgr::~SbiDllMgr()
{
USHORT nCount = aDllArr.Count();
for( USHORT nCur = 0; nCur < nCount; nCur++ )
{
ImplSbiDll* pDll = (ImplSbiDll*)aDllArr.GetObject( nCur );
FreeDllHandle( pDll->GetHandle() );
delete pDll;
}
}
void SbiDllMgr::FreeDll( const ByteString& rDllName )
{
USHORT nPos;
BOOL bRet = aDllArr.Seek_Entry( (ByteStringPtr)&rDllName, &nPos );
if( bRet )
{
ImplSbiDll* pDll = (ImplSbiDll*)aDllArr.GetObject(nPos);
FreeDllHandle( pDll->GetHandle() );
delete pDll;
aDllArr.Remove( nPos, 1 );
}
}
ImplSbiDll* SbiDllMgr::GetDll( const ByteString& rDllName )
{
USHORT nPos;
ImplSbiDll* pDll = 0;
BOOL bRet = aDllArr.Seek_Entry( (ByteStringPtr)&rDllName, &nPos );
if( bRet )
pDll = (ImplSbiDll*)aDllArr.GetObject(nPos);
else
{
SbiDllHandle hDll = CreateDllHandle( rDllName );
if( hDll )
{
pDll = new ImplSbiDll( rDllName, hDll );
aDllArr.Insert( (ByteStringPtr)pDll );
}
}
return pDll;
}
SbiDllProc SbiDllMgr::GetProc( ImplSbiDll* pDll, const ByteString& rProcName )
{
DBG_ASSERT(pDll,"GetProc: No dll-ptr");
SbiDllProc pProc;
pProc = pDll->GetProc( rProcName );
if( !pProc )
{
pProc = GetProcAddr( pDll->GetHandle(), rProcName );
if( pProc )
pDll->InsertProc( rProcName, pProc );
}
return pProc;
}
SbError SbiDllMgr::Call( const char* pProcName, const char* pDllName,
SbxArray* pArgs, SbxVariable& rResult, BOOL bCDecl )
{
DBG_ASSERT(pProcName&&pDllName,"Call: Bad parms");
SbError nSbErr = 0;
ByteString aDllName( pDllName );
CheckDllName( aDllName );
ImplSbiDll* pDll = GetDll( aDllName );
if( pDll )
{
SbiDllProc pProc = GetProc( pDll, pProcName );
if( pProc )
{
if( bCDecl )
nSbErr = CallProcC( pProc, pArgs, rResult );
else
nSbErr = CallProc( pProc, pArgs, rResult );
}
else
nSbErr = SbERR_PROC_UNDEFINED;
}
else
nSbErr = SbERR_BAD_DLL_LOAD;
return nSbErr;
}
// ***********************************************************************
// ******************* abhaengige Implementationen ***********************
// ***********************************************************************
void SbiDllMgr::CheckDllName( ByteString& rDllName )
{
#if defined(WIN) || defined(WNT) // || defined(OS2)
if( rDllName.Search('.') == STRING_NOTFOUND )
rDllName += ".DLL";
#endif
}
SbiDllHandle SbiDllMgr::CreateDllHandle( const ByteString& rDllName )
{
#if defined(MAC) || defined(UNX)
SbiDllHandle hLib=0;
#else
SbiDllHandle hLib;
#endif
#if defined(WIN)
hLib = LoadLibrary( (const char*)rDllName );
if( (ULONG)hLib < 32 )
hLib = 0;
#elif defined(WNT)
hLib = LoadLibrary( rDllName.GetBuffer() );
if( !(ULONG)hLib )
{
#ifdef DBG_UTIL
ULONG nLastErr = GetLastError();
#endif
hLib = 0;
}
#elif defined(OS2)
char cErr[ 100 ];
if( DosLoadModule( (PSZ) cErr, 100, (const char*)rDllName, &hLib ) )
hLib = 0;
#endif
return hLib;
}
void SbiDllMgr::FreeDllHandle( SbiDllHandle hLib )
{
#if defined(WIN) || defined(WNT)
if( hLib )
FreeLibrary ((HINSTANCE) hLib);
#elif defined(OS2)
if( hLib )
DosFreeModule( (HMODULE) hLib );
#endif
}
SbiDllProc SbiDllMgr::GetProcAddr(SbiDllHandle hLib, const ByteString& rProcName)
{
char buf1 [128];
char buf2 [128];
SbiDllProc pProc = 0;
short nOrd = 0;
// Ordinal?
if( rProcName.GetBuffer()[0] == '@' )
nOrd = atoi( rProcName.GetBuffer()+1 );
// Moegliche Parameter weg:
strcpy( buf1, rProcName.GetBuffer() );
char *p = strchr( buf1, '#' );
if( p )
*p = 0;
strcpy( buf2, "_" );
strcat( buf2, buf1 );
#if defined(WIN) || defined(WNT)
if( nOrd > 0 )
pProc = (SbiDllProc)GetProcAddress( hLib, (char*)(long) nOrd );
else
{
// 2. mit Parametern:
pProc = (SbiDllProc)GetProcAddress ( hLib, rProcName.GetBuffer() );
// 3. nur der Name:
if (!pProc)
pProc = (SbiDllProc)GetProcAddress( hLib, buf1 );
// 4. der Name mit Underline vorweg:
if( !pProc )
pProc = (SbiDllProc)GetProcAddress( hLib, buf2 );
}
#elif defined(OS2)
PSZ pp;
APIRET rc;
// 1. Ordinal oder mit Parametern:
rc = DosQueryProcAddr( hLib, nOrd, pp = (char*)rProcName.GetStr(), &pProc );
// 2. nur der Name:
if( rc )
rc = DosQueryProcAddr( hLib, 0, pp = (PSZ)buf1, &pProc );
// 3. der Name mit Underline vorweg:
if( rc )
rc = DosQueryProcAddr( hLib, 0, pp = (PSZ)buf2, &pProc );
if( rc )
pProc = NULL;
else
{
// 16-bit oder 32-bit?
ULONG nInfo = 0;
if( DosQueryProcType( hLib, nOrd, pp, &nInfo ) )
nInfo = 0;;
}
#endif
return pProc;
}
SbError SbiDllMgr::CallProc( SbiDllProc pProc, SbxArray* pArgs,
SbxVariable& rResult )
{
// ByteString aStr("Calling DLL at ");
// aStr += (ULONG)pProc;
// InfoBox( 0, aStr ).Execute();
INT16 nInt16; int nInt; INT32 nInt32; float nSingle; double nDouble;
char* pStr;
USHORT nSize;
char* pStack = (char*)CreateStack( pArgs, nSize );
switch( rResult.GetType() )
{
case SbxINTEGER:
nInt16 = CallINT(pProc, pStack, (short)nSize );
rResult.PutInteger( nInt16 );
break;
case SbxUINT:
case SbxUSHORT:
nInt16 = (INT16)CallINT(pProc, pStack, (short)nSize );
rResult.PutUShort( (USHORT)nInt16 );
break;
case SbxERROR:
nInt16 = (INT16)CallINT(pProc, pStack, (short)nSize );
rResult.PutErr( (USHORT)nInt16 );
break;
case SbxINT:
nInt = CallINT(pProc, pStack, (short)nSize );
rResult.PutInt( nInt );
break;
case SbxLONG:
nInt32 = CallLNG(pProc, pStack, (short)nSize );
rResult.PutLong( nInt32 );
break;
case SbxULONG:
nInt32 = CallINT(pProc, pStack, (short)nSize );
rResult.PutULong( (ULONG)nInt32 );
break;
#ifndef WNT
case SbxSINGLE:
nSingle = CallSNG(pProc, pStack, (short)nSize );
rResult.PutSingle( nSingle );
break;
#endif
case SbxDOUBLE:
#ifdef WNT
case SbxSINGLE:
#endif
nDouble = CallDBL(pProc, pStack, (short)nSize );
rResult.PutDouble( nDouble );
break;
case SbxDATE:
nDouble = CallDBL(pProc, pStack, (short)nSize );
rResult.PutDate( nDouble );
break;
case SbxCHAR:
case SbxBYTE:
case SbxBOOL:
nInt16 = CallINT(pProc, pStack, (short)nSize );
rResult.PutByte( (BYTE)nInt16 );
break;
case SbxSTRING:
case SbxLPSTR:
pStr = CallSTR(pProc, pStack, (short)nSize );
rResult.PutString( String::CreateFromAscii( pStr ) );
break;
case SbxNULL:
case SbxEMPTY:
nInt16 = CallINT(pProc, pStack, (short)nSize );
// Rueckgabe nur zulaessig, wenn variant!
if( !rResult.IsFixed() )
rResult.PutInteger( nInt16 );
break;
case SbxCURRENCY:
case SbxOBJECT:
case SbxDATAOBJECT:
default:
CallINT(pProc, pStack, (short)nSize );
break;
}
delete pStack;
if( pArgs )
{
// die Laengen aller uebergebenen Strings anpassen
USHORT nCount = pArgs->Count();
for( USHORT nCur = 1; nCur < nCount; nCur++ )
{
SbxVariable* pVar = pArgs->Get( nCur );
BOOL bIsString = ( pVar->GetType() == SbxSTRING ) ||
( pVar->GetType() == SbxLPSTR );
if( pVar->GetFlags() & SBX_REFERENCE )
{
pVar->ResetFlag( SBX_REFERENCE ); // Sbx moechte es so
if( bIsString )
{
ByteString aByteStr( (char*)pVar->GetUserData() );
String aStr( aByteStr, gsl_getSystemTextEncoding() );
pVar->PutString( aStr );
}
}
if( bIsString )
{
delete (char*)(pVar->GetUserData());
pVar->SetUserData( 0 );
}
}
}
return 0;
}
SbError SbiDllMgr::CallProcC( SbiDllProc pProc, SbxArray* pArgs,
SbxVariable& rResult )
{
DBG_ERROR("C calling convention not supported");
return (USHORT)SbERR_BAD_ARGUMENT;
}
void* SbiDllMgr::CreateStack( SbxArray* pArgs, USHORT& rSize )
{
if( !pArgs )
{
rSize = 0;
return 0;
}
char* pStack = new char[ 2048 ];
char* pTop = pStack;
USHORT nCount = pArgs->Count();
// erstes Element ueberspringen
#ifndef WIN
for( USHORT nCur = 1; nCur < nCount; nCur++ )
#else
// unter 16-Bit Windows anders rum (OS/2 ?????)
for( USHORT nCur = nCount-1; nCur >= 1; nCur-- )
#endif
{
SbxVariable* pVar = pArgs->Get( nCur );
// AB 22.1.1996, Referenz
if( pVar->GetFlags() & SBX_REFERENCE ) // Es ist eine Referenz
{
switch( pVar->GetType() )
{
case SbxINTEGER:
case SbxUINT:
case SbxINT:
case SbxUSHORT:
case SbxLONG:
case SbxULONG:
case SbxSINGLE:
case SbxDOUBLE:
case SbxCHAR:
case SbxBYTE:
case SbxBOOL:
*((void**)pTop) = (void*)&(pVar->aData);
pTop += sizeof( void* );
break;
case SbxSTRING:
case SbxLPSTR:
{
USHORT nLen = 256;
ByteString rStr( pVar->GetString(), gsl_getSystemTextEncoding() );
if( rStr.Len() > 255 )
nLen = rStr.Len() + 1;
char* pStr = new char[ nLen ];
strcpy( pStr, rStr.GetBuffer() );
// ist nicht so sauber, aber wir sparen ein Pointerarray
DBG_ASSERT(sizeof(UINT32)>=sizeof(char*),"Gleich krachts im Basic");
pVar->SetUserData( (UINT32)pStr );
*((const char**)pTop) = pStr;
pTop += sizeof( char* );
}
break;
case SbxNULL:
case SbxEMPTY:
case SbxERROR:
case SbxDATE:
case SbxCURRENCY:
case SbxOBJECT:
case SbxDATAOBJECT:
default:
break;
}
}
else
{
// ByVal
switch( pVar->GetType() )
{
case SbxINTEGER:
case SbxUINT:
case SbxINT:
case SbxUSHORT:
*((INT16*)pTop) = pVar->GetInteger();
pTop += sizeof( INT16 );
break;
case SbxLONG:
case SbxULONG:
*((INT32*)pTop) = pVar->GetLong();
pTop += sizeof( INT32 );
break;
case SbxSINGLE:
*((float*)pTop) = pVar->GetSingle();
pTop += sizeof( float );
break;
case SbxDOUBLE:
*((double*)pTop) = pVar->GetDouble();
pTop += sizeof( double );
break;
case SbxSTRING:
case SbxLPSTR:
{
char* pStr = new char[ pVar->GetString().Len() + 1 ];
ByteString aByteStr( pVar->GetString(), gsl_getSystemTextEncoding() );
strcpy( pStr, aByteStr.GetBuffer() );
// ist nicht so sauber, aber wir sparen ein Pointerarray
DBG_ASSERT(sizeof(UINT32)>=sizeof(char*),"Gleich krachts im Basic");
pVar->SetUserData( (UINT32)pStr );
*((const char**)pTop) = pStr;
pTop += sizeof( char* );
}
break;
case SbxCHAR:
case SbxBYTE:
case SbxBOOL:
*((BYTE*)pTop) = pVar->GetByte();
pTop += sizeof( BYTE );
break;
case SbxNULL:
case SbxEMPTY:
case SbxERROR:
case SbxDATE:
case SbxCURRENCY:
case SbxOBJECT:
case SbxDATAOBJECT:
default:
break;
}
}
}
rSize = (USHORT)((ULONG)pTop - (ULONG)pStack);
return pStack;
}
+135
View File
@@ -0,0 +1,135 @@
/*************************************************************************
*
* $RCSfile: dllmgr.hxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _DLLMGR_HXX
#define _DLLMGR_HXX
#define _SVSTDARR_BYTESTRINGSSORT
#ifndef _SVARRAY_HXX //autogen
#include <svtools/svarray.hxx>
#endif
#ifndef _SVSTDARR_HXX //autogen
#include <svtools/svstdarr.hxx>
#endif
// !!! nur zum debuggen fuer infoboxes !!!
//#ifndef _SV_HXX
//#include <sv.hxx>
//#endif
//#ifndef _TOOLS_HXX
//#include <tools.hxx>
//#endif
#if SUPD > 340
#define _SVSTDARR_STRINGS
//#ifndef _SVSTDARR_HXX
//#include <svstdarr.hxx>
//#endif
#else
//#include <svmem.hxx>
#endif
#ifndef _SBERRORS_HXX
#include <sberrors.hxx>
#endif
class SbxArray;
class SbxVariable;
class ImplSbiDll;
class ImplSbiProc;
SV_DECL_PTRARR_SORT(ImplDllArr,ByteStringPtr,5,5)
class SbiDllMgr
{
ImplDllArr aDllArr;
SbiDllMgr( const SbiDllMgr& );
#ifdef _DLLMGR_CXX
ImplSbiDll* GetDll( const ByteString& rDllName );
SbiDllProc GetProc( ImplSbiDll*, const ByteString& rProcName );
SbiDllHandle CreateDllHandle( const ByteString& rDllName );
void FreeDllHandle( SbiDllHandle );
SbiDllProc GetProcAddr( SbiDllHandle, const ByteString& pProcName );
SbError CallProc( SbiDllProc pProc, SbxArray* pArgs,
SbxVariable& rResult );
SbError CallProcC( SbiDllProc pProc, SbxArray* pArgs,
SbxVariable& rResult );
void* CreateStack( SbxArray* pArgs, USHORT& rSize );
void CheckDllName( ByteString& rName );
#endif
public:
SbiDllMgr();
~SbiDllMgr();
SbError Call( const char* pFunc, const char* pDll,
SbxArray* pArgs, SbxVariable& rResult,
BOOL bCDecl );
void FreeDll( const ByteString& rDllName );
};
#endif
+247
View File
@@ -0,0 +1,247 @@
/*************************************************************************
*
* $RCSfile: inputbox.cxx,v $
*
* $Revision: 1.1.1.1 $
*
* last change: $Author: hr $ $Date: 2000-09-18 16:12:11 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library 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 for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef NOOLDSV //autogen
#include <vcl/system.hxx>
#endif
#ifndef _SV_BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#ifndef _SV_FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _SV_EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif
#ifndef _SV_DIALOG_HXX //autogen
#include <vcl/dialog.hxx>
#endif
#ifndef _SV_SVAPP_HXX
#include <vcl/svapp.hxx>
#endif
#include <svtools/sbx.hxx>
#include "runtime.hxx"
#pragma hdrstop
#include "stdobj.hxx"
#include "rtlproto.hxx"
#include "segmentc.hxx"
#pragma SW_SEGMENT_CLASS( SBRUNTIME, SBRUNTIME_CODE )
class SvRTLInputBox : public ModalDialog
{
Edit aEdit;
OKButton aOk;
CancelButton aCancel;
FixedText aPromptText;
String aText;
void PositionDialog( long nXTwips, long nYTwips, const Size& rDlgSize );
void InitButtons( const Size& rDlgSize );
void PositionEdit( const Size& rDlgSize );
void PositionPrompt( const String& rPrompt, const Size& rDlgSize );
DECL_LINK( OkHdl, Button * );
DECL_LINK( CancelHdl, Button * );
public:
SvRTLInputBox( Window* pParent, const String& rPrompt, const String& rTitle,
const String& rDefault, long nXTwips = -1, long nYTwips = -1 );
String GetText() const { return aText; }
};
SvRTLInputBox::SvRTLInputBox( Window* pParent, const String& rPrompt,
const String& rTitle, const String& rDefault,
long nXTwips, long nYTwips ) :
ModalDialog( pParent,WB_SVLOOK | WB_MOVEABLE | WB_CLOSEABLE ),
aEdit( this, WB_LEFT | WB_BORDER ),
aOk( this ), aCancel( this ), aPromptText( this, WB_WORDBREAK )
{
SetMapMode( MapMode( MAP_APPFONT ) );
Size aDlgSizeApp( 280, 80 );
PositionDialog( nXTwips, nYTwips, aDlgSizeApp );
InitButtons( aDlgSizeApp );
PositionEdit( aDlgSizeApp );
PositionPrompt( rPrompt, aDlgSizeApp );
aOk.Show();
aCancel.Show();
aEdit.Show();
aPromptText.Show();
SetText( rTitle );
Font aFont( GetFont());
Color aColor( GetBackgroundBrush().GetFillColor());
aFont.SetFillColor( aColor );
aEdit.SetFont( aFont );
aEdit.SetText( rDefault );
aEdit.SetSelection( Selection( SELECTION_MIN, SELECTION_MAX ) );
}
void SvRTLInputBox::InitButtons( const Size& rDlgSize )
{
aOk.SetSizePixel( LogicToPixel( Size( 45, 15) ));
aCancel.SetSizePixel( LogicToPixel( Size( 45, 15) ));
Point aPos( rDlgSize.Width()-45-10, 5 );
aOk.SetPosPixel( LogicToPixel( Point(aPos) ));
aPos.Y() += 16;
aCancel.SetPosPixel( LogicToPixel( Point(aPos) ));
aOk.SetClickHdl(LINK(this,SvRTLInputBox, OkHdl));
aCancel.SetClickHdl(LINK(this,SvRTLInputBox,CancelHdl));
}
void SvRTLInputBox::PositionDialog(long nXTwips, long nYTwips, const Size& rDlgSize)
{
Size aScreenSzApp(Window::GetOutputSizePixel());
aScreenSzApp = PixelToLogic( aScreenSzApp );
Point aDlgPosApp( nXTwips, nYTwips );
aDlgPosApp = LogicToPixel( aDlgPosApp, MAP_TWIP );
aDlgPosApp = PixelToLogic( aDlgPosApp );
if ( nXTwips == -1 || nYTwips == -1 ||
aDlgPosApp.X() >= aScreenSzApp.Width() ||
aDlgPosApp.Y() >= aScreenSzApp.Height() )
{
aDlgPosApp.X() = ( aScreenSzApp.Width() - rDlgSize.Width() ) / 2;
aDlgPosApp.Y() = ( aScreenSzApp.Height() - rDlgSize.Height() ) / 2;
}
SetSizePixel( LogicToPixel(rDlgSize) );
SetPosPixel( LogicToPixel(aDlgPosApp) );
}
void SvRTLInputBox::PositionEdit( const Size& rDlgSize )
{
aEdit.SetPosPixel( LogicToPixel( Point( 5,rDlgSize.Height()-35)));
aEdit.SetSizePixel( LogicToPixel( Size(rDlgSize.Width()-15,12)));
}
void SvRTLInputBox::PositionPrompt(const String& rPrompt,const Size& rDlgSize)
{
if ( rPrompt.Len() == 0 )
return;
String aText( rPrompt );
aText.ConvertLineEnd( LINEEND_CR );
aPromptText.SetPosPixel( LogicToPixel(Point(5,5)));
aPromptText.SetText( aText );
Size aSize( rDlgSize );
aSize.Width() -= 70;
aSize.Height() -= 50;
aPromptText.SetSizePixel( LogicToPixel(aSize));
}
IMPL_LINK_INLINE_START( SvRTLInputBox, OkHdl, Button *, pButton )
{
aText = aEdit.GetText();
EndDialog( 1 );
return 0;
}
IMPL_LINK_INLINE_END( SvRTLInputBox, OkHdl, Button *, pButton )
IMPL_LINK_INLINE_START( SvRTLInputBox, CancelHdl, Button *, pButton )
{
aText.Erase();
EndDialog( 0 );
return 0;
}
IMPL_LINK_INLINE_END( SvRTLInputBox, CancelHdl, Button *, pButton )
// *********************************************************************
// *********************************************************************
// *********************************************************************
// Syntax: String InputBox( Prompt, [Title], [Default] [, nXpos, nYpos ] )
RTLFUNC(InputBox)
{
ULONG nArgCount = rPar.Count();
if ( nArgCount < 2 )
StarBASIC::Error( SbERR_BAD_ARGUMENT );
else
{
String aTitle;
String aDefault;
INT32 nX = -1, nY = -1; // zentrieren
const String& rPrompt = rPar.Get(1)->GetString();
if ( nArgCount > 2 )
aTitle = rPar.Get(2)->GetString();
if ( nArgCount > 3 )
aDefault = rPar.Get(3)->GetString();
if ( nArgCount > 4 )
{
if ( nArgCount != 6 )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
return;
}
nX = rPar.Get(4)->GetLong();
nY = rPar.Get(5)->GetLong();
}
SvRTLInputBox *pDlg=new SvRTLInputBox(GetpApp()->GetDefModalDialogParent(),
rPrompt,aTitle,aDefault,nX,nY);
pDlg->Execute();
rPar.Get(0)->PutString( pDlg->GetText() );
delete pDlg;
}
}

Some files were not shown because too many files have changed in this diff Show More