diff options
Diffstat (limited to 'rsc/source')
47 files changed, 0 insertions, 23757 deletions
diff --git a/rsc/source/misc/makefile.mk b/rsc/source/misc/makefile.mk deleted file mode 100644 index 02e6a2f887..0000000000 --- a/rsc/source/misc/makefile.mk +++ /dev/null @@ -1,52 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=rsc -TARGET=rscmis - -# --- Settings ------------------------------------------------------ - -ENABLE_EXCEPTIONS=true - -.INCLUDE : settings.mk - -.IF "$(BUILD_TYPE)"=="$(BUILD_TYPE:s/DESKTOP//)" -ALL: - @echo No need for this on non-desktop OSes -.ENDIF - -# --- Files --------------------------------------------------------- - -CXXFILES= rsclst.cxx \ - rscdbl.cxx - -OBJFILES= $(OBJ)$/rsclst.obj \ - $(OBJ)$/rscdbl.obj - -.INCLUDE : target.mk diff --git a/rsc/source/misc/rscdbl.cxx b/rsc/source/misc/rscdbl.cxx deleted file mode 100644 index 80bd241785..0000000000 --- a/rsc/source/misc/rscdbl.cxx +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" - -#include <stdio.h> -#include <rscdb.hxx> -#include <rscall.h> -#include <rschash.hxx> -#include <rsctree.hxx> -#include <rsctop.hxx> -#include "rsclst.hxx" - -REResourceList * InsertList( Atom nClassName, const RscId& rId, - REResourceList * pList ) { - REResourceList * pSubList; - const char * pStrClass; - ByteString aStrClass; - - pStrClass = pHS->getString( nClassName ).getStr(); - if( pStrClass ) - aStrClass = pStrClass; - else - aStrClass = rtl::OString::valueOf(static_cast<sal_Int32>(nClassName)); - - pSubList = new REResourceList( pList, aStrClass, rId ); - - return pSubList; -} - -void FillSubList( RSCINST & rInst, REResourceList * pList ) -{ - sal_uInt32 nCount, i; - SUBINFO_STRUCT aInfo; - REResourceList* pSubList; - RSCINST aTmpI; - - nCount = rInst.pClass->GetCount( rInst ); - for( i = 0; i < nCount; i++ ){ - aInfo = rInst.pClass->GetInfoEle( rInst, i ); - aTmpI = rInst.pClass->GetPosEle( rInst, i ); - pSubList = InsertList( aInfo.pClass->GetId(), - aInfo.aId, pList ); - FillSubList( aTmpI, pSubList ); - }; -} - -void FillListObj( ObjNode * pObjNode, RscTop * pRscTop, - REResourceList * pList, sal_uLong lFileKey ) -{ - if( pObjNode ){ - if( pObjNode->GetFileKey() == lFileKey ){ - RSCINST aTmpI; - REResourceList* pSubList; - - FillListObj( (ObjNode*)pObjNode->Left(), pRscTop, - pList, lFileKey ); - - pSubList = InsertList( pRscTop->GetId(), - pObjNode->GetRscId(), pList ); - - aTmpI.pClass = pRscTop; - aTmpI.pData = pObjNode->GetRscObj(); - FillSubList( aTmpI, pSubList ); - - FillListObj( (ObjNode*)pObjNode->Right(), pRscTop, - pList, lFileKey ); - } - }; -} - -void FillList( RscTop * pRscTop, REResourceList * pList, sal_uLong lFileKey ){ - if( pRscTop ){ - FillList( (RscTop*)pRscTop->Left(), pList, lFileKey ); - - FillListObj( pRscTop->GetObjNode(), pRscTop, pList, lFileKey ); - - FillList( (RscTop*)pRscTop->Right(), pList, lFileKey ); - }; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/misc/rsclst.cxx b/rsc/source/misc/rsclst.cxx deleted file mode 100644 index a137ad304d..0000000000 --- a/rsc/source/misc/rsclst.cxx +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" - -#include "rsclst.hxx" - -REResourceList :: REResourceList() -{ - bVisible = sal_False; - pParent = NULL; -} - -REResourceList :: REResourceList( REResourceList* pParentList, - ByteString& rClassName, - const RscId & rResourceID, sal_Bool bVis ) -{ - pParent = pParentList; - aClassName = rClassName; - aRscId = rResourceID; - bVisible = bVis; -} - -REResourceList :: ~REResourceList() -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/erscerr.cxx b/rsc/source/parser/erscerr.cxx deleted file mode 100644 index 8746990fcd..0000000000 --- a/rsc/source/parser/erscerr.cxx +++ /dev/null @@ -1,476 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -#include <stdlib.h> -#include <stdio.h> - -#include <tools/rcid.h> -#include <rschash.hxx> -#include <rscerror.h> -#include <rscall.h> -#include <rscdb.hxx> -#include <rscpar.hxx> - -#include "rsclex.hxx" - -/************************************************************************* -|* -|* ERRTYPE::operator = ; -|* -*************************************************************************/ -ERRTYPE& ERRTYPE::operator = ( const ERRTYPE & rError ) -{ - if( !IsError() ){ - if( rError.IsError() || !IsWarning() ) - nError = rError.nError; - } - return *this; -} - -/************************************************************************* -|* -|* RscError::StdOut(); -|* -*************************************************************************/ -void RscError::StdOut( const char * pStr, const RscVerbosity _verbosityLevel ) -{ - if ( m_verbosity >= _verbosityLevel ) - { - if( pStr ){ - printf( "%s", pStr ); - fflush( stdout ); - } - } -} - -/************************************************************************* -|* -|* RscError::StdErr(); -|* -*************************************************************************/ -void RscError::StdErr( const char * pStr ) -{ - if( pStr ) - fprintf( stderr, "%s", pStr ); -} - -/************************************************************************* -|* -|* RscError::LstOut(); -|* -*************************************************************************/ -void RscError::LstOut( const char * pStr ){ - if( fListing && pStr ) - fprintf( fListing, "%s", pStr ); -} - -/************************************************************************* -|* -|* RscError::StdLstOut(); -|* -*************************************************************************/ -void RscError::StdLstOut( const char * pStr ){ - StdOut( pStr ); - LstOut( pStr ); -} - -/************************************************************************* -|* -|* RscError::StdLstErr(); -|* -*************************************************************************/ -void RscError::StdLstErr( const char * pStr ){ - StdErr( pStr ); - LstOut( pStr ); -} - -/************************************************************************* -|* -|* RscError::WriteError(); -|* -*************************************************************************/ -void RscError::WriteError( const ERRTYPE& rError, const char * pMessage ) -{ - switch( rError ) - { - case ERR_ERROR: { - StdLstErr( "!! " ); - if( 1 == nErrors ) - StdLstErr(rtl::OString::valueOf(static_cast<sal_Int32>(nErrors )).getStr()); - else - StdLstErr(rtl::OString::valueOf(static_cast<sal_Int32>(nErrors -1)).getStr()); - StdLstErr( " Error" ); - StdLstErr( " found!!" ); - } - break; - - case ERR_UNKNOWN_METHOD: - StdLstErr( "The used type is not allowed." ); - break; - - case ERR_OPENFILE: - StdLstErr( "This file <" ); - StdLstErr( pMessage ); - StdLstErr( "> cannot be opened." ); - break; - - case ERR_RENAMEFILE: - StdLstErr( "rename <" ); - StdLstErr( pMessage ); - StdLstErr( "> s not possible." ); - break; - - case ERR_FILESIZE: - StdLstErr( "Wrong file <" ); - StdLstErr( pMessage ); - StdLstErr( "> length." ); - break; - - case ERR_FILEFORMAT: - StdLstErr( "Wrong file type <" ); - StdLstErr( pMessage ); - StdLstErr( ">." ); - break; - - case ERR_NOCHAR: - StdLstErr( "Character: '\\xxx'; The value xxx is greater than 255."); - break; - - case ERR_NORSCINST: - StdLstErr( "Internal error, instance invalid."); - break; - - - case ERR_NOINPUT: - StdLstErr( "Input file was not specified.\n"); - case ERR_USAGE: - StdLstOut( "Copyright (C) 2000, 2010 Oracle and/or its affiliates.\n" ); - { - char buf[40]; - - StdLstOut( "DataVersion: " ); - sprintf( buf, "%d.%d\n\n", - RSCVERSION_ID / 100, RSCVERSION_ID % 100 ); - StdLstOut( buf ); - }; - - StdLstOut( "Command line: rsc [Switches] <Source File(s)>\n" ); - StdLstOut( "Command line: rsc @<Command File>\n" ); - StdLstOut( "-h shows this help.\n" ); - StdLstOut( "-p No Preprocessor.\n" ); - StdLstOut( "-s Syntax analysis, creates .srs file\n"); - StdLstOut( "-l Linker, links files created with rsc -s,\n" ); - StdLstOut( " creates .rc file and .res file.\n" ); - StdLstOut( "-r Prevents .res file.\n" ); - StdLstOut( "-d Symbol definitions for the Preprocessor.\n" ); - StdLstOut( "-i Include directives for the Preprocessor.\n" ); - StdLstOut( "-presponse Use response file for Preprocessor.\n" ); - StdLstOut( "-lg<language> Use a different language.\n" ); - StdLstOut( "-pp=<filename> Use a different Preprocessor.\n" ); - StdLstOut( "-rsc2=<filename> Specify the location for rsc2.\n" ); - StdLstOut( "No longer existent: -rc<filename> Use a different system resource compiler.\n" ); - StdLstOut( "-fs=<filename> Name of the .res file.\n" ); - StdLstOut( "-lip=<path> additional search path for system dependant files\n" ); - StdLstOut( "-fp=<filename> Renaming of the .srs file.\n" ); - StdLstOut( "-fl=<filename> Listing file.\n" ); - StdLstOut( "-fh=<filename> Header file.\n" ); - StdLstOut( "-fc=<filename> Code file.\n" ); - StdLstOut( "-ft=<filename> Touch a file when done in rsc2 (for dependencies)\n" ); - StdLstOut( "-fr=<filename> Ressource constructor .cxx-file.\n" ); - StdLstOut( "-fx=<filename> Name of .src-file.\n" ); - StdLstOut( "-oil=<dir> Output directory for image list files\n" ); - StdLstOut( "-r<ENV>=<path> replace <path> by <ENV> in image list files\n" ); - StdLstOut( "-CHARSET_... Convert to this character set.\n" ); - StdLstOut( "-BIGENDIAN Format of number values.\n" ); - StdLstOut( "-LITTLEENDIAN Format of number values.\n" ); - StdLstOut( "-SMART Generate smart names (cxx, hxx).\n" ); - StdLstOut( "-SrsDefault Only write one language to srs file.\n" ); - StdLstOut( "\nwhen creating multiple .res files in one pass, please give these\n" ); - StdLstOut( "options in consecutive blocks:\n" ); - StdLstOut( "-lg<language> -fs<filename> [-lip<path> [-lip<path>] ]\n" ); - StdLstOut( "a new block begins when either -lg or -fs is used again.\n" ); - break; - - case ERR_UNKNOWNSW: - StdLstErr( "Unknown switch <" ); - StdLstErr( pMessage ); - StdLstErr( ">." ); - break; - - case ERR_REFTODEEP: - StdLstErr( "Too many reference levels have been used (see Switch -RefDeep)." ); - break; - - case ERR_CONT_INVALIDPOS: - StdLstErr( "Internal error, Container class: invalid position." ); - break; - - case ERR_CONT_INVALIDTYPE: - StdLstErr( "Invalid type <" ); - StdLstErr( pMessage ); - StdLstErr( ">." ); - break; - - case ERR_ARRAY_INVALIDINDEX: - StdLstErr( "Internal error, Array class: invalid index." ); - break; - - case ERR_RSCINST_NOVARNAME: - StdLstErr( "Internal error, invalid name of variable." ); - break; - - case ERR_YACC: - StdLstErr( pMessage ); - break; - - case ERR_DOUBLEID: - StdLstErr( "Two global resources have the same identifier." ); - break; - - case ERR_FALSETYPE: - StdLstErr( "Wrong type <" ); - StdLstErr( pMessage ); - StdLstErr( ">." ); - break; - - case ERR_NOVARIABLENAME: - StdLstErr( "The variable <" ); - StdLstErr( pMessage ); - StdLstErr( "> must not be used here." ); - break; - - case ERR_RSCRANGE_OUTDEFSET: - StdLstErr( "The used value is not in the expected domain." ); - break; - - case ERR_USHORTRANGE: - StdLstErr( "Value is <" ); - StdLstErr( pMessage ); - StdLstErr( "> the allowed domain is from 0 up to 65535." ); - break; - - case ERR_IDRANGE: - StdLstErr( "Value is <" ); - StdLstErr( pMessage ); - StdLstErr( "> the allowed domain is from 1 up to 32767." ); - break; - - case ERR_NOCOPYOBJ: - StdLstErr( "Default resource <" ); - StdLstErr( pMessage ); - StdLstErr( "> not found." ); - break; - - case ERR_REFNOTALLOWED: - StdLstErr( "The use of a reference is not allowed." ); - break; - - case ERR_COPYNOTALLOWED: - StdLstErr( "The use of a default resource is not allowed." ); - break; - - case ERR_IDEXPECTED: - StdLstErr( "An identifier needs to be specified." ); - break; - - case ERR_DOUBLEDEFINE: - StdLstErr( "The symbol <" ); - StdLstErr( pMessage ); - StdLstErr( "> is defined twice." ); - break; - - case ERR_RSCINST_RESERVEDNAME: - StdLstErr( "The symbol <" ); - StdLstErr( pMessage ); - StdLstErr( "> is a reserved name." ); - break; - - case ERR_ZERODIVISION: - StdLstErr( "Attempt to divide by zero." ); - break; - - case ERR_PRAGMA: - StdLstErr( "Error in a #pragma statement." ); - break; - - case ERR_DECLAREDEFINE: - StdLstErr( "Error in the declaration part of the macro." ); - break; - - case ERR_NOTYPE: - StdLstErr( "type expected." ); - break; - - case ERR_NOIMAGE: - StdLstErr( "The image(s) <" ); - StdLstErr( pMessage ); - StdLstErr( "> could not be found." ); - break; - -/****************** W A R N I N G S **************************************/ - case WRN_LOCALID: - StdLstErr( "Sub resources should have an identifier < 256." ); - break; - - case WRN_GLOBALID: - StdLstErr( "Global resources should have an identifier >= 256." ); - break; - - case WRN_SUBINMEMBER: - StdLstErr( "Sub resources are ignored." ); - break; - - case WRN_CONT_NOID: - StdLstErr( "Resources without name are ignored." ); - break; - - case WRN_CONT_DOUBLEID: - StdLstErr( "Two local resources have the same identifier." ); - break; - - case WRN_STR_REFNOTFOUND: - StdLstErr( "String reference <" ); - StdLstErr( pMessage ); - StdLstErr( " > could not be resolved." ); - break; - - case WRN_MGR_REFNOTFOUND: - StdLstErr( "Reference <" ); - StdLstErr( pMessage ); - StdLstErr( " > could not be resolved." ); - break; - - default: - if( pMessage ){ - StdLstErr( "\nMessage: " ); - StdLstErr( pMessage ); - }; - break; - } -} - -/************************************************************************* -|* -|* RscErrorFormat() -|* -*************************************************************************/ -void RscError::ErrorFormat( const ERRTYPE& rError, RscTop * pClass, - const RscId & aId ){ - char buf[ 10 ]; - sal_uInt32 i; - - if( pFI ) - { - pFI->SetError( rError ); - StdErr( "\n" ); - StdErr( pFI->GetLine() ); - StdErr( "\n" ); - // Fehlerposition anzeigen - for( i = 0; (i +1) < pFI->GetScanPos(); i++ ) - StdLstErr( " " ); - LstOut( " ^" ); //Zeilennummern beachten - StdErr( "^" ); - StdLstErr( "\n" ); - } - StdLstErr( "f" ); - sprintf( buf, "%u", (unsigned int)rError ); - StdLstErr( buf ); - - if( pFI && pTC ){ - StdLstErr( ": \"" ); - StdLstErr( pTC->aFileTab.Get( pFI->GetFileIndex() )->aFileName.GetBuffer() ); - StdLstErr( "\", line " ); - sprintf( buf, "%u", (unsigned int)pFI->GetLineNo() ); - StdLstErr( buf ); - } - - if( rError.IsError() ) - StdLstErr( ": Error" ); - else - StdLstErr( ": Warning" ); - - if( pClass || aId.IsId() ) - { - StdLstErr( " in the object (" ); - if( pClass ) - { - StdLstErr( "Type: " ); - StdLstErr( pHS->getString( pClass->GetId() ).getStr() ); - if( aId.IsId() ) - StdLstErr( ", " ); - } - if( aId.IsId() ) - StdLstErr( aId.GetName().GetBuffer() ); - StdLstErr( "):\n" ); - } - else - StdLstErr( ": " ); -} - -/************************************************************************* -|* -|* RscError::Error() -|* -*************************************************************************/ -void RscError::Error( const ERRTYPE& rError, RscTop * pClass, - const RscId & aId, const char * pMessage ) -{ - if( WRN_LOCALID == rError ) // Keine Warning erzeugen - return; - if( rError.IsError() ) - nErrors++; - if( rError.IsError() || rError.IsWarning() ){ - ErrorFormat( rError, pClass, aId ); - WriteError( rError, pMessage ); - StdLstErr( "\n" ); - }; -} - -/************************************************************************* -|* -|* RscError::FatalError(); -|* -*************************************************************************/ -void RscError::FatalError( const ERRTYPE& rError, const RscId &aId, - const char * pMessage ) -{ - if( ERR_USAGE != rError ){ - nErrors++; - ErrorFormat( rError, NULL, aId ); - WriteError( rError, pMessage ); - StdLstErr( "\nTerminating compiler\n" ); - } - else - WriteError( rError, pMessage ); - - exit( 1 ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/makefile.mk b/rsc/source/parser/makefile.mk deleted file mode 100644 index b128bbfd94..0000000000 --- a/rsc/source/parser/makefile.mk +++ /dev/null @@ -1,72 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PROJECTPCH=parser -PROJECTPCHSOURCE=parser -PRJNAME=rsc -TARGET=rscpar - -# --- Settings ----------------------------------------------------- - -#prjpch=T - -ENABLE_EXCEPTIONS=true - -.INCLUDE : settings.mk - -.IF "$(BUILD_TYPE)"=="$(BUILD_TYPE:s/DESKTOP//)" -ALL: - @echo No need for this on non-desktop OSes -.ENDIF - -# --- Files -------------------------------------------------------- - -YACCTARGET= $(INCCOM)$/yyrscyacc.cxx -YACCFILES= rscyacc.y - -OBJFILES= $(OBJ)$/rscpar.obj \ - $(OBJ)$/rscyacc.obj \ - $(OBJ)$/rsclex.obj \ - $(OBJ)$/erscerr.obj \ - $(OBJ)$/rsckey.obj \ - $(OBJ)$/rscinit.obj \ - $(OBJ)$/rscibas.obj \ - $(OBJ)$/rscdb.obj \ - $(OBJ)$/rscicpx.obj - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk - -$(OBJ)$/rscibas.obj : $(YACCTARGET) -$(OBJ)$/rscinit.obj : $(YACCTARGET) -$(OBJ)$/rscicpx.obj : $(YACCTARGET) -$(OBJ)$/rsclex.obj : $(YACCTARGET) -$(OBJ)$/rscyacc.obj : $(YACCTARGET) - diff --git a/rsc/source/parser/rscdb.cxx b/rsc/source/parser/rscdb.cxx deleted file mode 100644 index 967de8134f..0000000000 --- a/rsc/source/parser/rscdb.cxx +++ /dev/null @@ -1,975 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ -// C and C++ Includes. -#include <ctype.h> // isdigit(), isalpha() -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include <tools/fsys.hxx> -#include <tools/rc.h> -#include <tools/isofallback.hxx> -#include <rtl/strbuf.hxx> -#include <sal/macros.h> - -// Programmabhaengige Includes. -#include <rsctree.hxx> -#include <rsctop.hxx> -#include <rscmgr.hxx> -#include <rscdb.hxx> -#include <rscrsc.hxx> - -using ::rtl::OString; -using ::rtl::OStringBuffer; - -/************************************************************************* -|* -|* RscTypCont :: RscTypCont -|* -*************************************************************************/ -RscTypCont :: RscTypCont( RscError * pErrHdl, - RSCBYTEORDER_TYPE nOrder, - const ByteString & rSearchPath, - sal_uInt32 nFlagsP ) - : - nSourceCharSet( RTL_TEXTENCODING_UTF8 ), - nByteOrder( nOrder ), - aSearchPath( rSearchPath ), - aBool( pHS->getID( "sal_Bool" ), RSC_NOTYPE ), - aShort( pHS->getID( "short" ), RSC_NOTYPE ), - aUShort( pHS->getID( "sal_uInt16" ), RSC_NOTYPE ), - aLong( pHS->getID( "long" ), RSC_NOTYPE ), - aEnumLong( pHS->getID( "enum_long" ), RSC_NOTYPE ), - aIdUShort( pHS->getID( "IDUSHORT" ), RSC_NOTYPE ), - aIdNoZeroUShort( pHS->getID( "IDUSHORT" ), RSC_NOTYPE ), - aNoZeroShort( pHS->getID( "NoZeroShort" ), RSC_NOTYPE ), - a1to12Short( pHS->getID( "MonthShort" ), RSC_NOTYPE ), - a0to23Short( pHS->getID( "HourShort" ), RSC_NOTYPE ), - a1to31Short( pHS->getID( "DayShort" ), RSC_NOTYPE ), - a0to59Short( pHS->getID( "MinuteShort" ), RSC_NOTYPE ), - a0to99Short( pHS->getID( "_0to59Short" ), RSC_NOTYPE ), - a0to9999Short( pHS->getID( "YearShort" ), RSC_NOTYPE ), - aIdLong( pHS->getID( "IDLONG" ), RSC_NOTYPE ), - aString( pHS->getID( "Chars" ), RSC_NOTYPE ), - aStringLiteral( pHS->getID( "Chars" ), RSC_NOTYPE ), - aWinBits( pHS->getID( "WinBits" ), RSC_NOTYPE ), - aLangType(), - aLangString( pHS->getID( "Lang_Chars" ), RSC_NOTYPE, &aString, &aLangType ), - aLangShort( pHS->getID( "Lang_short" ), RSC_NOTYPE, &aShort, &aLangType ), - nAcceleratorType( 0 ), - nFlags( nFlagsP ) -{ - nUniqueId = 256; - nPMId = RSC_VERSIONCONTROL +1; //mindestens einen groesser - pEH = pErrHdl; - Init(); -} - -static sal_uInt32 getLangIdAndShortenLocale( RscTypCont* pTypCont, - rtl::OString& rLang, - rtl::OString& rCountry, - rtl::OString& rVariant ) -{ - rtl::OStringBuffer aLangStr( 64 ); - aLangStr.append( rLang.toAsciiLowerCase() ); - if( rCountry.getLength() ) - { - aLangStr.append( '-' ); - aLangStr.append( rCountry.toAsciiUpperCase() ); - } - if( rVariant.getLength() ) - { - aLangStr.append( '-' ); - aLangStr.append( rVariant ); - } - rtl::OString aL( aLangStr.makeStringAndClear() ); - sal_uInt32 nRet = GetLangId( aL ); - if( nRet == 0 ) - { - pTypCont->AddLanguage( aL ); - nRet = GetLangId( aL ); - } - if( rVariant.getLength() ) - rVariant = rtl::OString(); - else if( rCountry.getLength() ) - rCountry = rtl::OString(); - else - rLang = rtl::OString(); -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, " %s (0x%hx)", aL.getStr(), (int)nRet ); -#endif - return nRet; -} - -ByteString RscTypCont::ChangeLanguage( const ByteString& rNewLang ) -{ - ByteString aRet = aLanguage; - aLanguage = rNewLang; - - rtl::OString aLang = aLanguage; - rtl::OString aLg, aCountry, aVariant; - sal_Int32 nIndex = 0; - aLg = aLang.getToken( 0, '-', nIndex ); - if( nIndex != -1 ) - aCountry = aLang.getToken( 0, '-', nIndex ); - if( nIndex != -1 ) - aVariant = aLang.copy( nIndex ); - - bool bAppendEnUsFallback = - ! (rNewLang.EqualsIgnoreCaseAscii( "en-US" ) || - rNewLang.EqualsIgnoreCaseAscii( "x-no-translate" ) ); - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "RscTypCont::ChangeLanguage:" ); -#endif - aLangFallbacks.clear(); - - do - { - aLangFallbacks.push_back(getLangIdAndShortenLocale( this, aLg, aCountry, aVariant ) ); - } while( aLg.getLength() ); - - if( bAppendEnUsFallback ) - { - aLg = "en"; - aCountry = "US"; - aVariant = rtl::OString(); - aLangFallbacks.push_back( getLangIdAndShortenLocale( this, aLg, aCountry, aVariant ) ); - } - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "\n" ); -#endif - - return aRet; -} - -Atom RscTypCont::AddLanguage( const char* pLang ) -{ - return aLangType.AddLanguage( pLang, aNmTb ); -} - - -/************************************************************************* -|* -|* RscTypCont :: ~RscTypCont -|* -*************************************************************************/ -void DestroyNode( RscTop * pRscTop, ObjNode * pObjNode ){ - if( pObjNode ){ - DestroyNode( pRscTop, (ObjNode*)pObjNode->Left() ); - DestroyNode( pRscTop, (ObjNode*)pObjNode->Right() ); - - if( pObjNode->GetRscObj() ){ - pRscTop->Destroy( RSCINST( pRscTop, pObjNode->GetRscObj() ) ); - rtl_freeMemory( pObjNode->GetRscObj() ); - } - delete pObjNode; - }; -} - -void DestroySubTrees( RscTop * pRscTop ){ - if( pRscTop ){ - DestroySubTrees( (RscTop*)pRscTop->Left() ); - - DestroyNode( pRscTop, pRscTop->GetObjNode() ); - - DestroySubTrees( (RscTop*)pRscTop->Right() ); - }; -} - -void DestroyTree( RscTop * pRscTop ){ - if( pRscTop ){ - DestroyTree( (RscTop*)pRscTop->Left() ); - DestroyTree( (RscTop*)pRscTop->Right() ); - - delete pRscTop; - }; -} - -void Pre_dtorTree( RscTop * pRscTop ){ - if( pRscTop ){ - Pre_dtorTree( (RscTop*)pRscTop->Left() ); - Pre_dtorTree( (RscTop*)pRscTop->Right() ); - - pRscTop->Pre_dtor(); - }; -} - -RscTypCont :: ~RscTypCont(){ - // Alle Unterbaeume loeschen - aVersion.pClass->Destroy( aVersion ); - rtl_freeMemory( aVersion.pData ); - DestroySubTrees( pRoot ); - - // Alle Klassen noch gueltig, jeweilige Instanzen freigeben - // BasisTypen - for ( size_t i = 0, n = aBaseLst.size(); i < n; ++i ) - aBaseLst[ i ]->Pre_dtor(); - aBool.Pre_dtor(); - aShort.Pre_dtor(); - aUShort.Pre_dtor(); - aIdUShort.Pre_dtor(); - aIdNoZeroUShort.Pre_dtor(); - aNoZeroShort.Pre_dtor(); - aIdLong.Pre_dtor(); - aString.Pre_dtor(); - aWinBits.Pre_dtor(); - aVersion.pClass->Pre_dtor(); - // Zusammengesetzte Typen - Pre_dtorTree( pRoot ); - - // Klassen zerstoeren - delete aVersion.pClass; - DestroyTree( pRoot ); - - for ( size_t i = 0, n = aBaseLst.size(); i < n; ++i ) - delete aBaseLst[ i ]; - aBaseLst.clear(); - - for ( size_t i = 0, n = aSysLst.size(); i < n; ++i ) - delete aSysLst[ i ]; - aSysLst.clear(); -} - -void RscTypCont::ClearSysNames() -{ - for ( size_t i = 0, n = aSysLst.size(); i < n; ++i ) - delete aSysLst[ i ]; - aSysLst.clear(); -} - -//======================================================================= -RscTop * RscTypCont::SearchType( Atom nId ) -/* [Beschreibung] - - Sucht eine Basistyp nId; -*/ -{ - if( nId == InvalidAtom ) - return NULL; - -#define ELSE_IF( a ) \ - else if( a.GetId() == nId ) \ - return &a; \ - - if( aBool.GetId() == nId ) - return &aBool; - ELSE_IF( aShort ) - ELSE_IF( aUShort ) - ELSE_IF( aLong ) - ELSE_IF( aEnumLong ) - ELSE_IF( aIdUShort ) - ELSE_IF( aIdNoZeroUShort ) - ELSE_IF( aNoZeroShort ) - ELSE_IF( a1to12Short ) - ELSE_IF( a0to23Short ) - ELSE_IF( a1to31Short ) - ELSE_IF( a0to59Short ) - ELSE_IF( a0to99Short ) - ELSE_IF( a0to9999Short ) - ELSE_IF( aIdLong ) - ELSE_IF( aString ) - ELSE_IF( aWinBits ) - ELSE_IF( aLangType ) - ELSE_IF( aLangString ) - ELSE_IF( aLangShort ) - - for ( size_t i = 0, n = aBaseLst.size(); i < n; ++i ) - { - RscTop* pEle = aBaseLst[ i ]; - if( pEle->GetId() == nId ) - return pEle; - } - return NULL; -} - -/************************************************************************* -|* -|* RscTypCont :: PutSysName() -|* -*************************************************************************/ -sal_uInt32 RscTypCont :: PutSysName( sal_uInt32 nRscTyp, char * pFileName, - sal_uInt32 nConst, sal_uInt32 nId, sal_Bool bFirst ) -{ - RscSysEntry *pSysEntry; - RscSysEntry *pFoundEntry = NULL; - sal_Bool bId1 = sal_False; - - for ( size_t i = 0, n = aSysLst.size(); i < n; ++i ) - { - pSysEntry = aSysLst[ i ]; - if( pSysEntry->nKey == 1 ) - bId1 = sal_True; - if( !strcmp( pSysEntry->aFileName.GetBuffer(), pFileName ) ) - if( pSysEntry->nRscTyp == nRscTyp - && pSysEntry->nTyp == nConst - && pSysEntry->nRefId == nId - ) { - pFoundEntry = pSysEntry; - break; - } - } - pSysEntry = pFoundEntry; - - if ( !pSysEntry || (bFirst && !bId1) ) - { - pSysEntry = new RscSysEntry; - pSysEntry->nKey = nUniqueId++; - pSysEntry->nRscTyp = nRscTyp; - pSysEntry->nTyp = nConst; - pSysEntry->nRefId = nId; - pSysEntry->aFileName = (const char*)pFileName; - if( bFirst && !bId1 ) - { - pSysEntry->nKey = 1; - aSysLst.insert( aSysLst.begin(), pSysEntry ); - } - else - aSysLst.push_back( pSysEntry ); - } - - return pSysEntry->nKey; -} - -/************************************************************************* -|* -|* RscTypCont :: WriteInc -|* -*************************************************************************/ -void RscTypCont :: WriteInc( FILE * fOutput, sal_uLong lFileKey ) -{ - RscFile * pFName; - - if( NOFILE_INDEX == lFileKey ) - { - pFName = aFileTab.First(); - while( pFName ) - { - if( pFName && pFName->IsIncFile() ) - { - fprintf( fOutput, "#include " ); - fprintf( fOutput, "\"%s\"\n", - pFName->aFileName.GetBuffer() ); - } - pFName = aFileTab.Next(); - } - } - else - { - RscDepend * pDep; - RscFile * pFile; - - pFName = aFileTab.Get( lFileKey ); - if( pFName ) - { - for ( size_t i = 0, n = pFName->aDepLst.size(); i < n; ++i ) - { - pDep = pFName->aDepLst[ i ]; - if( pDep->GetFileKey() != lFileKey ) - { - pFile = aFileTab.GetFile( pDep->GetFileKey() ); - if( pFile ) - { - fprintf( fOutput, "#include " ); - fprintf( fOutput, "\"%s\"\n", - pFile->aFileName.GetBuffer() ); - } - } - }; - }; - }; -} - -/************************************************************************* -|* -|* RscTypCont :: Methoden die ueber all Knoten laufen -|* -*************************************************************************/ - -class RscEnumerateObj -{ -friend class RscEnumerateRef; -private: - ERRTYPE aError; // Enthaelt den ersten Fehler - RscTypCont* pTypCont; - FILE * fOutput; // AusgabeDatei - sal_uLong lFileKey; // Welche src-Datei - RscTop * pClass; - - DECL_LINK( CallBackWriteRc, ObjNode * ); - DECL_LINK( CallBackWriteSrc, ObjNode * ); - DECL_LINK( CallBackWriteCxx, ObjNode * ); - DECL_LINK( CallBackWriteHxx, ObjNode * ); - - ERRTYPE WriteRc( RscTop * pCl, ObjNode * pRoot ) - { - pClass = pCl; - if( pRoot ) - pRoot->EnumNodes( LINK( this, RscEnumerateObj, CallBackWriteRc ) ); - return aError; - } - ERRTYPE WriteSrc( RscTop * pCl, ObjNode * pRoot ){ - pClass = pCl; - if( pRoot ) - pRoot->EnumNodes( LINK( this, RscEnumerateObj, CallBackWriteSrc ) ); - return aError; - } - ERRTYPE WriteCxx( RscTop * pCl, ObjNode * pRoot ){ - pClass = pCl; - if( pRoot ) - pRoot->EnumNodes( LINK( this, RscEnumerateObj, CallBackWriteCxx ) ); - return aError; - } - ERRTYPE WriteHxx( RscTop * pCl, ObjNode * pRoot ){ - pClass = pCl; - if( pRoot ) - pRoot->EnumNodes( LINK( this, RscEnumerateObj, CallBackWriteHxx ) ); - return aError; - } -public: - void WriteRcFile( RscWriteRc & rMem, FILE * fOutput ); -}; - -/************************************************************************* -|* -|* RscEnumerateObj :: CallBackWriteRc -|* -*************************************************************************/ -IMPL_LINK( RscEnumerateObj, CallBackWriteRc, ObjNode *, pObjNode ) -{ - RscWriteRc aMem( pTypCont->GetByteOrder() ); - - aError = pClass->WriteRcHeader( RSCINST( pClass, pObjNode->GetRscObj() ), - aMem, pTypCont, - pObjNode->GetRscId(), 0, sal_True ); - if( aError.IsError() || aError.IsWarning() ) - pTypCont->pEH->Error( aError, pClass, pObjNode->GetRscId() ); - - WriteRcFile( aMem, fOutput ); - return 0; -} - -/************************************************************************* -|* -|* RscEnumerateObj :: CallBackWriteSrc -|* -*************************************************************************/ -IMPL_LINK_INLINE_START( RscEnumerateObj, CallBackWriteSrc, ObjNode *, pObjNode ) -{ - if( pObjNode->GetFileKey() == lFileKey ){ - pClass->WriteSrcHeader( RSCINST( pClass, pObjNode->GetRscObj() ), - fOutput, pTypCont, 0, - pObjNode->GetRscId(), "" ); - fprintf( fOutput, ";\n" ); - } - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateObj, CallBackWriteSrc, ObjNode *, pObjNode ) - -/************************************************************************* -|* -|* RscEnumerateObj :: CallBackWriteCxx -|* -*************************************************************************/ -IMPL_LINK_INLINE_START( RscEnumerateObj, CallBackWriteCxx, ObjNode *, pObjNode ) -{ - if( pClass->IsCodeWriteable() && pObjNode->GetFileKey() == lFileKey ) - aError = pClass->WriteCxxHeader( - RSCINST( pClass, pObjNode->GetRscObj() ), - fOutput, pTypCont, pObjNode->GetRscId() ); - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateObj, CallBackWriteCxx, ObjNode *, pObjNode ) - -/************************************************************************* -|* -|* RscEnumerateObj :: CallBackWriteHxx -|* -*************************************************************************/ -IMPL_LINK_INLINE_START( RscEnumerateObj, CallBackWriteHxx, ObjNode *, pObjNode ) -{ - if( pClass->IsCodeWriteable() && pObjNode->GetFileKey() == lFileKey ) - aError = pClass->WriteHxxHeader( - RSCINST( pClass, pObjNode->GetRscObj() ), - fOutput, pTypCont, pObjNode->GetRscId() ); - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateObj, CallBackWriteHxx, ObjNode *, pObjNode ) - -/************************************************************************* -|* -|* RscEnumerateObj :: WriteRcFile -|* -*************************************************************************/ -void RscEnumerateObj :: WriteRcFile( RscWriteRc & rMem, FILE * fOut ){ - // Definition der Struktur, aus denen die Resource aufgebaut ist - /* - struct RSHEADER_TYPE{ - sal_uInt32 nId; // Identifier der Resource - sal_uInt32 nRT; // Resource Typ - sal_uInt32 nGlobOff; // Globaler Offset - sal_uInt32 nLocalOff; // Lokaler Offset - } aHeader; - */ - - sal_uInt32 nId = rMem.GetLong( 0 ); - sal_uInt32 nRT = rMem.GetLong( 4 ); - - // Tabelle wird entsprechend gefuellt - pTypCont->PutTranslatorKey( (sal_uInt64(nRT) << 32) + sal_uInt64(nId) ); - - if( nRT == RSC_VERSIONCONTROL ) - { // kommt immmer als letztes - sal_Int32 nCount = pTypCont->aIdTranslator.size(); - // groesse der Tabelle - sal_uInt32 nSize = (nCount * (sizeof(sal_uInt64)+sizeof(sal_Int32))) + sizeof(sal_Int32); - - rMem.Put( nCount ); //Anzahl speichern - for( std::map< sal_uInt64, sal_uLong >::const_iterator it = - pTypCont->aIdTranslator.begin(); it != pTypCont->aIdTranslator.end(); ++it ) - { - // Schluessel schreiben - rMem.Put( it->first ); - // Objekt Id oder Position schreiben - rMem.Put( (sal_Int32)it->second ); - } - rMem.Put( nSize ); // Groesse hinten Speichern - } - - //Dateioffset neu setzen - pTypCont->IncFilePos( rMem.Size() ); - - - //Position wurde vorher in Tabelle geschrieben - fwrite( rMem.GetBuffer(), rMem.Size(), 1, fOut ); - -}; - -class RscEnumerateRef -{ -private: - RscTop * pRoot; - - DECL_LINK( CallBackWriteRc, RscTop * ); - DECL_LINK( CallBackWriteSrc, RscTop * ); - DECL_LINK( CallBackWriteCxx, RscTop * ); - DECL_LINK( CallBackWriteHxx, RscTop * ); - DECL_LINK( CallBackWriteSyntax, RscTop * ); - DECL_LINK( CallBackWriteRcCtor, RscTop * ); -public: - RscEnumerateObj aEnumObj; - - RscEnumerateRef( RscTypCont * pTC, RscTop * pR, - FILE * fOutput ) - { - aEnumObj.pTypCont = pTC; - aEnumObj.fOutput = fOutput; - pRoot = pR; - } - ERRTYPE WriteRc() - { - aEnumObj.aError.Clear(); - pRoot->EnumNodes( LINK( this, RscEnumerateRef, CallBackWriteRc ) ); - return aEnumObj.aError; - }; - - ERRTYPE WriteSrc( sal_uLong lFileKey ) - { - aEnumObj.lFileKey = lFileKey; - - aEnumObj.aError.Clear(); - pRoot->EnumNodes( LINK( this, RscEnumerateRef, CallBackWriteSrc ) ); - return aEnumObj.aError; - } - - ERRTYPE WriteCxx( sal_uLong lFileKey ) - { - aEnumObj.lFileKey = lFileKey; - - aEnumObj.aError.Clear(); - pRoot->EnumNodes( LINK( this, RscEnumerateRef, CallBackWriteCxx ) ); - return aEnumObj.aError; - } - - ERRTYPE WriteHxx( sal_uLong lFileKey ) - { - aEnumObj.lFileKey = lFileKey; - - aEnumObj.aError.Clear(); - pRoot->EnumNodes( LINK( this, RscEnumerateRef, CallBackWriteHxx ) ); - return aEnumObj.aError; - } - - void WriteSyntax() - { - pRoot->EnumNodes( LINK( this, RscEnumerateRef, - CallBackWriteSyntax ) ); - } - - void WriteRcCtor() - { - pRoot->EnumNodes( LINK( this, RscEnumerateRef, - CallBackWriteRcCtor ) ); - } -}; - -/************************************************************************* -|* -|* RscRscEnumerateRef :: CallBack... -|* -*************************************************************************/ -IMPL_LINK_INLINE_START( RscEnumerateRef, CallBackWriteRc, RscTop *, pRef ) -{ - aEnumObj.WriteRc( pRef, pRef->GetObjNode() ); - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateRef, CallBackWriteRc, RscTop *, pRef ) -IMPL_LINK_INLINE_START( RscEnumerateRef, CallBackWriteSrc, RscTop *, pRef ) -{ - aEnumObj.WriteSrc( pRef, pRef->GetObjNode() ); - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateRef, CallBackWriteSrc, RscTop *, pRef ) -IMPL_LINK_INLINE_START( RscEnumerateRef, CallBackWriteCxx, RscTop *, pRef ) -{ - if( pRef->IsCodeWriteable() ) - aEnumObj.WriteCxx( pRef, pRef->GetObjNode() ); - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateRef, CallBackWriteCxx, RscTop *, pRef ) -IMPL_LINK_INLINE_START( RscEnumerateRef, CallBackWriteHxx, RscTop *, pRef ) -{ - if( pRef->IsCodeWriteable() ) - aEnumObj.WriteHxx( pRef, pRef->GetObjNode() ); - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateRef, CallBackWriteHxx, RscTop *, pRef ) -IMPL_LINK_INLINE_START( RscEnumerateRef, CallBackWriteSyntax, RscTop *, pRef ) -{ - pRef->WriteSyntaxHeader( aEnumObj.fOutput, aEnumObj.pTypCont ); - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateRef, CallBackWriteSyntax, RscTop *, pRef ) -IMPL_LINK_INLINE_START( RscEnumerateRef, CallBackWriteRcCtor, RscTop *, pRef ) -{ - pRef->WriteRcCtor( aEnumObj.fOutput, aEnumObj.pTypCont ); - return 0; -} -IMPL_LINK_INLINE_END( RscEnumerateRef, CallBackWriteRcCtor, RscTop *, pRef ) - -/************************************************************************* -|* -|* RscTypCont :: WriteRc -|* -*************************************************************************/ - -ERRTYPE RscTypCont::WriteRc( WriteRcContext& rContext ) -{ - ERRTYPE aError; - RscEnumerateRef aEnumRef( this, pRoot, rContext.fOutput ); - - aIdTranslator.clear(); - nFilePos = 0; - nPMId = RSCVERSION_ID +1; //mindestens einen groesser - - aError = aEnumRef.WriteRc(); - - // version control - RscWriteRc aMem( nByteOrder ); - aVersion.pClass->WriteRcHeader( aVersion, aMem, this, RscId( RSCVERSION_ID ), 0, sal_True ); - aEnumRef.aEnumObj.WriteRcFile( aMem, rContext.fOutput ); - - return aError; -} - -/************************************************************************* -|* -|* RscTypCont :: WriteSrc -|* -*************************************************************************/ -void RscTypCont :: WriteSrc( FILE * fOutput, sal_uLong nFileKey, - CharSet /*nCharSet*/, sal_Bool bName ) -{ - RscFile * pFName; - RscEnumerateRef aEnumRef( this, pRoot, fOutput ); - - unsigned char aUTF8BOM[3] = { 0xef, 0xbb, 0xbf }; - fwrite( aUTF8BOM, sizeof(unsigned char), SAL_N_ELEMENTS(aUTF8BOM), fOutput ); - if( bName ) - { - WriteInc( fOutput, nFileKey ); - - if( NOFILE_INDEX == nFileKey ) - { - pFName = aFileTab.First(); - while( pFName ){ - if( !pFName->IsIncFile() ) - pFName->aDefLst.WriteAll( fOutput ); - aEnumRef.WriteSrc( aFileTab.GetIndex( pFName ) ); - pFName = aFileTab.Next(); - }; - } - else - { - pFName = aFileTab.Get( nFileKey ); - if( pFName ){ - pFName->aDefLst.WriteAll( fOutput ); - aEnumRef.WriteSrc( nFileKey ); - } - } - } - else - { - RscId::SetNames( sal_False ); - if( NOFILE_INDEX == nFileKey ) - { - pFName = aFileTab.First(); - while( pFName ) - { - aEnumRef.WriteSrc( aFileTab.GetIndex( pFName ) ); - pFName = aFileTab.Next(); - }; - } - else - aEnumRef.WriteSrc( nFileKey ); - RscId::SetNames(); - }; -} - -/************************************************************************* -|* -|* RscTypCont :: WriteHxx -|* -*************************************************************************/ -ERRTYPE RscTypCont :: WriteHxx( FILE * fOutput, sal_uLong nFileKey ) -{ - fprintf( fOutput, "#include <tools/rc.hxx>\n" ); - fprintf( fOutput, "#include <tools/resid.hxx>\n" ); - fprintf( fOutput, "#include <vcl/accel.hxx>\n" ); - fprintf( fOutput, "#include <vcl/bitmap.hxx>\n" ); - fprintf( fOutput, "#include <vcl/button.hxx>\n" ); - fprintf( fOutput, "#include <tools/color.hxx>\n" ); - fprintf( fOutput, "#include <vcl/combobox.hxx>\n" ); - fprintf( fOutput, "#include <vcl/ctrl.hxx>\n" ); - fprintf( fOutput, "#include <vcl/dialog.hxx>\n" ); - fprintf( fOutput, "#include <vcl/edit.hxx>\n" ); - fprintf( fOutput, "#include <vcl/field.hxx>\n" ); - fprintf( fOutput, "#include <vcl/fixed.hxx>\n" ); - fprintf( fOutput, "#include <vcl/group.hxx>\n" ); - fprintf( fOutput, "#include <vcl/image.hxx>\n" ); - fprintf( fOutput, "#include <vcl/button.hxx>\n" ); - fprintf( fOutput, "#include <vcl/keycod.hxx>\n" ); - fprintf( fOutput, "#include <vcl/lstbox.hxx>\n" ); - fprintf( fOutput, "#include <vcl/mapmod.hxx>\n" ); - fprintf( fOutput, "#include <vcl/menu.hxx>\n" ); - fprintf( fOutput, "#include <vcl/menubtn.hxx>\n" ); - fprintf( fOutput, "#include <vcl/morebtn.hxx>\n" ); - fprintf( fOutput, "#include <vcl/msgbox.hxx>\n" ); - fprintf( fOutput, "#include <vcl/scrbar.hxx>\n" ); - fprintf( fOutput, "#include <vcl/spin.hxx>\n" ); - fprintf( fOutput, "#include <vcl/spinfld.hxx>\n" ); - fprintf( fOutput, "#include <vcl/splitwin.hxx>\n" ); - fprintf( fOutput, "#include <vcl/status.hxx>\n" ); - fprintf( fOutput, "#include <vcl/tabctrl.hxx>\n" ); - fprintf( fOutput, "#include <vcl/tabdlg.hxx>\n" ); - fprintf( fOutput, "#include <vcl/tabpage.hxx>\n" ); - fprintf( fOutput, "#include <vcl/toolbox.hxx>\n" ); - fprintf( fOutput, "#include <vcl/window.hxx>\n" ); - fprintf( fOutput, "#include <vcl/wrkwin.hxx>\n" ); - fprintf( fOutput, "#include <svtools/svmedit.hxx>\n" ); - - RscEnumerateRef aEnumRef( this, pRoot, fOutput ); - ERRTYPE aError; - - if( NOFILE_INDEX == nFileKey ) - { - RscFile * pFName; - - pFName = aFileTab.First(); - while( pFName ) - { - aError = aEnumRef.WriteHxx( aFileTab.GetIndex( pFName ) ); - pFName = aFileTab.Next(); - }; - } - else - aError = aEnumRef.WriteHxx( nFileKey ); - - return aError; -} - -/************************************************************************* -|* -|* RscTypCont :: WriteCxx -|* -*************************************************************************/ -ERRTYPE RscTypCont::WriteCxx( FILE * fOutput, sal_uLong nFileKey, - const ByteString & rHxxName ) -{ - RscEnumerateRef aEnumRef( this, pRoot, fOutput ); - ERRTYPE aError; - fprintf( fOutput, "#include <string.h>\n" ); - WriteInc( fOutput, nFileKey ); - if( rHxxName.Len() ) - fprintf( fOutput, "#include \"%s\"\n", rHxxName.GetBuffer() ); - fprintf( fOutput, "\n\n" ); - - if( NOFILE_INDEX == nFileKey ) - { - RscFile * pFName; - - pFName = aFileTab.First(); - while( pFName ) - { - aError = aEnumRef.WriteCxx( aFileTab.GetIndex( pFName ) ); - pFName = aFileTab.Next(); - }; - } - else - aError = aEnumRef.WriteCxx( nFileKey ); - - return aError; -} - -/************************************************************************* -|* -|* RscTypCont :: WriteSyntax -|* -*************************************************************************/ -void RscTypCont::WriteSyntax( FILE * fOutput ) -{ - for( size_t i = 0; i < aBaseLst.size(); i++ ) - aBaseLst[ i ]->WriteSyntaxHeader( fOutput, this ); - RscEnumerateRef aEnumRef( this, pRoot, fOutput ); - aEnumRef.WriteSyntax(); -} - -//======================================================================= -void RscTypCont::WriteRcCtor -( - FILE * fOutput -) -{ - RscEnumerateRef aEnumRef( this, pRoot, fOutput ); - aEnumRef.WriteRcCtor(); -} - -/************************************************************************* -|* -|* RscTypCont :: Delete() -|* -*************************************************************************/ -class RscDel -{ - sal_uLong lFileKey; - DECL_LINK( Delete, RscTop * ); -public: - RscDel( RscTop * pRoot, sal_uLong lKey ); -}; - - -inline RscDel::RscDel( RscTop * pRoot, sal_uLong lKey ) -{ - lFileKey = lKey; - pRoot->EnumNodes( LINK( this, RscDel, Delete ) ); -} - -IMPL_LINK_INLINE_START( RscDel, Delete, RscTop *, pNode ) -{ - if( pNode->GetObjNode() ) - pNode->pObjBiTree = pNode->GetObjNode()->DelObjNode( pNode, lFileKey ); - return 0; -} -IMPL_LINK_INLINE_END( RscDel, Delete, RscTop *, pNode ) - -void RscTypCont :: Delete( sal_uLong lFileKey ){ - // Resourceinstanzen loeschen - RscDel aDel( pRoot, lFileKey ); - // Defines loeschen - aFileTab.DeleteFileContext( lFileKey ); -} - -sal_Bool IsInstConsistent( ObjNode * pObjNode, RscTop * pRscTop ) -{ - sal_Bool bRet = sal_True; - - if( pObjNode ){ - RSCINST aTmpI; - - if( ! IsInstConsistent( (ObjNode*)pObjNode->Left(), pRscTop ) ) - bRet = sal_False; - - aTmpI.pClass = pRscTop; - aTmpI.pData = pObjNode->GetRscObj(); - if( ! aTmpI.pClass->IsConsistent( aTmpI ) ) - bRet = sal_False; - - if( ! IsInstConsistent( (ObjNode*)pObjNode->Right(), pRscTop ) ) - bRet = sal_False; - }; - - return( bRet ); -} - -sal_Bool MakeConsistent( RscTop * pRscTop ) -{ - sal_Bool bRet = sal_True; - - if( pRscTop ){ - if( ! ::MakeConsistent( (RscTop*)pRscTop->Left() ) ) - bRet = sal_False; - - if( pRscTop->GetObjNode() ){ - if( ! pRscTop->GetObjNode()->IsConsistent() ){ - pRscTop->GetObjNode()->OrderTree(); - if( ! pRscTop->GetObjNode()->IsConsistent() ) - bRet = sal_False; - } - if( ! IsInstConsistent( pRscTop->GetObjNode(), pRscTop ) ) - bRet = sal_False; - } - - if( ! ::MakeConsistent( (RscTop*)pRscTop->Right() ) ) - bRet = sal_False; - }; - - return bRet; -} - -sal_uInt32 RscTypCont::PutTranslatorKey( sal_uInt64 nKey ) -{ - aIdTranslator[ nKey ] = nFilePos; - return nPMId++; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rscibas.cxx b/rsc/source/parser/rscibas.cxx deleted file mode 100644 index 02017474d5..0000000000 --- a/rsc/source/parser/rscibas.cxx +++ /dev/null @@ -1,644 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" - -/****************** I N C L U D E S **************************************/ -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include <i18npool/mslangid.hxx> -#include <tools/rc.h> -#include <tools/color.hxx> - -#include <vclrsc.hxx> -#include <rscconst.hxx> -#include <rscarray.hxx> -#include <rscclass.hxx> -#include <rsccont.hxx> -#include <rscdb.hxx> - - -#include "rsclex.hxx" -#include <yyrscyacc.hxx> - -#include <boost/unordered_map.hpp> - -/****************** M A C R O S ******************************************/ -void RscTypCont::SETCONST( RscConst * pClass, const char * szString, sal_uInt32 nVal ) -{ -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "setconst : %s\n", szString ); -#endif - pClass->SetConstant( aNmTb.Put( szString, - CONSTNAME, nVal ), nVal ); -} - -void RscTypCont::SETCONST( RscConst * pClass, Atom nName, sal_uInt32 nVal ) -{ -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "setconst hash: %u\n", (unsigned int)nName ); -#endif - pClass->SetConstant( aNmTb.Put( nName, - CONSTNAME, nVal ), nVal ); -} - -/****************** C O D E **********************************************/ -/************************************************************************* -|* RscTypCont::InitLangType() -|* -|* Beschreibung -*************************************************************************/ - -typedef boost::unordered_map< rtl::OString, sal_uInt32, rtl::OStringHash > langmap; -static langmap ULong_Iso_map; - -sal_uInt32 GetLangId( const ByteString& aLang ) -{ - langmap::iterator pIter = ULong_Iso_map.find( aLang ); - if ( pIter != ULong_Iso_map.end()) - return pIter->second; - return 0; -} - -void RscLangEnum::Init( RscNameTable& rNames ) -{ - SetConstant( rNames.Put( "SYSTEM", CONSTNAME, (long)LANGUAGE_SYSTEM ), LANGUAGE_SYSTEM ); - SetConstant( rNames.Put( "DONTKNOW", CONSTNAME, LANGUAGE_DONTKNOW ), LANGUAGE_DONTKNOW ); - - sal_Int32 nIndex = 0; - mnLangId = 0x400; // stay away from selfdefined... - char csep = '-'; - const MsLangId::IsoLangEntry* pLangEntry; - ByteString aCountry, aLang; - - while ( NULL != ( pLangEntry = MsLangId::getIsoLangEntry( nIndex )) && ( pLangEntry->mnLang != LANGUAGE_DONTKNOW )) - { -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "ISO Language in : %d\n", - (int)nIndex, - pLangEntry->mnLang, - MsLangId::convertLanguageToIsoByteString( pLangEntry->mnLang ).getStr() ); -#endif - aLang = pLangEntry->maLangStr; - aCountry = pLangEntry->maCountry; - if ( aLang.EqualsIgnoreCaseAscii( aCountry ) || ! aCountry.Len() ) - { - SetConstant( rNames.Put( aLang.GetBuffer(), CONSTNAME, mnLangId ), mnLangId ); - if ( ! GetLangId( aLang )) - ULong_Iso_map[ aLang ] = mnLangId; -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "ISO Language out: %s 0x%lx\n", aLang.GetBuffer(), mnLangId ); -#endif - mnLangId++; - } - else - { - SetConstant( rNames.Put( aLang.GetBuffer(), CONSTNAME, mnLangId ), mnLangId ); - if ( ! GetLangId( aLang )) - ULong_Iso_map[ aLang ] = mnLangId; -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "ISO Language out: %s 0x%lx", aLang.GetBuffer(), mnLangId ); -#endif - mnLangId++; - aLang += csep; - aLang += aCountry.ToUpperAscii(); - SetConstant( rNames.Put( aLang.GetBuffer(), CONSTNAME, mnLangId ), mnLangId ); - if ( ! GetLangId( aLang )) - ULong_Iso_map[ aLang ] = mnLangId; -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, " %s 0x%lx\n", aLang.GetBuffer(), mnLangId ); -#endif - mnLangId++; -// hack - survive "x-no-translate" - if ( aLang == "en-US" ) - { -// SetConstant( rNames.Put( "x-no-translate", CONSTNAME, mnLangId ), mnLangId ); -// mnLangId++; - SetConstant( rNames.Put( "x-comment", CONSTNAME, mnLangId ), mnLangId ); - mnLangId++; - } - } - nIndex++; - } - - ByteString aEnvIsoTokens = getenv( "RSC_LANG_ISO" ); - if ( aEnvIsoTokens.Len() ) - { - ByteString aIsoToken; - sal_uInt16 nTokenCounter = 0; - sal_Bool bOneMore = 1; - while ( bOneMore ) - { - aIsoToken = aEnvIsoTokens.GetToken( nTokenCounter, ' ' ); - if ( aIsoToken.Len() ) - { - SetConstant( rNames.Put( aIsoToken.GetBuffer(), CONSTNAME, mnLangId ), mnLangId ); - if ( ! GetLangId( aIsoToken )) - ULong_Iso_map[ aIsoToken ] = mnLangId; -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "Env ISO Language out: %s 0x%lx\n", aIsoToken.GetBuffer(), mnLangId ); -#endif - mnLangId++; - } - else - bOneMore = 0; - nTokenCounter++; - } - } - - SetConstant( rNames.Put( "LANGUAGE_USER1", CONSTNAME, LANGUAGE_USER1 ), LANGUAGE_USER1 ); - SetConstant( rNames.Put( "LANGUAGE_USER2", CONSTNAME, LANGUAGE_USER2 ), LANGUAGE_USER2 ); - SetConstant( rNames.Put( "LANGUAGE_USER3", CONSTNAME, LANGUAGE_USER3 ), LANGUAGE_USER3 ); - SetConstant( rNames.Put( "LANGUAGE_USER4", CONSTNAME, LANGUAGE_USER4 ), LANGUAGE_USER4 ); - SetConstant( rNames.Put( "LANGUAGE_USER5", CONSTNAME, LANGUAGE_USER5 ), LANGUAGE_USER5 ); - SetConstant( rNames.Put( "LANGUAGE_USER6", CONSTNAME, LANGUAGE_USER6 ), LANGUAGE_USER6 ); - SetConstant( rNames.Put( "LANGUAGE_USER7", CONSTNAME, LANGUAGE_USER7 ), LANGUAGE_USER7 ); - SetConstant( rNames.Put( "LANGUAGE_USER8", CONSTNAME, LANGUAGE_USER8 ), LANGUAGE_USER8 ); - SetConstant( rNames.Put( "EXTERN", CONSTNAME, LANGUAGE_USER9 ), LANGUAGE_USER9 ); -} - -Atom RscLangEnum::AddLanguage( const char* pLang, RscNameTable& rNames ) -{ - Atom nResult = 0; - KEY_STRUCT aStruct; - if( ! rNames.Get( nResult = pHS->getID( pLang ), &aStruct ) ) - { - SetConstant( nResult = rNames.Put( pLang, CONSTNAME, mnLangId ), mnLangId ); - // insert new lang to ULong_Iso_map - rtl::OString aLang( pLang ); - if ( ! GetLangId( aLang )) - ULong_Iso_map[ aLang ] = mnLangId; - // increase id counter - mnLangId++; - } - #if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "AddLanguage( %s ) = %d\n", pLang, nResult ); - #endif - return nResult; -} - -RscEnum * RscTypCont::InitLangType() -{ - aLangType.Init( aNmTb ); - return( &aLangType ); -} - -/************************************************************************* -|* -|* RscTypCont::InitFieldUnitsType() -|* -*************************************************************************/ -RscEnum * RscTypCont::InitFieldUnitsType() -{ - RscEnum * pFieldUnits; - pFieldUnits = new RscEnum( pHS->getID( "EnumFieldUnit" ), RSC_NOTYPE ); - - SETCONST( pFieldUnits, "FUNIT_NONE", FUNIT_NONE ); - SETCONST( pFieldUnits, "FUNIT_MM", FUNIT_MM ); - SETCONST( pFieldUnits, "FUNIT_CM", FUNIT_CM ); - SETCONST( pFieldUnits, "FUNIT_M", FUNIT_M ); - SETCONST( pFieldUnits, "FUNIT_KM", FUNIT_KM ); - SETCONST( pFieldUnits, "FUNIT_TWIP", FUNIT_TWIP ); - SETCONST( pFieldUnits, "FUNIT_POINT", FUNIT_POINT ); - SETCONST( pFieldUnits, "FUNIT_PICA", FUNIT_PICA ); - SETCONST( pFieldUnits, "FUNIT_INCH", FUNIT_INCH ); - SETCONST( pFieldUnits, "FUNIT_FOOT", FUNIT_FOOT ); - SETCONST( pFieldUnits, "FUNIT_MILE", FUNIT_MILE ); - SETCONST( pFieldUnits, "FUNIT_CUSTOM", FUNIT_CUSTOM ); - // Amelia : adds two units ,"char" and "line" - SETCONST( pFieldUnits, "FUNIT_CHAR", FUNIT_CHAR ); - SETCONST( pFieldUnits, "FUNIT_LINE", FUNIT_LINE ); - SETCONST( pFieldUnits, "FUNIT_PERCENT", FUNIT_PERCENT ); - - return pFieldUnits; -} - -/************************************************************************* -|* -|* RscTypCont::InitTimeFieldFormat() -|* -*************************************************************************/ -RscEnum * RscTypCont::InitTimeFieldFormat() -{ - RscEnum * pTimeFieldFormat; - pTimeFieldFormat = new RscEnum( pHS->getID( "EnumTimeFieldFormat" ), - RSC_NOTYPE ); - - SETCONST( pTimeFieldFormat, "TIMEF_NONE", TIMEF_NONE ); - SETCONST( pTimeFieldFormat, "TIMEF_SEC", TIMEF_SEC ); - SETCONST( pTimeFieldFormat, "TIMEF_100TH_SEC", TIMEF_100TH_SEC ); - - return pTimeFieldFormat; -} - -/************************************************************************* -|* -|* RscTypCont::InitColor() -|* -*************************************************************************/ -RscEnum * RscTypCont::InitColor(){ - RscEnum * pColor; - pColor = new RscEnum( pHS->getID( "EnumColor" ), RSC_NOTYPE ); - - SETCONST( pColor, "COL_BLACK", COL_BLACK ); - SETCONST( pColor, "COL_BLUE", COL_BLUE ); - SETCONST( pColor, "COL_GREEN", COL_GREEN ); - SETCONST( pColor, "COL_CYAN", COL_CYAN ); - SETCONST( pColor, "COL_RED", COL_RED ); - SETCONST( pColor, "COL_MAGENTA", COL_MAGENTA ); - SETCONST( pColor, "COL_BROWN", COL_BROWN ); - SETCONST( pColor, "COL_GRAY", COL_GRAY ); - SETCONST( pColor, "COL_LIGHTGRAY", COL_LIGHTGRAY ); - SETCONST( pColor, "COL_LIGHTBLUE", COL_LIGHTBLUE ); - SETCONST( pColor, "COL_LIGHTGREEN", COL_LIGHTGREEN ); - SETCONST( pColor, "COL_LIGHTCYAN", COL_LIGHTCYAN ); - SETCONST( pColor, "COL_LIGHTRED", COL_LIGHTRED ); - SETCONST( pColor, "COL_LIGHTMAGENTA", COL_LIGHTMAGENTA ); - SETCONST( pColor, "COL_YELLOW", COL_YELLOW ); - SETCONST( pColor, "COL_WHITE", COL_WHITE ); - - return( pColor ); -} - -/************************************************************************* -|* -|* RscTypCont::InitMapUnit() -|* -*************************************************************************/ -RscEnum * RscTypCont::InitMapUnit(){ - RscEnum * pMapUnit; - pMapUnit = new RscEnum( pHS->getID( "EnumMapUnit" ), RSC_NOTYPE ); - - SETCONST( pMapUnit, "MAP_PIXEL", MAP_PIXEL ); - SETCONST( pMapUnit, "MAP_SYSFONT", MAP_SYSFONT ); - SETCONST( pMapUnit, "MAP_100TH_MM", MAP_100TH_MM ); - SETCONST( pMapUnit, "MAP_10TH_MM", MAP_10TH_MM ); - SETCONST( pMapUnit, "MAP_MM", MAP_MM ); - SETCONST( pMapUnit, "MAP_CM", MAP_CM ); - SETCONST( pMapUnit, "MAP_1000TH_INCH", MAP_1000TH_INCH ); - SETCONST( pMapUnit, "MAP_100TH_INCH", MAP_100TH_INCH ); - SETCONST( pMapUnit, "MAP_10TH_INCH", MAP_10TH_INCH ); - SETCONST( pMapUnit, "MAP_INCH", MAP_INCH ); - SETCONST( pMapUnit, "MAP_POINT", MAP_POINT ); - SETCONST( pMapUnit, "MAP_TWIP", MAP_TWIP ); - SETCONST( pMapUnit, "MAP_APPFONT", MAP_APPFONT ); - SETCONST( pMapUnit, "MAP_SV", RSC_EXTRAMAPUNIT ); - return( pMapUnit ); -} - -/************************************************************************* -|* -|* RscTypCont::InitKey() -|* -*************************************************************************/ -RscEnum * RscTypCont::InitKey(){ - RscEnum * pKey; - pKey = new RscEnum( pHS->getID( "EnumKey" ), RSC_NOTYPE ); - - SETCONST( pKey, "KEY_0", com::sun::star::awt::Key::NUM0 ); - SETCONST( pKey, "KEY_1", com::sun::star::awt::Key::NUM1 ); - SETCONST( pKey, "KEY_2", com::sun::star::awt::Key::NUM2 ); - SETCONST( pKey, "KEY_3", com::sun::star::awt::Key::NUM3 ); - SETCONST( pKey, "KEY_4", com::sun::star::awt::Key::NUM4 ); - SETCONST( pKey, "KEY_5", com::sun::star::awt::Key::NUM5 ); - SETCONST( pKey, "KEY_6", com::sun::star::awt::Key::NUM6 ); - SETCONST( pKey, "KEY_7", com::sun::star::awt::Key::NUM7 ); - SETCONST( pKey, "KEY_8", com::sun::star::awt::Key::NUM8 ); - SETCONST( pKey, "KEY_9", com::sun::star::awt::Key::NUM9 ); - - SETCONST( pKey, "KEY_A", com::sun::star::awt::Key::A ); - SETCONST( pKey, "KEY_B", com::sun::star::awt::Key::B ); - SETCONST( pKey, "KEY_C", com::sun::star::awt::Key::C ); - SETCONST( pKey, "KEY_D", com::sun::star::awt::Key::D ); - SETCONST( pKey, "KEY_E", com::sun::star::awt::Key::E ); - SETCONST( pKey, "KEY_F", com::sun::star::awt::Key::F ); - SETCONST( pKey, "KEY_G", com::sun::star::awt::Key::G ); - SETCONST( pKey, "KEY_H", com::sun::star::awt::Key::H ); - SETCONST( pKey, "KEY_I", com::sun::star::awt::Key::I ); - SETCONST( pKey, "KEY_J", com::sun::star::awt::Key::J ); - SETCONST( pKey, "KEY_K", com::sun::star::awt::Key::K ); - SETCONST( pKey, "KEY_L", com::sun::star::awt::Key::L ); - SETCONST( pKey, "KEY_M", com::sun::star::awt::Key::M ); - SETCONST( pKey, "KEY_N", com::sun::star::awt::Key::N ); - SETCONST( pKey, "KEY_O", com::sun::star::awt::Key::O ); - SETCONST( pKey, "KEY_P", com::sun::star::awt::Key::P ); - SETCONST( pKey, "KEY_Q", com::sun::star::awt::Key::Q ); - SETCONST( pKey, "KEY_R", com::sun::star::awt::Key::R ); - SETCONST( pKey, "KEY_S", com::sun::star::awt::Key::S ); - SETCONST( pKey, "KEY_T", com::sun::star::awt::Key::T ); - SETCONST( pKey, "KEY_U", com::sun::star::awt::Key::U ); - SETCONST( pKey, "KEY_V", com::sun::star::awt::Key::V ); - SETCONST( pKey, "KEY_W", com::sun::star::awt::Key::W ); - SETCONST( pKey, "KEY_X", com::sun::star::awt::Key::X ); - SETCONST( pKey, "KEY_Y", com::sun::star::awt::Key::Y ); - SETCONST( pKey, "KEY_Z", com::sun::star::awt::Key::Z ); - - SETCONST( pKey, "KEY_F1", com::sun::star::awt::Key::F1 ); - SETCONST( pKey, "KEY_F2", com::sun::star::awt::Key::F2 ); - SETCONST( pKey, "KEY_F3", com::sun::star::awt::Key::F3 ); - SETCONST( pKey, "KEY_F4", com::sun::star::awt::Key::F4 ); - SETCONST( pKey, "KEY_F5", com::sun::star::awt::Key::F5 ); - SETCONST( pKey, "KEY_F6", com::sun::star::awt::Key::F6 ); - SETCONST( pKey, "KEY_F7", com::sun::star::awt::Key::F7 ); - SETCONST( pKey, "KEY_F8", com::sun::star::awt::Key::F8 ); - SETCONST( pKey, "KEY_F9", com::sun::star::awt::Key::F9 ); - SETCONST( pKey, "KEY_F10", com::sun::star::awt::Key::F10 ); - SETCONST( pKey, "KEY_F11", com::sun::star::awt::Key::F11 ); - SETCONST( pKey, "KEY_F12", com::sun::star::awt::Key::F12 ); - SETCONST( pKey, "KEY_F13", com::sun::star::awt::Key::F13 ); - SETCONST( pKey, "KEY_F14", com::sun::star::awt::Key::F14 ); - SETCONST( pKey, "KEY_F15", com::sun::star::awt::Key::F15 ); - SETCONST( pKey, "KEY_F16", com::sun::star::awt::Key::F16 ); - SETCONST( pKey, "KEY_F17", com::sun::star::awt::Key::F17 ); - SETCONST( pKey, "KEY_F18", com::sun::star::awt::Key::F18 ); - SETCONST( pKey, "KEY_F19", com::sun::star::awt::Key::F19 ); - SETCONST( pKey, "KEY_F20", com::sun::star::awt::Key::F20 ); - SETCONST( pKey, "KEY_F21", com::sun::star::awt::Key::F21 ); - SETCONST( pKey, "KEY_F22", com::sun::star::awt::Key::F22 ); - SETCONST( pKey, "KEY_F23", com::sun::star::awt::Key::F23 ); - SETCONST( pKey, "KEY_F24", com::sun::star::awt::Key::F24 ); - SETCONST( pKey, "KEY_F25", com::sun::star::awt::Key::F25 ); - SETCONST( pKey, "KEY_F26", com::sun::star::awt::Key::F26 ); - - SETCONST( pKey, "KEY_DOWN", com::sun::star::awt::Key::DOWN ); - SETCONST( pKey, "KEY_UP", com::sun::star::awt::Key::UP ); - SETCONST( pKey, "KEY_LEFT", com::sun::star::awt::Key::LEFT ); - SETCONST( pKey, "KEY_RIGHT", com::sun::star::awt::Key::RIGHT ); - SETCONST( pKey, "KEY_HOME", com::sun::star::awt::Key::HOME ); - SETCONST( pKey, "KEY_END", com::sun::star::awt::Key::END ); - SETCONST( pKey, "KEY_PAGEUP", com::sun::star::awt::Key::PAGEUP ); - SETCONST( pKey, "KEY_PAGEDOWN", com::sun::star::awt::Key::PAGEDOWN ); - - SETCONST( pKey, "KEY_RETURN", com::sun::star::awt::Key::RETURN ); - SETCONST( pKey, "KEY_ESCAPE", com::sun::star::awt::Key::ESCAPE ); - SETCONST( pKey, "KEY_TAB", com::sun::star::awt::Key::TAB ); - SETCONST( pKey, "KEY_BACKSPACE", com::sun::star::awt::Key::BACKSPACE ); - SETCONST( pKey, "KEY_SPACE", com::sun::star::awt::Key::SPACE ); - SETCONST( pKey, "KEY_INSERT", com::sun::star::awt::Key::INSERT ); - SETCONST( pKey, "KEY_DELETE", com::sun::star::awt::Key::DELETE ); - - SETCONST( pKey, "KEY_ADD", com::sun::star::awt::Key::ADD ); - SETCONST( pKey, "KEY_SUBTRACT", com::sun::star::awt::Key::SUBTRACT ); - SETCONST( pKey, "KEY_MULTIPLY", com::sun::star::awt::Key::MULTIPLY ); - SETCONST( pKey, "KEY_DIVIDE", com::sun::star::awt::Key::DIVIDE ); - SETCONST( pKey, "KEY_POINT", com::sun::star::awt::Key::POINT ); - SETCONST( pKey, "KEY_COMMA", com::sun::star::awt::Key::COMMA ); - SETCONST( pKey, "KEY_LESS", com::sun::star::awt::Key::LESS ); - SETCONST( pKey, "KEY_GREATER", com::sun::star::awt::Key::GREATER ); - SETCONST( pKey, "KEY_EQUAL", com::sun::star::awt::Key::EQUAL ); - - SETCONST( pKey, "KEY_OPEN", com::sun::star::awt::Key::OPEN ); - SETCONST( pKey, "KEY_CUT", com::sun::star::awt::Key::CUT ); - SETCONST( pKey, "KEY_COPY", com::sun::star::awt::Key::COPY ); - SETCONST( pKey, "KEY_PASTE", com::sun::star::awt::Key::PASTE ); - SETCONST( pKey, "KEY_UNDO", com::sun::star::awt::Key::UNDO ); - SETCONST( pKey, "KEY_REPEAT", com::sun::star::awt::Key::REPEAT ); - SETCONST( pKey, "KEY_FIND", com::sun::star::awt::Key::FIND ); - SETCONST( pKey, "KEY_PROPERTIES", com::sun::star::awt::Key::PROPERTIES ); - SETCONST( pKey, "KEY_FRONT", com::sun::star::awt::Key::FRONT ); - SETCONST( pKey, "KEY_CONTEXTMENU", com::sun::star::awt::Key::CONTEXTMENU ); - SETCONST( pKey, "KEY_HELP", com::sun::star::awt::Key::HELP ); - SETCONST( pKey, "KEY_HANGUL_HANJA", com::sun::star::awt::Key::HANGUL_HANJA ); - SETCONST( pKey, "KEY_DECIMAL", com::sun::star::awt::Key::DECIMAL ); - SETCONST( pKey, "KEY_TILDE", com::sun::star::awt::Key::TILDE ); - SETCONST( pKey, "KEY_QUOTELEFT", com::sun::star::awt::Key::QUOTELEFT ); - - return( pKey ); -} - -/************************************************************************* -|* -|* RscTypCont::InitTriState() -|* -*************************************************************************/ -RscEnum * RscTypCont::InitTriState(){ - RscEnum * pTriState; - pTriState = new RscEnum( pHS->getID( "EnumTriState" ), RSC_NOTYPE ); - - SETCONST( pTriState, "STATE_NOCHECK", STATE_NOCHECK ); - SETCONST( pTriState, "STATE_CHECK", STATE_CHECK ); - SETCONST( pTriState, "STATE_DONTKNOW", STATE_DONTKNOW ); - - return( pTriState ); -} - -/************************************************************************* -|* -|* RscTypCont::InitMessButtons() -|* -*************************************************************************/ -RscEnum * RscTypCont::InitMessButtons() -{ - RscEnum * pMessButtons; - pMessButtons = new RscEnum( pHS->getID( "EnumMessButtons" ), RSC_NOTYPE ); - SETCONST( pMessButtons, "WB_OK", sal::static_int_cast<sal_uInt32>(WB_OK) ); - SETCONST( pMessButtons, "WB_OK_CANCEL", sal::static_int_cast<sal_uInt32>(WB_OK_CANCEL) ); - SETCONST( pMessButtons, "WB_YES_NO", sal::static_int_cast<sal_uInt32>(WB_YES_NO) ); - SETCONST( pMessButtons, "WB_YES_NO_CANCEL", sal::static_int_cast<sal_uInt32>(WB_YES_NO_CANCEL) ); - SETCONST( pMessButtons, "WB_RETRY_CANCEL", sal::static_int_cast<sal_uInt32>(WB_RETRY_CANCEL) ); - SETCONST( pMessButtons, "WB_ABORT_RETRY_IGNORE", sal::static_int_cast<sal_uInt32>(WB_ABORT_RETRY_IGNORE) ); - return( pMessButtons ); -} - -/************************************************************************* -|* -|* RscTypCont::InitMessDefButton() -|* -*************************************************************************/ -RscEnum * RscTypCont::InitMessDefButton(){ - RscEnum * pMessDefButton; - pMessDefButton = new RscEnum( pHS->getID( "EnumMessDefButton" ), - RSC_NOTYPE ); - - SETCONST( pMessDefButton, "WB_DEF_OK", sal::static_int_cast<sal_uInt32>(WB_DEF_OK) ); - SETCONST( pMessDefButton, "WB_DEF_CANCEL", sal::static_int_cast<sal_uInt32>(WB_DEF_CANCEL) ); - SETCONST( pMessDefButton, "WB_DEF_RETRY", sal::static_int_cast<sal_uInt32>(WB_DEF_RETRY) ); - SETCONST( pMessDefButton, "WB_DEF_YES", sal::static_int_cast<sal_uInt32>(WB_DEF_YES) ); - SETCONST( pMessDefButton, "WB_DEF_NO", sal::static_int_cast<sal_uInt32>(WB_DEF_NO) ); - SETCONST( pMessDefButton, "WB_DEF_IGNORE", sal::static_int_cast<sal_uInt32>(WB_DEF_IGNORE) ); - return( pMessDefButton ); -} - -/************************************************************************* -|* -|* RscTypCont::InitGeometry() -|* -*************************************************************************/ -RscTupel * RscTypCont::InitGeometry() -{ - RscTop * pTupel; - Atom nId; - - // Clientvariablen einfuegen - pTupel = new RscTupel( pHS->getID( "TupelDeltaSystem" ), - RSC_NOTYPE, NULL ); - nId = aNmTb.Put( "X", VARNAME ); - pTupel->SetVariable( nId, &aShort ); - nId = aNmTb.Put( "Y", VARNAME ); - pTupel->SetVariable( nId, &aShort ); - nId = aNmTb.Put( "WIDTH", VARNAME ); - pTupel->SetVariable( nId, &aShort ); - nId = aNmTb.Put( "HEIGHT", VARNAME ); - pTupel->SetVariable( nId, &aShort ); - - return (RscTupel *)pTupel; -} - -/************************************************************************* -|* -|* RscTypCont::InitLangGeometry() -|* -*************************************************************************/ -RscArray * RscTypCont::InitLangGeometry( RscTupel * pGeo ) -{ - return new RscArray( pHS->getID( "Lang_TupelGeometry" ), RSC_NOTYPE, pGeo, &aLangType ); -} - -/************************************************************************* -|* -|* RscTypCont::InitStringList() -|* -*************************************************************************/ -RscCont * RscTypCont::InitStringList() -{ - RscCont * pCont; - - pCont = new RscCont( pHS->getID( "Chars[]" ), RSC_NOTYPE ); - pCont->SetTypeClass( &aString ); - - return pCont; -} - -/************************************************************************* -|* -|* RscTypCont::InitLangStringList() -|* -*************************************************************************/ -RscArray * RscTypCont::InitLangStringList( RscCont * pStrLst ) -{ - return new RscArray( pHS->getID( "Lang_CharsList" ), - RSC_NOTYPE, pStrLst, &aLangType ); -} - -/************************************************************************* -|* -|* RscTypCont::InitStringTupel() -|* -*************************************************************************/ -RscTupel * RscTypCont::InitStringTupel() -{ - RscTop * pTupel; - Atom nId; - - // Clientvariablen einfuegen - pTupel = new RscTupel( pHS->getID( "CharsTupel" ), RSC_NOTYPE, NULL ); - nId = aNmTb.Put( "FILTER", VARNAME ); - pTupel->SetVariable( nId, &aString ); - nId = aNmTb.Put( "MASK", VARNAME ); - pTupel->SetVariable( nId, &aString ); - - return (RscTupel *)pTupel; -} - -/************************************************************************* -|* -|* RscTypCont::InitStringLongTupel() -|* -*************************************************************************/ -RscTupel * RscTypCont::InitStringLongTupel() -{ - RscTop * pTupel; - Atom nId; - - // Clientvariablen einfuegen - pTupel = new RscTupel( pHS->getID( "CharsLongTupel" ), RSC_NOTYPE, NULL ); - nId = aNmTb.Put( "ItemText", VARNAME ); - pTupel->SetVariable( nId, &aString ); - nId = aNmTb.Put( "ItemId", VARNAME ); - pTupel->SetVariable( nId, &aEnumLong ); - - return (RscTupel *)pTupel; -} - -/************************************************************************* -|* -|* RscTypCont::InitStringTupelList() -|* -*************************************************************************/ -RscCont * RscTypCont::InitStringTupelList( RscTupel * pTupelString ) -{ - RscCont * pCont; - - pCont = new RscCont( pHS->getID( "CharsCharsTupel[]" ), RSC_NOTYPE ); - pCont->SetTypeClass( pTupelString ); - - return pCont; -} - -/************************************************************************* -|* -|* RscTypCont::InitStringLongTupelList() -|* -*************************************************************************/ -RscCont * RscTypCont::InitStringLongTupelList( RscTupel * pStringLong ) -{ - RscCont * pCont; - - pCont = new RscCont( pHS->getID( "CharsLongTupel[]" ), RSC_NOTYPE ); - pCont->SetTypeClass( pStringLong ); - - return pCont; -} - -/************************************************************************* -|* -|* RscTypCont::InitLangStringTupelList() -|* -*************************************************************************/ -RscArray * RscTypCont::InitLangStringTupelList( RscCont * pStrTupelLst ) -{ - return new RscArray( pHS->getID( "Lang_CharsCharsTupel" ), - RSC_NOTYPE, pStrTupelLst, &aLangType ); -} - -/************************************************************************* -|* -|* RscTypCont::InitLangStringLongTupelList() -|* -*************************************************************************/ -RscArray * RscTypCont::InitLangStringLongTupelList( RscCont * pStrLongTupelLst ) -{ - return new RscArray( pHS->getID( "Lang_CharsLongTupelList" ), - RSC_NOTYPE, pStrLongTupelLst, &aLangType ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rscicpx.cxx b/rsc/source/parser/rscicpx.cxx deleted file mode 100644 index 8517aabb0d..0000000000 --- a/rsc/source/parser/rscicpx.cxx +++ /dev/null @@ -1,2350 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" - -/****************** I N C L U D E S **************************************/ -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> - -#include <tools/rc.h> - -#include <vclrsc.hxx> -#include <rscmgr.hxx> -#include <rscclass.hxx> -#include <rsccont.hxx> -#include <rscdb.hxx> -#include <rsc/rscsfx.hxx> - -#include "rsclex.hxx" -#include <yyrscyacc.hxx> - -/************************************************************************* -|* RscTypCont::InsWinBit() -*************************************************************************/ -void RscTypCont::InsWinBit( RscTop * pClass, const ByteString & rName, - Atom nVal ) -{ - RscClient * pClient; - - // Clientvariablen einfuegen - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, &aWinBits, nVal ) - ); - Atom nId = aNmTb.Put( rName.GetBuffer(), VARNAME ); - pClass->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nWinBitVarId ); -} - -#define INS_WINBIT( pClass, WinBit ) \ - InsWinBit( pClass, #WinBit, n##WinBit##Id ); - -/************************************************************************* -|* RscTypCont::InitClassMgr() -*************************************************************************/ -RscTop * RscTypCont::InitClassMgr() -{ - RscTop * pClassMgr; - RscBaseCont * pClass; - Atom nId; - - aBaseLst.push_back( pClass = new RscBaseCont( InvalidAtom, RSC_NOTYPE, NULL, sal_False ) ); - - nId = pHS->getID( "Resource" ); - pClassMgr = new RscMgr( nId, RSC_RESOURCE, pClass ); - aNmTb.Put( nId, CLASSNAME, pClassMgr ); - pClassMgr->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - // Variablen anlegen - { - RscContWriteSrc * pCont; - - // Variablen anlegen - aBaseLst.push_back( pCont = new RscContExtraData( pHS->getID( "ContExtradata" ), RSC_NOTYPE ) ); - pCont->SetTypeClass( &aShort, &aString ); - nRsc_EXTRADATA = nId = aNmTb.Put( "ExtraData", VARNAME ); - pClassMgr->SetVariable( nId, pCont ); - }; - nId = aNmTb.Put( "Comment", VARNAME ); - pClassMgr->SetVariable( nId, &aString, NULL, VAR_NORC ); - - pClass->SetTypeClass( pClassMgr ); - - return pClassMgr; -} - -/************************************************************************* -|* RscTypCont::InitClassString() -*************************************************************************/ -RscTop * RscTypCont::InitClassString( RscTop * pSuper ){ - Atom nId; - RscTop * pClassString; - - nId = pHS->getID( "String" ); - pClassString = new RscClass( nId, RSC_STRING, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassString ); - pClassString->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - // Variablen anlegen - nId = aNmTb.Put( "Text", VARNAME ); - pClassString->SetVariable( nId, &aLangString ); - return( pClassString ); -} - -/************************************************************************* -|* RscTypCont::InitClassBitmap() -*************************************************************************/ -RscTop * RscTypCont::InitClassBitmap( RscTop * pSuper ){ - Atom nId; - RscTop * pClassBitmap; - - nId = pHS->getID( "Bitmap" ); - pClassBitmap = new RscSysDepend( nId, RSC_BITMAP, pSuper ); - pClassBitmap->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - aNmTb.Put( nId, CLASSNAME, pClassBitmap ); - - // Die Klasse RscSysDepend behandelt die Variablen - // "FILE" gesondert - nId = aNmTb.Put( "File", VARNAME ); - pClassBitmap->SetVariable( nId, &aLangString, NULL, VAR_NORC ); - - return( pClassBitmap ); -} - -/************************************************************************* -|* RscTypCont::InitClassColor() -*************************************************************************/ -RscTop * RscTypCont::InitClassColor( RscTop * pSuper, RscEnum * pColor ){ - Atom nId; - RscTop * pClassColor; - - // Klasse anlegen - nId = pHS->getID( "Color" ); - pClassColor = new RscClass( nId, RSC_COLOR, pSuper ); - pClassColor->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - aNmTb.Put( nId, CLASSNAME, pClassColor ); - - // Variablen anlegen - nId = aNmTb.Put( "Red", VARNAME ); - pClassColor->SetVariable( nId, &aUShort ); - nId = aNmTb.Put( "Green", VARNAME ); - pClassColor->SetVariable( nId, &aUShort ); - nId = aNmTb.Put( "Blue", VARNAME ); - pClassColor->SetVariable( nId, &aUShort ); - nId = aNmTb.Put( "Predefine", VARNAME ); - pClassColor->SetVariable( nId, pColor ); - - return( pClassColor ); -} - -/************************************************************************* -|* RscTypCont::InitClassImage() -*************************************************************************/ -RscTop * RscTypCont::InitClassImage( RscTop * pSuper, RscTop * pClassBitmap, - RscTop * pClassColor ) -{ - Atom nId; - RscTop * pClassImage; - - // Klasse anlegen - nId = pHS->getID( "Image" ); - pClassImage = new RscClass( nId, RSC_IMAGE, pSuper ); - pClassImage->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - aNmTb.Put( nId, CLASSNAME, pClassImage ); - - // Variablen anlegen - nId = aNmTb.Put( "ImageBitmap", VARNAME ); - pClassImage->SetVariable( nId, pClassBitmap, NULL, 0, RSC_IMAGE_IMAGEBITMAP ); - nId = aNmTb.Put( "MaskBitmap", VARNAME ); - pClassImage->SetVariable( nId, pClassBitmap, NULL, 0, RSC_IMAGE_MASKBITMAP ); - nId = aNmTb.Put( "MaskColor", VARNAME ); - pClassImage->SetVariable( nId, pClassColor, NULL, - VAR_SVDYNAMIC, RSC_IMAGE_MASKCOLOR ); - - return( pClassImage ); -} - -/************************************************************************* -|* RscTypCont::InitClassImageList() -*************************************************************************/ -RscTop * RscTypCont::InitClassImageList( RscTop * pSuper, RscTop * /*pClassBitmap*/, - RscTop * pClassColor, RscCont * pStrLst ) -{ - Atom nId; - RscTop * pClassImageList; - - // Klasse anlegen - nId = pHS->getID( "ImageList" ); - pClassImageList = new RscClass( nId, RSC_IMAGELIST, pSuper ); - pClassImageList->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - aNmTb.Put( nId, CLASSNAME, pClassImageList ); - - nId = aNmTb.Put( "Prefix", VARNAME ); - pClassImageList->SetVariable( nId, &aString ); - - nId = aNmTb.Put( "MaskColor", VARNAME ); - pClassImageList->SetVariable( nId, pClassColor, NULL, - VAR_SVDYNAMIC, RSC_IMAGELIST_MASKCOLOR ); - - RscCont * pCont = new RscCont( pHS->getID( "sal_uInt16 *" ), RSC_NOTYPE ); - pCont->SetTypeClass( &aIdUShort ); - aBaseLst.push_back( pCont ); - nId = aNmTb.Put( "IdList", VARNAME ); - pClassImageList->SetVariable( nId, pCont, NULL, 0, - RSC_IMAGELIST_IDLIST ); - - nId = aNmTb.Put( "FileList", VARNAME ); - pClassImageList->SetVariable( nId, pStrLst ); - - nId = aNmTb.Put( "IdCount", VARNAME ); - pClassImageList->SetVariable( nId, &aUShort, NULL, 0, - RSC_IMAGELIST_IDCOUNT ); - return( pClassImageList ); -} - -/************************************************************************* -|* RscTypCont::InitClassWindow() -*************************************************************************/ -RscTop * RscTypCont::InitClassWindow( RscTop * pSuper, RscEnum * pMapUnit, - RscArray * pLangGeo ) -{ - Atom nId; - RscTop * pClassWindow; - - // Klasse anlegen - nId = pHS->getID( "Window" ); - pClassWindow = new RscClass( nId, RSC_WINDOW, pSuper ); - pClassWindow->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassWindow ); - - // Variablen anlegen - { - RscFlag * pFlag; - RscClient * pClient; - Atom nVarId, nDisableId, nOutputSizeId; - - aBaseLst.push_back( pFlag = new RscFlag( pHS->getID( "FlagWndExtra" ), RSC_NOTYPE ) ); - - // Konstanten in Tabelle stellen - nDisableId = pHS->getID( "RSWND_DISABLE" ); - SETCONST( pFlag, nDisableId, RSWND_DISABLED ); - nOutputSizeId = pHS->getID( "RSWND_OUTPUTSIZE" ); - SETCONST( pFlag, nOutputSizeId, RSWND_CLIENTSIZE ); - - // Variable einfuegen - nVarId = aNmTb.Put( "_RscExtraFlags", VARNAME ); - pClassWindow->SetVariable( nVarId, pFlag, NULL, - VAR_HIDDEN | VAR_NOENUM ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nDisableId ) - ); - nId = aNmTb.Put( "Disable", VARNAME ); - pClassWindow->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nOutputSizeId ) - ); - nId = aNmTb.Put( "OutputSize", VARNAME ); - pClassWindow->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - } - - pClassWindow->SetVariable( nWinBitVarId, &aWinBits, NULL, - VAR_HIDDEN | VAR_NOENUM ); - - INS_WINBIT(pClassWindow,Border) - INS_WINBIT(pClassWindow,Hide) - INS_WINBIT(pClassWindow,ClipChildren) - INS_WINBIT(pClassWindow,SVLook) - InsWinBit( pClassWindow, "DialogControl", nTabControlId ); - - nId = aNmTb.Put( "HelpID", VARNAME ); - pClassWindow->SetVariable( nId, &aStringLiteral, NULL, 0, WINDOW_HELPID ); - - - nRsc_XYMAPMODEId = nId = aNmTb.Put( "_XYMapMode", VARNAME ); - pClassWindow->SetVariable( nId, pMapUnit, NULL, 0, WINDOW_XYMAPMODE ); - nRsc_X = nId = aNmTb.Put( "_X", VARNAME ); - pClassWindow->SetVariable( nId, &aLong, NULL, 0, WINDOW_X ); - nRsc_Y = nId = aNmTb.Put( "_Y", VARNAME ); - pClassWindow->SetVariable( nId, &aLong, NULL, 0, WINDOW_Y ); - - nRsc_WHMAPMODEId = nId = aNmTb.Put( "_WHMapMode", VARNAME ); - pClassWindow->SetVariable( nId, pMapUnit, NULL, 0, WINDOW_WHMAPMODE ); - nRsc_WIDTH = nId = aNmTb.Put( "_Width", VARNAME ); - pClassWindow->SetVariable( nId, &aLong, NULL, 0, WINDOW_WIDTH ); - nRsc_HEIGHT = nId = aNmTb.Put( "_Height", VARNAME ); - pClassWindow->SetVariable( nId, &aLong, NULL, 0, WINDOW_HEIGHT ); - - nRsc_DELTALANG = nId = aNmTb.Put( "DeltaLang", VARNAME ); - pClassWindow->SetVariable( nId, pLangGeo, NULL, VAR_NORC | VAR_NOENUM); - nId = aNmTb.Put( "Text", VARNAME ); - pClassWindow->SetVariable( nId, &aLangString, NULL, 0, WINDOW_TEXT ); - nId = aNmTb.Put( "HelpText", VARNAME ); - pClassWindow->SetVariable( nId, &aLangString, NULL, 0, WINDOW_HELPTEXT ); - nId = aNmTb.Put( "QuickHelpText", VARNAME ); - pClassWindow->SetVariable( nId, &aLangString, NULL, 0, WINDOW_QUICKTEXT ); - nId = aNmTb.Put( "ExtraLong", VARNAME ); - pClassWindow->SetVariable( nId, &aLong, NULL, 0, WINDOW_EXTRALONG ); - nId = aNmTb.Put( "UniqueId", VARNAME ); - pClassWindow->SetVariable( nId, &aString, NULL, 0, WINDOW_UNIQUEID ); - - // BorderStyle - RscEnum* pBorderStyleEnum = new RscEnum( pHS->getID( "WindowBorderStyle" ), RSC_NOTYPE ); - aBaseLst.push_back( pBorderStyleEnum ); - - // Konstanten in Tabelle stellen - SETCONST( pBorderStyleEnum, pHS->getID( "WINDOW_BORDER_NORMAL" ), WINDOW_BORDER_NORMAL ); - SETCONST( pBorderStyleEnum, pHS->getID( "WINDOW_BORDER_MONO" ), WINDOW_BORDER_MONO ); - SETCONST( pBorderStyleEnum, pHS->getID( "WINDOW_BORDER_ACTIVE" ), WINDOW_BORDER_ACTIVE ); - SETCONST( pBorderStyleEnum, pHS->getID( "WINDOW_BORDER_DOUBLEOUT" ), WINDOW_BORDER_DOUBLEOUT ); - SETCONST( pBorderStyleEnum, pHS->getID( "WINDOW_BORDER_MENU" ), WINDOW_BORDER_MENU ); - SETCONST( pBorderStyleEnum, pHS->getID( "WINDOW_BORDER_NOBORDER" ), WINDOW_BORDER_NOBORDER ); - - // Variable einfuegen - nId = aNmTb.Put( "BorderStyle", VARNAME ); - pClassWindow->SetVariable( nId, pBorderStyleEnum, NULL, - 0, - WINDOW_BORDER_STYLE ); - - return( pClassWindow ); -} - -/************************************************************************* -|* RscTypCont::InitClassSystemWindow() -*************************************************************************/ -RscTop * RscTypCont::InitClassSystemWindow( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassSystemWindow; - - // Klasse anlegen - nId = pHS->getID( "SystemWindow" ); - pClassSystemWindow = new RscClass( nId, RSC_SYSWINDOW, pSuper ); - pClassSystemWindow->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassSystemWindow ); - - INS_WINBIT(pClassSystemWindow,Sizeable) - INS_WINBIT(pClassSystemWindow,Moveable) - InsWinBit( pClassSystemWindow, "Minable", nMinimizeId ); - InsWinBit( pClassSystemWindow, "Maxable", nMaximizeId ); - INS_WINBIT(pClassSystemWindow,Closeable) - INS_WINBIT(pClassSystemWindow,App) - INS_WINBIT(pClassSystemWindow,SysWin) - - return pClassSystemWindow ; -} - -/************************************************************************* -|* RscTypCont::InitClassWorkWindow() -*************************************************************************/ -RscTop * RscTypCont::InitClassWorkWindow( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassWorkWindow; - - // Klasse anlegen - nId = pHS->getID( "WorkWindow" ); - pClassWorkWindow = new RscClass( nId, RSC_WORKWIN, pSuper ); - pClassWorkWindow->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassWorkWindow ); - - // Variablen anlegen - { - Atom nVarId; - RscEnum * pShow; - - aBaseLst.push_back( pShow = new RscEnum( pHS->getID( "EnumShowState" ), RSC_NOTYPE ) ); - - SETCONST( pShow, "SHOW_NORMAL", WORKWIN_SHOWNORMAL ); - SETCONST( pShow, "SHOW_MINIMIZED", WORKWIN_SHOWMINIMIZED ); - SETCONST( pShow, "SHOW_MAXIMIZED", WORKWIN_SHOWMAXIMIZED ); - - - // Variable einfuegen - nVarId = aNmTb.Put( "Show", VARNAME ); - pClassWorkWindow->SetVariable( nVarId, pShow, NULL ); - } - - return pClassWorkWindow; -} - -/************************************************************************* -|* RscTypCont::InitClassDialogBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassModalDialog( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassDialog; - - // Klasse anlegen - nId = pHS->getID( "ModalDialog" ); - pClassDialog = new RscClass( nId, RSC_MODALDIALOG, pSuper ); - pClassDialog->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassDialog ); - - InsWinBit( pClassDialog, "SysModal", nSysmodalId ); - - return pClassDialog; -} - -/************************************************************************* -|* RscTypCont::InitClassModelessDialog() -*************************************************************************/ -RscTop * RscTypCont::InitClassModelessDialog( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassDialog; - - // Klasse anlegen - nId = pHS->getID( "ModelessDialog" ); - pClassDialog = new RscClass( nId, RSC_MODELESSDIALOG, pSuper ); - pClassDialog->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassDialog ); - - return pClassDialog; -} - -/************************************************************************* -|* RscTypCont::InitClassControl() -*************************************************************************/ -RscTop * RscTypCont::InitClassControl( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassControl; - - // Klasse anlegen - nId = pHS->getID( "Control" ); - pClassControl = new RscClass( nId, RSC_CONTROL, pSuper ); - pClassControl->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassControl ); - - InsWinBit( pClassControl, "TabStop", nTabstopId ); - INS_WINBIT(pClassControl,Group) - - return pClassControl; -} - -/************************************************************************* -|* RscTypCont::InitClassCheckBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassCheckBox( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassCheckBox; - - // Klasse anlegen - nId = pHS->getID( "CheckBox" ); - pClassCheckBox = new RscClass( nId, RSC_CHECKBOX, pSuper ); - pClassCheckBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassCheckBox ); - - // Variablen anlegen - INS_WINBIT( pClassCheckBox, WordBreak ) - INS_WINBIT( pClassCheckBox, Top ) - INS_WINBIT( pClassCheckBox, VCenter ) - INS_WINBIT( pClassCheckBox, Bottom ) - - nId = aNmTb.Put( "Check", VARNAME ); - pClassCheckBox->SetVariable( nId, &aBool ); - - return pClassCheckBox; -} - -/************************************************************************* -|* RscTypCont::InitClassPushButton() -*************************************************************************/ -RscTop * RscTypCont::InitClassPushButton( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassPushButton; - - // Klasse anlegen - nId = pHS->getID( "PushButton" ); - pClassPushButton = new RscClass( nId, RSC_PUSHBUTTON, pSuper ); - pClassPushButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassPushButton ); - - InsWinBit( pClassPushButton, "DefButton", nDefaultId ); - INS_WINBIT( pClassPushButton, Top ) - INS_WINBIT( pClassPushButton, VCenter ) - INS_WINBIT( pClassPushButton, Bottom ) - - return pClassPushButton; -} - -/************************************************************************* -|* RscTypCont::InitClassTriStateBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassTriStateBox( RscTop * pSuper, - RscEnum * pTriState ) -{ - Atom nId; - RscTop * pClassTriStateBox; - - nId = pHS->getID( "TriStateBox" ); - pClassTriStateBox = new RscClass( nId, RSC_TRISTATEBOX, pSuper ); - pClassTriStateBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassTriStateBox ); - - // Variablen anlegen - nId = aNmTb.Put( "State", VARNAME ); - pClassTriStateBox->SetVariable( nId, pTriState ); - nId = aNmTb.Put( "TriStateDisable", VARNAME ); - pClassTriStateBox->SetVariable( nId, &aBool ); - - return( pClassTriStateBox ); -} - -/************************************************************************* -|* RscTypCont::InitClassMenuButton() -*************************************************************************/ -RscTop * RscTypCont::InitClassMenuButton( RscTop * pSuper, - RscTop * pClassMenu ) -{ - Atom nId; - RscTop * pClassMenuButton; - - nId = pHS->getID( "MenuButton" ); - pClassMenuButton = new RscClass( nId, RSC_MENUBUTTON, pSuper ); - pClassMenuButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassMenuButton ); - - // Variablen anlegen - nId = aNmTb.Put( "ButtonMenu", VARNAME ); - pClassMenuButton->SetVariable( nId, pClassMenu, NULL, 0, - RSCMENUBUTTON_MENU ); - - return( pClassMenuButton ); -} - - -/************************************************************************* -|* RscTypCont::InitClassImageButton() -*************************************************************************/ -RscTop * RscTypCont::InitClassImageButton( RscTop * pSuper, - RscTop * pClassImage, - RscEnum * pTriState ) -{ - Atom nId; - RscTop * pClassImageButton; - - // Klasse anlegen - nId = pHS->getID( "ImageButton" ); - pClassImageButton = new RscClass( nId, RSC_IMAGEBUTTON, pSuper ); - pClassImageButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassImageButton ); - - // Variablen anlegen - { - nId = aNmTb.Put( "ButtonImage", VARNAME ); - pClassImageButton->SetVariable( nId, pClassImage, NULL, 0, - RSC_IMAGEBUTTON_IMAGE ); - } - // Variablen anlegen - { - Atom nVarId; - RscEnum * pSymbol; - - aBaseLst.push_back( pSymbol = new RscEnum( pHS->getID( "EnumSymbolButton" ), RSC_NOTYPE ) ); - - SETCONST( pSymbol, "IMAGEBUTTON_DONTKNOW", SYMBOL_DONTKNOW ); - SETCONST( pSymbol, "IMAGEBUTTON_IMAGE", SYMBOL_IMAGE ); - SETCONST( pSymbol, "IMAGEBUTTON_ARROW_UP", SYMBOL_ARROW_UP ); - SETCONST( pSymbol, "IMAGEBUTTON_ARROW_DOWN", SYMBOL_ARROW_DOWN ); - SETCONST( pSymbol, "IMAGEBUTTON_ARROW_LEFT", SYMBOL_ARROW_LEFT ); - SETCONST( pSymbol, "IMAGEBUTTON_ARROW_RIGHT", SYMBOL_ARROW_RIGHT ); - SETCONST( pSymbol, "IMAGEBUTTON_SPIN_UP", SYMBOL_SPIN_UP ); - SETCONST( pSymbol, "IMAGEBUTTON_SPIN_DOWN", SYMBOL_SPIN_DOWN ); - SETCONST( pSymbol, "IMAGEBUTTON_SPIN_LEFT", SYMBOL_SPIN_LEFT ); - SETCONST( pSymbol, "IMAGEBUTTON_SPIN_RIGHT", SYMBOL_SPIN_RIGHT ); - SETCONST( pSymbol, "IMAGEBUTTON_FIRST", SYMBOL_FIRST ); - SETCONST( pSymbol, "IMAGEBUTTON_LAST", SYMBOL_LAST ); - SETCONST( pSymbol, "IMAGEBUTTON_PREV", SYMBOL_PREV ); - SETCONST( pSymbol, "IMAGEBUTTON_NEXT", SYMBOL_NEXT ); - SETCONST( pSymbol, "IMAGEBUTTON_PAGEUP", SYMBOL_PAGEUP ); - SETCONST( pSymbol, "IMAGEBUTTON_PAGEDOWN", SYMBOL_PAGEDOWN ); - SETCONST( pSymbol, "IMAGEBUTTON_PLAY", SYMBOL_PLAY ); - SETCONST( pSymbol, "IMAGEBUTTON_REVERSEPLAY", SYMBOL_REVERSEPLAY ); - SETCONST( pSymbol, "IMAGEBUTTON_STOP", SYMBOL_STOP ); - SETCONST( pSymbol, "IMAGEBUTTON_PAUSE", SYMBOL_PAUSE ); - SETCONST( pSymbol, "IMAGEBUTTON_WINDSTART", SYMBOL_WINDSTART ); - SETCONST( pSymbol, "IMAGEBUTTON_WINDEND", SYMBOL_WINDEND ); - SETCONST( pSymbol, "IMAGEBUTTON_WINDBACKWARD", SYMBOL_WINDBACKWARD ); - SETCONST( pSymbol, "IMAGEBUTTON_WINDFORWARD", SYMBOL_WINDFORWARD ); - - // Variable einfuegen - nVarId = aNmTb.Put( "Symbol", VARNAME ); - pClassImageButton->SetVariable( nVarId, pSymbol, NULL, 0, - RSC_IMAGEBUTTON_SYMBOL ); - } - nId = aNmTb.Put( "State", VARNAME ); - pClassImageButton->SetVariable( nId, pTriState, NULL, 0, - RSC_IMAGEBUTTON_STATE ); - - INS_WINBIT(pClassImageButton,Repeat) - INS_WINBIT(pClassImageButton,SmallStyle) - INS_WINBIT(pClassImageButton,RectStyle) - - return pClassImageButton; -} - -/************************************************************************* -|* RscTypCont::InitClassEdit() -*************************************************************************/ -RscTop * RscTypCont::InitClassEdit( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassEdit; - - // Klasse anlegen - nId = pHS->getID( "Edit" ); - pClassEdit = new RscClass( nId, RSC_EDIT, pSuper ); - pClassEdit->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassEdit ); - - INS_WINBIT(pClassEdit,Left) - INS_WINBIT(pClassEdit,Center) - INS_WINBIT(pClassEdit,Right) - INS_WINBIT(pClassEdit,PassWord) - INS_WINBIT(pClassEdit,ReadOnly) - - nId = aNmTb.Put( "MaxTextLength", VARNAME ); - pClassEdit->SetVariable( nId, &aUShort ); - - return pClassEdit; -} - -/************************************************************************* -|* RscTypCont::InitClassMultiLineedit() -*************************************************************************/ -RscTop * RscTypCont::InitClassMultiLineEdit( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassMultiLineEdit; - - // Klasse anlegen - nId = pHS->getID( "MultiLineEdit" ); - pClassMultiLineEdit = new RscClass( nId, RSC_MULTILINEEDIT, pSuper ); - pClassMultiLineEdit->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassMultiLineEdit ); - - INS_WINBIT( pClassMultiLineEdit, HScroll ); - INS_WINBIT( pClassMultiLineEdit, VScroll ); - INS_WINBIT( pClassMultiLineEdit, IgnoreTab ); - INS_WINBIT( pClassMultiLineEdit, AutoVScroll ) - - return pClassMultiLineEdit; -} - -/************************************************************************* -|* RscTypCont::InitClassScrollBar() -*************************************************************************/ -RscTop * RscTypCont::InitClassScrollBar( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassScrollBar; - - // Klasse anlegen - nId = pHS->getID( "ScrollBar" ); - pClassScrollBar = new RscClass( nId, RSC_SCROLLBAR, pSuper ); - pClassScrollBar->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassScrollBar ); - - // Variablen anlegen - nId = aNmTb.Put( "MinPos", VARNAME ); - pClassScrollBar->SetVariable( nId, &aShort ); - { - RSCINST aDfltI; - - aDfltI = aShort.Create( NULL, RSCINST(), sal_False ); - aDfltI.pClass->SetNumber( aDfltI, 100 ); -// aDfltI.pClass->MakeDefault( aDfltI ); - - nId = aNmTb.Put( "MaxPos", VARNAME ); - pClassScrollBar->SetVariable( nId, &aShort, &aDfltI ); - } - nId = aNmTb.Put( "ThumbPos", VARNAME ); - pClassScrollBar->SetVariable( nId, &aShort ); - { - RSCINST aDfltI; - - aDfltI = aShort.Create( NULL, RSCINST(), sal_False ); - aDfltI.pClass->SetNumber( aDfltI, 1 ); -// aDfltI.pClass->MakeDefault( aDfltI ); - - nId = aNmTb.Put( "PageSize", VARNAME); - pClassScrollBar->SetVariable( nId, &aShort, &aDfltI ); - } - { - RSCINST aDfltI; - - aDfltI = aShort.Create( NULL, RSCINST(), sal_False ); - aDfltI.pClass->SetNumber( aDfltI, 1 ); -// aDfltI.pClass->MakeDefault( aDfltI ); - nId = aNmTb.Put( "LineSize", VARNAME ); - pClassScrollBar->SetVariable( nId, &aShort, &aDfltI ); - } - nId = aNmTb.Put( "VisibleSize", VARNAME ); - pClassScrollBar->SetVariable( nId, &aShort ); - - INS_WINBIT( pClassScrollBar, HScroll ); - INS_WINBIT( pClassScrollBar, VScroll ); - INS_WINBIT( pClassScrollBar, Drag ) - - return pClassScrollBar; -} - -/************************************************************************* -|* RscTypCont::InitClassListBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassListBox( RscTop * pSuper, RscArray * pStrLst ) -{ - Atom nId; - RscTop * pClassListBox; - - // Klasse anlegen - nId = pHS->getID( "ListBox" ); - pClassListBox = new RscClass( nId, RSC_LISTBOX, pSuper ); - pClassListBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassListBox ); - - // Variablen anlegen - INS_WINBIT(pClassListBox,Sort) - INS_WINBIT(pClassListBox,DropDown) - INS_WINBIT(pClassListBox,HScroll); - INS_WINBIT(pClassListBox,VScroll); - INS_WINBIT(pClassListBox,AutoSize) - INS_WINBIT(pClassListBox,AutoHScroll) - INS_WINBIT(pClassListBox,DDExtraWidth) - - { - RSCINST aDflt = aUShort.Create( NULL, RSCINST(), sal_False ); - aDflt.pClass->SetNumber( aDflt, (sal_uInt16)0xFFFF ); - nId = aNmTb.Put( "CurPos", VARNAME ); - pClassListBox->SetVariable( nId, &aUShort, &aDflt ); - } - nId = aNmTb.Put( "StringList", VARNAME ); - pClassListBox->SetVariable( nId, pStrLst ); - - return pClassListBox; -} - -/************************************************************************* -|* RscTypCont::InitClassMultiListBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassMultiListBox( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassMultiListBox; - - // Klasse anlegen - nId = pHS->getID( "MultiListBox" ); - pClassMultiListBox = new RscClass( nId, RSC_MULTILISTBOX, pSuper ); - pClassMultiListBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassMultiListBox ); - - INS_WINBIT(pClassMultiListBox,SimpleMode) - - return pClassMultiListBox; -} - -/************************************************************************* -|* RscTypCont::InitClassComboBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassComboBox( RscTop * pSuper, RscArray * pStrLst ) -{ - Atom nId; - RscTop * pClassComboBox; - - // Klasse anlegen - nId = pHS->getID( "ComboBox" ); - pClassComboBox = new RscClass( nId, RSC_COMBOBOX, pSuper ); - pClassComboBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassComboBox ); - - // Variablen anlegen - INS_WINBIT(pClassComboBox,DropDown) - INS_WINBIT(pClassComboBox,Sort) - INS_WINBIT(pClassComboBox,HScroll); - INS_WINBIT(pClassComboBox,VScroll); - INS_WINBIT(pClassComboBox,AutoSize) - INS_WINBIT(pClassComboBox,AutoHScroll) - INS_WINBIT(pClassComboBox,DDExtraWidth) - - nId = aNmTb.Put( "StringList", VARNAME ); - pClassComboBox->SetVariable( nId, pStrLst ); - - return pClassComboBox; -} - -/************************************************************************* -|* RscTypCont::InitClassFixedText() -*************************************************************************/ -RscTop * RscTypCont::InitClassFixedText( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassFixedText; - - // Klasse anlegen - nId = pHS->getID( "FixedText" ); - pClassFixedText = new RscClass( nId, RSC_TEXT, pSuper ); - pClassFixedText->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassFixedText ); - - // Variablen anlegen - INS_WINBIT(pClassFixedText,Left) - INS_WINBIT(pClassFixedText,Center) - INS_WINBIT(pClassFixedText,Right) - INS_WINBIT(pClassFixedText,WordBreak) - INS_WINBIT(pClassFixedText,LeftLabel) - INS_WINBIT(pClassFixedText,NoLabel) - INS_WINBIT(pClassFixedText,Top) - INS_WINBIT(pClassFixedText,VCenter) - INS_WINBIT(pClassFixedText,Bottom) - - return pClassFixedText; -} - -/************************************************************************* -|* RscTypCont::InitClassFixedBitmap() -*************************************************************************/ -RscTop * RscTypCont::InitClassFixedBitmap( RscTop * pSuper, RscTop * pClassBitmap ) -{ - Atom nId; - RscTop * pClassFixedBitmap; - - // Klasse anlegen - nId = pHS->getID( "FixedBitmap" ); - pClassFixedBitmap = new RscClass( nId, RSC_FIXEDBITMAP, pSuper ); - pClassFixedBitmap->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassFixedBitmap ); - - INS_WINBIT(pClassFixedBitmap,Scale) - - // Variablen anlegen - nId = aNmTb.Put( "Fixed", VARNAME ); - pClassFixedBitmap->SetVariable( nId, pClassBitmap, 0, 0, RSC_FIXEDBITMAP_BITMAP ); - - return pClassFixedBitmap; -} - -/************************************************************************* -|* RscTypCont::InitClassFixedImage() -*************************************************************************/ -RscTop * RscTypCont::InitClassFixedImage( RscTop * pSuper, RscTop * pClassImage ) -{ - Atom nId; - RscTop * pClassFixedImage; - - // Klasse anlegen - nId = pHS->getID( "FixedImage" ); - pClassFixedImage = new RscClass( nId, RSC_FIXEDIMAGE, pSuper ); - pClassFixedImage->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassFixedImage ); - - // Variablen anlegen - nId = aNmTb.Put( "Fixed", VARNAME ); - pClassFixedImage->SetVariable( nId, pClassImage, 0, 0, RSC_FIXEDIMAGE_IMAGE ); - - return pClassFixedImage; -} - -/************************************************************************* -|* RscTypCont::InitClassImageRadioButton() -*************************************************************************/ -RscTop * RscTypCont::InitClassRadioButton( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassRadioButton; - - // Klasse anlegen - nId = pHS->getID( "RadioButton" ); - pClassRadioButton = new RscClass( nId, RSC_RADIOBUTTON, pSuper ); - pClassRadioButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassRadioButton ); - - // Variablen anlegen - INS_WINBIT( pClassRadioButton, WordBreak ) - INS_WINBIT( pClassRadioButton, Top ) - INS_WINBIT( pClassRadioButton, VCenter ) - INS_WINBIT( pClassRadioButton, Bottom ) - - nId = aNmTb.Put( "Check", VARNAME ); - pClassRadioButton->SetVariable( nId, &aBool ); - - return pClassRadioButton; -} - -/************************************************************************* -|* RscTypCont::InitClassImageRadioButton() -*************************************************************************/ -RscTop * RscTypCont::InitClassImageRadioButton( RscTop * pSuper, RscTop * pClassImage ) -{ - Atom nId; - RscTop * pClassImageRadioButton; - - // Klasse anlegen - nId = pHS->getID( "ImageRadioButton" ); - pClassImageRadioButton = new RscClass( nId, RSC_IMAGERADIOBUTTON, pSuper ); - pClassImageRadioButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassImageRadioButton ); - - // Variablen anlegen - INS_WINBIT(pClassImageRadioButton,TopImage) - nId = aNmTb.Put( "RadioButtonImage", VARNAME ); - pClassImageRadioButton->SetVariable( nId, pClassImage, 0, 0, RSC_IMAGERADIOBUTTON_IMAGE ); - - return pClassImageRadioButton; -} - -/************************************************************************* -|* RscTypCont::InitClassKeyCode() -*************************************************************************/ -RscTop * RscTypCont::InitClassKeyCode( RscTop * pSuper, RscEnum * pKey ) -{ - Atom nId; - RscTop * pClassKeyCode; - - // Klasse anlegen - nId = pHS->getID( "KeyCode" ); - pClassKeyCode = new RscClass( nId, RSC_KEYCODE, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassKeyCode ); - - // Variablen anlegen - nId = aNmTb.Put( "Code", VARNAME ); - pClassKeyCode->SetVariable( nId, pKey ); - - { - RscFlag * pFlag; - RscClient * pClient; - Atom nVarId, nShiftId, nMod1Id, nMod2Id; - - aBaseLst.push_back( pFlag = new RscFlag( pHS->getID( "FlagKeyModifier" ), RSC_NOTYPE ) ); - - // Konstanten in Tabelle stellen - nShiftId = pHS->getID( "KEY_SHIFT" ); - SETCONST( pFlag, nShiftId, KEY_SHIFT ); - nMod1Id = pHS->getID( "KEY_MOD1" ); - SETCONST( pFlag, nMod1Id, KEY_MOD1 ); - nMod2Id = pHS->getID( "KEY_MOD2" ); - SETCONST( pFlag, nMod2Id, KEY_MOD2 ); - - // Variable einfuegen - nVarId = aNmTb.Put( "_ModifierFlags", VARNAME ); - pClassKeyCode->SetVariable( nVarId, pFlag, NULL, - VAR_HIDDEN | VAR_NOENUM ); - - // Clientvariablen einfuegen - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nShiftId ) - ); - nId = aNmTb.Put( "Shift", VARNAME ); - pClassKeyCode->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nMod1Id ) - ); - nId = aNmTb.Put( "Modifier1", VARNAME ); - pClassKeyCode->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nMod2Id ) - ); - nId = aNmTb.Put( "Modifier2", VARNAME ); - pClassKeyCode->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - } - { - Atom nVarId; - RscEnum * pKeyFunc; - - aBaseLst.push_back( pKeyFunc = new RscEnum( pHS->getID( "EnumKeyFunc" ), RSC_NOTYPE ) ); - - SETCONST( pKeyFunc, "KEYFUNC_DONTKNOW", KEYFUNC_DONTKNOW ); - SETCONST( pKeyFunc, "KEYFUNC_NEW", KEYFUNC_NEW ); - SETCONST( pKeyFunc, "KEYFUNC_OPEN", KEYFUNC_OPEN ); - SETCONST( pKeyFunc, "KEYFUNC_SAVE", KEYFUNC_SAVE ); - SETCONST( pKeyFunc, "KEYFUNC_SAVEAS", KEYFUNC_SAVEAS ); - SETCONST( pKeyFunc, "KEYFUNC_PRINT", KEYFUNC_PRINT ); - SETCONST( pKeyFunc, "KEYFUNC_CLOSE", KEYFUNC_CLOSE ); - SETCONST( pKeyFunc, "KEYFUNC_QUIT", KEYFUNC_QUIT ); - SETCONST( pKeyFunc, "KEYFUNC_CUT", KEYFUNC_CUT ); - SETCONST( pKeyFunc, "KEYFUNC_COPY", KEYFUNC_COPY ); - SETCONST( pKeyFunc, "KEYFUNC_PASTE", KEYFUNC_PASTE ); - SETCONST( pKeyFunc, "KEYFUNC_UNDO", KEYFUNC_UNDO ); - SETCONST( pKeyFunc, "KEYFUNC_REDO", KEYFUNC_REDO ); - SETCONST( pKeyFunc, "KEYFUNC_DELETE", KEYFUNC_DELETE ); - SETCONST( pKeyFunc, "KEYFUNC_REPEAT", KEYFUNC_REPEAT ); - SETCONST( pKeyFunc, "KEYFUNC_FIND", KEYFUNC_FIND ); - SETCONST( pKeyFunc, "KEYFUNC_PROPERTIES", KEYFUNC_PROPERTIES ); - SETCONST( pKeyFunc, "KEYFUNC_FRONT", KEYFUNC_FRONT ); - SETCONST( pKeyFunc, "KEYFUNC_FINDBACKWARD", KEYFUNC_FINDBACKWARD ); - // Variable einfuegen - nVarId = aNmTb.Put( "Function", VARNAME ); - pClassKeyCode->SetVariable( nVarId, pKeyFunc, NULL ); - } - - return pClassKeyCode; -} - -/************************************************************************* -|* RscTypCont::InitClassAccelItem() -*************************************************************************/ -RscTop * RscTypCont::InitClassAccelItem( RscTop * pSuper, - RscTop * pClassKeyCode ) -{ - Atom nId; - RscTop * pClassAccelItem; - - // Klasse anlegen - nId = pHS->getID( "AcceleratorItem" ); - pClassAccelItem = new RscClass( nId, RSC_ACCELITEM, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassAccelItem ); - - // Variablen anlegen - nId = aNmTb.Put( "Identifier", VARNAME ); - pClassAccelItem->SetVariable( nId, &aIdNoZeroUShort ); - nId = aNmTb.Put( "Disable", VARNAME ); - pClassAccelItem->SetVariable( nId, &aBool ); - nId = aNmTb.Put( "Key", VARNAME ); - pClassAccelItem->SetVariable( nId, pClassKeyCode, NULL, 0, - ACCELITEM_KEY ); - - return pClassAccelItem; -} - -/************************************************************************* -|* RscTypCont::InitClassAccelm() -*************************************************************************/ -RscTop * RscTypCont::InitClassAccel( RscTop * pSuper, RscTop * pClassAccelItem ) -{ - Atom nId; - RscTop * pClassAccel; - - // Klasse anlegen - nId = pHS->getID( "Accelerator" ); - pClassAccel = new RscClass( nId, RSC_ACCEL, pSuper ); - pClassAccel->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - aNmTb.Put( nId, CLASSNAME, pClassAccel ); - - // Variablen anlegen - nId = aNmTb.Put( "HelpText", VARNAME ); - pClassAccel->SetVariable( nId, &aLangString ); - { - RscCont * pCont; - - aBaseLst.push_back( - pCont = new RscCont( pHS->getID( "ContAcceleratorKey" ), RSC_NOTYPE ) - ); - pCont->SetTypeClass( pClassAccelItem ); - nId = aNmTb.Put( "ItemList", VARNAME ); - pClassAccel->SetVariable( nId, pCont ); - } - - return pClassAccel; -} - -/************************************************************************* -|* RscTypCont::InitClassMenuItem() -*************************************************************************/ -RscTop * RscTypCont::InitClassMenuItem( RscTop * pSuper, - RscTop * pClassBitmap, - RscTop * pClassKeyCode ) -{ - Atom nId; - RscTop * pClassMenuItem; - - // Klasse anlegen - nId = pHS->getID( "MenuItem" ); - pClassMenuItem = new RscClass( nId, RSC_MENUITEM, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassMenuItem ); - - // Variablen anlegen - nId = aNmTb.Put( "Separator", VARNAME ); - pClassMenuItem->SetVariable( nId, &aBool, NULL, 0, - RSC_MENUITEM_SEPARATOR ); - nId = aNmTb.Put( "Identifier", VARNAME ); - pClassMenuItem->SetVariable( nId, &aIdNoZeroUShort, NULL, 0, - RSC_MENUITEM_ID ); - { - RscFlag * pFlag; - RscClient * pClient; - Atom nVarId, nAutoCheckId, nRadioCheckId; - Atom nCheckableId, nAboutId, nHelpId; - - aBaseLst.push_back( pFlag = new RscFlag( pHS->getID( "FlagMenuState" ), RSC_NOTYPE ) ); - - // Konstanten in Tabelle stellen - nCheckableId = pHS->getID( "MIB_CHECKABLE" ); - SETCONST( pFlag, nCheckableId, MIB_CHECKABLE ); - nAutoCheckId = pHS->getID( "MIB_AUTOCHECK" ); - SETCONST( pFlag, nAutoCheckId, MIB_AUTOCHECK ); - nRadioCheckId = pHS->getID( "MIB_RADIOCHECK" ); - SETCONST( pFlag, nRadioCheckId, MIB_RADIOCHECK ); - nAboutId = pHS->getID( "MIB_ABOUT" ); - SETCONST( pFlag, nAboutId, MIB_ABOUT ); - nHelpId = pHS->getID( "MIB_HELP" ); - SETCONST( pFlag, nHelpId, MIB_HELP ); - - // Variable einfuegen - nVarId = aNmTb.Put( "_MenuItemFlags", VARNAME ); - pClassMenuItem->SetVariable( nVarId, pFlag, NULL, - VAR_HIDDEN | VAR_NOENUM, - RSC_MENUITEM_STATUS ); - - // Clientvariablen einfuegen - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nCheckableId ) - ); - nId = aNmTb.Put( "Checkable", VARNAME ); - pClassMenuItem->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nAutoCheckId ) - ); - nId = aNmTb.Put( "AutoCheck", VARNAME ); - pClassMenuItem->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nRadioCheckId ) - ); - nId = aNmTb.Put( "RadioCheck", VARNAME ); - pClassMenuItem->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nAboutId ) - ); - nId = aNmTb.Put( "About", VARNAME ); - pClassMenuItem->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, nHelpId ) - ); - nId = aNmTb.Put( "Help", VARNAME ); - pClassMenuItem->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nVarId ); - - } - nId = aNmTb.Put( "Text", VARNAME ); - pClassMenuItem->SetVariable( nId, &aLangString, NULL, 0, - RSC_MENUITEM_TEXT ); - nId = aNmTb.Put( "ItemBitmap", VARNAME ); - pClassMenuItem->SetVariable( nId, pClassBitmap, NULL, 0, - RSC_MENUITEM_BITMAP ); - nId = aNmTb.Put( "HelpText", VARNAME ); - pClassMenuItem->SetVariable( nId, &aLangString, NULL, 0, - RSC_MENUITEM_HELPTEXT ); - nId = aNmTb.Put( "HelpID", VARNAME ); - pClassMenuItem->SetVariable( nId, &aStringLiteral, NULL, 0, - RSC_MENUITEM_HELPID ); - nId = aNmTb.Put( "AccelKey", VARNAME ); - pClassMenuItem->SetVariable( nId, pClassKeyCode, NULL, 0, - RSC_MENUITEM_KEYCODE ); - nId = aNmTb.Put( "Check", VARNAME ); - pClassMenuItem->SetVariable( nId, &aBool, NULL, 0, - RSC_MENUITEM_CHECKED ); - nId = aNmTb.Put( "Disable", VARNAME ); - pClassMenuItem->SetVariable( nId, &aBool, NULL, 0, - RSC_MENUITEM_DISABLE ); - nId = aNmTb.Put( "Command", VARNAME ); - pClassMenuItem->SetVariable( nId, &aString, NULL, 0, - RSC_MENUITEM_COMMAND ); - - return pClassMenuItem; -} - -/************************************************************************* -|* RscTypCont::InitClassMenu() -*************************************************************************/ -RscTop * RscTypCont::InitClassMenu( RscTop * pSuper, - RscTop * pClassMenuItem ) -{ - Atom nId; - RscTop * pClassMenu; - - // Klasse anlegen - nId = pHS->getID( "Menu" ); - pClassMenu = new RscClass( nId, RSC_MENU, pSuper ); - pClassMenu->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - aNmTb.Put( nId, CLASSNAME, pClassMenu ); - - // Variablen anlegen - { - RscCont * pCont; - - aBaseLst.push_back( pCont = new RscCont( pHS->getID( "ContMenuItem" ), RSC_NOTYPE ) ); - pCont->SetTypeClass( pClassMenuItem ); - nId = aNmTb.Put( "ItemList", VARNAME ); - pClassMenu->SetVariable( nId, pCont, NULL, 0, RSC_MENU_ITEMS ); - } - nId = aNmTb.Put( "Text", VARNAME ); - pClassMenu->SetVariable( nId, &aLangString, NULL, 0, RSC_MENU_TEXT ); - nId = aNmTb.Put( "DefaultItemId", VARNAME ); - pClassMenu->SetVariable( nId, &aIdUShort, NULL, 0, - RSC_MENU_DEFAULTITEMID ); - - return pClassMenu; -} - -/************************************************************************* -|* RscTypCont::InitClassMessageBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassMessBox( RscTop * pSuper, - RscEnum * pMessButtons, - RscEnum * pMessDefButton ) -{ - Atom nId; - RscTop * pClassMessBox; - - // Klasse anlegen - nId = pHS->getID( "MessBox" ); - pClassMessBox = new RscClass( nId, RSC_MESSBOX, pSuper ); - pClassMessBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassMessBox ); - - // Variablen anlegen - nId = aNmTb.Put( "Buttons", VARNAME ); - pClassMessBox->SetVariable( nId, pMessButtons ); - nId = aNmTb.Put( "DefButton", VARNAME ); - pClassMessBox->SetVariable( nId, pMessDefButton ); - nId = aNmTb.Put( "HelpID", VARNAME ); - pClassMessBox->SetVariable( nId, &aStringLiteral ); - nId = aNmTb.Put( "SysModal", VARNAME ); - pClassMessBox->SetVariable( nId, &aBool ); - nId = aNmTb.Put( "Title", VARNAME ); - pClassMessBox->SetVariable( nId, &aLangString ); - nId = aNmTb.Put( "Message", VARNAME ); - pClassMessBox->SetVariable( nId, &aLangString ); - nId = aNmTb.Put( "HelpText", VARNAME ); - pClassMessBox->SetVariable( nId, &aLangString ); - - return pClassMessBox; -} - -/************************************************************************* -|* RscTypCont::InitClassSplitter() -*************************************************************************/ -RscTop * RscTypCont::InitClassSplitter( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassSplitter; - - // Klasse anlegen - nId = pHS->getID( "Splitter" ); - pClassSplitter = new RscClass( nId, RSC_SPLITTER, pSuper ); - pClassSplitter->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassSplitter ); - - INS_WINBIT(pClassSplitter,HScroll); - INS_WINBIT(pClassSplitter,VScroll); - - return pClassSplitter; -} - -/************************************************************************* -|* RscTypCont::InitClassSplitWindow() -*************************************************************************/ -RscTop * RscTypCont::InitClassSplitWindow( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassSplitWindow; - - // Klasse anlegen - nId = pHS->getID( "SplitWindow" ); - pClassSplitWindow = new RscClass( nId, RSC_SPLITWINDOW, pSuper ); - pClassSplitWindow->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassSplitWindow ); - - INS_WINBIT(pClassSplitWindow,Sizeable) - INS_WINBIT(pClassSplitWindow,NoSplitDraw) - - return pClassSplitWindow; -} - -/************************************************************************* -|* RscTypCont::InitClassTime() -*************************************************************************/ -RscTop * RscTypCont::InitClassTime( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassTime; - - // Klasse anlegen - nId = pHS->getID( "Time" ); - pClassTime = new RscClass( nId, RSC_TIME, pSuper ); - pClassTime->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - aNmTb.Put( nId, CLASSNAME, pClassTime ); - - // Variablen anlegen - nId = aNmTb.Put( "Hour", VARNAME ); - pClassTime->SetVariable( nId, &a0to23Short, NULL, 0, TIME_HOUR ); - - nId = aNmTb.Put( "Minute", VARNAME ); - pClassTime->SetVariable( nId, &a0to59Short, NULL, 0, TIME_MINUTE ); - - nId = aNmTb.Put( "Second", VARNAME ); - pClassTime->SetVariable( nId, &a0to59Short, NULL, 0, TIME_SECOND ); - - nId = aNmTb.Put( "Sec100", VARNAME ); // weiss noch nich - pClassTime->SetVariable( nId, &a0to99Short, NULL, 0, TIME_SEC100 ); - - return pClassTime; -} - -/************************************************************************* -|* RscTypCont::InitClassDate() -*************************************************************************/ -RscTop * RscTypCont::InitClassDate( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassDate; - - // Klasse anlegen - nId = pHS->getID( "Date" ); - pClassDate = new RscClass( nId, RSC_DATE, pSuper ); - pClassDate->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - aNmTb.Put( nId, CLASSNAME, pClassDate ); - - // Variablen anlegen - nId = aNmTb.Put( "Year", VARNAME ); - pClassDate->SetVariable( nId, &a0to9999Short, NULL, 0, DATE_YEAR ); - - nId = aNmTb.Put( "Month", VARNAME ); - pClassDate->SetVariable( nId, &a1to12Short, NULL, 0, DATE_MONTH ); - - nId = aNmTb.Put( "Day", VARNAME ); - pClassDate->SetVariable( nId, &a1to31Short, NULL, 0, DATE_DAY ); - - return pClassDate; -} - -/************************************************************************* -|* RscTypCont::InitClassPatternFormatter() -*************************************************************************/ -RscTop * RscTypCont::InitClassPatternFormatter( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassPattern; - - // Klasse anlegen - nId = pHS->getID( "PatternFormatter" ); - pClassPattern = new RscClass( nId, RSC_NOTYPE, pSuper ); - pClassPattern->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - // Variablen anlegen - nId = aNmTb.Put( "StrictFormat", VARNAME ); - pClassPattern->SetVariable( nId, &aBool, NULL, - 0, PATTERNFORMATTER_STRICTFORMAT ); - nId = aNmTb.Put( "EditMask", VARNAME ); - pClassPattern->SetVariable( nId, &aLangString, NULL, - 0, PATTERNFORMATTER_EDITMASK ); - nId = aNmTb.Put( "LiteralMask", VARNAME ); - pClassPattern->SetVariable( nId, &aLangString, NULL, - 0, PATTERNFORMATTER_LITTERALMASK ); - - return pClassPattern; -} - -/************************************************************************* -|* RscTypCont::InitClassNumericFormatter() -*************************************************************************/ -RscTop * RscTypCont::InitClassNumericFormatter( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassNumeric; - - // Klasse anlegen - nId = pHS->getID( "NumericFormatter" ); - pClassNumeric = new RscClass( nId, RSC_NOTYPE, pSuper ); - pClassNumeric->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - // Variablen anlegen - nId = aNmTb.Put( "Minimum", VARNAME ); - pClassNumeric->SetVariable( nId, &aIdLong, NULL, - 0, NUMERICFORMATTER_MIN ); - nId = aNmTb.Put( "Maximum", VARNAME ); - pClassNumeric->SetVariable( nId, &aIdLong, NULL, - 0, NUMERICFORMATTER_MAX ); - nId = aNmTb.Put( "StrictFormat", VARNAME ); - pClassNumeric->SetVariable( nId, &aBool, NULL, - 0, NUMERICFORMATTER_STRICTFORMAT ); - nId = aNmTb.Put( "DecimalDigits", VARNAME ); - pClassNumeric->SetVariable( nId, &aUShort, NULL, - 0, NUMERICFORMATTER_DECIMALDIGITS ); - nId = aNmTb.Put( "Value", VARNAME ); - pClassNumeric->SetVariable( nId, &aIdLong, NULL, - 0, NUMERICFORMATTER_VALUE ); - nId = aNmTb.Put( "NoThousandSep", VARNAME ); - pClassNumeric->SetVariable( nId, &aBool, NULL, - 0, NUMERICFORMATTER_NOTHOUSANDSEP ); - - return pClassNumeric; -} - -/************************************************************************* -|* RscTypCont::InitClassMetricFormatter() -*************************************************************************/ -RscTop * RscTypCont::InitClassMetricFormatter( RscTop * pSuper, - RscEnum * pFieldUnits ) -{ - Atom nId; - RscTop * pClassMetric; - - // Klasse anlegen - nId = pHS->getID( "MetricFormatter" ); - pClassMetric = new RscClass( nId, RSC_NOTYPE, pSuper ); - pClassMetric->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - // Variablen anlegen - nId = aNmTb.Put( "Unit", VARNAME ); - pClassMetric->SetVariable( nId, pFieldUnits, NULL, - 0, METRICFORMATTER_UNIT ); - nId = aNmTb.Put( "CustomUnitText", VARNAME ); - pClassMetric->SetVariable( nId, &aLangString, NULL, - 0, METRICFORMATTER_CUSTOMUNITTEXT ); - - return pClassMetric; -} - -/************************************************************************* -|* RscTypCont::InitClassCurrencyFormatter() -*************************************************************************/ -RscTop * RscTypCont::InitClassCurrencyFormatter -( - RscTop * pSuper, - RscEnum * /* pFieldUnits */) -{ - Atom nId; - RscTop * pClassCurrency; - - // Klasse anlegen - nId = pHS->getID( "CurrencyFormatter" ); - pClassCurrency = new RscClass( nId, RSC_NOTYPE, pSuper ); - pClassCurrency->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - return pClassCurrency; -} - -/************************************************************************* -|* RscTypCont::InitClassDateFormatter() -*************************************************************************/ -RscTop * RscTypCont::InitClassDateFormatter( RscTop * pSuper, - RscTop * pClassDate ) -{ - Atom nId; - RscTop * pClassDateF; - - // Klasse anlegen - nId = pHS->getID( "DateFormatter" ); - pClassDateF = new RscClass( nId, RSC_NOTYPE, pSuper ); - pClassDateF->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - // Variablen anlegen - nId = aNmTb.Put( "Minimum", VARNAME ); - pClassDateF->SetVariable( nId, pClassDate, NULL, - 0, DATEFORMATTER_MIN ); - nId = aNmTb.Put( "Maximum", VARNAME ); - pClassDateF->SetVariable( nId, pClassDate, NULL, - 0, DATEFORMATTER_MAX ); - nId = aNmTb.Put( "LongFormat", VARNAME ); - pClassDateF->SetVariable( nId, &aBool, NULL, - 0, DATEFORMATTER_LONGFORMAT ); - nId = aNmTb.Put( "StrictFormat", VARNAME ); - pClassDateF->SetVariable( nId, &aBool, NULL, - 0, DATEFORMATTER_STRICTFORMAT ); - nId = aNmTb.Put( "Value", VARNAME ); - pClassDateF->SetVariable( nId, pClassDate, NULL, - 0, DATEFORMATTER_VALUE ); - - return pClassDateF; -} - -/************************************************************************* -|* RscTypCont::InitClassTimeFormatter() -*************************************************************************/ -RscTop * RscTypCont::InitClassTimeFormatter( RscTop * pSuper, - RscTop * pClassTime, - RscEnum * pTimeFieldFormat ) -{ - Atom nId; - RscTop * pClassTimeF; - - // Klasse anlegen - nId = pHS->getID( "TimeFormatter" ); - pClassTimeF = new RscClass( nId, RSC_NOTYPE, pSuper ); - pClassTimeF->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - - // Variablen anlegen - nId = aNmTb.Put( "Minimum", VARNAME ); - pClassTimeF->SetVariable( nId, pClassTime, NULL, - 0, TIMEFORMATTER_MIN ); - nId = aNmTb.Put( "Maximum", VARNAME ); - pClassTimeF->SetVariable( nId, pClassTime, NULL, - 0, TIMEFORMATTER_MAX ); - nId = aNmTb.Put( "Format", VARNAME ); - pClassTimeF->SetVariable( nId, pTimeFieldFormat, NULL, - 0, TIMEFORMATTER_TIMEFIELDFORMAT ); - nId = aNmTb.Put( "Duration", VARNAME ); - pClassTimeF->SetVariable( nId, &aBool, NULL, - 0, TIMEFORMATTER_DURATION ); - nId = aNmTb.Put( "StrictFormat", VARNAME ); - pClassTimeF->SetVariable( nId, &aBool, NULL, - 0, TIMEFORMATTER_STRICTFORMAT ); - nId = aNmTb.Put( "Value", VARNAME ); - pClassTimeF->SetVariable( nId, pClassTime, NULL, - 0, TIMEFORMATTER_VALUE ); - - return pClassTimeF; -} - -/************************************************************************* -|* RscTypCont::InitClassSpinField() -*************************************************************************/ -RscTop * RscTypCont::InitClassSpinField( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassSpinField; - - // Klasse anlegen - nId = pHS->getID( "SpinField" ); - pClassSpinField = new RscClass( nId, RSC_SPINFIELD, pSuper ); - pClassSpinField->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassSpinField ); - - INS_WINBIT(pClassSpinField,Repeat) - INS_WINBIT(pClassSpinField,Spin) - - return pClassSpinField; -} - -/************************************************************************* -|* RscTypCont::InitClassPatternField() -*************************************************************************/ -RscTop * RscTypCont::InitClassPatternField( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassPatternField; - - // Klasse anlegen - nId = pHS->getID( "PatternField" ); - pClassPatternField = new RscClass( nId, RSC_PATTERNFIELD, pSuper ); - pClassPatternField->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassPatternField ); - - return pClassPatternField; -} - -/************************************************************************* -|* RscTypCont::InitClassNumericField() -*************************************************************************/ -RscTop * RscTypCont::InitClassNumericField( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassNumericField; - - // Klasse anlegen - nId = pHS->getID( "NumericField" ); - pClassNumericField = new RscClass( nId, RSC_NUMERICFIELD, pSuper ); - pClassNumericField->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassNumericField ); - - // Variablen anlegen - nId = aNmTb.Put( "First", VARNAME ); - pClassNumericField->SetVariable( nId, &aIdLong, NULL, - 0, NUMERICFIELD_FIRST ); - nId = aNmTb.Put( "Last", VARNAME ); - pClassNumericField->SetVariable( nId, &aIdLong, NULL, - 0, NUMERICFIELD_LAST ); - nId = aNmTb.Put( "SpinSize", VARNAME ); - pClassNumericField->SetVariable( nId, &aIdLong, NULL, - 0, NUMERICFIELD_SPINSIZE ); - return pClassNumericField; -} - -/************************************************************************* -|* RscTypCont::InitClassMetricField() -*************************************************************************/ -RscTop * RscTypCont::InitClassMetricField( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassMetricField; - - // Klasse anlegen - nId = pHS->getID( "MetricField" ); - pClassMetricField = new RscClass( nId, RSC_METRICFIELD, pSuper ); - pClassMetricField->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassMetricField ); - - // Variablen anlegen - nId = aNmTb.Put( "First", VARNAME ); - pClassMetricField->SetVariable( nId, &aIdLong, NULL, - 0, METRICFIELD_FIRST ); - nId = aNmTb.Put( "Last", VARNAME ); - pClassMetricField->SetVariable( nId, &aIdLong, NULL, - 0, METRICFIELD_LAST ); - nId = aNmTb.Put( "SpinSize", VARNAME ); - pClassMetricField->SetVariable( nId, &aIdLong, NULL, - 0, METRICFIELD_SPINSIZE ); - - return pClassMetricField; -} - -/************************************************************************* -|* RscTypCont::InitClassCurrencyField() -*************************************************************************/ -RscTop * RscTypCont::InitClassCurrencyField -( - const char * pClassName, - sal_uInt32 nRT, - RscTop * pSuper -) -{ - Atom nId; - RscTop * pClassCurrencyField; - - // Klasse anlegen - nId = pHS->getID( pClassName ); - pClassCurrencyField = new RscClass( nId, nRT, pSuper ); - pClassCurrencyField->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassCurrencyField ); - - // Variablen anlegen - nId = aNmTb.Put( "First", VARNAME ); - pClassCurrencyField->SetVariable( nId, &aIdLong, NULL, - 0, CURRENCYFIELD_FIRST ); - nId = aNmTb.Put( "Last", VARNAME ); - pClassCurrencyField->SetVariable( nId, &aIdLong, NULL, - 0, CURRENCYFIELD_LAST ); - nId = aNmTb.Put( "SpinSize", VARNAME ); - pClassCurrencyField->SetVariable( nId, &aIdLong, NULL, - 0, CURRENCYFIELD_SPINSIZE ); - - return pClassCurrencyField; -} - -/************************************************************************* -|* RscTypCont::InitClassDateField() -*************************************************************************/ -RscTop * RscTypCont::InitClassDateField( RscTop * pSuper, RscTop * pClassDate ) -{ - Atom nId; - RscTop * pClassDateField; - - // Klasse anlegen - nId = pHS->getID( "DateField" ); - pClassDateField = new RscClass( nId, RSC_DATEFIELD, pSuper ); - pClassDateField->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassDateField ); - - // Variablen anlegen - nId = aNmTb.Put( "First", VARNAME ); - pClassDateField->SetVariable( nId, pClassDate, NULL, 0, DATEFIELD_FIRST ); - nId = aNmTb.Put( "Last", VARNAME ); - pClassDateField->SetVariable( nId, pClassDate, NULL, 0, DATEFIELD_LAST ); - - return pClassDateField; -} - -/************************************************************************* -|* RscTypCont::InitClassTimeField() -*************************************************************************/ -RscTop * RscTypCont::InitClassTimeField( RscTop * pSuper, RscTop * pClassTime ) -{ - Atom nId; - RscTop * pClassTimeField; - - // Klasse anlegen - nId = pHS->getID( "TimeField" ); - pClassTimeField = new RscClass( nId, RSC_TIMEFIELD, pSuper ); - pClassTimeField->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassTimeField ); - - // Variablen anlegen - nId = aNmTb.Put( "First", VARNAME ); - pClassTimeField->SetVariable( nId, pClassTime, NULL, 0, TIMEFIELD_FIRST ); - nId = aNmTb.Put( "Last", VARNAME ); - pClassTimeField->SetVariable( nId, pClassTime, NULL, 0, TIMEFIELD_LAST ); - - return pClassTimeField; -} - -/************************************************************************* -|* RscTypCont::InitClassPatternBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassPatternBox( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassPatternBox; - - // Klasse anlegen - nId = pHS->getID( "PatternBox" ); - pClassPatternBox = new RscClass( nId, RSC_PATTERNBOX, pSuper ); - pClassPatternBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassPatternBox ); - - return pClassPatternBox; -} - -/************************************************************************* -|* RscTypCont::InitClassNumericBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassNumericBox( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassNumericBox; - - // Klasse anlegen - nId = pHS->getID( "NumericBox" ); - pClassNumericBox = new RscClass( nId, RSC_NUMERICBOX, pSuper ); - pClassNumericBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassNumericBox ); - - // Variablen anlegen - - return pClassNumericBox; -} - -/************************************************************************* -|* RscTypCont::InitClassMetricBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassMetricBox( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassMetricBox; - - // Klasse anlegen - nId = pHS->getID( "MetricBox" ); - pClassMetricBox = new RscClass( nId, RSC_METRICBOX, pSuper ); - pClassMetricBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassMetricBox ); - - // Variablen anlegen - - return pClassMetricBox; -} - -/************************************************************************* -|* RscTypCont::InitClassCurrencyBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassCurrencyBox -( - const char * pClassName, - sal_uInt32 nRT, - RscTop * pSuper -) -{ - Atom nId; - RscTop * pClassCurrencyBox; - - // Klasse anlegen - nId = pHS->getID( pClassName ); - pClassCurrencyBox = new RscClass( nId, nRT, pSuper ); - pClassCurrencyBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassCurrencyBox ); - - // Variablen anlegen - - return pClassCurrencyBox; -} - -/************************************************************************* -|* RscTypCont::InitClassDateBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassDateBox( RscTop * pSuper, - RscTop * /*pClassDate*/ ) -{ - Atom nId; - RscTop * pClassDateBox; - - // Klasse anlegen - nId = pHS->getID( "DateBox" ); - pClassDateBox = new RscClass( nId, RSC_DATEBOX, pSuper ); - pClassDateBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassDateBox ); - - // Variablen anlegen - - return pClassDateBox; -} - -/************************************************************************* -|* RscTypCont::InitClassTimeBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassTimeBox( RscTop * pSuper, - RscTop * /*pClassTime*/ ) -{ - Atom nId; - RscTop * pClassTimeBox; - - // Klasse anlegen - nId = pHS->getID( "TimeBox" ); - pClassTimeBox = new RscClass( nId, RSC_TIMEBOX, pSuper ); - pClassTimeBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - aNmTb.Put( nId, CLASSNAME, pClassTimeBox ); - - // Variablen anlegen - - return pClassTimeBox; -} - -/************************************************************************* -|* RscTypCont::InitClassDockWindow() -*************************************************************************/ -RscTop * RscTypCont::InitClassDockingWindow( RscTop * pSuper, - RscEnum * pMapUnit ) -{ - Atom nId; - RscTop * pClassDockWindow; - - // Klasse anlegen - nId = pHS->getID( "DockingWindow" ); - pClassDockWindow = new RscClass( nId, RSC_DOCKINGWINDOW, pSuper ); - pClassDockWindow->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassDockWindow ); - - // Variablen anlegen - nId = aNmTb.Put( "_FloatingPosMapMode", VARNAME ); - pClassDockWindow->SetVariable( nId, pMapUnit, NULL, 0, - RSC_DOCKINGWINDOW_XYMAPMODE ); - nId = aNmTb.Put( "_FloatingPosX", VARNAME ); - pClassDockWindow->SetVariable( nId, &aShort, NULL, 0, - RSC_DOCKINGWINDOW_X ); - nId = aNmTb.Put( "_FloatingPosY", VARNAME ); - pClassDockWindow->SetVariable( nId, &aShort, NULL, 0, - RSC_DOCKINGWINDOW_Y ); - nId = aNmTb.Put( "FloatingMode", VARNAME ); - pClassDockWindow->SetVariable( nId, &aBool, NULL, 0, - RSC_DOCKINGWINDOW_FLOATING ); - - INS_WINBIT(pClassDockWindow,Moveable) - INS_WINBIT(pClassDockWindow,Sizeable) - INS_WINBIT(pClassDockWindow,EnableResizing) - INS_WINBIT(pClassDockWindow,Closeable) - INS_WINBIT(pClassDockWindow,HideWhenDeactivate); - INS_WINBIT(pClassDockWindow,Zoomable); - INS_WINBIT(pClassDockWindow,Dockable); - - return pClassDockWindow; -} - -/************************************************************************* -|* RscTypCont::InitClassToolBoxItem() -*************************************************************************/ -RscTop * RscTypCont::InitClassToolBoxItem( RscTop * pSuper, - RscTop * pClassBitmap, - RscTop * pClassImage, - RscEnum * pTriState ) -{ - Atom nId; - RscTop * pClassToolBoxItem; - - // Klasse anlegen - nId = pHS->getID( "ToolBoxItem" ); - pClassToolBoxItem = new RscClass( nId, RSC_TOOLBOXITEM, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassToolBoxItem ); - - // Variablen anlegen - nId = aNmTb.Put( "Identifier", VARNAME ); - pClassToolBoxItem->SetVariable( nId, &aIdNoZeroUShort, NULL, 0, - RSC_TOOLBOXITEM_ID ); - { - RscEnum * pEnum; - - aBaseLst.push_back( pEnum = new RscEnum( pHS->getID( "EnumToolBoxItemType" ), RSC_NOTYPE ) ); - SETCONST( pEnum, "TOOLBOXITEM_BUTTON", TOOLBOXITEM_BUTTON ); - SETCONST( pEnum, "TOOLBOXITEM_SPACE", TOOLBOXITEM_SPACE ); - SETCONST( pEnum, "TOOLBOXITEM_SEPARATOR", TOOLBOXITEM_SEPARATOR ); - SETCONST( pEnum, "TOOLBOXITEM_BREAK", TOOLBOXITEM_BREAK ); - - // Variable einfuegen - nId = aNmTb.Put( "Type", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pEnum, NULL, 0, - RSC_TOOLBOXITEM_TYPE ); - } - { - RscFlag * pFlag; - RscClient * pClient; - Atom l_nVarId, l_nAutoCheckId, l_nRadioCheckId, l_nCheckableId, l_nLeftId, l_nAutoSizeId, l_nDropDownId; - - aBaseLst.push_back( pFlag = new RscFlag( pHS->getID( "FlagToolBoxState" ), RSC_NOTYPE ) ); - - // Konstanten in Tabelle stellen - l_nCheckableId = pHS->getID( "TIB_CHECKABLE" ); - SETCONST( pFlag, l_nCheckableId, TIB_CHECKABLE ); - l_nAutoCheckId = pHS->getID( "TIB_AUTOCHECK" ); - SETCONST( pFlag, l_nAutoCheckId, TIB_AUTOCHECK ); - l_nRadioCheckId = pHS->getID( "TIB_RADIOCHECK" ); - SETCONST( pFlag, l_nRadioCheckId, TIB_RADIOCHECK ); - l_nLeftId = pHS->getID( "TIB_LEFT" ); - SETCONST( pFlag, l_nLeftId, TIB_LEFT ); - l_nAutoSizeId = pHS->getID( "TIB_AUTOSIZE" ); - SETCONST( pFlag, l_nAutoSizeId, TIB_AUTOSIZE ); - l_nDropDownId = pHS->getID( "TIB_DROPDOWN" ); - SETCONST( pFlag, l_nDropDownId, TIB_DROPDOWN ); - - // Variable einfuegen - l_nVarId = aNmTb.Put( "_ToolBoxItemFlags", VARNAME ); - pClassToolBoxItem->SetVariable( l_nVarId, pFlag, NULL, - VAR_HIDDEN | VAR_NOENUM, - RSC_TOOLBOXITEM_STATUS ); - - // Clientvariablen einfuegen - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, l_nCheckableId ) - ); - nId = aNmTb.Put( "Checkable", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pClient, NULL, VAR_NODATAINST, 0, l_nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, l_nAutoCheckId ) - ); - nId = aNmTb.Put( "AutoCheck", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pClient, NULL, VAR_NODATAINST, 0, l_nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, l_nRadioCheckId ) - ); - nId = aNmTb.Put( "RadioCheck", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pClient, NULL, VAR_NODATAINST, 0, l_nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, l_nLeftId ) - ); - nId = aNmTb.Put( "Left", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pClient, NULL, VAR_NODATAINST, 0, l_nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, l_nAutoSizeId ) - ); - nId = aNmTb.Put( "AutoSize", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pClient, NULL, VAR_NODATAINST, 0, l_nVarId ); - - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, pFlag, l_nDropDownId ) - ); - nId = aNmTb.Put( "DropDown", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pClient, NULL, VAR_NODATAINST, 0, l_nVarId ); - } - nId = aNmTb.Put( "HelpID", VARNAME ); - pClassToolBoxItem->SetVariable( nId, &aStringLiteral, NULL, 0, - RSC_TOOLBOXITEM_HELPID ); - nId = aNmTb.Put( "Text", VARNAME ); - pClassToolBoxItem->SetVariable( nId, &aLangString, NULL, 0, - RSC_TOOLBOXITEM_TEXT ); - nId = aNmTb.Put( "HelpText", VARNAME ); - pClassToolBoxItem->SetVariable( nId, &aLangString, NULL, 0, - RSC_TOOLBOXITEM_HELPTEXT ); - nId = aNmTb.Put( "ItemBitmap", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pClassBitmap, NULL, 0, - RSC_TOOLBOXITEM_BITMAP ); - nId = aNmTb.Put( "ItemImage", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pClassImage, NULL, 0, - RSC_TOOLBOXITEM_IMAGE ); - nId = aNmTb.Put( "Disable", VARNAME ); - pClassToolBoxItem->SetVariable( nId, &aBool, NULL, 0, - RSC_TOOLBOXITEM_DISABLE ); - - nId = aNmTb.Put( "State", VARNAME ); - pClassToolBoxItem->SetVariable( nId, pTriState, NULL, 0, - RSC_TOOLBOXITEM_STATE ); - nId = aNmTb.Put( "Hide", VARNAME ); - pClassToolBoxItem->SetVariable( nId, &aBool, NULL, 0, - RSC_TOOLBOXITEM_HIDE ); - nId = aNmTb.Put( "Hide", VARNAME ); - pClassToolBoxItem->SetVariable( nId, &aBool, NULL, 0, - RSC_TOOLBOXITEM_HIDE ); - nId = aNmTb.Put( "Command", VARNAME ); - pClassToolBoxItem->SetVariable( nId, &aString, NULL, 0, - RSC_TOOLBOXITEM_COMMAND ); - - return pClassToolBoxItem; -} - -/************************************************************************* -|* RscTypCont::InitClassToolBox() -*************************************************************************/ -RscTop * RscTypCont::InitClassToolBox( RscTop * pSuper, - RscTop * pClassToolBoxItem, - RscTop * pClassImageList ) -{ - Atom nId; - RscTop * pClassToolBox; - - // Klasse anlegen - nId = pHS->getID( "ToolBox" ); - pClassToolBox = new RscClass( nId, RSC_TOOLBOX, pSuper ); - pClassToolBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassToolBox ); - - // Variablen anlegen - { - RscEnum * pEnum; - - aBaseLst.push_back( pEnum = new RscEnum( pHS->getID( "EnumButtonType" ), RSC_NOTYPE ) ); - SETCONST( pEnum, "BUTTON_SYMBOL", BUTTON_SYMBOL ); - SETCONST( pEnum, "BUTTON_TEXT", BUTTON_TEXT ); - SETCONST( pEnum, "BUTTON_SYMBOLTEXT", BUTTON_SYMBOLTEXT ); - - // Variable einfuegen - nId = aNmTb.Put( "ButtonType", VARNAME ); - pClassToolBox->SetVariable( nId, pEnum, NULL, 0, - RSC_TOOLBOX_BUTTONTYPE ); - } - { - RscEnum * pEnum; - - aBaseLst.push_back( pEnum = new RscEnum( pHS->getID( "EnumToolBoxAlign" ), RSC_NOTYPE ) ); - SETCONST( pEnum, "BOXALIGN_TOP", WINDOWALIGN_TOP ); - SETCONST( pEnum, "BOXALIGN_LEFT", WINDOWALIGN_LEFT ); - SETCONST( pEnum, "BOXALIGN_RIGHT", WINDOWALIGN_RIGHT ); - SETCONST( pEnum, "BOXALIGN_BOTTOM", WINDOWALIGN_BOTTOM ); - - // Variable einfuegen - nId = aNmTb.Put( "Align", VARNAME ); - pClassToolBox->SetVariable( nId, pEnum, NULL, 0, - RSC_TOOLBOX_ALIGN ); - } - nId = aNmTb.Put( "LineCount", VARNAME ); - pClassToolBox->SetVariable( nId, &aIdNoZeroUShort, NULL, 0, - RSC_TOOLBOX_LINECOUNT ); - nId = aNmTb.Put( "FloatingLines", VARNAME ); - pClassToolBox->SetVariable( nId, &aUShort, NULL, 0, - RSC_TOOLBOX_FLOATLINES ); - nId = aNmTb.Put( "Customize", VARNAME ); - pClassToolBox->SetVariable( nId, &aBool, NULL, 0, - RSC_TOOLBOX_CUSTOMIZE ); - nId = aNmTb.Put( "MenuStrings", VARNAME ); - pClassToolBox->SetVariable( nId, &aBool, NULL, 0, - RSC_TOOLBOX_MENUSTRINGS ); - nId = aNmTb.Put( "ItemImageList", VARNAME ); - pClassToolBox->SetVariable( nId, pClassImageList, NULL, 0, - RSC_TOOLBOX_ITEMIMAGELIST ); - { - RscLangArray* pLA; - RscCont * pCont; - - aBaseLst.push_back( pCont = new RscCont( pHS->getID( "ContToolBoxItem" ), RSC_NOTYPE ) ); - pCont->SetTypeClass( pClassToolBoxItem ); - aBaseLst.push_back( - pLA = new RscLangArray( pHS->getID( "LangContToolBoxItem" ) - , RSC_NOTYPE - , pCont - , &aLangType - ) - ); - nId = aNmTb.Put( "ItemList", VARNAME ); - pClassToolBox->SetVariable( nId, pLA, NULL, 0, - RSC_TOOLBOX_ITEMLIST ); - } - INS_WINBIT(pClassToolBox,Scroll) - INS_WINBIT(pClassToolBox,LineSpacing) - INS_WINBIT(pClassToolBox,RectStyle) - INS_WINBIT(pClassToolBox,Tabstop) - - return pClassToolBox; -} - -/************************************************************************* -|* RscTypCont::InitClassStatusBar() -*************************************************************************/ -RscTop * RscTypCont::InitClassStatusBar( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassStatusBar; - - // Klasse anlegen - nId = pHS->getID( "StatusBar" ); - pClassStatusBar = new RscClass( nId, RSC_STATUSBAR, pSuper ); - pClassStatusBar->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassStatusBar ); - - // Variablen anlegen - INS_WINBIT(pClassStatusBar,Left) - INS_WINBIT(pClassStatusBar,Right) - - return pClassStatusBar; -} - -/************************************************************************* -|* RscTypCont::InitClassMoreButton() -*************************************************************************/ -RscTop * RscTypCont::InitClassMoreButton( RscTop * pSuper, RscEnum * pMapUnit ) -{ - Atom nId; - RscTop * pClassMoreButton; - - // Klasse anlegen - nId = pHS->getID( "MoreButton" ); - pClassMoreButton = new RscClass( nId, RSC_MOREBUTTON, pSuper ); - pClassMoreButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassMoreButton ); - - // Variablen anlegen - nId = aNmTb.Put( "State", VARNAME ); - pClassMoreButton->SetVariable( nId, &aBool, NULL, 0, - RSC_MOREBUTTON_STATE ); - nId = aNmTb.Put( "MapUnit", VARNAME ); - pClassMoreButton->SetVariable( nId, pMapUnit, NULL, 0, - RSC_MOREBUTTON_MAPUNIT ); - nId = aNmTb.Put( "Delta", VARNAME ); - pClassMoreButton->SetVariable( nId, &aUShort, NULL, 0, - RSC_MOREBUTTON_DELTA ); - - return pClassMoreButton; -} - -/************************************************************************* -|* RscTypCont::InitClassFloatingWindow() -*************************************************************************/ -RscTop * RscTypCont::InitClassFloatingWindow( RscTop * pSuper, - RscEnum * pMapUnit ) -{ - Atom nId; - RscTop * pClassFloatingWindow; - - // Klasse anlegen - nId = pHS->getID( "FloatingWindow" ); - pClassFloatingWindow = new RscClass( nId, RSC_FLOATINGWINDOW, pSuper ); - pClassFloatingWindow->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassFloatingWindow ); - - // Variablen anlegen - nId = aNmTb.Put( "_ZoomInMapMode", VARNAME ); - pClassFloatingWindow->SetVariable( nId, pMapUnit, NULL, 0, - RSC_FLOATINGWINDOW_WHMAPMODE ); - nId = aNmTb.Put( "_ZoomInWidth", VARNAME ); - pClassFloatingWindow->SetVariable( nId, &aShort, NULL, 0, - RSC_FLOATINGWINDOW_WIDTH ); - nId = aNmTb.Put( "_ZoomInHeight", VARNAME ); - pClassFloatingWindow->SetVariable( nId, &aShort, NULL, 0, - RSC_FLOATINGWINDOW_HEIGHT ); - nId = aNmTb.Put( "ZoomIn", VARNAME ); - pClassFloatingWindow->SetVariable( nId, &aBool, NULL, 0, - RSC_FLOATINGWINDOW_ZOOMIN ); - - INS_WINBIT(pClassFloatingWindow,Zoomable) - INS_WINBIT(pClassFloatingWindow,HideWhenDeactivate) - INS_WINBIT(pClassFloatingWindow,EnableResizing) - INS_WINBIT(pClassFloatingWindow,StdPopup) - - return pClassFloatingWindow; -} - -/************************************************************************* -|* RscTypCont::InitClassTabControlItem() -*************************************************************************/ -RscTop * RscTypCont::InitClassTabControlItem( RscTop * pSuper, - RscTop * /*pClassTabPage*/ ) -{ - Atom nId; - RscTop * pClassTabControlItem; - - // Klasse anlegen - nId = pHS->getID( "PageItem" ); - pClassTabControlItem = new RscClass( nId, RSC_TABCONTROLITEM, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassTabControlItem ); - - // Variablen anlegen - nId = aNmTb.Put( "Identifier", VARNAME ); - pClassTabControlItem->SetVariable( nId, &aIdNoZeroUShort, NULL, 0, - RSC_TABCONTROLITEM_ID ); - nId = aNmTb.Put( "Text", VARNAME ); - pClassTabControlItem->SetVariable( nId, &aLangString, NULL, 0, - RSC_TABCONTROLITEM_TEXT ); - nId = aNmTb.Put( "PageResID", VARNAME ); - pClassTabControlItem->SetVariable( nId, &aIdLong, NULL, 0, - RSC_TABCONTROLITEM_PAGERESID ); - - return pClassTabControlItem; -} - -/************************************************************************* -|* RscTypCont::InitClassTabControl() -*************************************************************************/ -RscTop * RscTypCont::InitClassTabControl( RscTop * pSuper, - RscTop * pClassTabControlItem ) -{ - Atom nId; - RscTop * pClassTabControl; - - // Klasse anlegen - nId = pHS->getID( "TabControl" ); - pClassTabControl = new RscClass( nId, RSC_TABCONTROL, pSuper ); - pClassTabControl->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - aNmTb.Put( nId, CLASSNAME, pClassTabControl ); - - // Variablen anlegen - { - RscCont * pCont; - - aBaseLst.push_back( pCont = new RscCont( pHS->getID( "ContTabControlItem" ), RSC_NOTYPE ) ); - pCont->SetTypeClass( pClassTabControlItem ); - nId = aNmTb.Put( "PageList", VARNAME ); - pClassTabControl->SetVariable( nId, pCont, NULL, 0, - RSC_TABCONTROL_ITEMLIST ); - - INS_WINBIT( pClassTabControl, DropDown ); - } - - return pClassTabControl; -} - -/************************************************************************* -|* RscTypCont::InitClassSfxFamilyStyleItem() -*************************************************************************/ -RscTop * RscTypCont::InitClassSfxStyleFamilyItem( RscTop * pSuper, - RscTop * pClassBitmap, - RscTop * pClassImage, - RscArray * pStrLst ) -{ - Atom nId; - RscTop * pClassSfxFamilyStyleItem; - - // Klasse anlegen - nId = pHS->getID( "SfxStyleFamilyItem" ); - pClassSfxFamilyStyleItem = new RscClass( nId, RSC_SFX_STYLE_FAMILY_ITEM, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassSfxFamilyStyleItem ); - - nId = aNmTb.Put( "FilterList", VARNAME ); - pClassSfxFamilyStyleItem->SetVariable( nId, pStrLst, NULL, 0, - RSC_SFX_STYLE_ITEM_LIST ); - nId = aNmTb.Put( "StyleBitmap", VARNAME ); - pClassSfxFamilyStyleItem->SetVariable( nId, pClassBitmap, NULL, 0, - RSC_SFX_STYLE_ITEM_BITMAP ); - nId = aNmTb.Put( "Text", VARNAME ); - pClassSfxFamilyStyleItem->SetVariable( nId, &aLangString, NULL, 0, - RSC_SFX_STYLE_ITEM_TEXT ); - nId = aNmTb.Put( "HelpText", VARNAME ); - pClassSfxFamilyStyleItem->SetVariable( nId, &aLangString, NULL, 0, - RSC_SFX_STYLE_ITEM_HELPTEXT ); - { - RscEnum * pSfxStyleFamily; - pSfxStyleFamily = new RscEnum( pHS->getID( "StyleFamily" ), - RSC_NOTYPE ); - - SETCONST( pSfxStyleFamily, "SFX_STYLE_FAMILY_PARA", SFX_STYLE_FAMILY_PARA ); - SETCONST( pSfxStyleFamily, "SFX_STYLE_FAMILY_CHAR", SFX_STYLE_FAMILY_CHAR ); - SETCONST( pSfxStyleFamily, "SFX_STYLE_FAMILY_FRAME",SFX_STYLE_FAMILY_FRAME); - SETCONST( pSfxStyleFamily, "SFX_STYLE_FAMILY_PAGE", SFX_STYLE_FAMILY_PAGE ); - SETCONST( pSfxStyleFamily, "SFX_STYLE_FAMILY_PSEUDO", SFX_STYLE_FAMILY_PSEUDO ); - aBaseLst.push_back( pSfxStyleFamily ); - - nId = aNmTb.Put( "StyleFamily", VARNAME ); - pClassSfxFamilyStyleItem->SetVariable( nId, pSfxStyleFamily, NULL, 0, - RSC_SFX_STYLE_ITEM_STYLEFAMILY ); - } - nId = aNmTb.Put( "StyleImage", VARNAME ); - pClassSfxFamilyStyleItem->SetVariable( nId, pClassImage, NULL, 0, - RSC_SFX_STYLE_ITEM_IMAGE ); - return pClassSfxFamilyStyleItem; -} - -/************************************************************************* -|* RscTypCont::InitClassSfxTemplateDialogm() -*************************************************************************/ -RscTop * RscTypCont::InitClassSfxTemplateDialog( RscTop * pSuper, - RscTop * pClassFamilyStyleItem ) -{ - Atom nId; - RscTop * pClassSfxTemplateDialog; - - // Klasse anlegen - nId = pHS->getID( "SfxStyleFamilies" ); - pClassSfxTemplateDialog = new RscClass( nId, RSC_SFX_STYLE_FAMILIES, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassSfxTemplateDialog ); - - // Variablen anlegen - { - RscCont * pCont; - - aBaseLst.push_back( - pCont = new RscCont( pHS->getID( "ContFamilyStyleItem" ), RSC_NOTYPE ) - ); - pCont->SetTypeClass( pClassFamilyStyleItem ); - nId = aNmTb.Put( "StyleFamilyList", VARNAME ); - pClassSfxTemplateDialog->SetVariable( nId, pCont ); - } - - return pClassSfxTemplateDialog; -} - -/************************************************************************* -|* RscTypCont::InitClassSfxSlotInfo() -*************************************************************************/ -RscTop * RscTypCont::InitClassSfxSlotInfo( RscTop * pSuper ) -{ - Atom nId; - RscTop * pClassSfxSlotInfo; - - // Klasse anlegen - nId = pHS->getID( "SfxSlotInfo" ); - pClassSfxSlotInfo = new RscClass( nId, RSC_SFX_SLOT_INFO, pSuper ); - aNmTb.Put( nId, CLASSNAME, pClassSfxSlotInfo ); - - nId = aNmTb.Put( "SlotName", VARNAME ); - pClassSfxSlotInfo->SetVariable( nId, &aLangString, NULL, 0, - RSC_SFX_SLOT_INFO_SLOTNAME ); - nId = aNmTb.Put( "HelpText", VARNAME ); - pClassSfxSlotInfo->SetVariable( nId, &aLangString, NULL, 0, - RSC_SFX_SLOT_INFO_HELPTEXT ); - return pClassSfxSlotInfo; -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rscinit.cxx b/rsc/source/parser/rscinit.cxx deleted file mode 100644 index ae6b7b607c..0000000000 --- a/rsc/source/parser/rscinit.cxx +++ /dev/null @@ -1,934 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" - -/****************** I N C L U D E S **************************************/ -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> - -#include <tools/rc.h> - -#include <vclrsc.hxx> - -// Programmabhaengige Includes. -#include <rsctree.hxx> -#include <rsctop.hxx> -#include <rscrange.hxx> -#include <rscconst.hxx> -#include <rscflag.hxx> -#include <rscstr.hxx> -#include <rsccont.hxx> -#include <rscmgr.hxx> -#include <rscclass.hxx> -#include <rsckey.hxx> -#include <rscdb.hxx> - -#include "rsclex.hxx" -#include <yyrscyacc.hxx> - -/****************** M a c r o s ******************************************/ -#define INS_WINBIT( pClass, WinBit ) \ - InsWinBit( pClass, #WinBit, n##WinBit##Id ); - -/****************** C O D E **********************************************/ -void NameToVerCtrl( RSCINST & aVersion, RscTop * pClass, - RscTop * pClassString ) -{ - if( pClass ) - { - NameToVerCtrl( aVersion, (RscTop *)pClass->Left(), pClassString ); - { - RSCINST aVI; - RSCINST aStr; - - // Namen in Versionskontrolle einsetzen - aVersion.pClass-> - GetElement( aVersion, RscId( pClass->GetTypId() ), - pClassString, RSCINST(), &aVI ); - aStr = aVI.pClass->GetVariable( aVI, pHS->getID( "TEXT" ), - RSCINST() ); - aStr.pClass->SetString( aStr, pHS->getString( pClass->GetId() ).getStr() ); - } - NameToVerCtrl( aVersion, (RscTop *)pClass->Right(), pClassString ); - } -} - -/************************************************************************* -|* -|* RscTypCont::Init() -|* -*************************************************************************/ -void RscTypCont::Init() -{ - RscEnum * pFieldUnits; - RscEnum * pTimeFieldFormat; - RscEnum * pColor; - RscEnum * pMapUnit; - RscEnum * pKey; - RscEnum * pTriState; - RscEnum * pMessButtons; - RscEnum * pMessDefButton; - RscTupel * pGeometry; - RscArray * pLangGeometry; - RscCont * pStringList; - RscArray * pLangStringList; - RscTupel * pStringTupel; - RscTupel * pStringLongTupel; - RscCont * pStringTupelList; - RscCont * pStringLongTupelList; - RscArray * pLangStringTupelList; - RscArray * pLangStringLongTupelList; - - RscTop * pClassMgr; - RscTop * pClassString; - RscTop * pClassStringArray; - RscTop * pClassBitmap; - RscTop * pClassColor; - RscTop * pClassImage; - RscTop * pClassImageList; - RscTop * pClassWindow; - RscTop * pClassSystemWindow; - RscTop * pClassWorkWindow; - RscTop * pClassDialog; - RscTop * pClassModalDialog; - RscTop * pClassModelessDialog; - RscTop * pClassControl; - RscTop * pClassButton; - RscTop * pClassCheckBox; - RscTop * pClassPushButton; - RscTop * pClassOKButton; - RscTop * pClassCancelButton; - RscTop * pClassHelpButton; - RscTop * pClassRadioButton; - RscTop * pClassImageRadioButton; - RscTop * pClassImageButton; - RscTop * pClassTriStateBox; - RscTop * pClassEdit; - RscTop * pClassMultiLineEdit; - RscTop * pClassScrollBar; - RscTop * pClassListBox; - RscTop * pClassMultiListBox; - RscTop * pClassComboBox; - RscTop * pClassFixedText; - RscTop * pClassFixedBitmap; - RscTop * pClassFixedImage; - RscTop * pClassGroupBox; - RscTop * pClassKeyCode; - RscTop * pLangClassKeyCode; - RscTop * pClassAccelItem; - RscTop * pClassAccel; - RscTop * pClassMenuItem; - RscTop * pClassMenu; - RscTop * pClassMenuButton; - RscTop * pClassMessBox; - RscTop * pClassInfoBox; - RscTop * pClassWarningBox; - RscTop * pClassErrorBox; - RscTop * pClassQueryBox; - RscTop * pClassSplitter; - RscTop * pClassSplitWindow; - RscTop * pClassSpinButton; - RscTop * pClassTime; - RscTop * pClassDate; - RscTop * pClassSpinField; - RscTop * pClassPatternField; - RscTop * pClassNumericField; - RscTop * pClassMetricField; - RscTop * pClassCurrencyField; - RscTop * pClassLongCurrencyField; - RscTop * pClassDateField; - RscTop * pClassTimeField; - RscTop * pClassPatternBox; - RscTop * pClassNumericBox; - RscTop * pClassMetricBox; - RscTop * pClassCurrencyBox; - RscTop * pClassLongCurrencyBox; - RscTop * pClassDateBox; - RscTop * pClassTimeBox; - RscTop * pClassDockingWindow; - RscTop * pClassToolBoxItem; - RscTop * pClassToolBox; - RscTop * pClassStatusBar; - RscTop * pClassMoreButton; - RscTop * pClassFloatingWindow; - RscTop * pClassTabPage; - RscTop * pClassTabDialog; - RscTop * pClassTabControlItem; - RscTop * pClassTabControl; - RscTop * pClassFixedLine; - RscTop * pClassScrollBarBox; - RscTop * pClassSfxStyleFamilyItem; - RscTop * pClassSfxTemplateDialog; - RscTop * pClassSfxSlotInfo; - - Atom nId; - - aNmTb.SetSort( sal_False ); -{ - /********** C O M P I L E R T Y P E N ******************************/ - aNmTb.Put( "LINE", LINE, (long)0 ); - aNmTb.Put( "NOT", NOT, (long)0 ); - aNmTb.Put( "DEFINE", DEFINE, (long)0 ); - aNmTb.Put( "INCLUDE", INCLUDE, (long)0 ); - aNmTb.Put( "DEFAULT", DEFAULT, (long)0 ); - aNmTb.Put( "class", CLASS, (long)0 ); - aNmTb.Put( "extendable", EXTENDABLE, (long)0 ); - aNmTb.Put( "writeifset", WRITEIFSET, (long)0 ); - -/* Werte fuer Aufzaehlungstypen */ - aNmTb.Put( "TRUE", BOOLEAN, (long)sal_True ); - aNmTb.Put( "FALSE", BOOLEAN, (long)sal_False ); - - #if 0 -/* Vordefinierte HilfeId's */ - aNmTb.Put( "HELP_INDEX", NUMBER, OOO_HELP_INDEX ); - aNmTb.Put( "HELP_HELPONHELP", NUMBER, OOO_HELP_HELPONHELP ); - #endif - - aNmTb.Put( "XSCALE", XSCALE , (long)0 ); - aNmTb.Put( "YSCALE", YSCALE , (long)0 ); - aNmTb.Put( "RGB", RGB , (long)0 ); - aNmTb.Put( "POSSIZE", GEOMETRY, (long)0 ); - aNmTb.Put( "POS", POSITION, (long)0 ); - aNmTb.Put( "SIZE", DIMENSION, (long)0 ); - aNmTb.Put( "ZoomInOutputSize", INZOOMOUTPUTSIZE,(long)0 ); - aNmTb.Put( "FloatingPos", FLOATINGPOS, (long)0 ); -} - /********** B A S I S T Y P E N ************************************/ -{ - /********** S H O R T ************************************************/ - aShort.SetRange( -32768, 32767 ); - - /********** U S H O R T **********************************************/ - aUShort.SetRange( 0, 0xFFFF ); - - /********** L O N G **************************************************/ - aLong.SetRange( SAL_MIN_INT32, SAL_MAX_INT32 ); - aEnumLong.SetRange( SAL_MIN_INT32, SAL_MAX_INT32 ); - - /********** I D U S H O R T ******************************************/ - aIdUShort.SetRange( 0, 0xFFFF ); - - /********** I D N O Z E R O U S H O R T ******************************/ - aIdNoZeroUShort.SetRange( 1, 0xFFFF ); - - /********** N O Z E R O S H O R T ************************************/ - aNoZeroShort.SetRange( -32768, 32767 ); - aNoZeroShort.SetOutRange( 0 ); - - /********** R A N G E S H O R T **************************************/ - a1to12Short.SetRange( 1, 12 ); - a0to23Short.SetRange( 0, 23 ); - a1to31Short.SetRange( 1, 31 ); - a0to59Short.SetRange( 0, 59 ); - a0to99Short.SetRange( 0, 99 ); - a0to9999Short.SetRange( 0, 9999 ); - - /********** I D R A N G E ********************************************/ - aIdLong.SetRange( SAL_MIN_INT32, SAL_MAX_INT32 ); -} -{ - /********** W I N B I T S F L A G ************************************/ - // Variablenname fuer WinBits - nWinBitVarId = aNmTb.Put( "_WinBits", VARNAME ); - - // Windows - nBorderId = pHS->getID( "WB_BORDER" ); - aWinBits.SetConstant( nBorderId, sal::static_int_cast<sal_Int32>(WB_BORDER) ); - nHideId = pHS->getID( "WB_HIDE" ); - aWinBits.SetConstant( nHideId, sal::static_int_cast<sal_Int32>(WB_HIDE) ); - nClipChildrenId = pHS->getID( "WB_CLIPCHILDREN" ); - aWinBits.SetConstant( nClipChildrenId, sal::static_int_cast<sal_Int32>(WB_CLIPCHILDREN) ); - nSizeableId = pHS->getID( "WB_SIZEABLE" ); - aWinBits.SetConstant( nSizeableId, sal::static_int_cast<sal_Int32>(WB_SIZEABLE) ); - nMoveableId = pHS->getID( "WB_MOVEABLE" ); - aWinBits.SetConstant( nMoveableId, sal::static_int_cast<sal_Int32>(WB_MOVEABLE) ); - nMinimizeId = pHS->getID( "WB_MINABLE" ); - aWinBits.SetConstant( nMinimizeId, 0 /*WB_MINABLE*/ ); - nMaximizeId = pHS->getID( "WB_MAXABLE" ); - aWinBits.SetConstant( nMaximizeId, 0 /*WB_MAXABLE*/ ); - nCloseableId = pHS->getID( "WB_CLOSEABLE" ); - aWinBits.SetConstant( nCloseableId, sal::static_int_cast<sal_Int32>(WB_CLOSEABLE) ); - nAppId = pHS->getID( "WB_APP" ); - aWinBits.SetConstant( nAppId, sal::static_int_cast<sal_Int32>(WB_APP) ); - nTabstopId = pHS->getID( "WB_TABSTOP" ); - aWinBits.SetConstant( nTabstopId, sal::static_int_cast<sal_Int32>(WB_TABSTOP) ); - nGroupId = pHS->getID( "WB_GROUP" ); - aWinBits.SetConstant( nGroupId, sal::static_int_cast<sal_Int32>(WB_GROUP) ); - nSysmodalId = pHS->getID( "WB_SYSMODAL" ); - aWinBits.SetConstant( nSysmodalId, 0 /*WB_SYSMODAL*/ ); -} -{ - nLeftId = pHS->getID( "WB_LEFT" ); - aWinBits.SetConstant( nLeftId, sal::static_int_cast<sal_Int32>(WB_LEFT) ); - nCenterId = pHS->getID( "WB_CENTER" ); - aWinBits.SetConstant( nCenterId, sal::static_int_cast<sal_Int32>(WB_CENTER) ); - nRightId = pHS->getID( "WB_RIGHT" ); - aWinBits.SetConstant( nRightId, sal::static_int_cast<sal_Int32>(WB_RIGHT) ); - nTopId = pHS->getID( "WB_TOP" ); - aWinBits.SetConstant( nTopId, sal::static_int_cast<sal_Int32>(WB_TOP) ); - nVCenterId = pHS->getID( "WB_VCENTER" ); - aWinBits.SetConstant( nVCenterId, sal::static_int_cast<sal_Int32>(WB_VCENTER) ); - nBottomId = pHS->getID( "WB_BOTTOM" ); - aWinBits.SetConstant( nBottomId, sal::static_int_cast<sal_Int32>(WB_BOTTOM) ); - nHScrollId = pHS->getID( "WB_HSCROLL" ); - aWinBits.SetConstant( nHScrollId, sal::static_int_cast<sal_Int32>(WB_HSCROLL) ); - nVScrollId = pHS->getID( "WB_VSCROLL" ); - aWinBits.SetConstant( nVScrollId, sal::static_int_cast<sal_Int32>(WB_VSCROLL) ); - nSortId = pHS->getID( "WB_SORT" ); - aWinBits.SetConstant( nSortId, sal::static_int_cast<sal_Int32>(WB_SORT) ); - nDefaultId = pHS->getID( "WB_DEFBUTTON" ); - aWinBits.SetConstant( nDefaultId, sal::static_int_cast<sal_Int32>(WB_DEFBUTTON) ); - nRepeatId = pHS->getID( "WB_REPEAT" ); - aWinBits.SetConstant( nRepeatId, sal::static_int_cast<sal_Int32>(WB_REPEAT) ); - nSVLookId = pHS->getID( "WB_SVLOOK" ); - aWinBits.SetConstant( nSVLookId, sal::static_int_cast<sal_Int32>(WB_3DLOOK) ); - nDropDownId = pHS->getID( "WB_DROPDOWN" ); - aWinBits.SetConstant( nDropDownId, sal::static_int_cast<sal_Int32>(WB_DROPDOWN) ); - nPassWordId = pHS->getID( "WB_PASSWORD" ); - aWinBits.SetConstant( nPassWordId, sal::static_int_cast<sal_Int32>(WB_PASSWORD) ); - nReadOnlyId = pHS->getID( "WB_READONLY" ); - aWinBits.SetConstant( nReadOnlyId, sal::static_int_cast<sal_Int32>(WB_READONLY) ); - nAutoSizeId = pHS->getID( "WB_AUTOSIZE" ); - aWinBits.SetConstant( nAutoSizeId, sal::static_int_cast<sal_Int32>(WB_AUTOSIZE) ); - nSpinId = pHS->getID( "WB_SPIN" ); - aWinBits.SetConstant( nSpinId, sal::static_int_cast<sal_Int32>(WB_SPIN) ); - nTabControlId = pHS->getID( "WB_DIALOGCONTROL" ); - aWinBits.SetConstant( nTabControlId, sal::static_int_cast<sal_Int32>(WB_DIALOGCONTROL) ); - nSimpleModeId = pHS->getID( "WB_SIMPLEMODE" ); - aWinBits.SetConstant( nSimpleModeId, sal::static_int_cast<sal_Int32>(WB_SIMPLEMODE) ); - nDragId = pHS->getID( "WB_DRAG" ); - aWinBits.SetConstant( nDragId, sal::static_int_cast<sal_Int32>(WB_DRAG) ); - nScrollId = pHS->getID( "WB_SCROLL" ); - aWinBits.SetConstant( nScrollId, sal::static_int_cast<sal_Int32>(WB_SCROLL) ); - nZoomableId = pHS->getID( "WB_ZOOMABLE" ); - aWinBits.SetConstant( nZoomableId, sal::static_int_cast<sal_Int32>(WB_ROLLABLE) ); - nHideWhenDeactivateId = pHS->getID( "WB_HIDEWHENDEACTIVATE" ); - aWinBits.SetConstant( nHideWhenDeactivateId, 0 /*WB_HIDEWHENDEACTIVATE*/ ); - nAutoHScrollId = pHS->getID( "WB_AUTOHSCROLL" ); - aWinBits.SetConstant( nAutoHScrollId, sal::static_int_cast<sal_Int32>(WB_AUTOHSCROLL) ); - nAutoVScrollId = pHS->getID( "WB_AUTOVSCROLL" ); - aWinBits.SetConstant( nAutoVScrollId, sal::static_int_cast<sal_Int32>(WB_AUTOVSCROLL) ); - nDDExtraWidthId = pHS->getID( "WB_DDEXTRAWIDTH" ); - aWinBits.SetConstant( nDDExtraWidthId, 0 /*WB_DDEXTRAWIDTH*/ ); - nWordBreakId = pHS->getID( "WB_WORDBREAK" ); - aWinBits.SetConstant( nWordBreakId, sal::static_int_cast<sal_Int32>(WB_WORDBREAK) ); - nLeftLabelId = pHS->getID( "WB_LEFTLABEL" ); - aWinBits.SetConstant( nLeftLabelId, 0 /*WB_LEFTLABEL*/ ); - nHasLinesId = pHS->getID( "WB_HASLINES" ); - aWinBits.SetConstant( nHasLinesId, sal::static_int_cast<sal_Int32>(WB_HASLINES) ); - nHasButtonsId = pHS->getID( "WB_HASBUTTONS" ); - aWinBits.SetConstant( nHasButtonsId, sal::static_int_cast<sal_Int32>(WB_HASBUTTONS) ); - nRectStyleId = pHS->getID( "WB_RECTSTYLE" ); - aWinBits.SetConstant( nRectStyleId, sal::static_int_cast<sal_Int32>(WB_RECTSTYLE) ); - nLineSpacingId = pHS->getID( "WB_LINESPACING" ); - aWinBits.SetConstant( nLineSpacingId, sal::static_int_cast<sal_Int32>(WB_LINESPACING) ); - nSmallStyleId = pHS->getID( "WB_SMALLSTYLE" ); - aWinBits.SetConstant( nSmallStyleId, sal::static_int_cast<sal_Int32>(WB_SMALLSTYLE) ); - nEnableResizingId = pHS->getID( "WB_ENABLERESIZING" ); - aWinBits.SetConstant( nEnableResizingId, 0 /*WB_ENABLERESIZING*/ ); - nDockableId = pHS->getID( "WB_DOCKABLE" ); - aWinBits.SetConstant( nDockableId, sal::static_int_cast<sal_Int32>(WB_DOCKABLE) ); - nScaleId = pHS->getID( "WB_SCALE" ); - aWinBits.SetConstant( nScaleId, sal::static_int_cast<sal_Int32>(WB_SCALE) ); - nIgnoreTabId = pHS->getID( "WB_IGNORETAB" ); - aWinBits.SetConstant( nIgnoreTabId, sal::static_int_cast<sal_Int32>(WB_IGNORETAB) ); - nNoSplitDrawId = pHS->getID( "WB_NOSPLITDRAW" ); - aWinBits.SetConstant( nNoSplitDrawId, sal::static_int_cast<sal_Int32>(WB_NOSPLITDRAW) ); - nTopImageId = pHS->getID( "WB_TOPIMAGE" ); - aWinBits.SetConstant( nTopImageId, sal::static_int_cast<sal_Int32>(WB_TOPIMAGE) ); - nNoLabelId = pHS->getID( "WB_NOLABEL" ); - aWinBits.SetConstant( nNoLabelId, sal::static_int_cast<sal_Int32>(WB_NOLABEL) ); - nVertId = pHS->getID( "WB_VERT" ); - aWinBits.SetConstant( nVertId, sal::static_int_cast<sal_Int32>(WB_VERT) ); - nSysWinId = pHS->getID( "WB_SYSTEMWINDOW" ); - aWinBits.SetConstant( nSysWinId, sal::static_int_cast<sal_Int32>(WB_SYSTEMWINDOW) ); - nStdPopupId = pHS->getID( "WB_STDPOPUP" ); - aWinBits.SetConstant( nStdPopupId, sal::static_int_cast<sal_Int32>(WB_STDPOPUP) ); -} -{ - /********** I n i t B a s i c T y p e s **************************/ - InitLangType(); - aBaseLst.push_back( pFieldUnits = InitFieldUnitsType() ); - aBaseLst.push_back( pTimeFieldFormat = InitTimeFieldFormat() ); - aBaseLst.push_back( pColor = InitColor() ); - aBaseLst.push_back( pMapUnit = InitMapUnit() ); - aBaseLst.push_back( pKey = InitKey() ); - aBaseLst.push_back( pTriState = InitTriState() ); - aBaseLst.push_back( pMessButtons = InitMessButtons() ); - aBaseLst.push_back( pMessDefButton = InitMessDefButton() ); - - aBaseLst.push_back( pGeometry = InitGeometry() ); - aBaseLst.push_back( pLangGeometry = InitLangGeometry( pGeometry ) ); - aBaseLst.push_back( pStringList = InitStringList() ); - aBaseLst.push_back( pLangStringList = InitLangStringList( pStringList ) ); - aBaseLst.push_back( pStringTupel = InitStringTupel() ); - aBaseLst.push_back( pStringTupelList = InitStringTupelList( pStringTupel ) ); - aBaseLst.push_back( pLangStringTupelList = InitLangStringTupelList( pStringTupelList ) ); - aBaseLst.push_back( pStringLongTupel = InitStringLongTupel() ); - aBaseLst.push_back( pStringLongTupelList = InitStringLongTupelList( pStringLongTupel ) ); - aBaseLst.push_back( pLangStringLongTupelList = InitLangStringLongTupelList( pStringLongTupelList ) ); -} -{ - /********** R E S O U R C E T Y P E N ******************************/ - /********** R S C M G R **********************************************/ - pRoot = pClassMgr = InitClassMgr(); - - /********** V e r s i o n s k o n t r o l l e ************************/ - aVersion.pClass = new RscClass( pHS->getID( "VersionControl" ), - RSC_VERSIONCONTROL, pClassMgr ); - aVersion = aVersion.pClass->Create( NULL, RSCINST() ); - - /********** S T R I N G **********************************************/ - pClassString = InitClassString( pClassMgr ); - pRoot->Insert( pClassString ); - - // String als Referenzklasse des Basisstrings einsetzen - aString.SetRefClass( pClassString ); - - /********** S T R I N G L I S T **************************************/ - // Klasse anlegen - nId = pHS->getID( "StringArray" ); - pClassStringArray = new RscClass( nId, RSC_STRINGARRAY, pClassMgr ); - pClassStringArray->SetCallPar( *pStdPar1, *pStdPar2, *pStdParType ); - aNmTb.Put( nId, CLASSNAME, pClassStringArray ); - pRoot->Insert( pClassStringArray ); - - // Variablen anlegen - nId = aNmTb.Put( "ItemList", VARNAME ); - pClassStringArray->SetVariable( nId, pLangStringLongTupelList ); - - /********** B I T M A P **********************************************/ - pClassBitmap = InitClassBitmap( pClassMgr ); - pRoot->Insert( pClassBitmap ); - -} -{ - /********** C O L O R ************************************************/ - pClassColor = InitClassColor( pClassMgr, pColor ); - pRoot->Insert( pClassColor ); - - /********** I M A G E ************************************************/ - pClassImage = InitClassImage( pClassMgr, pClassBitmap, pClassColor ); - pRoot->Insert( pClassImage ); - - /********** I M A G E L I S T ****************************************/ - pClassImageList = InitClassImageList( pClassMgr, pClassBitmap, - pClassColor, pStringLongTupelList ); - pRoot->Insert( pClassImageList ); - - /********** W I N D O W **********************************************/ - pClassWindow = InitClassWindow( pClassMgr, pMapUnit, - pLangGeometry ); - pRoot->Insert( pClassWindow ); -} -{ - - /********** S Y S T E M W I N D O W **********************************/ - pClassSystemWindow = InitClassSystemWindow( pClassWindow ); - //aBaseLst.Insert( pClassSystemWindow, LIST_APPEND ); - pRoot->Insert( pClassSystemWindow ); - - /********** W O R K W I N D O W **************************************/ - pClassWorkWindow = InitClassWorkWindow( pClassSystemWindow ); - pRoot->Insert( pClassWorkWindow ); - - /********** D I A L O G **********************************************/ - // Klasse anlegen - pClassDialog = new RscClass( pHS->getID( "Dialog" ), - RSC_DIALOG, pClassSystemWindow ); - pClassDialog->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aBaseLst.push_back( pClassDialog ); - - /********** M O D A L D I A L O G ***********************************/ - // Klasse anlegen - pClassModalDialog = InitClassModalDialog( pClassDialog ); - pRoot->Insert( pClassModalDialog ); - - /********** M O D E L E S S D I A L O G ******************************/ - // Klasse anlegen - pClassModelessDialog = InitClassModelessDialog( pClassDialog ); - pRoot->Insert( pClassModelessDialog ); -} -{ - /********** C O N T R O L ********************************************/ - pClassControl = InitClassControl( pClassWindow ); - pRoot->Insert( pClassControl ); - - /********** B U T T O N **********************************************/ - // Klasse anlegen - nId = pHS->getID( "Button" ); - pClassButton = new RscClass( nId, RSC_BUTTON, pClassControl ); - pClassButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassButton ); - pRoot->Insert( pClassButton ); - - /********** C H E C K B O X ******************************************/ - pClassCheckBox = InitClassCheckBox( pClassButton ); - pRoot->Insert( pClassCheckBox ); - - /********** P U S H B U T T O N **************************************/ - // Klasse anlegen - pClassPushButton = InitClassPushButton( pClassButton ); - pRoot->Insert( pClassPushButton ); - - /********** H E L P B U T T O N **************************************/ - // Klasse anlegen - nId = pHS->getID( "HelpButton" ); - pClassHelpButton = new RscClass( nId, RSC_HELPBUTTON, - pClassPushButton ); - pClassHelpButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassHelpButton ); - pRoot->Insert( pClassHelpButton ); - - /********** O K B U T T O N ******************************************/ - // Klasse anlegen - nId = pHS->getID( "OKButton" ); - pClassOKButton = new RscClass( nId, RSC_OKBUTTON, - pClassPushButton ); - pClassOKButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassOKButton ); - pRoot->Insert( pClassOKButton ); - - /********** C A N C E L B U T T O N **********************************/ - // Klasse anlegen - nId = pHS->getID( "CancelButton" ); - pClassCancelButton = new RscClass( nId, RSC_CANCELBUTTON, - pClassPushButton ); - pClassCancelButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassCancelButton ); - pRoot->Insert( pClassCancelButton ); -} -{ - /********** R A D I O B U T T O N ************************************/ - pClassRadioButton = InitClassRadioButton( pClassButton ); - pRoot->Insert( pClassRadioButton ); - - /********** I m a g e R a d i o B u t t o n **************************/ - nId = pHS->getID( "ImageRadioButton" ); - pClassImageRadioButton = InitClassImageRadioButton( pClassRadioButton, - pClassImage ); - pRoot->Insert( pClassImageRadioButton ); - - /********** T R I S T A T E B O X ************************************/ - pClassTriStateBox = InitClassTriStateBox( pClassControl, pTriState ); - pRoot->Insert( pClassTriStateBox ); - - /********** I M A G E B U T T O N ************************************/ - pClassImageButton = InitClassImageButton( pClassPushButton, - pClassImage, pTriState ); - pRoot->Insert( pClassImageButton ); - - /********** E D I T **************************************************/ - pClassEdit = InitClassEdit( pClassControl ); - pRoot->Insert( pClassEdit ); - - /********** M U L T I L I N E E D I T ********************************/ - pClassMultiLineEdit = InitClassMultiLineEdit( pClassEdit ); - pRoot->Insert( pClassMultiLineEdit ); - - /********** S C R O L L B A R ****************************************/ - pClassScrollBar = InitClassScrollBar( pClassControl ); - pRoot->Insert( pClassScrollBar ); - -} -{ - /********** L I S T B O X ********************************************/ - pClassListBox = InitClassListBox( pClassControl, pLangStringLongTupelList ); - pRoot->Insert( pClassListBox ); - - /********** M U L T I L I S T B O X **********************************/ - pClassMultiListBox = InitClassMultiListBox( pClassListBox); - pRoot->Insert( pClassMultiListBox ); - - /********** C O M B O B O X ******************************************/ - pClassComboBox = InitClassComboBox( pClassEdit, pLangStringList ); - pRoot->Insert( pClassComboBox ); - - /********** F I X E D T E X T ****************************************/ - pClassFixedText = InitClassFixedText( pClassControl ); - pRoot->Insert( pClassFixedText ); - - /********** F i x e d B i t m a p ************************************/ - pClassFixedBitmap = InitClassFixedBitmap( pClassControl, pClassBitmap ); - pRoot->Insert( pClassFixedBitmap ); - - /********** F i x e d I m a g e **************************************/ - pClassFixedImage = InitClassFixedImage( pClassControl, pClassImage ); - pRoot->Insert( pClassFixedImage ); - - /********** G R O U P B O X ******************************************/ - // Klasse anlegen - nId = pHS->getID( "GroupBox" ); - pClassGroupBox = new RscClass( nId, RSC_GROUPBOX, pClassControl ); - pClassGroupBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassGroupBox ); - pRoot->Insert( pClassGroupBox ); - - /********** K E Y C O D E ********************************************/ - pClassKeyCode = InitClassKeyCode( pClassMgr, pKey ); - pRoot->Insert( pClassKeyCode ); - { - pLangClassKeyCode = new RscClassArray( pHS->getID( "LangKeyCode" ), - RSC_KEYCODE, pClassKeyCode, &aLangType ); - aBaseLst.push_back( pLangClassKeyCode ); - } - - /********** A C C E L I T E M ***************************************/ - pClassAccelItem = InitClassAccelItem( pClassMgr, pLangClassKeyCode ); - pRoot->Insert( pClassAccelItem ); -} -{ - /********** A C C E L E R A T O R ************************************/ - pClassAccel = InitClassAccel( pClassMgr, pClassAccelItem ); - pRoot->Insert( pClassAccel ); - nAcceleratorType = pClassAccel->GetId(); - - /********** A C C E L I T E M ***************************************/ - // pClassAccel ist erst hier definiert - nId = aNmTb.Put( "SubAccelerator", VARNAME ); - pClassAccelItem->SetVariable( nId, pClassAccel, NULL, VAR_SVDYNAMIC, - ACCELITEM_ACCEL ); - - /********** M E N U I T E M ******************************************/ - pClassMenuItem = InitClassMenuItem( pClassMgr, pClassBitmap, - pLangClassKeyCode ); - pRoot->Insert( pClassMenuItem ); - - /********** M E N U **************************************************/ - pClassMenu = InitClassMenu( pClassMgr, pClassMenuItem ); - pRoot->Insert( pClassMenu ); - - /********** M E N U I T E M ******************************************/ - // pClassMenu ist erst hier definiert - nId = aNmTb.Put( "SubMenu", VARNAME ); - pClassMenuItem->SetVariable( nId, pClassMenu, NULL, VAR_SVDYNAMIC, - RSC_MENUITEM_MENU ); - - /********** M E N U B U T T O N **************************************/ - pClassMenuButton = InitClassMenuButton( pClassControl, pClassMenu ); - pRoot->Insert( pClassMenuButton ); - - /********** M E S S A G E B O X **************************************/ - pClassMessBox = InitClassMessBox( pClassMgr, pMessButtons, - pMessDefButton ); - pRoot->Insert( pClassMessBox ); - - /********** I N F O B O X ********************************************/ - // Klasse anlegen - nId = pHS->getID( "InfoBox" ); - pClassInfoBox = new RscClass( nId, RSC_INFOBOX, pClassMessBox ); - pClassInfoBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassInfoBox ); - pRoot->Insert( pClassInfoBox ); - - /********** W A R N I N G B O X **************************************/ - // Klasse anlegen - nId = pHS->getID( "WarningBox" ); - pClassWarningBox = new RscClass( nId, RSC_WARNINGBOX, pClassMessBox ); - pClassWarningBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassWarningBox ); - pRoot->Insert( pClassWarningBox ); - - /********** E R R O R B O X ******************************************/ - // Klasse anlegen - nId = pHS->getID( "ErrorBox" ); - pClassErrorBox = new RscClass( nId, RSC_ERRORBOX, pClassMessBox ); - pClassErrorBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassErrorBox ); - pRoot->Insert( pClassErrorBox ); - - /********** Q U E R Y B O X ******************************************/ - // Klasse anlegen - nId = pHS->getID( "QueryBox" ); - pClassQueryBox = new RscClass( nId, RSC_QUERYBOX, pClassMessBox ); - pClassQueryBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassQueryBox ); - pRoot->Insert( pClassQueryBox ); -} -{ - /********** S P L I T T E R ******************************************/ - pClassSplitter = InitClassSplitter( pClassWindow ); - pRoot->Insert( pClassSplitter ); - - /********** S P L I T W I N D O W ************************************/ - pClassSplitWindow = InitClassSplitWindow( pClassWindow ); - pRoot->Insert( pClassSplitWindow ); - - /********** S P I N B U T T O N **************************************/ - // Klasse anlegen - nId = pHS->getID( "SpinButton" ); - pClassSpinButton = new RscClass( nId, RSC_SPINBUTTON, pClassControl ); - pClassSpinButton->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassSpinButton ); - { - RscClient * pClient; - - // Clientvariablen einfuegen - // Sysmodal - aBaseLst.push_back( - pClient = new RscClient( pHS->getID( "sal_Bool" ), RSC_NOTYPE, &aWinBits, nRepeatId ) - ); - nId = aNmTb.Put( "Repeat", VARNAME ); - pClassSpinButton->SetVariable( nId, pClient, NULL, - VAR_NODATAINST, 0, nWinBitVarId ); - } - pRoot->Insert( pClassSpinButton ); -} -{ - /********** T I M E **************************************************/ - pClassTime = InitClassTime( pClassMgr ); - pRoot->Insert( pClassTime ); - - /********** D A T E **************************************************/ - pClassDate = InitClassDate( pClassMgr ); - pRoot->Insert( pClassDate ); -} -{ - /********** S P I N F I E L D ****************************************/ - pClassSpinField = InitClassSpinField( pClassEdit ); - pRoot->Insert( pClassSpinField ); -} -{ - /********** P A T T E R N F I E L D **********************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassPatternFormatter( pClassSpinField ); - aBaseLst.push_back( pClassTmp ); - - pClassPatternField = InitClassPatternField( pClassTmp ); - pRoot->Insert( pClassPatternField ); - } - /********** N U M E R I C F I E L D **********************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassNumericFormatter( pClassSpinField ); - aBaseLst.push_back( pClassTmp ); - - pClassNumericField = InitClassNumericField( pClassTmp ); - pRoot->Insert( pClassNumericField ); - } - /********** M E T R I C F I E L D ************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassNumericFormatter( pClassSpinField ); - aBaseLst.push_back( pClassTmp ); - pClassTmp = InitClassMetricFormatter( pClassTmp, pFieldUnits ); - aBaseLst.push_back( pClassTmp ); - - pClassMetricField = InitClassMetricField( pClassTmp ); - pRoot->Insert( pClassMetricField ); - } - /********** C U R R E N C Y F I E L D ********************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassNumericFormatter( pClassSpinField ); - aBaseLst.push_back( pClassTmp ); - pClassTmp = InitClassCurrencyFormatter( pClassTmp, pFieldUnits ); - aBaseLst.push_back( pClassTmp ); - - pClassCurrencyField = InitClassCurrencyField( "CurrencyField", RSC_CURRENCYFIELD, pClassTmp ); - pRoot->Insert( pClassCurrencyField ); - - pClassLongCurrencyField = InitClassCurrencyField( "LongCurrencyField", RSC_LONGCURRENCYFIELD, pClassTmp ); - pRoot->Insert( pClassLongCurrencyField ); - - } - /********** D A T E F I E L D ****************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassDateFormatter( pClassSpinField, pClassDate ); - aBaseLst.push_back( pClassTmp ); - - pClassDateField = InitClassDateField( pClassTmp, pClassDate ); - pRoot->Insert( pClassDateField ); - } - /********** T I M E F I E L D ****************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassTimeFormatter( pClassSpinField, pClassTime, - pTimeFieldFormat ); - aBaseLst.push_back( pClassTmp ); - - pClassTimeField = InitClassTimeField( pClassTmp, pClassTime ); - pRoot->Insert( pClassTimeField ); - } - /********** P A T T E R N B O X **************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassPatternFormatter( pClassComboBox ); - aBaseLst.push_back( pClassTmp ); - - pClassPatternBox = InitClassPatternBox( pClassTmp ); - pRoot->Insert( pClassPatternBox ); - } - /********** N U M E R I C B O X **************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassNumericFormatter( pClassComboBox ); - aBaseLst.push_back( pClassTmp ); - - pClassNumericBox = InitClassNumericBox( pClassTmp ); - pRoot->Insert( pClassNumericBox ); - } -} -{ - /********** M E T R I C B O X ****************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassNumericFormatter( pClassComboBox ); - aBaseLst.push_back( pClassTmp ); - pClassTmp = InitClassMetricFormatter( pClassTmp, pFieldUnits ); - aBaseLst.push_back( pClassTmp ); - - pClassMetricBox = InitClassMetricBox( pClassTmp ); - pRoot->Insert( pClassMetricBox ); - } - /********** C U R R E N C Y B O X ************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassNumericFormatter( pClassComboBox ); - aBaseLst.push_back( pClassTmp ); - pClassTmp = InitClassCurrencyFormatter( pClassTmp, pFieldUnits ); - aBaseLst.push_back( pClassTmp ); - - pClassCurrencyBox = InitClassCurrencyBox( "CurrencyBox", RSC_CURRENCYBOX, pClassTmp ); - pRoot->Insert( pClassCurrencyBox ); - - pClassLongCurrencyBox = InitClassCurrencyBox( "LongCurrencyBox", RSC_LONGCURRENCYBOX, pClassTmp ); - pRoot->Insert( pClassLongCurrencyBox ); - } - /********** D A T E B O X ********************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassDateFormatter( pClassComboBox, pClassDate ); - aBaseLst.push_back( pClassTmp ); - - pClassDateBox = InitClassDateBox( pClassTmp, pClassDate ); - pRoot->Insert( pClassDateBox ); - } - /********** T I M E B O X ********************************************/ - { // Mehrfachvererbung von Hand - RscTop * pClassTmp = InitClassTimeFormatter( pClassComboBox, pClassTime, - pTimeFieldFormat ); - aBaseLst.push_back( pClassTmp ); - - pClassTimeBox = InitClassTimeBox( pClassTmp, pClassTime ); - pRoot->Insert( pClassTimeBox ); - } - /********** D O C K I N G W I N D O W ********************************/ - pClassDockingWindow = InitClassDockingWindow( pClassWindow, pMapUnit ); - pRoot->Insert( pClassDockingWindow ); - - /********** T O O L B O X I T E M ************************************/ - pClassToolBoxItem = InitClassToolBoxItem( pClassMgr, pClassBitmap, - pClassImage, pTriState ); - pRoot->Insert( pClassToolBoxItem ); - - /********** T O O L B O X ********************************************/ - pClassToolBox = InitClassToolBox( pClassDockingWindow, pClassToolBoxItem, - pClassImageList ); - pRoot->Insert( pClassToolBox ); - - /********** S T A T U S B A R ****************************************/ - pClassStatusBar = InitClassStatusBar( pClassWindow ); - pRoot->Insert( pClassStatusBar ); - - /********** M O R E B U T T O N **************************************/ - pClassMoreButton = InitClassMoreButton( pClassPushButton, pMapUnit ); - pRoot->Insert( pClassMoreButton ); - - /********** F L O A T W I N D O W ************************************/ - pClassFloatingWindow = InitClassFloatingWindow( pClassSystemWindow, - pMapUnit ); - pRoot->Insert( pClassFloatingWindow ); - - /********** T A B P A G E ********************************************/ - // Klasse anlegen - nId = pHS->getID( "TabPage" ); - pClassTabPage = - new RscClass( nId, RSC_TABPAGE, pClassWindow ); - pClassTabPage->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassTabPage ); - pRoot->Insert( pClassTabPage ); - - /********** T A B D I A L O G ****************************************/ - // Klasse anlegen - nId = pHS->getID( "TabDialog" ); - pClassTabDialog = - new RscClass( nId, RSC_TABDIALOG, pClassModalDialog ); - pClassTabDialog->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassTabDialog ); - pRoot->Insert( pClassTabDialog ); - - /********** T A B C O N T R O L I T E M *******************************/ - pClassTabControlItem = InitClassTabControlItem( pClassMgr, - pClassTabPage ); - pRoot->Insert( pClassTabControlItem ); - - /********** T A B C O N T R O L **************************************/ - pClassTabControl = InitClassTabControl( pClassControl, - pClassTabControlItem ); - pRoot->Insert( pClassTabControl ); - - /********** F I X E D L I N E ****************************************/ - // Klasse anlegen - nId = pHS->getID( "FixedLine" ); - pClassFixedLine = - new RscClass( nId, RSC_FIXEDLINE, pClassControl ); - pClassFixedLine->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - - INS_WINBIT(pClassFixedLine,Vert) - - aNmTb.Put( nId, CLASSNAME, pClassFixedLine ); - pRoot->Insert( pClassFixedLine ); - - /********** S C R O L L B A R B O X **********************************/ - // Klasse anlegen - nId = pHS->getID( "ScrollBarBox" ); - pClassScrollBarBox = - new RscClass( nId, RSC_SCROLLBARBOX, pClassWindow ); - pClassScrollBarBox->SetCallPar( *pWinPar1, *pWinPar2, *pWinParType ); - aNmTb.Put( nId, CLASSNAME, pClassScrollBarBox ); - pRoot->Insert( pClassScrollBarBox ); - INS_WINBIT(pClassScrollBarBox,Sizeable) - - /********** S F X S T Y L E F A M I L Y I T E M **********************/ - pClassSfxStyleFamilyItem = InitClassSfxStyleFamilyItem( pClassMgr, - pClassBitmap, - pClassImage, - pLangStringLongTupelList ); - pRoot->Insert( pClassSfxStyleFamilyItem ); - - /********** S F X T E M P L A T E D I A L O G ************************/ - pClassSfxTemplateDialog = InitClassSfxTemplateDialog( pClassMgr, - pClassSfxStyleFamilyItem ); - pRoot->Insert( pClassSfxTemplateDialog ); - - /********** S F X I N F O I T E M ************************************/ - pClassSfxSlotInfo = InitClassSfxSlotInfo( pClassMgr ); - pRoot->Insert( pClassSfxSlotInfo ); -} - NameToVerCtrl( aVersion, pRoot, pClassString ); - - aNmTb.SetSort(); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rsckey.cxx b/rsc/source/parser/rsckey.cxx deleted file mode 100644 index a3b88a1df8..0000000000 --- a/rsc/source/parser/rsckey.cxx +++ /dev/null @@ -1,175 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ -#include <stdlib.h> -#include <stdio.h> -#include <ctype.h> -#include <string.h> -#include <rscall.h> -#include <rsctools.hxx> -#include <rschash.hxx> -#include <rsckey.hxx> - -#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) -#define _cdecl __cdecl -#endif - -/****************** C o d e **********************************************/ -/****************** keyword sort function ********************************/ -extern "C" { - int SAL_CALL KeyCompare( const void * pFirst, const void * pSecond ); -} - -int SAL_CALL KeyCompare( const void * pFirst, const void * pSecond ) -{ - if( ((KEY_STRUCT *)pFirst)->nName > ((KEY_STRUCT *)pSecond)->nName ) - return( 1 ); - else if( ((KEY_STRUCT *)pFirst)->nName < ((KEY_STRUCT *)pSecond)->nName ) - return( -1 ); - else - return( 0 ); -} - -/************************************************************************* -|* -|* RscNameTable::RscNameTable() -|* -*************************************************************************/ -RscNameTable::RscNameTable() { - bSort = sal_True; - nEntries = 0; - pTable = NULL; -}; - -/************************************************************************* -|* -|* RscNameTable::~RscNameTable() -|* -*************************************************************************/ -RscNameTable::~RscNameTable() { - if( pTable ) - rtl_freeMemory( pTable ); -}; - - -/************************************************************************* -|* -|* RscNameTable::SetSort() -|* -*************************************************************************/ -void RscNameTable::SetSort( sal_Bool bSorted ){ - bSort = bSorted; - if( bSort && pTable){ - // Schluesselwort Feld sortieren - qsort( (void *)pTable, nEntries, - sizeof( KEY_STRUCT ), KeyCompare ); - }; -}; - -/************************************************************************* -|* -|* RscNameTable::Put() -|* -*************************************************************************/ -Atom RscNameTable::Put( Atom nName, sal_uInt32 nTyp, long nValue ){ - if( pTable ) - pTable = (KEY_STRUCT *) - rtl_reallocateMemory( (void *)pTable, - ((nEntries +1) * sizeof( KEY_STRUCT )) ); - else - pTable = (KEY_STRUCT *) - rtl_allocateMemory( ((nEntries +1) - * sizeof( KEY_STRUCT )) ); - pTable[ nEntries ].nName = nName; - pTable[ nEntries ].nTyp = nTyp; - pTable[ nEntries ].yylval = nValue; - nEntries++; - if( bSort ) - SetSort(); - return( nName ); -}; - -Atom RscNameTable::Put( const char * pName, sal_uInt32 nTyp, long nValue ) -{ - return( Put( pHS->getID( pName ), nTyp, nValue ) ); -}; - -Atom RscNameTable::Put( const char * pName, sal_uInt32 nTyp ) -{ - Atom nId; - - nId = pHS->getID( pName ); - return( Put( nId, nTyp, (long)nId ) ); -}; - -Atom RscNameTable::Put( Atom nName, sal_uInt32 nTyp, RscTop * pClass ) -{ - return( Put( nName, nTyp, (long)pClass ) ); -}; - -/************************************************************************* -|* -|* RscNameTable::Get() -|* -*************************************************************************/ -sal_Bool RscNameTable::Get( Atom nName, KEY_STRUCT * pEle ){ - KEY_STRUCT * pKey = NULL; - KEY_STRUCT aSearchName; - sal_uInt32 i; - - if( bSort ){ - // Suche nach dem Schluesselwort - aSearchName.nName = nName; - pKey = (KEY_STRUCT *)bsearch( -#ifdef UNX - (const char *) &aSearchName, (char *)pTable, -#else - (const void *) &aSearchName, (const void *)pTable, -#endif - nEntries, sizeof( KEY_STRUCT ), KeyCompare ); - } - else{ - i = 0; - while( i < nEntries && !pKey ){ - if( pTable[ i ].nName == nName ) - pKey = &pTable[ i ]; - i++; - }; - }; - - if( pKey ){ // Schluesselwort gefunden - *pEle = *pKey; - return( sal_True ); - }; - return( sal_False ); -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rsclex.cxx b/rsc/source/parser/rsclex.cxx deleted file mode 100644 index b21f4288f8..0000000000 --- a/rsc/source/parser/rsclex.cxx +++ /dev/null @@ -1,416 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> -#include <limits.h> - -#ifdef _RSCERROR_H -#include <rscerror.h> -#endif -#include <rschash.hxx> -#include <rscdb.hxx> -#include <rsctop.hxx> -#include <rsckey.hxx> -#include <rscpar.hxx> -#include <rscdef.hxx> - -#include "rsclex.hxx" -#include <yyrscyacc.hxx> - -#include <rtl/textcvt.h> -#include <rtl/textenc.h> - -using ::rtl::OString; -using ::rtl::OStringBuffer; -using ::rtl::OStringHash; - -const char* StringContainer::putString( const char* pString ) -{ - OString aString( static_cast<const sal_Char*>(pString) ); - std::pair< - boost::unordered_set< OString, OStringHash >::iterator, - bool > aInsert = - m_aStrings.insert( aString ); - - return aInsert.first->getStr(); -} - -/*************************************************************************/ -int c; -sal_Bool bLastInclude;// War letztes Symbol INCLUDE -RscFileInst* pFI; -RscTypCont* pTC; -RscExpression * pExp; -struct KeyVal { - int nKeyWord; - YYSTYPE aYYSType; -} aKeyVal[ 1 ]; -sal_Bool bTargetDefined; - -StringContainer* pStringContainer = NULL; - - -/****************** C O D E **********************************************/ -sal_uInt32 GetNumber(){ - sal_uInt32 l = 0; - sal_uInt32 nLog = 10; - - if( '0' == c ){ - c = pFI->GetFastChar(); - if( 'x' == c ){ - nLog = 16; - c = pFI->GetFastChar(); - } - }; - - if( nLog == 16 ){ - while( isxdigit( c ) ){ - if( isdigit( c ) ) - l = l * nLog + (c - '0'); - else - l = l * nLog + (toupper( c ) - 'A' + 10 ); - c = pFI->GetFastChar(); - } - } - else{ - while( isdigit( c ) || 'x' == c ){ - l = l * nLog + (c - '0'); - c = pFI->GetFastChar(); - } - } - - while( c=='U' || c=='u' || c=='l' || c=='L' ) //Wg. Unsigned Longs - c = pFI->GetFastChar(); - - if( l > 0x7fffffff ) //Oberstes bit gegebenenfalls abschneiden; - l &= 0x7fffffff; - - return( l ); -} - -int MakeToken( YYSTYPE * pTokenVal ){ - int c1; - - while( sal_True ){ // Kommentare und Leerzeichen ueberlesen - while( isspace( c ) ) - c = pFI->GetFastChar(); - if( '/' == c ){ - c1 = c; - c = pFI->GetFastChar(); - if( '/' == c ){ - while( '\n' != c && !pFI->IsEof() ) - c = pFI->GetFastChar(); - c = pFI->GetFastChar(); - } - else if( '*' == c ){ - c = pFI->GetFastChar(); - do { - while( '*' != c && !pFI->IsEof() ) - c = pFI->GetFastChar(); - c = pFI->GetFastChar(); - } while( '/' != c && !pFI->IsEof() ); - c = pFI->GetFastChar(); - } - else - return( c1 ); - } - else - break; - }; - - if( c == pFI->IsEof() ){ - return( 0 ); - } - - if( bLastInclude ){ - bLastInclude = sal_False; //Zuruecksetzten - if( '<' == c ){ - OStringBuffer aBuf( 256 ); - c = pFI->GetFastChar(); - while( '>' != c && !pFI->IsEof() ) - { - aBuf.append( sal_Char(c) ); - c = pFI->GetFastChar(); - }; - c = pFI->GetFastChar(); - pTokenVal->string = const_cast<char*>(pStringContainer->putString( aBuf.getStr() )); - return( INCLUDE_STRING ); - }; - } - - if( c == '"' ) - { - OStringBuffer aBuf( 256 ); - sal_Bool bDone = sal_False; - while( !bDone && !pFI->IsEof() && c ) - { - c = pFI->GetFastChar(); - if( c == '"' ) - { - do - { - c = pFI->GetFastChar(); - } - while( c == ' ' || c == '\t' ); - if( c == '"' ) - { - // this is a continued string - // note: multiline string continuations are handled by the parser - // see rscyacc.y - } - else - bDone = sal_True; - } - else if( c == '\\' ) - { - aBuf.append( '\\' ); - c = pFI->GetFastChar(); - if( c ) - aBuf.append( sal_Char(c) ); - } - else - aBuf.append( sal_Char(c) ); - } - pTokenVal->string = const_cast<char*>(pStringContainer->putString( aBuf.getStr() )); - return( STRING ); - } - if (isdigit (c)){ - pTokenVal->value = GetNumber(); - return( NUMBER ); - } - - if( isalpha (c) || (c == '_') ){ - Atom nHashId; - OStringBuffer aBuf( 256 ); - - while( isalnum (c) || (c == '_') || (c == '-') ) - { - aBuf.append( sal_Char(c) ); - c = pFI->GetFastChar(); - } - - nHashId = pHS->getID( aBuf.getStr(), true ); - if( InvalidAtom != nHashId ) - { - KEY_STRUCT aKey; - - // Suche nach dem Schluesselwort - if( pTC->aNmTb.Get( nHashId, &aKey ) ) - { - - // Schluesselwort gefunden - switch( aKey.nTyp ) - { - case CLASSNAME: - pTokenVal->pClass = (RscTop *)aKey.yylval; - break; - case VARNAME: - pTokenVal->varid = aKey.nName; - break; - case CONSTNAME: - pTokenVal->constname.hashid = aKey.nName; - pTokenVal->constname.nValue = aKey.yylval; - break; - case BOOLEAN: - pTokenVal->svbool = (sal_Bool)aKey.yylval; - break; - case INCLUDE: - bLastInclude = sal_True; - default: - pTokenVal->value = aKey.yylval; - }; - - return( aKey.nTyp ); - } - else - { - pTokenVal->string = const_cast<char*>(pStringContainer->putString( aBuf.getStr() )); - return( SYMBOL ); - } - } - else{ // Symbol - RscDefine * pDef; - - pDef = pTC->aFileTab.FindDef( aBuf.getStr() ); - if( pDef ){ - pTokenVal->defineele = pDef; - - return( RSCDEFINE ); - } - - pTokenVal->string = const_cast<char*>(pStringContainer->putString( aBuf.getStr() )); - return( SYMBOL ); - } - } - - if( c=='<' ) - { - c = pFI->GetFastChar(); - if( c=='<' ) - { - c = pFI->GetFastChar(); - return LEFTSHIFT; - } - else - return '<'; - } - - if( c=='>' ) - { - c = pFI->GetFastChar(); - if( c=='>' ) - { - c = pFI->GetFastChar(); - return RIGHTSHIFT; - } - else - return '>'; - } - - c1 = c; - c = pFI->GetFastChar(); - return( c1 ); -} - -#if defined( RS6000 ) -extern "C" int yylex() -#else -int yylex() -#endif -{ - if( bTargetDefined ) - bTargetDefined = sal_False; - else - aKeyVal[ 0 ].nKeyWord = - MakeToken( &aKeyVal[ 0 ].aYYSType ); - - yylval = aKeyVal[ 0 ].aYYSType; - return( aKeyVal[ 0 ].nKeyWord ); -} - -/****************** yyerror **********************************************/ -#ifdef RS6000 -extern "C" void yyerror( char* pMessage ) -#elif defined SOLARIS -extern "C" void yyerror( const char* pMessage ) -#else -void yyerror( char* pMessage ) -#endif -{ - pTC->pEH->Error( ERR_YACC, NULL, RscId(), pMessage ); -} - -/****************** parser start function ********************************/ -void InitParser( RscFileInst * pFileInst ) -{ - pTC = pFileInst->pTypCont; // Datenkontainer setzten - pFI = pFileInst; - pStringContainer = new StringContainer(); - pExp = NULL; //fuer MacroParser - bTargetDefined = sal_False; - - // Anfangszeichen initialisieren - bLastInclude = sal_False; - c = pFI->GetFastChar(); -} - -void EndParser(){ - // Stack abraeumen - while( ! S.IsEmpty() ) - S.Pop(); - - // free string container - delete pStringContainer; - pStringContainer = NULL; - - if( pExp ) - delete pExp; - pTC = NULL; - pFI = NULL; - pExp = NULL; - -} - -void IncludeParser( RscFileInst * pFileInst ) -{ - int nToken; // Wert des Tokens - YYSTYPE aYYSType; // Daten des Tokens - RscFile * pFName; // Filestruktur - sal_uLong lKey; // Fileschluessel - RscTypCont * pTypCon = pFileInst->pTypCont; - - pFName = pTypCon->aFileTab.Get( pFileInst->GetFileIndex() ); - InitParser( pFileInst ); - - nToken = MakeToken( &aYYSType ); - while( 0 != nToken && CLASSNAME != nToken ){ - if( '#' == nToken ){ - if( INCLUDE == (nToken = MakeToken( &aYYSType )) ){ - if( STRING == (nToken = MakeToken( &aYYSType )) ){ - lKey = pTypCon->aFileTab.NewIncFile( aYYSType.string, - aYYSType.string ); - pFName->InsertDependFile( lKey, ULONG_MAX ); - } - else if( INCLUDE_STRING == nToken ){ - lKey = pTypCon->aFileTab.NewIncFile( aYYSType.string, - ByteString() ); - pFName->InsertDependFile( lKey, ULONG_MAX ); - }; - }; - }; - nToken = MakeToken( &aYYSType ); - }; - - EndParser(); -} - -ERRTYPE parser( RscFileInst * pFileInst ) -{ - ERRTYPE aError; - - InitParser( pFileInst ); - - aError = yyparse(); - - EndParser(); - - // yyparser gibt 0 zurueck, wenn erfolgreich - if( 0 == aError ) - aError.Clear(); - if( pFileInst->pTypCont->pEH->nErrors ) - aError = ERR_ERROR; - pFileInst->SetError( aError ); - return( aError ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rsclex.hxx b/rsc/source/parser/rsclex.hxx deleted file mode 100644 index 433dbef26e..0000000000 --- a/rsc/source/parser/rsclex.hxx +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <tools/stack.hxx> - -#include <boost/unordered_set.hpp> -#include <rtl/strbuf.hxx> -#include <rtl/string.hxx> - -// a buffer for unique strings -class StringContainer -{ - boost::unordered_set< rtl::OString, rtl::OStringHash > m_aStrings; -public: - StringContainer() {} - ~StringContainer() {} - - const char* putString( const char* pString ); -}; - - -enum MODE_ENUM { MODE_MODELESS, MODE_APPLICATIONMODAL, MODE_SYSTEMMODAL }; - -enum JUSTIFY_ENUM { JUST_CENTER, JUST_RIGHT, JUST_LEFT }; - -enum SHOW_ENUM { SHOW_NORMAL, SHOW_MINIMIZED, SHOW_MAXIMIZED }; - -enum ENUMHEADER { HEADER_NAME, HEADER_NUMBER }; - -enum REF_ENUM { TYPE_NOTHING, TYPE_REF, TYPE_COPY }; - -struct RSCHEADER { - RscTop * pClass; - RscExpType nName1; - REF_ENUM nTyp; - RscTop * pRefClass; - RscExpType nName2; -}; - -/************** O b j e c t s t a c k ************************************/ -struct Node { - Node* pPrev; - RSCINST aInst; - sal_uInt32 nTupelRec; // Rekursionstiefe fuer Tupel - Node() { pPrev = NULL; nTupelRec = 0; }; -}; - -class ObjectStack { - private : - Node* pRoot; - public : - - ObjectStack () { pRoot = NULL; } - - const RSCINST & Top () { return pRoot->aInst; } - sal_Bool IsEmpty() { return( pRoot == NULL ); } - void IncTupelRec() { pRoot->nTupelRec++; } - void DecTupelRec() { pRoot->nTupelRec--; } - sal_uInt32 TupelRecCount() const { return pRoot->nTupelRec; } - void Push( RSCINST aInst ) - { - Node* pTmp; - - pTmp = pRoot; - pRoot = new Node; - pRoot->aInst = aInst; - pRoot->pPrev = pTmp; - } - void Pop() - { - Node* pTmp; - - pTmp = pRoot; - pRoot = pTmp->pPrev; - delete pTmp; - } -}; - -/****************** F o r w a r d s **************************************/ -#if defined( RS6000 ) -extern "C" int yyparse(); // forward Deklaration fuer erzeugte Funktion -extern "C" void yyerror( char * ); -extern "C" int yylex( void ); -#elif defined ( SOLARIS ) -extern "C" int yyparse(); // forward Deklaration fuer erzeugte Funktion -extern "C" void yyerror( const char * ); -extern "C" int yylex( void ); -#else -#if defined ( GCC ) || (_MSC_VER >= 1400) -int yyparse(); // forward Deklaration fuer erzeugte Funktion -#else -yyparse(); // forward Deklaration fuer erzeugte Funktion -#endif -void yyerror( char * ); -int yylex( void ); -#endif - -class RscTypCont; -class RscFileInst; - -extern RscTypCont* pTC; -extern RscFileInst * pFI; -extern RscExpression * pExp; -extern ObjectStack S; -extern StringContainer* pStringContainer; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rscpar.cxx b/rsc/source/parser/rscpar.cxx deleted file mode 100644 index 09fc415419..0000000000 --- a/rsc/source/parser/rscpar.cxx +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ -// C and C++ Includes. -#include <string.h> -#include <rscpar.hxx> -#include <rscdb.hxx> - -/****************** R s c F i l e I n s t ********************************/ -/****************** C O D E **********************************************/ -/************************************************************************* -|* -|* RscFileInst::Init() -|* -*************************************************************************/ -void RscFileInst::Init() -{ - nLineNo = 0; - nLineBufLen = 256; - pLine = (char *)rtl_allocateMemory( nLineBufLen ); - *pLine = '\0'; - nScanPos = 0; - cLastChar = '\0'; - bEof = sal_False; -}; - -/************************************************************************* -|* -|* RscFileInst::RscFileInst() -|* -*************************************************************************/ -RscFileInst::RscFileInst( RscTypCont * pTC, sal_uLong lIndexSrc, - sal_uLong lFIndex, FILE * fFile ) -{ - pTypCont = pTC; - Init(); - - lFileIndex = lFIndex; - lSrcIndex = lIndexSrc; - fInputFile = fFile; - - //Status: Zeiger am Ende des Lesepuffers - nInputPos = nInputEndPos = nInputBufLen = READBUFFER_MAX; - pInput = (char *)rtl_allocateMemory( nInputBufLen ); -} - -/************************************************************************* -|* -|* RscFileInst::~RscFileInst() -|* -*************************************************************************/ -RscFileInst::~RscFileInst(){ - if( pInput ) - rtl_freeMemory( pInput ); - if( pLine ) - rtl_freeMemory( pLine ); -} - -/************************************************************************* -|* -|* RscFileInst::GetChar() -|* -*************************************************************************/ -int RscFileInst::GetChar() -{ - if( pLine[ nScanPos ] ) - return( pLine[ nScanPos++ ] ); - else if( nInputPos >= nInputEndPos && nInputEndPos != nInputBufLen ) - { - // Dateiende - bEof = sal_True; - return 0; - } - else - { - GetNewLine(); - return( '\n' ); - } -} - -/************************************************************************* -|* -|* RscFileInst::GetNewLine() -|* -*************************************************************************/ -void RscFileInst::GetNewLine() -{ - nLineNo++; - nScanPos = 0; - - //laeuft bis Dateiende - sal_uInt32 nLen = 0; - while( (nInputPos < nInputEndPos) || (nInputEndPos == nInputBufLen) ) - { - if( (nInputPos >= nInputEndPos) && fInputFile ) - { - nInputEndPos = fread( pInput, 1, nInputBufLen, fInputFile ); - nInputPos = 0; - } - - while( nInputPos < nInputEndPos ) - { - //immer eine Zeile lesen - if( nLen >= nLineBufLen ) - { - nLineBufLen += 256; - // einen dazu fuer '\0' - pLine = (char*)rtl_reallocateMemory( pLine, nLineBufLen +1 ); - } - - // cr lf, lf cr, lf oder cr wird '\0' - if( pInput[ nInputPos ] == '\n' ){ - nInputPos++; - if( cLastChar != '\r' ){ - cLastChar = '\n'; - pLine[ nLen++ ] = '\0'; - goto END; - } - } - else if( pInput[ nInputPos ] == '\r' ){ - nInputPos++; - if( cLastChar != '\n' ){ - cLastChar = '\r'; - pLine[ nLen++ ] = '\0'; - goto END; - } - } - else - { - pLine[ nLen++ ] = pInput[ nInputPos++ ]; - if( nLen > 2 ) - { - if( (unsigned char)pLine[nLen-3] == 0xef && - (unsigned char)pLine[nLen-2] == 0xbb && - (unsigned char)pLine[nLen-1] == 0xbf ) - { - nLen -= 3; - } - } - } - }; - }; - - // Abbruch ueber EOF - pLine[ nLen ] = '\0'; - -END: - if( pTypCont->pEH->GetListFile() ){ - char buf[ 10 ]; - - sprintf( buf, "%5d ", (int)GetLineNo() ); - pTypCont->pEH->LstOut( buf ); - pTypCont->pEH->LstOut( GetLine() ); - pTypCont->pEH->LstOut( "\n" ); - } -} - -/************************************************************************* -|* -|* RscFileInst::SetError() -|* -*************************************************************************/ -void RscFileInst::SetError( ERRTYPE aError ) -{ - if( aError.IsOk() ) - { - aFirstError = aError; - nErrorLine = GetLineNo(); - nErrorPos = GetScanPos() -1; - }; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rscyacc.cxx b/rsc/source/parser/rscyacc.cxx deleted file mode 100644 index 8c505a80a9..0000000000 --- a/rsc/source/parser/rscyacc.cxx +++ /dev/null @@ -1,270 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -#include <stdio.h> -#include <ctype.h> -#include <string.h> - -#include <tools/rc.h> -#include <rscerror.h> -#include <rsctools.hxx> -#include <rscclass.hxx> -#include <rsccont.hxx> -#include <rsctree.hxx> -#include <rscdb.hxx> -#include <rscdef.hxx> -#include <rscpar.hxx> - -#include "rsclex.hxx" - -/************** V a r i a b l e n ****************************************/ -ObjectStack S; -RscTop * pCurClass; -sal_uInt32 nCurMask; -char szErrBuf[ 100 ]; - -/************** H i l f s F u n k t i o n e n ****************************/ -RSCINST GetVarInst( const RSCINST & rInst, const char * pVarName ) -{ - RSCINST aInst; - - aInst = rInst.pClass->GetVariable( rInst, pHS->getID( pVarName ), - RSCINST() ); - - if( !aInst.pData ) - pTC->pEH->Error( ERR_NOVARIABLENAME, rInst.pClass, RscId() ); - - return( aInst ); -} - -void SetNumber( const RSCINST & rInst, const char * pVarName, sal_Int32 lValue ) -{ - RSCINST aInst; - - aInst = GetVarInst( rInst, pVarName ); - - if( aInst.pData ){ - ERRTYPE aError; - aError = aInst.pClass->SetNumber( aInst, lValue ); - - if( aError.IsError() ) - pTC->pEH->Error( aError, aInst.pClass, RscId() ); - } -} - -void SetConst( const RSCINST & rInst, const char * pVarName, - Atom nValueId, sal_Int32 nVal ) -{ - RSCINST aInst; - - aInst = GetVarInst( rInst, pVarName ); - if( aInst.pData ) - { - ERRTYPE aError; - aError = aInst.pClass->SetConst( aInst, nValueId, nVal ); - - if( aError.IsError() ) - pTC->pEH->Error( aError, aInst.pClass, RscId() ); - } -} - -void SetString( const RSCINST & rInst, const char * pVarName, const char * pStr ) -{ - RSCINST aInst; - - aInst = GetVarInst( rInst, pVarName ); - if( aInst.pData ){ - ERRTYPE aError; - aError = aInst.pClass->SetString( aInst, pStr ); - - if( aError.IsError() ) - pTC->pEH->Error( aError, aInst.pClass, RscId() ); - } -} - -RscId MakeRscId( RscExpType aExpType ) -{ - if( !aExpType.IsNothing() ) - { - sal_Int32 lValue(0); - - if( !aExpType.Evaluate( &lValue ) ) - pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); - if( lValue < 1 || lValue > (sal_Int32)0x7FFF ) - { - pTC->pEH->Error( ERR_IDRANGE, NULL, RscId(), - rtl::OString::valueOf(lValue).getStr() ); - } - - if( aExpType.IsDefinition() ) - return RscId( aExpType.aExp.pDef ); - else - return RscId( lValue ); - } - return RscId(); -} - -sal_Bool DoClassHeader( RSCHEADER * pHeader, sal_Bool bMember ) -{ - RSCINST aCopyInst; - RscId aName1 = MakeRscId( pHeader->nName1 ); - RscId aName2 = MakeRscId( pHeader->nName2 ); - - if( pHeader->pRefClass ) - aCopyInst.pClass = pHeader->pRefClass; - else - aCopyInst.pClass = pHeader->pClass; - - if( TYPE_COPY == pHeader->nTyp ) - { - ObjNode * pCopyObj = aCopyInst.pClass->GetObjNode( aName2 ); - - if( !pCopyObj ) - { - ByteString aMsg( pHS->getString( aCopyInst.pClass->GetId() ) ); - aMsg += ' '; - aMsg += aName2.GetName(); - pTC->pEH->Error( ERR_NOCOPYOBJ, pHeader->pClass, aName1, - aMsg.GetBuffer() ); - } - else - aCopyInst.pData = pCopyObj->GetRscObj(); - } - - if( bMember ) - { - // Angabe von Superklassen oder abgeleiteten Klassen ist jetzt erlaubt - if( S.Top().pClass->InHierarchy( pHeader->pClass ) - || pHeader->pClass->InHierarchy( S.Top().pClass) ) - { - if( aCopyInst.IsInst() ) - { - RSCINST aTmpI( S.Top() ); - aTmpI.pClass->Destroy( aTmpI ); - aTmpI.pClass->Create( &aTmpI, aCopyInst ); - }; - } - else - pTC->pEH->Error( ERR_FALSETYPE, S.Top().pClass, aName1, - pHS->getString( pHeader->pClass->GetId() ) ); - } - else - { - if( S.IsEmpty() ) - { - if( (sal_Int32)aName1 < 256 ) - pTC->pEH->Error( WRN_GLOBALID, pHeader->pClass, aName1 ); - - if( aCopyInst.IsInst() ) - S.Push( pHeader->pClass->Create( NULL, aCopyInst ) ); - else - S.Push( pHeader->pClass->Create( NULL, RSCINST() ) ); - - ObjNode * pNode = new ObjNode( aName1, S.Top().pData, - pFI->GetFileIndex() ); - pTC->pEH->StdOut( ".", RscVerbosityVerbose ); - - if( !aName1.IsId() ) - pTC->pEH->Error( ERR_IDEXPECTED, pHeader->pClass, aName1 ); - else if( !pHeader->pClass->PutObjNode( pNode ) ) - pTC->pEH->Error( ERR_DOUBLEID, pHeader->pClass, aName1 ); - } - else - { - RSCINST aTmpI; - ERRTYPE aError; - - if( (sal_Int32)aName1 >= 256 && aName1.IsId() ) - pTC->pEH->Error( WRN_LOCALID, pHeader->pClass, aName1 ); - aError = S.Top().pClass->GetElement( S.Top(), aName1, - pHeader->pClass, aCopyInst, &aTmpI ); - - if( aError.IsWarning() ) - pTC->pEH->Error( aError, pHeader->pClass, aName1 ); - else if( aError.IsError() ) - { - if( ERR_CONT_INVALIDTYPE == aError ) - pTC->pEH->Error( aError, S.Top().pClass, aName1, - pHS->getString( pHeader->pClass->GetId() ) ); - else - pTC->pEH->Error( aError, S.Top().pClass, aName1 ); - S.Top().pClass->GetElement( S.Top(), RscId(), - pHeader->pClass, RSCINST(), &aTmpI ); - - if( !aTmpI.IsInst() ) - return( sal_False ); - } - S.Push( aTmpI ); - }; - }; - if( TYPE_REF == pHeader->nTyp ) - { - ERRTYPE aError; - - aError = S.Top().pClass->SetRef( S.Top(), aName2 ); - pTC->pEH->Error( aError, S.Top().pClass, aName1 ); - } - - return( sal_True ); -} - -RSCINST GetFirstTupelEle( const RSCINST & rTop ) -{ // Aufwaertskompatible, Tupel probieren - RSCINST aInst; - ERRTYPE aErr; - - aErr = rTop.pClass->GetElement( rTop, RscId(), NULL, RSCINST(), &aInst ); - if( !aErr.IsError() ) - aInst = aInst.pClass->GetTupelVar( aInst, 0, RSCINST() ); - return aInst; -} - -/************** Y a c c C o d e ****************************************/ -//#define YYDEBUG 1 - -#define TYPE_Atom 0 -#define TYPE_RESID 1 - -#ifdef UNX -#define YYMAXDEPTH 2000 -#else -#define YYMAXDEPTH 800 -#endif - -#if defined _MSC_VER -#pragma warning(push, 1) -#pragma warning(disable:4129 4273 4701 4702) -#endif -#include "yyrscyacc.cxx" -#if defined _MSC_VER -#pragma warning(pop) -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/parser/rscyacc.y b/rsc/source/parser/rscyacc.y deleted file mode 100644 index 24240d1842..0000000000 --- a/rsc/source/parser/rscyacc.y +++ /dev/null @@ -1,1118 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -%{ -#if defined __GNUC__ -#pragma GCC system_header -#elif defined __SUNPRO_CC -#pragma disable_warn -#endif -%} - -/* Compilerstack */ - -%union { - Atom varid; - struct { - Atom hashid; - sal_Int32 nValue; - } constname; - RscTop * pClass; - RSCHEADER header; - struct { - CLASS_DATA pData; - RscTop * pClass; - } instance; - sal_Int32 value; - sal_uInt16 ushort; - short exp_short; - char * string; - sal_Bool svbool; - REF_ENUM copyref; - RscDefine * defineele; - CharSet charset; - RscExpType macrostruct; -} - -/* Token */ -%token <value> NUMBER -%token <string> SYMBOL -%token <defineele> RSCDEFINE -%token <string> STRING -%token <string> INCLUDE_STRING -%token <character> CHARACTER -%token <svbool> BOOLEAN - -%token LINE -%token AUTO_ID -%token NOT -%token XSCALE -%token YSCALE -%token RGB -%token GEOMETRY -%token POSITION -%token DIMENSION -%token INZOOMOUTPUTSIZE -%token FLOATINGPOS -%token DEFINE -%token INCLUDE -%token MACROTARGET -%token DEFAULT - - -%token <pClass> CLASSNAME -%token <varid> VARNAME -%token <constname> CONSTNAME -%token CLASS -%token EXTENDABLE -%token WRITEIFSET - - -%type <macrostruct> macro_expression -%type <macrostruct> id_expression -%type <value> long_expression -%type <string> string_multiline - -%type <pClass> type -%type <pClass> type_base -%type <header> class_header_body -%type <header> class_header -%type <header> var_header_class -%type <copyref> copy_ref -%type <ushort> type_flags - - -%left '|' -%left '&' -%left LEFTSHIFT RIGHTSHIFT -%left '+' '-' -%left '*' '/' -%left UNARYMINUS -%left UNARYPLUS -%left ',' -%left '(' ')' - - -/* Grammatik */ - -%start resource_definitions - -%% - -/********************** D E F I N I T I O N S ****************************/ -resource_definitions - : - | resource_definitions resource_definition - | MACROTARGET macro_expression - { - RscExpType aExpType; - sal_Int32 lValue; - - aExpType.cType = RSCEXP_NOTHING; - pExp = new RscExpression( aExpType, '+', $2 ); - if( !pExp->Evaluate( &lValue ) ) - pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); - } - ; - -resource_definition - : line_number - | '#' DEFINE SYMBOL macro_expression - { - sal_Bool bError = sal_False; - - if( $4.IsNumber() ){ - if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(), - ByteString( $3 ), - $4.GetLong(), ULONG_MAX ) ) - bError = sal_True; - } - else if( $4.IsDefinition() ){ - RscExpType aExpType; - RscExpression * pExpr; - - aExpType.cType = RSCEXP_NOTHING; - aExpType.SetLong( 0 ); - aExpType.cType = RSCEXP_LONG; - pExpr = new RscExpression( aExpType, '+', $4 ); - - if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(), - ByteString( $3 ), pExpr, ULONG_MAX ) ) - bError = sal_True; - } - else if( $4.IsExpression() ){ - if( !pTC->aFileTab.NewDef( pFI->GetFileIndex(), - ByteString( $3 ), $4.aExp.pExp, - ULONG_MAX ) ) - bError = sal_True; - } - - if( bError ){ - pTC->pEH->Error( ERR_DECLAREDEFINE, NULL, RscId(), $3 ); - } - } - | '#' DEFINE RSCDEFINE macro_expression - { - pTC->pEH->Error( ERR_DOUBLEDEFINE, NULL, RscId(), $3->GetName().GetBuffer() ); - } - | '#' INCLUDE STRING - { - } - | '#' INCLUDE INCLUDE_STRING - { - } - | class_definition ';' - { -#ifdef D40 - void * pMem; - pMem = rtl_allocateMemory( 20000 ); - rtl_freeMemory( pMem ); -#endif - } - | new_class_definition_header '{' new_class_definition_body '}' ';' - | new_class_definition_header ';' - ; - -new_class_definition_header - : CLASS SYMBOL id_expression ':' CLASSNAME - { - sal_Int32 lType; - - $3.Evaluate( &lType ); - - // Klasse anlegen - Atom nId = pHS->getID( $2 ); - pCurClass = new RscClass( nId, lType, $5 ); - nCurMask = 1; - pTC->aNmTb.Put( nId, CLASSNAME, pCurClass ); - pTC->GetRoot()->Insert( pCurClass ); - } - | CLASS CLASSNAME id_expression ':' CLASSNAME - { - pCurClass = $2; - nCurMask = 1; - } - ; - -new_class_definition_body - : - | property_definition ';' new_class_definition_body - ; - -property_definition - : type_flags type SYMBOL - { - // Variable anlegen - Atom nId = pTC->aNmTb.Put( $3, VARNAME ); - pCurClass->SetVariable( nId, $2, NULL, $1, nCurMask ); - nCurMask <<= 1; - } - | type_flags type VARNAME - { - pCurClass->SetVariable( $3, $2, NULL, $1, nCurMask ); - nCurMask <<= 1; - } - ; - -type_flags - : type_flags EXTENDABLE - { - $$ = $1 | VAR_EXTENDABLE; - } - | type_flags WRITEIFSET - { - $$ = $1 | VAR_SVDYNAMIC; - } - | - { - $$ = 0; - } - ; - -type - : type_base - { - $$ = $1; - } - | type_base '[' ']' - { - if( $1 ) - { - ByteString aTypeName = pHS->getString( $1->GetId() ); - aTypeName += "[]"; - $$ = pTC->SearchType( pHS->getID( aTypeName.GetBuffer(), true ) ); - if( !$$ ) - { - RscCont * pCont; - pCont = new RscCont( pHS->getID( aTypeName.GetBuffer() ), RSC_NOTYPE ); - pCont->SetTypeClass( $1 ); - pTC->InsertType( pCont ); - $$ = pCont; - } - } - else - $$ = NULL; - } - ; - -type_base - : CLASSNAME - { - $$ = $1; - } - | SYMBOL - { - RscTop * pType = pTC->SearchType( pHS->getID( $1, true ) ); - if( !pType ) - pTC->pEH->Error( ERR_NOTYPE, pCurClass, RscId() ); - $$ = pType; - } - ; - -class_definition - : class_header class_body - { - if( TYPE_REF == $1.nTyp ) - pTC->pEH->Error( ERR_REFNOTALLOWED, S.Top().pClass, - RscId( $1.nName1 ) ); - S.Pop(); - } - | class_header - { - ERRTYPE aError; - RscId aRscId( $1.nName1 ); - - if( TYPE_NOTHING == $1.nTyp && aRscId.IsId() ) - aError = S.Top().pClass->SetRef( S.Top(), aRscId ); - else if( TYPE_COPY == $1.nTyp ) - aError = ERR_COPYNOTALLOWED; - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, aRscId ); - S.Pop(); - } - ; - -class_header - : class_header_body - { - if( !DoClassHeader( &$1, sal_False ) ) - return( ERR_ERROR ); - $$ = $1; - } - ; - -copy_ref - : '<' - { - $$ = TYPE_COPY; - } - | ',' - { - $$ = TYPE_REF; - } - ; - -class_header_body - : CLASSNAME id_expression copy_ref CLASSNAME id_expression - { - $$.pClass = $1; - $$.nName1 = $2; - $$.nTyp = $3; - $$.pRefClass = $4; - $$.nName2 = $5; - } - | CLASSNAME id_expression copy_ref id_expression - { - $$.pClass = $1; - $$.nName1 = $2; - $$.nTyp = $3; - $$.pRefClass = NULL; - $$.nName2 = $4; - } - | CLASSNAME id_expression - { - $$.pClass = $1; - $$.nName1 = $2; - $$.nTyp = TYPE_NOTHING; - $$.pRefClass = NULL; - $$.nName2.cType = RSCEXP_NOTHING; - } - | CLASSNAME copy_ref id_expression - { - $$.pClass = $1; - $$.nName1.cType = RSCEXP_NOTHING; - $$.nTyp = $2; - $$.pRefClass = NULL; - $$.nName2 = $3; - } - | CLASSNAME copy_ref CLASSNAME id_expression - { - $$.pClass = $1; - $$.nName1.cType = RSCEXP_NOTHING; - $$.nTyp = $2; - $$.pRefClass = $3; - $$.nName2 = $4; - } - | CLASSNAME - { - $$.pClass = $1; - $$.nName1.cType = RSCEXP_NOTHING; - $$.nTyp = TYPE_NOTHING; - $$.nName2.cType = RSCEXP_NOTHING; - } - ; - -class_body - : '{' var_definitions '}' - | '{' '}' - | string_multiline - { - SetString( S.Top(), "TEXT", $1 ); - } - ; - -var_definitions - : var_definition - | var_definitions var_definition - ; - -xy_mapmode - : CONSTNAME - { - SetConst( S.Top(), "_XYMAPMODE", $1.hashid, $1.nValue ); - } - | - ; - -wh_mapmode - : CONSTNAME - { - SetConst( S.Top(), "_WHMAPMODE", $1.hashid, $1.nValue ); - } - | - ; - -xywh_mapmode - : CONSTNAME - { - SetConst( S.Top(), "_XYMAPMODE", $1.hashid, $1.nValue ); - SetConst( S.Top(), "_WHMAPMODE", $1.hashid, $1.nValue ); - } - | - ; - -var_definition - : line_number - | var_header var_body ';' - { - S.Pop(); - } - | class_definition ';' - | var_header_class class_body ';' - { - if( TYPE_REF == $1.nTyp ) - pTC->pEH->Error( ERR_REFNOTALLOWED, S.Top().pClass, - RscId( $1.nName1 ) ); - - if( S.Top().pClass->GetCount( S.Top() ) ) - pTC->pEH->Error( WRN_SUBINMEMBER, S.Top().pClass, - RscId( $1.nName1 ) ); - - S.Pop(); - } - | var_header_class ';' - { - ERRTYPE aError; - RscId aRscId( $1.nName1 ); - - if( TYPE_NOTHING == $1.nTyp && aRscId.IsId() ) - aError = S.Top().pClass->SetRef( S.Top(), aRscId ); - else if( TYPE_COPY == $1.nTyp ) - aError = ERR_COPYNOTALLOWED; - if( S.Top().pClass->GetCount( S.Top() ) ) - aError = WRN_SUBINMEMBER; - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, aRscId ); - - S.Pop(); - } - | XSCALE '=' '(' long_expression ',' long_expression ')' ';' - { - SetNumber( S.Top(), "_XNUMERATOR", $4 ); - SetNumber( S.Top(), "_XDENOMINATOR", $6 ); - } - | YSCALE '=' '(' long_expression ',' long_expression ')' ';' - { - SetNumber( S.Top(), "_YNUMERATOR", $4 ); - SetNumber( S.Top(), "_YDENOMINATOR", $6 ); - } - | RGB '=' '(' long_expression ',' long_expression - ',' long_expression ')' ';' - { - SetNumber( S.Top(), "RED", $4 ); - SetNumber( S.Top(), "GREEN", $6 ); - SetNumber( S.Top(), "BLUE", $8 ); - } - | GEOMETRY '=' xywh_mapmode '(' long_expression ',' long_expression ',' - long_expression ',' long_expression ')' ';' - { - SetNumber( S.Top(), "_X", $5 ); - SetNumber( S.Top(), "_Y", $7 ); - SetNumber( S.Top(), "_WIDTH", $9 ); - SetNumber( S.Top(), "_HEIGHT", $11 ); - } - | POSITION '=' xy_mapmode '(' long_expression ',' long_expression - ')' ';' - { - SetNumber( S.Top(), "_X", $5 ); - SetNumber( S.Top(), "_Y", $7 ); - } - | DIMENSION '=' wh_mapmode '(' long_expression ',' long_expression - ')' ';' - { - SetNumber( S.Top(), "_WIDTH", $5 ); - SetNumber( S.Top(), "_HEIGHT", $7 ); - } - | INZOOMOUTPUTSIZE '=' CONSTNAME '(' long_expression ',' long_expression - ')' ';' - { - SetConst( S.Top(), "_ZOOMINMAPMODE", $3.hashid, $3.nValue ); - SetNumber( S.Top(), "_ZOOMINWIDTH", $5 ); - SetNumber( S.Top(), "_ZOOMINHEIGHT", $7 ); - } - | INZOOMOUTPUTSIZE '=' '(' long_expression ',' long_expression ')' ';' - { - SetNumber( S.Top(), "_ZOOMINWIDTH", $4 ); - SetNumber( S.Top(), "_ZOOMINHEIGHT", $6 ); - } - | FLOATINGPOS '=' CONSTNAME '(' long_expression ',' long_expression - ')' ';' - { - SetConst( S.Top(), "_FLOATINGPOSMAPMODE", $3.hashid, $3.nValue ); - SetNumber( S.Top(), "_FLOATINGPOSX", $5 ); - SetNumber( S.Top(), "_FLOATINGPOSY", $7 ); - } - | FLOATINGPOS '=' '(' long_expression ',' long_expression ')' ';' - { - SetNumber( S.Top(), "_FLOATINGPOSX", $4 ); - SetNumber( S.Top(), "_FLOATINGPOSY", $6 ); - } - ; - -var_header_class - : VARNAME '=' class_header_body - { - RSCINST aInst; - - aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST(), sal_False, $3.pClass ); - - if( aInst.pData ) - S.Push( aInst ); - else - { - pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), - pHS->getString( $1 ) ); - return( ERR_ERROR ); - }; - - if( !DoClassHeader( &$3, sal_True ) ) - return( ERR_ERROR ); - $$ = $3; - } - | VARNAME '[' CONSTNAME ']' '=' class_header_body - { - RSCINST aInst; - - aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); - - if( aInst.pData ) - { - ERRTYPE aError; - RSCINST aIdxInst; - - aError = aInst.pClass->GetArrayEle( aInst, $3.hashid, NULL, &aIdxInst ); - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - if( aError.IsError() ) - return( ERR_ERROR ); - S.Push( aIdxInst ); - } - else - { - pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), - pHS->getString( $1 ) ); - return( ERR_ERROR ); - }; - if( !DoClassHeader( &$6, sal_True ) ) - return( ERR_ERROR ); - $$ = $6; - } - | VARNAME '[' SYMBOL ']' '=' class_header_body - { - RSCINST aInst; - - aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); - - if( aInst.pData ) - { - long nNewLang = pTC->AddLanguage( $3 ); - ERRTYPE aError; - RSCINST aIdxInst; - - aError = aInst.pClass->GetArrayEle( aInst, nNewLang, NULL, &aIdxInst ); - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - if( aError.IsError() ) - return( ERR_ERROR ); - S.Push( aIdxInst ); - } - else - { - pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), - pHS->getString( $1 ) ); - return( ERR_ERROR ); - }; - if( !DoClassHeader( &$6, sal_True ) ) - return( ERR_ERROR ); - $$ = $6; - } - ; - -var_header - : VARNAME '=' - { - RSCINST aInst; - - aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); - - if( aInst.pData ) - S.Push( aInst ); - else{ - pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), - pHS->getString( $1 ) ); - return( ERR_ERROR ); - }; - } - | VARNAME '[' CONSTNAME ']' '=' - { - RSCINST aInst; - - aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); - - if( aInst.pData ) - { - ERRTYPE aError; - RSCINST aIdxInst; - - aError = aInst.pClass->GetArrayEle( aInst, $3.hashid, NULL, &aIdxInst ); - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - if( aError.IsError() ) - return( ERR_ERROR ); - S.Push( aIdxInst ); - } - else{ - pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), - pHS->getString( $1 ) ); - return( ERR_ERROR ); - }; - } - | VARNAME '[' SYMBOL ']' '=' - { - RSCINST aInst; - - aInst = S.Top().pClass->GetVariable( S.Top(), $1, RSCINST() ); - - if( aInst.pData ) - { - long nNewLang = pTC->AddLanguage( $3 ); - ERRTYPE aError; - RSCINST aIdxInst; - - aError = aInst.pClass->GetArrayEle( aInst, nNewLang, NULL, &aIdxInst ); - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - if( aError.IsError() ) - return( ERR_ERROR ); - S.Push( aIdxInst ); - } - else{ - pTC->pEH->Error( ERR_NOVARIABLENAME, S.Top().pClass, RscId(), - pHS->getString( $1 ) ); - return( ERR_ERROR ); - }; - } - ; -tupel_header0 - : - { - RSCINST aInst; - - aInst = S.Top().pClass->GetTupelVar( S.Top(), 0, RSCINST() ); - if( aInst.pData ) - S.Push( aInst ); - else - { - pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); - return( ERR_ERROR ); - }; - } - ; - -tupel_header1 - : - { - RSCINST aInst; - - aInst = S.Top().pClass->GetTupelVar( S.Top(), 1, RSCINST() ); - if( aInst.pData ) - S.Push( aInst ); - else - { - pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); - return( ERR_ERROR ); - }; - } - ; - -tupel_header2 - : - { - RSCINST aInst; - - aInst = S.Top().pClass->GetTupelVar( S.Top(), 2, RSCINST() ); - if( aInst.pData ) - S.Push( aInst ); - else - { - pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); - return( ERR_ERROR ); - }; - } - ; - -tupel_header3 - : - { - RSCINST aInst; - - aInst = S.Top().pClass->GetTupelVar( S.Top(), 3, RSCINST() ); - if( !aInst.pData ) - { - pTC->pEH->Error( ERR_NOTUPELNAME, S.Top().pClass, RscId() ); - return( ERR_ERROR ); - }; - S.Push( aInst ); - } - ; - -tupel_body - : var_body - { - S.Pop(); - } - ; - -var_list_header - : - { - ERRTYPE aError; - RSCINST aInst; - - aError = S.Top().pClass->GetElement( S.Top(), RscId(), - NULL, RSCINST(), &aInst ); - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - if( aError.IsError() ) - { // unbedingt Instanz auf den Stack bringen - aInst = S.Top().pClass->Create( NULL, RSCINST() ); - } - S.Push( aInst ); - } - ; - -list_body - : var_bodycomplex - { - S.Pop(); - } - ; - -list_header - : - { - sal_uInt32 nCount = S.Top().pClass->GetCount( S.Top() ); - sal_uInt32 i; - - for( i = nCount; i > 0; i-- ) - S.Top().pClass->DeletePos( S.Top(), i -1 ); - } - ; - -list - : list var_list_header list_body ';' - | list var_bodysimple ';' - | list class_definition ';' - | list line_number - | - ; - -var_bodysimple - : macro_expression - { - sal_Int32 l; - ERRTYPE aError; - - if( !$1.Evaluate( &l ) ) - pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); - else - { - aError = S.Top().pClass->SetRef( S.Top(), RscId( $1 ) ); - if( aError.IsError() ) - { - aError.Clear(); - aError = S.Top().pClass->SetNumber( S.Top(), l ); - } - if( aError.IsError() ) - { // Aufwaertskompatible, Tupel probieren - RSCINST aInst = GetFirstTupelEle( S.Top() ); - if( aInst.pData ) - { - aError.Clear(); // Fehler zuruecksetzen - aError = aInst.pClass->SetRef( aInst, RscId( $1 ) ); - if( aError.IsError() ) - { - aError.Clear(); - aError = aInst.pClass->SetNumber( aInst, l ); - } - } - } - } - - if( $1.IsExpression() ) - delete $1.aExp.pExp; - - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - } - | CONSTNAME - { - ERRTYPE aError; - aError = S.Top().pClass->SetConst( S.Top(), $1.hashid, $1.nValue ); - if( aError.IsError() ) - { // Aufwaertskompatible, Tupel probieren - RSCINST aInst = GetFirstTupelEle( S.Top() ); - if( aInst.pData ) - { - aError.Clear(); // Fehler zuruecksetzen - aError = aInst.pClass->SetConst( aInst, $1.hashid, $1.nValue ); - } - } - - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - } - | NOT CONSTNAME - { - ERRTYPE aError; - aError = S.Top().pClass->SetNotConst( S.Top(), $2.hashid ); - if( aError.IsError() ) - { // Aufwaertskompatible, Tupel probieren - RSCINST aInst = GetFirstTupelEle( S.Top() ); - if( aInst.pData ) - { - aError.Clear(); // Fehler zuruecksetzen - aError = aInst.pClass->SetNotConst( aInst, $2.hashid ); - } - } - - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - } - | BOOLEAN - { - ERRTYPE aError; - aError = S.Top().pClass->SetBool( S.Top(), $1 ); - if( aError.IsError() ) - { // Aufwaertskompatible, Tupel probieren - RSCINST aInst = GetFirstTupelEle( S.Top() ); - if( aInst.pData ) - { - aError.Clear(); // Fehler zuruecksetzen - aError = aInst.pClass->SetBool( aInst, $1 ); - } - } - - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - } - | string_multiline - { - ERRTYPE aError; - aError = S.Top().pClass->SetString( S.Top(), $1 ); - if( aError.IsError() ) - { // Aufwaertskompatible, Tupel probieren - RSCINST aInst = GetFirstTupelEle( S.Top() ); - if( aInst.pData ) - { - aError.Clear(); // Fehler zuruecksetzen - aError = aInst.pClass->SetString( aInst, $1 ); - } - } - - if( aError.IsError() || aError.IsWarning() ) - pTC->pEH->Error( aError, S.Top().pClass, RscId() ); - } - | DEFAULT - ; - -var_bodycomplex - : '{' list_header list '}' - | '<' tupel_header0 tupel_body ';' '>' - | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';' '>' - | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';' - tupel_header2 tupel_body ';' '>' - | '<' tupel_header0 tupel_body ';' tupel_header1 tupel_body ';' - tupel_header2 tupel_body ';' tupel_header3 tupel_body ';' '>' - ; - -var_body - : var_bodysimple - | var_bodycomplex - ; - -/********************** work on yacc stack *******************************/ -string_multiline - : STRING - { - $$ = $1; - } - | string_multiline STRING - { - rtl::OStringBuffer aBuf( 256 ); - aBuf.append( $1 ); - aBuf.append( $2 ); - $$ = (char*)pStringContainer->putString( aBuf.getStr() ); - } - ; - -long_expression - : macro_expression - { - if( !$1.Evaluate( &$$ ) ) - pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); - if( $1.IsExpression() ) - delete $1.aExp.pExp; - } - ; - -macro_expression - : RSCDEFINE - { - $$.cType = RSCEXP_DEF; - $$.aExp.pDef = $1; - } - | NUMBER - { - $$.cType = RSCEXP_LONG; - $$.SetLong( $1 ); - } - | '-' macro_expression %prec UNARYMINUS - { - if( $2.IsNumber() ){ - $$.cType = $2.cType; - $$.SetLong( - $2.GetLong() ); - } - else{ - RscExpType aLeftExp; - - aLeftExp.cType = RSCEXP_NOTHING; - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( aLeftExp, '-', $2 ); - } - } - | '+' macro_expression %prec UNARYPLUS - { - $$ = $2; - } - | macro_expression '+' macro_expression - { - if( $1.IsNumber() && $3.IsNumber() ){ - $$.cType = RSCEXP_LONG; - $$.SetLong( $1.GetLong() + $3.GetLong() ); - } - else{ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, '+', $3 ); - } - } - | macro_expression '-' macro_expression - { - if( $1.IsNumber() && $3.IsNumber() ){ - $$.cType = RSCEXP_LONG; - $$.SetLong( $1.GetLong() - $3.GetLong() ); - } - else{ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, '-', $3 ); - } - } - | macro_expression '*' macro_expression - { - if( $1.IsNumber() && $3.IsNumber() ){ - $$.cType = RSCEXP_LONG; - $$.SetLong( $1.GetLong() * $3.GetLong() ); - } - else{ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, '*', $3 ); - } - } - | macro_expression '/' macro_expression - { - if( $1.IsNumber() && $3.IsNumber() ){ - if( 0 == $3.GetLong() ){ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, '/', $3 ); - } - else{ - $$.cType = RSCEXP_LONG; - $$.SetLong( $1.GetLong() / $3.GetLong() ); - } - } - else{ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, '/', $3 ); - } - } - | macro_expression '&' macro_expression - { - if( $1.IsNumber() && $3.IsNumber() ){ - $$.cType = RSCEXP_LONG; - $$.SetLong( $1.GetLong() & $3.GetLong() ); - } - else{ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, '&', $3 ); - } - } - | macro_expression '|' macro_expression - { - if( $1.IsNumber() && $3.IsNumber() ){ - $$.cType = RSCEXP_LONG; - $$.SetLong( $1.GetLong() | $3.GetLong() ); - } - else{ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, '|', $3 ); - } - } - | '(' macro_expression ')' - { - $$ = $2; - } - | macro_expression LEFTSHIFT macro_expression - { - if( $1.IsNumber() && $3.IsNumber() ){ - $$.cType = RSCEXP_LONG; - $$.SetLong( $1.GetLong() << $3.GetLong() ); - } - else{ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, 'l', $3 ); - } - } - | macro_expression RIGHTSHIFT macro_expression - { - if( $1.IsNumber() && $3.IsNumber() ){ - $$.cType = RSCEXP_LONG; - $$.SetLong( $1.GetLong() >> $3.GetLong() ); - } - else{ - $$.cType = RSCEXP_EXP; - $$.aExp.pExp = new RscExpression( $1, 'r', $3 ); - } - } - ; - -id_expression - : id_expression line_number - | macro_expression - { // pExpession auswerten und loeschen - if( RSCEXP_EXP == $1.cType ){ - sal_Int32 lValue; - - if( !$1.Evaluate( &lValue ) ) - pTC->pEH->Error( ERR_ZERODIVISION, NULL, RscId() ); - delete $1.aExp.pExp; - $$.cType = RSCEXP_LONG; - $$.SetLong( lValue ); - } - else - $$ = $1; - } - ; - -DUMMY_NUMBER - : NUMBER - { - } - | - { - } - ; - -line_number - : '#' LINE NUMBER STRING - { - RscFile * pFName; - - pFI->SetLineNo( $3 ); - pFI->SetFileIndex( pTC->aFileTab.NewCodeFile( ByteString( $4 ) ) ); - pFName = pTC->aFileTab.Get( pFI->GetFileIndex() ); - pFName->bLoaded = sal_True; - pFName->bScanned = sal_True; - } - | '#' NUMBER STRING DUMMY_NUMBER - { - RscFile * pFName; - - pFI->SetLineNo( $2 ); - pFI->SetFileIndex( pTC->aFileTab.NewCodeFile( ByteString( $3 ) ) ); - pFName = pTC->aFileTab.Get( pFI->GetFileIndex() ); - pFName->bLoaded = sal_True; - pFName->bScanned = sal_True; - } - | '#' NUMBER - { - pFI->SetLineNo( $2 ); - } - ; - - - - diff --git a/rsc/source/prj/gui.cxx b/rsc/source/prj/gui.cxx deleted file mode 100644 index a95111cf83..0000000000 --- a/rsc/source/prj/gui.cxx +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" - -#include <stdlib.h> -#include <stdio.h> -#include <rscrsc.hxx> -#include <rscdb.hxx> - -/*************** G l o b a l e V a r i a b l e n **********************/ -static RscCompiler * pRscCompiler = NULL; -/****************************************************************/ -/* */ -/* Function : ExitProgram() */ -/* */ -/* Description : Gibt die Temporaeren Dateien frei. */ -/****************************************************************/ -#if defined( UNX ) || defined ( GCC ) || defined(__MINGW32__) - void ExitProgram( void ){ -#else - void cdecl ExitProgram( void ){ -#endif - if( pRscCompiler ) - delete pRscCompiler; -} - -RscVerbosity lcl_determineVerbosity( int argc, char ** argv ) -{ - for ( int i = 0; i < argc; ++i ) - { - if ( argv[i] == NULL ) - continue; - if ( rsc_stricmp( argv[i], "-verbose" ) == 0 ) - return RscVerbosityVerbose; - if ( rsc_stricmp( argv[i], "-quiet" ) == 0 ) - return RscVerbositySilent; - } - return RscVerbosityNormal; -} - -int rsc2_main( int argc, char **argv ) -{ -#ifndef UNX - atexit( ExitProgram ); -#endif -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "debugging %s\n", argv[0] ); -#endif - - ERRTYPE aError; - - InitRscCompiler(); - RscError* pErrHdl = new RscError( lcl_determineVerbosity( argc, argv ) ); - RscCmdLine* pCmdLine = new RscCmdLine( argc, argv, pErrHdl ); - RscTypCont* pTypCont = new RscTypCont( pErrHdl, - pCmdLine->nByteOrder, - pCmdLine->aPath, - pCmdLine->nCommands ); - - if( pErrHdl->nErrors ) - aError = ERR_ERROR; - else{ - RscCompiler* pCompiler = new RscCompiler( pCmdLine, pTypCont ); - - pRscCompiler = pCompiler; - aError = pCompiler->Start(); - pRscCompiler = NULL; - - delete pCompiler; - } - - delete pTypCont; - delete pCmdLine; - delete pErrHdl; - delete pHS; // wird durch InitRscCompiler erzeugt - - if( aError.IsOk() ) - return( 0 ); - else - return( 1 ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/prj/makefile.mk b/rsc/source/prj/makefile.mk deleted file mode 100644 index f703d3e45b..0000000000 --- a/rsc/source/prj/makefile.mk +++ /dev/null @@ -1,67 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=rsc -TARGETTYPE=CUI -TARGET=rsc -LIBTARGET=NO - -# --- Settings ----------------------------------------------------------- - -ENABLE_EXCEPTIONS=true - -.INCLUDE : settings.mk - -.IF "$(BUILD_TYPE)"=="$(BUILD_TYPE:s/DESKTOP//)" -ALL: - @echo No need for this on non-desktop OSes -.ENDIF - -# --- Files -------------------------------------------------------------- - -OBJFILES= $(OBJ)$/gui.obj \ - $(OBJ)$/start.obj - -APP1TARGET= rsc -APP1STDLIBS=$(TOOLSLIB) $(I18NISOLANGLIB) $(SALLIB) # $(RTLLIB) -APP1LIBS= $(LB)$/rscmis.lib \ - $(LB)$/rscpar.lib \ - $(LB)$/rscres.lib \ - $(LB)$/rscrsc.lib \ - $(LB)$/rscpp.lib \ - $(LB)$/rsctoo.lib -APP1OBJS= $(OBJ)$/start.obj \ - $(OBJ)$/gui.obj -APP1STACK=64000 -APP1RPATH=NONE - -# --- Targets ------------------------------------------------------------ - -.INCLUDE : target.mk - diff --git a/rsc/source/prj/start.cxx b/rsc/source/prj/start.cxx deleted file mode 100644 index 5360955757..0000000000 --- a/rsc/source/prj/start.cxx +++ /dev/null @@ -1,354 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" - -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> -#include <string.h> - -#ifdef UNX -#include <unistd.h> -#include <sys/wait.h> -#else // UNX - -#include <io.h> -#include <process.h> -#include <dos.h> - -#endif // UNX -#include <rsctools.hxx> -#include <rscerror.h> -#include <sal/main.h> -#include <tools/fsys.hxx> - -/*************** C O D E ************************************************/ - -// Entry point declaration for modules rscpp and rsc2 -extern "C" -{ - int rscpp_main(int, char**); -} -int rsc2_main(int, char**); - -/************************************************************************* -|* CallPrePro() -|* -|* Beschreibung -*************************************************************************/ -static sal_Bool CallPrePro( const ByteString& rInput, - const ByteString& rOutput, - RscPtrPtr * pCmdLine, - sal_Bool bResponse ) -{ - RscPtrPtr aNewCmdL; // Kommandozeile - RscPtrPtr aRespCmdL; // Kommandozeile - RscPtrPtr * pCmdL = &aNewCmdL; - int i, nRet; - FILE* fRspFile = NULL; - ByteString aRspFileName; - - if( bResponse ) - { - aRspFileName = ::GetTmpFileName(); - fRspFile = fopen( aRspFileName.GetBuffer(), "w" ); - } - - if( !fRspFile ) - aNewCmdL.Append( rsc_strdup( "rscpp" ) ); - - bool bVerbose = false; - for( i = 1; i < int(pCmdLine->GetCount() -1); i++ ) - { - if ( 0 == rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-verbose" ) ) - { - bVerbose = true; - continue; - } - if ( !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-u", 2 ) - || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-i", 2 ) - || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-d", 2 ) - ) - { - aNewCmdL.Append( rsc_strdup( (char *)pCmdLine->GetEntry( i ) ) ); - } - } - - aNewCmdL.Append( rsc_strdup( rInput.GetBuffer() ) ); - aNewCmdL.Append( rsc_strdup( rOutput.GetBuffer() ) ); - aNewCmdL.Append( (void *)0 ); - - if ( bVerbose ) - { - printf( "Preprocessor commandline: " ); - for( i = 0; i < (int)(pCmdL->GetCount() -1); i++ ) - { - printf( " " ); - printf( "%s", (const char *)pCmdL->GetEntry( i ) ); - } - printf( "\n" ); - } - - if( fRspFile ) - { - aRespCmdL.Append( rsc_strdup( "rscpp" ) ); - ByteString aTmpStr( '@' ); - aTmpStr += aRspFileName; - aRespCmdL.Append( rsc_strdup( aTmpStr.GetBuffer() ) ); - aRespCmdL.Append( (void *)0 ); - - pCmdL = &aRespCmdL; - for( i = 0; i < (int)(aNewCmdL.GetCount() -1); i++ ) - { - fprintf( fRspFile, "%s ", (const char *)aNewCmdL.GetEntry( i ) ); - } - fclose( fRspFile ); - - if ( bVerbose ) - { - printf( "Preprocessor startline: " ); - for( i = 0; i < (int)(pCmdL->GetCount() -1); i++ ) - { - printf( " " ); - printf( "%s", (const char *)pCmdL->GetEntry( i ) ); - } - printf( "\n" ); - } - } - - nRet = rscpp_main( pCmdL->GetCount()-1, (char**)pCmdL->GetBlock() ); - - if ( fRspFile ) - #if OSL_DEBUG_LEVEL > 5 - fprintf( stderr, "leaving response file %s\n", aRspFileName.GetBuffer() ); - #else - unlink( aRspFileName.GetBuffer() ); - #endif - if ( nRet ) - return sal_False; - - return sal_True; -} - - -/************************************************************************* -|* CallRsc2 -|* -|* Beschreibung -*************************************************************************/ -static sal_Bool CallRsc2( RscStrList * pInputList, - ByteString aSrsName, - RscPtrPtr * pCmdLine ) -{ - int nRet; - ByteString* pString; - RscVerbosity eVerbosity = RscVerbosityNormal; - - RscPtrPtr aNewCmdL; - aNewCmdL.Append( rsc_strdup( "rsc2" ) ); - - for (int i = 1; i < (int)(pCmdLine->GetCount() -1); ++i) - { - if ( !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-verbose" ) ) - { - eVerbosity = RscVerbosityVerbose; - continue; - } - if ( !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-quiet" ) ) - { - eVerbosity = RscVerbositySilent; - continue; - } - if( !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-fp=", 4 ) - || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-fo=", 4 ) - || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-presponse", 9 ) - || !rsc_strnicmp( (char *)pCmdLine->GetEntry( i ), "-rc", 3 ) - || !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-+" ) - || !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-br" ) - || !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-bz" ) - || !rsc_stricmp( (char *)pCmdLine->GetEntry( i ), "-r" ) - || ( '-' != *(char *)pCmdLine->GetEntry( i ) ) ) - { - } - else - aNewCmdL.Append( rsc_strdup( (char *)pCmdLine->GetEntry( i ) ) ); - }; - - aNewCmdL.Append( rsc_strdup( aSrsName.GetBuffer() ) ); - - for ( size_t i = 0, n = pInputList->size(); i < n; ++i ) - { - pString = (*pInputList)[ i ]; - aNewCmdL.Append( rsc_strdup( pString->GetBuffer() ) ); - }; - - if ( eVerbosity >= RscVerbosityVerbose ) - { - printf( "Rsc2 commandline: " ); - for( size_t i = 0; i < (unsigned int)(aNewCmdL.GetCount() -1); i++ ) - { - printf( " %s", (const char *)aNewCmdL.GetEntry( i ) ); - } - printf( "\n" ); - } - - nRet = rsc2_main( aNewCmdL.GetCount(), (char**)aNewCmdL.GetBlock() ); - - if( nRet ) - return( sal_False ); - return( sal_True ); -} - -/************************************************************************* -|* -|* main() -|* -*************************************************************************/ -SAL_IMPLEMENT_MAIN_WITH_ARGS(argc, argv) -{ - sal_Bool bPrePro = sal_True; - sal_Bool bHelp = sal_False; - sal_Bool bError = sal_False; - sal_Bool bResponse = sal_False; - ByteString aSrsName; - ByteString aResName; - RscStrList aInputList; - RscStrList aTmpList; - char * pStr; - char ** ppStr; - RscPtrPtr aCmdLine; // Kommandozeile - sal_uInt32 i; - ByteString* pString; - - pStr = ::ResponseFile( &aCmdLine, argv, argc ); - if( pStr ) - { - printf( "Cannot open response file <%s>\n", pStr ); - return( 1 ); - }; - - ppStr = (char **)aCmdLine.GetBlock(); - ppStr++; - i = 1; - sal_Bool bSetSrs = sal_False; - while( ppStr && i < (aCmdLine.GetCount() -1) ) - { - if( '-' == **ppStr ) - { - if( !rsc_stricmp( (*ppStr) + 1, "p" ) - || !rsc_stricmp( (*ppStr) + 1, "l" ) ) - { // kein Preprozessor - bPrePro = sal_False; - } - else if( !rsc_stricmp( (*ppStr) + 1, "h" ) ) - { // Hilfe anzeigen - bHelp = sal_True; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "presponse", 9 ) ) - { // whether to use response file when parameterising preprocessor - bResponse = sal_True; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fo=", 3 ) ) - { // anderer Name fuer .res-file - aResName = (*ppStr) + 4; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fp=", 3 ) ) - { // anderer Name fuer .srs-file - bSetSrs = sal_True; - aSrsName = (*ppStr); - } - } - else - { - // Eingabedatei - aInputList.push_back( new ByteString( *ppStr ) ); - } - ppStr++; - i++; - } - - if( !aInputList.empty() ) - { - /* build the output file names */ - if( ! aResName.Len() ) - aResName = OutputFile( *aInputList[ 0 ], "res" ); - if( ! bSetSrs ) - { - aSrsName = "-fp="; - aSrsName += OutputFile( *aInputList[ 0 ], "srs" ); - } - }; - - if( bHelp ) - bPrePro = sal_False; - if( bPrePro && !aInputList.empty() ) - { - ByteString aTmpName; - - for ( size_t k = 0, n = aInputList.size(); k < n; ++k ) - { - pString = aInputList[ k ]; - aTmpName = ::GetTmpFileName(); - if( !CallPrePro( *pString, aTmpName, &aCmdLine, bResponse ) ) - { - printf( "Error starting preprocessor\n" ); - bError = sal_True; - break; - } - aTmpList.push_back( new ByteString( aTmpName ) ); - }; - }; - - if( !bError ) - { - if( !CallRsc2( bPrePro ? &aTmpList : &aInputList, aSrsName, &aCmdLine ) ) - { - if( !bHelp ) - { - printf( "Error starting rsc2 compiler\n" ); - bError = sal_True; - } - }; - }; - - for ( size_t k = 0, n = aTmpList.size(); k < n; ++k ) - unlink( aTmpList[ k ]->GetBuffer() ); - - return( bError ); -} - -void RscExit( sal_uInt32 nExit ) -{ - if( nExit ) - printf( "Program exit is %d\n", (int)nExit ); - exit( nExit ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/makefile.mk b/rsc/source/res/makefile.mk deleted file mode 100644 index 9f65263b57..0000000000 --- a/rsc/source/res/makefile.mk +++ /dev/null @@ -1,68 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=rsc -TARGET=rscres - -# --- Settings ------------------------------------------------------ - -ENABLE_EXCEPTIONS=true - -.INCLUDE : settings.mk - -.IF "$(BUILD_TYPE)"=="$(BUILD_TYPE:s/DESKTOP//)" -ALL: - @echo No need for this on non-desktop OSes -.ENDIF - -OBJFILES= $(OBJ)$/rscclobj.obj \ - $(OBJ)$/rsccont.obj \ - $(OBJ)$/rsctop.obj \ - $(OBJ)$/rscrange.obj \ - $(OBJ)$/rscconst.obj \ - $(OBJ)$/rscflag.obj \ - $(OBJ)$/rscstr.obj \ - $(OBJ)$/rscall.obj \ - $(OBJ)$/rscmgr.obj \ - $(OBJ)$/rscclass.obj \ - $(OBJ)$/rscarray.obj - -CXXFILES= rscclobj.cxx \ - rsctop.cxx \ - rscrange.cxx \ - rscconst.cxx \ - rscflag.cxx \ - rscstr.cxx \ - rscall.cxx \ - rsccont.cxx \ - rscclass.cxx \ - rscmgr.cxx \ - rscarray.cxx - -.INCLUDE : target.mk diff --git a/rsc/source/res/rscall.cxx b/rsc/source/res/rscall.cxx deleted file mode 100644 index abbc76e9ff..0000000000 --- a/rsc/source/res/rscall.cxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> - -// Programmabhaengige Includes. -#include <rscall.h> -#include <rsckey.hxx> - -Atom nRsc_XYMAPMODEId = InvalidAtom; -Atom nRsc_WHMAPMODEId = InvalidAtom; -Atom nRsc_X = InvalidAtom; -Atom nRsc_Y = InvalidAtom; -Atom nRsc_WIDTH = InvalidAtom; -Atom nRsc_HEIGHT = InvalidAtom; -Atom nRsc_DELTALANG = InvalidAtom; -Atom nRsc_DELTASYSTEM = InvalidAtom; -Atom nRsc_EXTRADATA = InvalidAtom; - -void InitRscCompiler() -{ - pStdParType = new ByteString( "( const ResId & rResId, sal_Bool" ); - pStdPar1 = new ByteString( '(' ); - pStdPar2 = new ByteString( '(' ); - - pWinParType = new ByteString( "( Window * pParent, const ResId & rResId, sal_Bool" ); - pWinPar1 = new ByteString( "( pParent," ); - pWinPar2 = new ByteString( "( this," ); - nRefDeep = 10; - nRsc_XYMAPMODEId = InvalidAtom; - nRsc_WHMAPMODEId = InvalidAtom; - pHS = new AtomContainer(); -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rscarray.cxx b/rsc/source/res/rscarray.cxx deleted file mode 100644 index 656bcfc7a1..0000000000 --- a/rsc/source/res/rscarray.cxx +++ /dev/null @@ -1,652 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -// Programmabhaengige Includes. -#include <rscconst.hxx> -#include <rscarray.hxx> -#include <rscdb.hxx> - -/****************** C O D E **********************************************/ -/****************** R s c I n s t N o d e ********************************/ -/************************************************************************* -|* -|* RscInstNode::RscInstNode() -|* -*************************************************************************/ -RscInstNode::RscInstNode( sal_uInt32 nId ) -{ - nTypeId = nId; -} - -/************************************************************************* -|* -|* RscInstNode::~RscInstNode() -|* -*************************************************************************/ -RscInstNode::~RscInstNode() -{ - if( aInst.IsInst() ) - { - aInst.pClass->Destroy( aInst ); - rtl_freeMemory( aInst.pData ); - } -} - -/************************************************************************* -|* -|* RscInstNode::GetId() -|* -*************************************************************************/ -sal_uInt32 RscInstNode::GetId() const -{ - return nTypeId; -} - -/****************** R s c A r r a y *************************************/ -/************************************************************************* -|* -|* RscArray::RscArray() -|* -*************************************************************************/ -RscArray::RscArray( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, RscEnum * pTypeCl ) - : RscTop( nId, nTypeId, pSuper ) -{ - pTypeClass = pTypeCl; - nOffInstData = RscTop::Size(); - nSize = nOffInstData + ALIGNED_SIZE( sizeof( RscArrayInst ) ); -} - -/************************************************************************* -|* -|* RscArray::~RscArray() -|* -*************************************************************************/ -RscArray::~RscArray() -{ -} - -/************************************************************************* -|* -|* RscArray::~RscArray() -|* -*************************************************************************/ -RSCCLASS_TYPE RscArray::GetClassType() const -{ - return RSCCLASS_ENUMARRAY; -} - -/************************************************************************* -|* -|* RscArray::GetIndexType() -|* -*************************************************************************/ -RscTop * RscArray::GetTypeClass() const -{ - return pTypeClass; -} - -/************************************************************************* -|* -|* RscArray::Create() -|* -*************************************************************************/ -static RscInstNode * Create( RscInstNode * pNode ) -{ - RscInstNode * pRetNode = NULL; - RscInstNode * pTmpNode; - - if( pNode ) - { - pRetNode = new RscInstNode( pNode->GetId() ); - pRetNode->aInst = pNode->aInst.pClass->Create( NULL, pNode->aInst ); - if( (pTmpNode = Create( pNode->Left() )) != NULL ) - pRetNode->Insert( pTmpNode ); - if( (pTmpNode = Create( pNode->Right() )) != NULL ) - pRetNode->Insert( pTmpNode ); - } - - return pRetNode; -} - -RSCINST RscArray::Create( RSCINST * pInst, const RSCINST & rDflt, - sal_Bool bOwnClass ) -{ - RSCINST aInst; - RscArrayInst * pClassData; - - if( !pInst ) - { - aInst.pClass = this; - aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() ); - } - else - aInst = *pInst; - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - RscTop::Create( &aInst, rDflt, bOwnClass ); - - pClassData = (RscArrayInst *)(aInst.pData + nOffInstData); - pClassData->pNode = NULL; - if( bOwnClass ) - { - RscArrayInst * pDfltClassData; - - pDfltClassData = (RscArrayInst *)(rDflt.pData + nOffInstData); - - pClassData->pNode = ::Create( pDfltClassData->pNode ); - } - return( aInst ); -} - -/************************************************************************* -|* -|* RscArray::Destroy() -|* -|* Beschreibung -|* -*************************************************************************/ -static void Destroy( RscInstNode * pNode ) -{ - if( pNode ) - { - Destroy( pNode->Left() ); - Destroy( pNode->Right() ); - delete pNode; - } -} - -void RscArray::Destroy( const RSCINST & rInst ) -{ - RscArrayInst * pClassData; - - RscTop::Destroy( rInst ); - - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - - //Baum rekursiv loeschen - ::Destroy( pClassData->pNode ); -} - -/************************************************************************* -|* -|* RscArray::GetValueEle() -|* -|* Beschreibung -|* -*************************************************************************/ -ERRTYPE RscArray::GetValueEle -( - const RSCINST & rInst, - sal_Int32 lValue, - RscTop * pCreateClass, - RSCINST * pGetInst -) -{ - RscArrayInst * pClassData; - RscInstNode * pNode; - - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - - ERRTYPE aError; - - Atom nId; - if( !pTypeClass->GetValueConst( sal_uInt32(lValue), &nId ) ) - { // nicht gefunden - return ERR_ARRAY_INVALIDINDEX; - } - - if( pClassData->pNode ) - pNode = pClassData->pNode->Search( sal_uInt32(lValue) ); - else - pNode = NULL; - -/* - if( pNode ) - { - if( pNode->aInst.pClass->IsDefault( pNode->aInst ) ) - { - GetSuperClass()->Destroy( pNode->aInst ); - GetSuperClass()->Create( &pNode->aInst, rInst ); - pNode->aInst.pClass->SetToDefault( pNode->aInst ); - } - } - else -*/ - if( !pNode ) - { - pNode = new RscInstNode( sal_uInt32(lValue) ); - if( pCreateClass && GetSuperClass()->InHierarchy( pCreateClass ) ) - pNode->aInst = pCreateClass->Create( NULL, rInst ); - else - pNode->aInst = GetSuperClass()->Create( NULL, rInst ); - pNode->aInst.pClass->SetToDefault( pNode->aInst ); - if( pClassData->pNode ) - pClassData->pNode->Insert( pNode ); - else - pClassData->pNode = pNode; - } - - *pGetInst = pNode->aInst; - return aError; -} - -/************************************************************************* -|* -|* RscArray::GetArrayEle() -|* -|* Beschreibung -|* -*************************************************************************/ -ERRTYPE RscArray::GetArrayEle -( - const RSCINST & rInst, - Atom nId, - RscTop * pCreateClass, - RSCINST * pGetInst -) -{ - sal_Int32 lValue; - if( !pTypeClass->GetConstValue( nId, &lValue ) ) - { // nicht gefunden - return ERR_ARRAY_INVALIDINDEX; - } - - return GetValueEle( rInst, lValue, pCreateClass, pGetInst ); -} - -/************************************************************************* -|* -|* RscArray::IsConsistent() -|* -*************************************************************************/ -static sal_Bool IsConsistent( RscInstNode * pNode ) -{ - sal_Bool bRet = sal_True; - - if( pNode ) - { - bRet = pNode->aInst.pClass->IsConsistent( pNode->aInst ); - if( !IsConsistent( pNode->Left() ) ) - bRet = sal_False; - if( !IsConsistent( pNode->Right() ) ) - bRet = sal_False; - } - return bRet; -} - -sal_Bool RscArray::IsConsistent( const RSCINST & rInst ) -{ - RscArrayInst * pClassData; - sal_Bool bRet; - - bRet = RscTop::IsConsistent( rInst ); - - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - if( !::IsConsistent( pClassData->pNode ) ) - bRet = sal_False; - - return( bRet ); -} - -/************************************************************************* -|* -|* RscArray::SetToDefault() -|* -*************************************************************************/ -static void SetToDefault( RscInstNode * pNode ) -{ - if( pNode ) - { - pNode->aInst.pClass->SetToDefault( pNode->aInst ); - SetToDefault( pNode->Left() ); - SetToDefault( pNode->Right() ); - } -} - -void RscArray::SetToDefault( const RSCINST & rInst ) -{ - RscArrayInst * pClassData; - - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - - ::SetToDefault( pClassData->pNode ); - - RscTop::SetToDefault( rInst ); -} - -/************************************************************************* -|* -|* RscArray::IsDefault() -|* -*************************************************************************/ -static sal_Bool IsDefault( RscInstNode * pNode ) -{ - sal_Bool bRet = sal_True; - - if( pNode ) - { - bRet = pNode->aInst.pClass->IsDefault( pNode->aInst ); - if( bRet ) - bRet = IsDefault( pNode->Left() ); - if( bRet ) - bRet = IsDefault( pNode->Right() ); - } - return bRet; -} - -sal_Bool RscArray::IsDefault( const RSCINST & rInst ) -{ - RscArrayInst * pClassData; - - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - - sal_Bool bRet = ::IsDefault( pClassData->pNode ); - - if( bRet ) - bRet = RscTop::IsDefault( rInst ); - return bRet; -} - -/************************************************************************* -|* -|* RscArray::IsValueDefault() -|* -*************************************************************************/ -static sal_Bool IsValueDefault( RscInstNode * pNode, CLASS_DATA pDef ) -{ - sal_Bool bRet = sal_True; - - if( pNode ) - { - bRet = pNode->aInst.pClass->IsValueDefault( pNode->aInst, pDef ); - if( bRet ) - bRet = IsValueDefault( pNode->Left(), pDef ); - if( bRet ) - bRet = IsValueDefault( pNode->Right(), pDef ); - } - return bRet; -} - -sal_Bool RscArray::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ) -{ - RscArrayInst * pClassData; - sal_Bool bRet; - - bRet = RscTop::IsValueDefault( rInst, pDef ); - - if( bRet ) - { - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - - bRet = ::IsValueDefault( pClassData->pNode, pDef ); - } - return bRet; -} - -/************************************************************************* -|* RscArray::WriteSrcHeader() -|* -|* Beschreibung -*************************************************************************/ -void RscArray::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const RscId & aId, const char * pVarName ) -{ - RscArrayInst * pClassData; - - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - - if( pTC->IsSrsDefault() ) - { // nur einen Wert schreiben - RscInstNode * pNode = NULL; - if( pClassData->pNode ) - { - std::vector< sal_uInt32 >::const_iterator it; - for( it = pTC->GetFallbacks().begin(); !pNode && it != pTC->GetFallbacks().end(); ++it ) - pNode = pClassData->pNode->Search( *it ); - } - - if( pNode ) - { - if( pNode->aInst.pClass->IsDefault( pNode->aInst ) ) - fprintf( fOutput, "Default" ); - else - pNode->aInst.pClass->WriteSrcHeader( - pNode->aInst, fOutput, - pTC, nTab, aId, pVarName ); - return; - } - } - - if( IsDefault( rInst ) ) - fprintf( fOutput, "Default" ); - else - { - RSCINST aSuper( GetSuperClass(), rInst.pData ); - aSuper.pClass->WriteSrcHeader( aSuper, fOutput, pTC, - nTab, aId, pVarName ); - } - if( !pTC->IsSrsDefault() ) - WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); -} - -/************************************************************************* -|* RscArray::WriteSrc() -|* -|* Beschreibung -*************************************************************************/ -static void WriteSrc( RscInstNode * pNode, FILE * fOutput, RscTypCont * pTC, - sal_uInt32 nTab, const char * pVarName, - CLASS_DATA pDfltData, RscConst * pTypeClass ) -{ - if( pNode ) - { - WriteSrc( pNode->Left(), fOutput, pTC, nTab, pVarName, - pDfltData, pTypeClass ); - if( !pNode->aInst.pClass->IsValueDefault( pNode->aInst, pDfltData ) ) - { - fprintf( fOutput, ";\n" ); - for( sal_uInt32 n = 0; n < nTab; n++ ) - fputc( '\t', fOutput ); - - Atom nIdxId; - pTypeClass->GetValueConst( pNode->GetId(), &nIdxId ); - fprintf( fOutput, "%s[ %s ] = ", pVarName, pHS->getString( nIdxId ).getStr() ); - pNode->aInst.pClass->WriteSrcHeader( pNode->aInst, fOutput, pTC, - nTab, RscId(), pVarName ); - } - WriteSrc( pNode->Right(), fOutput, pTC, nTab, pVarName, - pDfltData, pTypeClass ); - } -} - -void RscArray::WriteSrcArray( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const char * pVarName ) -{ - RscArrayInst * pClassData; - - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - - ::WriteSrc( pClassData->pNode, fOutput, pTC, nTab, pVarName, - rInst.pData, pTypeClass ); -}; - -void RscArray::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const char * pVarName ) -{ - WriteSrcArray( rInst, fOutput, pTC, nTab, pVarName ); -} - -/************************************************************************* -|* RscArray::WriteRc() -|* -|* Beschreibung -*************************************************************************/ -ERRTYPE RscArray::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) -{ - ERRTYPE aError; - RscArrayInst * pClassData; - RscInstNode * pNode = NULL; - - pClassData = (RscArrayInst *)(rInst.pData + nOffInstData); - - if( pClassData->pNode ) - { -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "RscArray::WriteRc: Fallback " ); -#endif - std::vector< sal_uInt32 >::const_iterator it; - for( it = pTC->GetFallbacks().begin(); !pNode && it != pTC->GetFallbacks().end(); ++it ) - { - pNode = pClassData->pNode->Search( *it ); -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, " 0x%hx", *it ); -#endif - } -#if OSL_DEBUG_LEVEL > 2 - fprintf( stderr, "\n" ); -#endif - } - - if( pNode ) - aError = pNode->aInst.pClass->WriteRc( pNode->aInst, rMem, pTC, - nDeep, bExtra ); - else - aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - - return aError; -} - -//======================================================================== -void RscArray::WriteRcAccess -( - FILE * fOutput, - RscTypCont * pTC, - const char * pName -) -{ - GetSuperClass()->WriteRcAccess( fOutput, pTC, pName ); -} - -/************************************************************************* -|* -|* RscClassArray::RscClassArray() -|* -*************************************************************************/ -RscClassArray::RscClassArray( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, - RscEnum * pTypeCl ) - : RscArray( nId, nTypeId, pSuper, pTypeCl ) -{ -} - -/************************************************************************* -|* -|* RscClassArray::~RscClassArray() -|* -*************************************************************************/ -RscClassArray::~RscClassArray() -{ -} - -/************************************************************************* -|* -|* RscClassArray::WriteSrcHeader() -|* -*************************************************************************/ -void RscClassArray::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const RscId & aId, const char * pName ) -{ - RscArray::WriteSrcHeader( rInst, fOutput, pTC, nTab, aId, pName ); -} - -/************************************************************************* -|* -|* RscClassArray::WriteSrc() -|* -*************************************************************************/ -void RscClassArray::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const char * pVarName ) -{ - RscArray::WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); -} - -/************************************************************************* -|* -|* RscClassArray::WriteRcHeader() -|* -*************************************************************************/ -ERRTYPE RscClassArray::WriteRcHeader( const RSCINST & rInst, RscWriteRc & aMem, - RscTypCont * pTC, const RscId & aId, - sal_uInt32 nDeep, sal_Bool bExtra ) -{ - // Eigenen Typ schreiben - return GetSuperClass()->WriteRcHeader( rInst, aMem, pTC, aId, - nDeep, bExtra ); -} - -/************************************************************************* -|* -|* RscLangArray::RscLangArray() -|* -*************************************************************************/ -RscLangArray::RscLangArray( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, - RscEnum * pTypeCl ) - : RscArray( nId, nTypeId, pSuper, pTypeCl ) -{ -} - -/************************************************************************* -|* -|* RscLangArray::RscLangArray() -|* -*************************************************************************/ -RSCCLASS_TYPE RscLangArray::GetClassType() const -{ - if( GetSuperClass() ) - return GetSuperClass()->GetClassType(); - else - return RscArray::GetClassType(); - -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rscclass.cxx b/rsc/source/res/rscclass.cxx deleted file mode 100644 index 63e6fed3f9..0000000000 --- a/rsc/source/res/rscclass.cxx +++ /dev/null @@ -1,1196 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -// Programmabhaengige Includes. -#include <rscdb.hxx> -#include <rscclass.hxx> - -#include <tools/fsys.hxx> -#include <tools/rcid.h> -#include <tools/rc.h> - -/****************** C O D E **********************************************/ -/****************** R s c C l a s s **************************************/ -/************************************************************************* -|* -|* RscClass::RscClass() -|* -*************************************************************************/ -RscClass::RscClass( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl ) - : RscTop( nId, nTypeId, pSuperCl ) -{ - nEntries = 0; - pVarTypeList = NULL; - nSuperSize = RscTop::Size(); - nSize = nSuperSize + ALIGNED_SIZE( sizeof( RscClassInst ) ); -} - -/************************************************************************* -|* -|* RscClass::Pre_dtor() -|* -*************************************************************************/ -void RscClass::Pre_dtor() -{ - sal_uInt32 i; - - RscTop::Pre_dtor(); - - for( i = 0; i < nEntries; i++ ) - { - if( pVarTypeList[ i ].pDefault ) - { - pVarTypeList[ i ].pClass->Destroy( - RSCINST( pVarTypeList[ i ].pClass, - pVarTypeList[ i ].pDefault ) ); - rtl_freeMemory( pVarTypeList[ i ].pDefault ); - pVarTypeList[ i ].pDefault = NULL; - }; - }; -} - -/************************************************************************* -|* -|* RscClass::~RscClass() -|* -*************************************************************************/ -RscClass::~RscClass() -{ - if( pVarTypeList ) - rtl_freeMemory( (void *)pVarTypeList ); -} - -/************************************************************************* -|* -|* RscClass::GetClassType() -|* -*************************************************************************/ -RSCCLASS_TYPE RscClass::GetClassType() const -{ - return RSCCLASS_COMPLEX; -} - -/************************************************************************* -|* -|* RscClass::GetInstData() -|* -*************************************************************************/ -RSCINST RscClass::GetInstData -( - CLASS_DATA pData, - sal_uInt32 nEle, - sal_Bool bGetCopy -) -{ - RSCINST aInst; - - aInst.pClass = pVarTypeList[ nEle ].pClass; - if( pData ) - { - if( VAR_NODATAINST & pVarTypeList[ nEle ].nVarType ) - { - RSCINST aTmpI; - - aTmpI.pClass = this; - aTmpI.pData = pData; - if( bGetCopy ) - aInst.pData = GetCopyVar( - aTmpI, - pVarTypeList[ nEle ].nDataBaseName - ).pData; - else - aInst.pData = GetVariable( - aTmpI, - pVarTypeList[ nEle ].nDataBaseName, - RSCINST() - ).pData; - } - else if( VAR_POINTER & pVarTypeList[ nEle ].nVarType ) - { - if( VAR_EXTENDABLE & pVarTypeList[ nEle ].nVarType ) - aInst = *(RSCINST *) - (pData + pVarTypeList[ nEle ].nOffset); - else - aInst.pData = *(CLASS_DATA *) - (pData + pVarTypeList[ nEle ].nOffset); - } - else - aInst.pData = pData + pVarTypeList[ nEle ].nOffset; - }; - return( aInst ); -} - -/************************************************************************* -|* -|* RscClass::GetInstDflt() -|* -|* Beschreibung -|* -*************************************************************************/ -CLASS_DATA RscClass::GetDfltData( sal_uInt32 nEle ) -{ - if( pVarTypeList[ nEle ].pDefault ) - return pVarTypeList[ nEle ].pDefault; - - return pVarTypeList[ nEle ].pClass->GetDefault().pData; -} - -/************************************************************************* -|* -|* RscClass::SetVarDflt() -|* -*************************************************************************/ -void RscClass::SetVarDflt( CLASS_DATA pData, sal_uInt32 nEle, sal_Bool bSet ) -{ - RscClassInst * pClass; - - pClass = (RscClassInst *)(pData + nSuperSize ); - if( bSet ) - pClass->nVarDflt |= ((sal_uLong)1 << nEle); - else - pClass->nVarDflt &= ~((sal_uLong)1 << nEle); -} - -/************************************************************************* -|* -|* RscClass::IsDflt() -|* -*************************************************************************/ -sal_Bool RscClass::IsDflt( CLASS_DATA pData, sal_uInt32 nEle ) -{ - RscClassInst * pClass; - sal_Bool bRet; - - pClass = (RscClassInst *)(pData + nSuperSize ); - if( pClass->nVarDflt & ((sal_uLong)1 << nEle) ) - bRet = sal_True; - else - bRet = sal_False; - return bRet; -} - -/************************************************************************* -|* -|* RscClass::Create() -|* -*************************************************************************/ -RSCINST RscClass::Create -( - RSCINST * pInst, - const RSCINST & rDflt, - sal_Bool bOwnClass -) -{ - sal_uInt32 i; - CLASS_DATA * ppData; - RSCINST aInst; - RSCINST aMemInst, aDfltI; - - if( !pInst ) - { - aInst.pClass = this; - aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() ); - } - else - aInst = *pInst; - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - RscTop::Create( &aInst, rDflt, bOwnClass ); - - if( bOwnClass ) - ((RscClassInst *)(aInst.pData + nSuperSize))->nVarDflt = - ((RscClassInst *)(rDflt.pData + nSuperSize))->nVarDflt; - else - ((RscClassInst *)(aInst.pData + nSuperSize))->nVarDflt = ~((sal_uLong)0); - - for( i = 0; i < nEntries; i++ ) - { - aDfltI = GetInstData( bOwnClass ? rDflt.pData : NULL, i, sal_True ); - - if( (VAR_POINTER & pVarTypeList[ i ].nVarType) - && !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) ) - { - if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType ) - { - RSCINST * pInstance = (RSCINST *) - (aInst.pData + pVarTypeList[ i ].nOffset ); - pInstance->pClass = pVarTypeList[ i ].pClass; - ppData = &pInstance->pData; - } - else - ppData = (CLASS_DATA* ) - (aInst.pData + pVarTypeList[ i ].nOffset ); - *ppData = NULL; - if( aDfltI.IsInst() ) - { - aMemInst = pVarTypeList[ i ].pClass->Create( NULL, aDfltI ); - *ppData = aMemInst.pData; - }; - } - else - { - aMemInst = GetInstData( aInst.pData, i, sal_True ); - aMemInst = aMemInst.pClass->Create( &aMemInst, aDfltI ); - }; - } - - return( aInst ); -} - -/************************************************************************* -|* -|* RscClass::Destroy() -|* -|* Beschreibung -|* -*************************************************************************/ -void RscClass::Destroy( const RSCINST & rInst ) -{ - sal_uInt32 i; - - RscTop::Destroy( rInst ); - - for( i = 0; i < nEntries; i++ ) - { - if( !(pVarTypeList[ i ].nVarType & VAR_NODATAINST) ) - { - RSCINST aTmpI; - - aTmpI = GetInstData( rInst.pData, i, sal_True ); - if( aTmpI.IsInst() ) - { - // Objekt loeschen - aTmpI.pClass->Destroy( aTmpI ); - if( pVarTypeList[ i ].nVarType & VAR_POINTER ) - { - // Speicher freigeben - rtl_freeMemory( aTmpI.pData ); - }; - }; - } - }; -} - -/************************************************************************* -|* -|* RscClass::SetVariable() -|* -|* Beschreibung -|* -*************************************************************************/ -ERRTYPE RscClass::SetVariable -( - Atom nVarName, - RscTop * pClass, - RSCINST * pDflt, - RSCVAR nVarType, - sal_uInt32 nMask, - Atom nDataBaseName -) -{ - if( pVarTypeList ) - pVarTypeList = (VARTYPE_STRUCT *) - rtl_reallocateMemory( (void *)pVarTypeList, - ((nEntries +1) * sizeof( VARTYPE_STRUCT )) ); - else - pVarTypeList = (VARTYPE_STRUCT *) - rtl_allocateMemory( ((nEntries +1) - * sizeof( VARTYPE_STRUCT )) ); - - pVarTypeList[ nEntries ].nVarName = nVarName; - pVarTypeList[ nEntries ].nMask = nMask; - pVarTypeList[ nEntries ].pClass = pClass; - pVarTypeList[ nEntries ].nOffset = nSize; - pVarTypeList[ nEntries ].nDataBaseName = nDataBaseName; - if( pDflt ) - pVarTypeList[ nEntries ].pDefault = pDflt->pData; - else - pVarTypeList[ nEntries ].pDefault = NULL; - - pVarTypeList[ nEntries ].nVarType = ~VAR_POINTER & nVarType; - if( pClass->Size() > 10 || (nVarType & VAR_EXTENDABLE) ) - pVarTypeList[ nEntries ].nVarType |= VAR_POINTER; - - if( !(pVarTypeList[ nEntries ].nVarType & VAR_NODATAINST) ) - { - if( pVarTypeList[ nEntries ].nVarType & VAR_POINTER ) - { - if( pVarTypeList[ nEntries ].nVarType & VAR_EXTENDABLE ) - nSize += sizeof( RSCINST ); - else - nSize += sizeof( CLASS_DATA ); - } - else - nSize += pClass->Size(); - } - - nEntries++; - if( nEntries > (sizeof( sal_uLong ) * 8) ) - { - // Bereich fuer Default zu klein - RscExit( 16 ); - }; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscClass::EnumVariable() -|* -|* Beschreibung -|* -*************************************************************************/ -void RscClass::EnumVariables( void * pData, VarEnumCallbackProc pProc ) -{ - sal_uInt32 i; - - RscTop::EnumVariables( pData, pProc ); - for( i = 0; i < nEntries; i ++ ) - { - if( !(pVarTypeList[ i ].nVarType & VAR_NOENUM) ) - (*pProc)( pData, pVarTypeList[ i ].pClass->GetClassType(), - pVarTypeList[ i ].nVarName ); - } -} - -/************************************************************************* -|* -|* RscClass::GetVariable() -|* -|* Beschreibung -|* -*************************************************************************/ -RSCINST RscClass::GetVariable -( - const RSCINST & rInst, - Atom nVarName, - const RSCINST & rInitInst, - sal_Bool bInitDflt, - RscTop * pCreateClass -) -{ - sal_uInt32 i = 0; - RSCINST aTmpI; - - while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName ) - i++; - if( i < nEntries ) - { - if( VAR_NODATAINST & pVarTypeList[ i ].nVarType ) - { - aTmpI = GetVariable( rInst, - pVarTypeList[ i ].nDataBaseName, - RSCINST() ); - aTmpI.pClass = pVarTypeList[ i ].pClass; - } - else - { - // Default Instanz generieren - RSCINST aDefInst = rInitInst; - if( !aDefInst.IsInst() && bInitDflt ) - { - // mit dem Variablen-Default besetzen - aDefInst.pData = pVarTypeList[ i ].pDefault; - aDefInst.pClass = pVarTypeList[ i ].pClass; - } - - aTmpI = GetInstData( rInst.pData, i ); - if( aTmpI.IsInst() ) - { - if( aDefInst.IsInst() ) - { - aTmpI.pClass->Destroy( aTmpI ); - aTmpI.pClass->Create( &aTmpI, aDefInst ); - } - } - else - { // Wird ueber Zeiger angegeben - if( VAR_EXTENDABLE & pVarTypeList[ i ].nVarType ) - { - RSCINST * pInst = (RSCINST *) - (rInst.pData + pVarTypeList[ i ].nOffset ); - if( pCreateClass && pCreateClass->InHierarchy( aTmpI.pClass ) ) - *pInst = pCreateClass->Create( NULL, aDefInst ); - else - *pInst = aTmpI.pClass->Create( NULL, aDefInst ); - aTmpI = *pInst; - } - else - { - CLASS_DATA * ppData - = (CLASS_DATA *)(rInst.pData + pVarTypeList[ i ].nOffset); - aTmpI = aTmpI.pClass->Create( NULL, aDefInst ); - *ppData = aTmpI.pData; - } - } - }; - // auf nicht Default setzen - SetVarDflt( rInst.pData, i, sal_False ); - return( aTmpI ); - }; - - return( RscTop::GetVariable( rInst, nVarName, rInitInst, - bInitDflt, pCreateClass ) ); -} - -/************************************************************************* -|* -|* RscClass::GetCopyVar() -|* -|* Beschreibung -|* -*************************************************************************/ -RSCINST RscClass::GetCopyVar -( - const RSCINST & rInst, - Atom nVarName -) -{ - sal_uInt32 i = 0; - RSCINST aVarI; - - while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName ) - i++; - - if( i < nEntries ) - { - if( VAR_NODATAINST & pVarTypeList[ i ].nVarType ) - { - aVarI = GetCopyVar( rInst, pVarTypeList[ i ].nDataBaseName ); - aVarI.pClass = pVarTypeList[ i ].pClass; - } - else - { - if( IsDflt( rInst.pData, i ) ) - { - // mit Variablen Default initialiaieren - aVarI = GetVariable( rInst, nVarName, RSCINST(), sal_True ); - SetVarDflt( rInst.pData, i, sal_True ); - } - else - aVarI = GetInstData( rInst.pData, i, sal_True ); - - }; - return aVarI ; - }; - - return RscTop::GetCopyVar( rInst, nVarName ); -} - -/************************************************************************* -|* -|* RscClass::IsConsistent() -|* -|* Beschreibung -|* -*************************************************************************/ -sal_Bool RscClass::IsConsistent( const RSCINST & rInst ) -{ - sal_uInt32 i = 0; - RSCINST aTmpI; - sal_Bool bRet; - - bRet = RscTop::IsConsistent( rInst ); - - for( i = 0; i < nEntries; i++ ) - { - if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) ) - { - aTmpI = GetInstData( rInst.pData, i, sal_True ); - - if( aTmpI.IsInst() ) - if( ! aTmpI.pClass->IsConsistent( aTmpI ) ) - bRet = sal_False; - } - }; - - return( bRet ); -} - -/************************************************************************* -|* -|* RscClass::SetToDefault() -|* -|* Beschreibung -|* -*************************************************************************/ -void RscClass::SetToDefault( const RSCINST & rInst ) -{ - sal_uInt32 i; - RSCINST aTmpI; - RscClassInst * pClass; - - pClass = (RscClassInst *)(rInst.pData + nSuperSize ); - - for( i = 0; i < nEntries; i++ ) - { - // Variablen ohne eigenen Speicher werden vom "Datenserver" - // auf Default gesetzt - if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) ) - { - aTmpI = GetInstData( rInst.pData, i, sal_True ); - if( aTmpI.IsInst() ) - aTmpI.pClass->SetToDefault( aTmpI ); - } - } - pClass->nVarDflt = ~((sal_uLong)0); // alles auf Default - - RscTop::SetToDefault( rInst ); -} - -/************************************************************************* -|* -|* RscClass::IsDefault() -|* -|* Beschreibung -|* -*************************************************************************/ -sal_Bool RscClass::IsDefault( const RSCINST & rInst ) -{ - sal_uInt32 i; - RSCINST aTmpI; - - for( i = 0; i < nEntries; i++ ) - { - // Variablen ohne eigenen Speicher werden vom "Datenserver" - // auf Default untersucht - if( !(VAR_NODATAINST & pVarTypeList[ i ].nVarType) ) - if( !IsDflt( rInst.pData, i ) ) - return( sal_False ); - }; - - return( RscTop::IsDefault( rInst ) ); -} - -/************************************************************************* -|* -|* RscClass::GetDefault() -|* -|* Beschreibung -|* -*************************************************************************/ -RSCINST RscClass::GetDefault( Atom nVarId ) -{ - sal_uInt32 i; - - i = 0; - while( i < nEntries && pVarTypeList[ i ].nVarName != nVarId ) - i++; - if( i < nEntries ) - { - RSCINST aTmpI; - - aTmpI.pClass = pVarTypeList[ i ].pClass; - aTmpI.pData = GetDfltData( i ); - return( aTmpI ); - }; - - return( RscTop::GetDefault( nVarId ) ); -} - -/************************************************************************* -|* -|* RscClass::IsValueDflt() -|* -|* Beschreibung -|* -*************************************************************************/ -sal_Bool RscClass::IsValueDflt( CLASS_DATA pData, sal_uInt32 nEle ) -{ - RSCINST aTmpI; - - aTmpI = GetInstData( pData, nEle, sal_True ); - - if( aTmpI.IsInst() ) - { - if( VAR_SVDYNAMIC & pVarTypeList[ nEle ].nVarType ) - return sal_False; - - if( aTmpI.pClass == pVarTypeList[ nEle ].pClass ) - //sie haben auch die gleiche Klasse - return aTmpI.pClass->IsValueDefault( aTmpI, GetDfltData( nEle ) ); - else - return sal_False; - } - return sal_True; -} - -/************************************************************************* -|* -|* RscClass::IsValueDefault() -|* -|* Beschreibung -|* -*************************************************************************/ -sal_Bool RscClass::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ) -{ - sal_uInt32 i = 0; - RSCINST aTmpI; - RSCINST aDfltI; - - if( !RscTop::IsValueDefault( rInst, pDef ) ) - return sal_False; - - if( pDef ) - { - for( i = 0; i < nEntries; i++ ) - { - aTmpI = GetInstData( rInst.pData, i, sal_True ); - if( aTmpI.IsInst() ) - { - if( aTmpI.pClass != pVarTypeList[ i ].pClass ) - //sie haben nicht die gleiche Klasse - return sal_False; - - aDfltI = GetInstData( pDef, i, sal_True ); - if( !aDfltI.IsInst() ) - aDfltI.pData = GetDfltData( i ); - - if( !aTmpI.pClass->IsValueDefault( aTmpI, aDfltI.pData ) ) - return sal_False; - } - } - } - else - return sal_False; - - return sal_True; -} - -/************************************************************************* -|* -|* RscClass::SetDefault() -|* -|* Beschreibung -|* -*************************************************************************/ -void RscClass::SetDefault( const RSCINST & rInst, Atom nVarName ) -{ - sal_uInt32 i = 0; - RSCINST aTmpI; - - while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName ) - i++; - - if( i < nEntries ) - { - aTmpI = GetInstData( rInst.pData, i, sal_True ); - if( aTmpI.IsInst() ) - { - aTmpI.pClass->Destroy( aTmpI ); - aTmpI.pClass->Create( &aTmpI, RSCINST() ); - SetVarDflt( rInst.pData, i, sal_True ); - } - } - else //In Superklasse nach Variable suchen - RscTop::SetDefault( rInst, nVarName ); - -} - - -/************************************************************************* -|* -|* RscClass::WriteSrc() -|* -|* Beschreibung -|* -*************************************************************************/ -void RscClass::WriteSrc -( - const RSCINST & rInst, - FILE * fOutput, - RscTypCont * pTC, - sal_uInt32 nTab, - const char * pVarName -) -{ - sal_uInt32 i = 0, n = 0; - RSCINST aTmpI; - - RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); - - for( i = 0; i < nEntries; i++ ) - { - if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) ) - { - // Hack wegen Position und Dimensiuon - if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName - || nRsc_WHMAPMODEId == pVarTypeList[ i ].nVarName ) - { - if( !IsDflt( rInst.pData, i ) //MapUnit - || !IsDflt( rInst.pData, i+1 ) //X, Width - || !IsDflt( rInst.pData, i+2 ) )//Y, Height - {// ein Wert ist nicht Default - for( n = 0; n < nTab; n++ ) - fputc( '\t', fOutput ); - if( nRsc_XYMAPMODEId == pVarTypeList[ i ].nVarName ) - fprintf( fOutput, "Pos = " ); - else - fprintf( fOutput, "Size = " ); - - if( !IsDflt( rInst.pData, i ) ) - { - aTmpI = GetInstData( rInst.pData, i, sal_True ); - aTmpI.pClass->WriteSrcHeader( - aTmpI, fOutput, pTC, nTab, RscId(), pVarName ); - } - - fprintf( fOutput, "( " ); - aTmpI = GetInstData( rInst.pData, i+1, sal_True ); - if( !aTmpI.IsInst() ) - aTmpI.pData = GetDfltData( i+1 ); - aTmpI.pClass->WriteSrcHeader( - aTmpI, fOutput, pTC, nTab, RscId(), pVarName ); - - fprintf( fOutput, ", " ); - aTmpI = GetInstData( rInst.pData, i+2, sal_True ); - if( !aTmpI.IsInst() ) - aTmpI.pData = GetDfltData( i+2 ); - aTmpI.pClass->WriteSrcHeader( - aTmpI, fOutput, pTC, nTab, RscId(), pVarName ); - fprintf( fOutput, " );\n" ); - } - i += 2; //_X, _Y oder _Widht, Height ueberlesen - } - else if( !IsDflt( rInst.pData, i ) - && !IsValueDflt( rInst.pData, i ) ) - { - aTmpI = GetInstData( rInst.pData, i, sal_True ); - - if( aTmpI.IsInst() ) - { - const char * pName = pHS->getString( pVarTypeList[ i ].nVarName ).getStr(); - - for( n = 0; n < nTab; n++ ) - fputc( '\t', fOutput ); - fprintf( fOutput, "%s", pName ); - fprintf( fOutput, " = " ); - aTmpI.pClass->WriteSrcHeader( - aTmpI, fOutput, pTC, nTab, RscId(), pName ); - fprintf( fOutput, ";\n" ); - } - }; - }; - }; - - return; -} - -/************************************************************************* -|* -|* RscClass::WriteInstRc() -|* -|* Beschreibung -|* -*************************************************************************/ -sal_Int32 RscClass::GetCorrectValues -( - const RSCINST & rInst, - sal_uInt32 nVarPos, - sal_uInt32 nTupelIdx, - RscTypCont * pTC -) -{ - sal_Int32 nLang = 0; - sal_Int32 nBaseValue; - - // Basiswert holen - RSCINST aTmpI = GetInstData( rInst.pData, nVarPos, sal_True ); - aTmpI.pClass->GetNumber( aTmpI, &nBaseValue ); - - // Sprach Delta holen - aTmpI = rInst.pClass->GetVariable( rInst, nRsc_DELTALANG, RSCINST() ); - if( aTmpI.IsInst() ) - { - RscWriteRc aMem; - aTmpI.pClass->WriteRc( aTmpI, aMem, pTC, 0, sal_False ); - nLang = (sal_Int32)aMem.GetShort( nTupelIdx * sizeof(sal_uInt16) ); - } - - return nLang + nBaseValue; -} - -ERRTYPE RscClass::WriteInstRc -( - const RSCINST & rInst, - RscWriteRc & rMem, - RscTypCont * pTC, - sal_uInt32 nDeep, - sal_Bool bExtra -) -{ - sal_uInt32 i = 0; - ERRTYPE aError; - RSCINST aTmpI; - sal_uInt32 nMaskOff = 0;// Offset um Maskenfeld zu addressieren - - // Wenn eine Variable Maskierung hat, dann Maskenfeld - for( i = 0; i < nEntries; i++ ) - { - if( pVarTypeList[ i ].nMask ) - { - nMaskOff = rMem.Size(); - rMem.Put( sal_uInt32(0) ); - break; - } - }; - - for( i = 0; i < nEntries && aError.IsOk(); i++ ) - { - if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType )) - { - if( pVarTypeList[ i ].nMask ) - { - if( !IsDflt( rInst.pData, i ) ) - { - if( nRsc_X == pVarTypeList[ i ].nVarName ) - { - sal_Int32 nVal = GetCorrectValues( rInst, i, 0, pTC ); - rMem.Put( nVal ); - } - else if( nRsc_Y == pVarTypeList[ i ].nVarName ) - { - sal_Int32 nVal = GetCorrectValues( rInst, i, 1, pTC ); - rMem.Put( nVal ); - } - else if( nRsc_WIDTH == pVarTypeList[ i ].nVarName ) - { - sal_Int32 nVal = GetCorrectValues( rInst, i, 2, pTC ); - rMem.Put( nVal ); - } - else if( nRsc_HEIGHT == pVarTypeList[ i ].nVarName ) - { - sal_Int32 nVal = GetCorrectValues( rInst, i, 3, pTC ); - rMem.Put( nVal ); - } - else - { - aTmpI = GetInstData( rInst.pData, i, sal_True ); - // Nur an Variable Extradata bExtra nicht auf sal_False - // setzen - aError = aTmpI.pClass-> - WriteRcHeader( aTmpI, rMem, pTC, - RscId(), nDeep, - (nRsc_EXTRADATA - == pVarTypeList[ i ].nVarName) - ? bExtra : sal_False ); - } - sal_uInt32 nMask = rMem.GetLong( nMaskOff ); - nMask |= pVarTypeList[ i ].nMask; - rMem.PutAt( nMaskOff, nMask ); - } - } - else{ - if( IsDflt( rInst.pData, i ) ) - { - aTmpI.pClass = pVarTypeList[ i ].pClass; - aTmpI.pData = GetDfltData( i ); - } - else - aTmpI = GetInstData( rInst.pData, i, sal_True ); - // Nur an Variable Extradata bExtra nicht auf sal_False - // setzen - aError = aTmpI.pClass-> - WriteRcHeader( aTmpI, rMem, pTC, - RscId(), nDeep, - (nRsc_EXTRADATA - == pVarTypeList[ i ].nVarName) - ? bExtra : sal_False ); - } - } - } - - return( aError ); -} - -/************************************************************************* -|* -|* RscClass::WriteRc() -|* -|* Beschreibung -|* -*************************************************************************/ -ERRTYPE RscClass::WriteRc -( - const RSCINST & rInst, - RscWriteRc & rMem, - RscTypCont * pTC, - sal_uInt32 nDeep, - sal_Bool bExtra -) -{ - ERRTYPE aError; - - aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - if( aError.IsOk() ) - aError = WriteInstRc( rInst, rMem, pTC, nDeep, bExtra ); - - return( aError ); -} - -/************************************************************************* -|* -|* RscClass::WriteSyntax() -|* -|* Beschreibung -|* -*************************************************************************/ -void RscClass::WriteSyntax( FILE * fOutput, RscTypCont * pTC ) -{ - RscTop::WriteSyntax( fOutput, pTC ); - - sal_uInt32 i; - // Wenn eine Variable Maskierung hat, dann Maskenfeld - fprintf( fOutput, "\t//%s\n", pHS->getString( GetId() ).getStr() ); - for( i = 0; i < nEntries; i++ ) - { - fprintf( fOutput, "\t%s", pHS->getString( pVarTypeList[ i ].nVarName ).getStr() ); - sal_uInt32 n = strlen( pHS->getString( pVarTypeList[ i ].nVarName ).getStr() ); - while( n < 20 ) - { - putc( ' ', fOutput ); - n++; - } - fprintf( fOutput, " = %s;\n", - pHS->getString( pVarTypeList[ i ].pClass->GetId() ).getStr() ); - }; -} - -//================================================================== -void RscClass::WriteRcAccess -( - FILE * fOutput, - RscTypCont * /*pTC*/, - const char * pName -) -{ - fprintf( fOutput, "\t\tSet%s( %s ", pName, pHS->getString( GetId() ).getStr() ); - fprintf( fOutput, "%s ", aCallPar2.GetBuffer() ); - fprintf( fOutput, "ResId( (RSHEADER_TYPE*)(pResData+nOffset) ) ) );\n" ); - fprintf( fOutput, "\t\tnOffset += GetObjSizeRes( (RSHEADER_TYPE*)(pResData+nOffset) );\n" ); -} - -//================================================================== -void RscClass::WriteRcCtor( FILE * fOutput, RscTypCont * pTC ) -{ - if( GetId() != InvalidAtom ) - { - // Konstruktor - fprintf( fOutput, "%s::%s%s bFreeResource )", - pHS->getString( GetId() ).getStr(), - pHS->getString( GetId() ).getStr(), - aCallParType.GetBuffer() ); - if( GetSuperClass() ) - { - // Superaufruf - fprintf( fOutput, "\n\t: %s", pHS->getString( GetSuperClass()->GetId() ).getStr() ); - fprintf( fOutput, "%s", GetSuperClass()->aCallPar1.GetBuffer() ); - fprintf( fOutput, " rResId.SetRT2( 0x%lx ) )", - sal::static_int_cast< unsigned long >(GetTypId()) ); - } - fprintf( fOutput, "\n{\n" ); - fprintf( fOutput, "\tsal_uInt32\tnObjMask;\n" ); - fprintf( fOutput, "\tsal_uInt32\tnOffset = 0;\n" ); - fprintf( fOutput, "\tBYTE *\tpResData;\n\n" ); - fprintf( fOutput, "\tpResData = (tBYTE *)GetClassRes();\n\n" ); - fprintf( fOutput, "\tnObjMask = *(sal_uInt32*)pResData;\n" ); - fprintf( fOutput, "\tnOffset += 4;\n\n" ); - - for( sal_uInt32 i = 0; i < nEntries; i++ ) - { - if( !((VAR_NODATAINST | VAR_NORC) & pVarTypeList[ i ].nVarType )) - { - fprintf( fOutput, "\tif( nObjMask & 0x%lx )\n\t{\n", - sal::static_int_cast< unsigned long >( - pVarTypeList[ i ].nMask) ); - - pVarTypeList[ i ].pClass->WriteRcAccess( fOutput, pTC, - pHS->getString( pVarTypeList[ i ].nVarName ).getStr() ); - - fprintf( fOutput, "\t}\n" ); - } - } - fprintf( fOutput, "\tIncrementRes( nOffset );\n" ); - fprintf( fOutput, "\tif( bFreeResource )\n" ); - fprintf( fOutput, "\t\tFreeResource();\n" ); - fprintf( fOutput, "}\n\n" ); - } -} - -/************************************************************************* -|* -|* RscSysDepend::RscSysDepend() -|* -|* Beschreibung -|* -*************************************************************************/ -RscSysDepend::RscSysDepend( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper ) - : RscClass( nId, nTypeId, pSuper ) -{} - -/************************************************************************* -|* -|* RscSysDepend::WriteRc() -|* -|* Beschreibung -|* -*************************************************************************/ -ERRTYPE RscSysDepend::WriteSysDependRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra, sal_Bool bFirst ) -{ - sal_uInt32 nId = 0xFFFFFFFF; - ERRTYPE aError; - RSCINST aFileName; - - //Instanz mit dem Dateinamen "FILENAME" holen - aFileName = RscClass::GetCopyVar( rInst, pHS->getID( "FILE", true ) ); - if( aFileName.IsInst() ) - { - RscWriteRc aTmpMem; - aError = aFileName.pClass->WriteRcHeader( aFileName, aTmpMem, pTC, - RscId(), nDeep, bExtra ); - // Obsolete - need changes in VCL - rMem.Put( sal_uInt32(0) ); - - // Identifier schreiben - if( aTmpMem.Size() && pTC && (*aTmpMem.GetUTF8( 0 ) != '\0') ) - { - nId = pTC->PutSysName( rInst.pClass->GetTypId(), - aTmpMem.GetUTF8( 0 ), - 0, 0, bFirst ); - } - rMem.Put( nId ); - aError = aFileName.pClass->WriteRcHeader( aFileName, rMem, pTC, - RscId(), nDeep, bExtra ); - } - else - aError = ERR_ERROR; - - return( aError ); -} - -/************************************************************************* -|* -|* RscSysDepend::WriteRc() -|* -|* Beschreibung -|* -*************************************************************************/ -ERRTYPE RscSysDepend::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) -{ - ERRTYPE aError = RscClass::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - - if( this == rInst.pClass ) - // nur wenn es eigen Klasse ist - aError = WriteSysDependRc( rInst, rMem, pTC, nDeep, bExtra ); - return aError; -} - -/************************************************************************* -|* -|* RscTupel::RscTupel() -|* -|* Beschreibung -|* -*************************************************************************/ -RscTupel::RscTupel( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper ) - : RscClass( nId, nTypeId, pSuper ) -{} - -/************************************************************************* -|* -|* RscTupel::GetTupelVar() -|* -|* Beschreibung -|* -*************************************************************************/ -RSCINST RscTupel::GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos, - const RSCINST & rInitInst ) -{ - if( nPos >= nEntries ) - { - return RSCINST(); - } - else - return GetVariable( rInst, pVarTypeList[ nPos ].nVarName, rInitInst ); -} - -/************************************************************************* -|* -|* RscTupel::WriteSrc() -|* -|* Beschreibung -|* -*************************************************************************/ -void RscTupel::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const char * pVarName ) -{ - sal_uInt32 i = 0; - RSCINST aTmpI; - - RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); - - fprintf( fOutput, "< " ); - for( i = 0; i < nEntries; i++ ) - { - if( !(VAR_HIDDEN & pVarTypeList[ i ].nVarType) ) - { - if( !IsDflt( rInst.pData, i ) - && !IsValueDflt( rInst.pData, i ) ) - { - aTmpI = GetInstData( rInst.pData, i, sal_True ); - - if( aTmpI.IsInst() ) - aTmpI.pClass->WriteSrcHeader( - aTmpI, fOutput, pTC, nTab, RscId(), pVarName ); - else - fprintf( fOutput, "Default" ); - } - else - fprintf( fOutput, "Default" ); - fprintf( fOutput, "; " ); - }; - }; - fprintf( fOutput, ">" ); - - return; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rscclobj.cxx b/rsc/source/res/rscclobj.cxx deleted file mode 100644 index 7005c9b38f..0000000000 --- a/rsc/source/res/rscclobj.cxx +++ /dev/null @@ -1,188 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. - -// Solar Definitionen -#include <tools/solar.h> - -// Programmabhaengige Includes. -#include <rscclobj.hxx> -#include <rsctop.hxx> - -/****************** C O D E **********************************************/ - -/****************** R e f N o d e ****************************************/ -/************************************************************************* -|* -|* RefNode::RefNode() -|* -*************************************************************************/ -RefNode::RefNode( Atom nTyp ){ - pObjBiTree = 0; - nTypNameId = nTyp; -} - -/************************************************************************* -|* -|* RefNode::GetId() -|* -*************************************************************************/ -sal_uInt32 RefNode::GetId() const -{ - return( nTypNameId ); -} - -/************************************************************************* -|* -|* RefNode::PutObjNode() -|* -*************************************************************************/ -sal_Bool RefNode::PutObjNode( ObjNode * pPutObject ){ -// insert a node in the b-tree pObjBiTree -// if the node with the same name is in pObjBiTree, -// return sal_False and no insert, - - if( pObjBiTree ) - return( pObjBiTree->Insert( pPutObject ) ); - - pObjBiTree = pPutObject; - return( sal_True ); -} - -/****************** O b j N o d e ****************************************/ -/************************************************************************* -|* -|* RefNode::GetObjNode() -|* -*************************************************************************/ -ObjNode * RefNode :: GetObjNode( const RscId & rRscId ){ -// insert a node in the b-tree pObjBiTree -// if the node with the same name is in pObjBiTree, -// return NULL and no insert, -// if not return the pointer to the Object - - if( pObjBiTree ) - return( pObjBiTree->Search( rRscId ) ); - return( NULL ); -} - -/************************************************************************* -|* -|* ObjNode::ObjNode() -|* -*************************************************************************/ -ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, sal_uLong lKey ){ - pRscObj = pData; - aRscId = rId; - lFileKey = lKey; -} - -/************************************************************************* -|* -|* ObjNode::DelObjNode() -|* -*************************************************************************/ -ObjNode * ObjNode::DelObjNode( RscTop * pClass, sal_uLong nFileKey ){ - ObjNode * pRetNode = this; - - if( Right() ) - pRight = ((ObjNode *)Right())->DelObjNode( pClass, nFileKey ); - if( Left() ) - pLeft = ((ObjNode *)Left())->DelObjNode( pClass, nFileKey ); - - if( GetFileKey() == nFileKey ){ - if( GetRscObj() ){ - pClass->Destroy( RSCINST( pClass, GetRscObj() ) ); - rtl_freeMemory( GetRscObj() ); - } - pRetNode = (ObjNode *)Right(); - if( pRetNode ){ - if( Left() ) - pRetNode->Insert( (ObjNode *)Left() ); - } - else - pRetNode = (ObjNode *)Left(); - delete this; - } - return pRetNode; -} - -/************************************************************************* -|* -|* ObjNode::GetId() -|* -*************************************************************************/ -sal_uInt32 ObjNode::GetId() const -{ - return( (sal_uInt32)(long)aRscId ); -} - -/************************************************************************* -|* -|* ObjNode::IsConsistent() -|* -*************************************************************************/ -sal_Bool ObjNode::IsConsistent() -{ - sal_Bool bRet = sal_True; - - if( (long)aRscId > 0x7FFF || (long)aRscId < 1 ) - { - bRet = sal_False; - } - else - { - if( Left() ) - { - if( !((ObjNode *)Left())->IsConsistent() ) - bRet = sal_False; - if( ((ObjNode *)Left())->aRscId >= aRscId ) - { - bRet = sal_False; - } - }; - if( Right() ) - { - if( ((ObjNode *)Right())->aRscId <= aRscId ) - { - bRet = sal_False; - } - if( !((ObjNode *)Right())->IsConsistent() ) - bRet = sal_False; - }; - }; - - return( bRet ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rscconst.cxx b/rsc/source/res/rscconst.cxx deleted file mode 100644 index 583b6b0f04..0000000000 --- a/rsc/source/res/rscconst.cxx +++ /dev/null @@ -1,348 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <cstdlib> -#include <cstdio> -#include <cstring> - -// Solar Definitionen -#include <tools/solar.h> - -// Programmabhaengige Includes. -#include <rscconst.hxx> -#include <rscall.h> -#include <rschash.hxx> -#include <tools/resid.hxx> - -/****************** C O D E **********************************************/ -/****************** R s c C o n s t **************************************/ -/************************************************************************* -|* -|* RscConst::RscConst() -|* -*************************************************************************/ -RscConst::RscConst( Atom nId, sal_uInt32 nTypeId ) - : RscTop( nId, nTypeId ) -{ - pVarArray = NULL; - nEntries = 0; -} - -/************************************************************************* -|* -|* RscConst::~RscConst() -|* -*************************************************************************/ -RscConst::~RscConst() -{ - if( pVarArray ) - rtl_freeMemory( (void *)pVarArray ); -} - -/************************************************************************* -|* -|* RscConst::GetClassType() -|* -*************************************************************************/ -RSCCLASS_TYPE RscConst::GetClassType() const -{ - return RSCCLASS_CONST; -} - -/************************************************************************* -|* -|* RscConst::SetConstance() -|* -*************************************************************************/ -ERRTYPE RscConst::SetConstant( Atom nVarName, sal_Int32 lValue ){ - if( pVarArray ) - pVarArray = (VarEle *) - rtl_reallocateMemory( (void *)pVarArray, - ((nEntries +1) * sizeof( VarEle )) ); - else - pVarArray = (VarEle *) - rtl_allocateMemory( ((nEntries +1) * sizeof( VarEle )) ); - pVarArray[ nEntries ].nId = nVarName; - pVarArray[ nEntries ].lValue = lValue; - nEntries++; - - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscConst::GetConstance() -|* -*************************************************************************/ -Atom RscConst::GetConstant( sal_uInt32 nPos ){ - if( nPos < nEntries ) - return pVarArray[ nPos ].nId; - return( InvalidAtom ); -} - -/************************************************************************* -|* -|* RscConst::GetConstValue() -|* -*************************************************************************/ -sal_Bool RscConst::GetConstValue( Atom nConst, sal_Int32 * pValue ) const -{ - sal_uInt32 i = 0; - - for( i = 0; i < nEntries; i++ ) - if( pVarArray[ i ].nId == nConst ) - { - *pValue = pVarArray[ i ].lValue; - return sal_True; - } - return sal_False; -} - -/************************************************************************* -|* -|* RscConst::GetValueConst() -|* -*************************************************************************/ -sal_Bool RscConst::GetValueConst( sal_Int32 lValue, Atom * pConst ) const -{ - sal_uInt32 i = 0; - - for( i = 0; i < nEntries; i++ ) - if( pVarArray[ i ].lValue == lValue ) - { - *pConst = pVarArray[ i ].nId; - return sal_True; - } - return sal_False; -} - -/************************************************************************* -|* -|* RscConst::GetConstPos() -|* -|* Beschreibung Sucht die Position der Konstanten -|* Return = nEntries, nicht gefunden -|* Return = Position im Feld -|* -*************************************************************************/ -sal_uInt32 RscConst::GetConstPos( Atom nConst ) -{ - sal_uInt32 i = 0; - - for( i = 0; i < nEntries; i++ ) - { - if( pVarArray[ i ].nId == nConst ) - return( i ); - } - - return( nEntries ); -} - -/************************************************************************* -|* -|* RscEnum::WriteSyntax() -|* -*************************************************************************/ -void RscConst::WriteSyntax( FILE * fOutput, RscTypCont * pTC ) -{ - RscTop::WriteSyntax( fOutput, pTC ); - - sal_uInt32 i = 0; - // Wenn eine Variable Maskierung hat, dann Maskenfeld - fprintf( fOutput, "\t" ); - for( i = 0; i < nEntries; i++ ) - { - fprintf( fOutput, "%s, ", pHS->getString( pVarArray[ i ].nId ).getStr() ); - if( 3 == (i % 4) && i < sal_uInt32(nEntries -1) ) - fprintf( fOutput, "\n\t" ); - }; - fprintf( fOutput, "\n" ); -} - -//================================================================== -void RscConst::WriteRcAccess -( - FILE * fOutput, - RscTypCont * /*pTC*/, - const char * pName -) -{ - fprintf( fOutput, "\t\tSet%s( %s( ", pName, pHS->getString( GetId() ).getStr() ); - fprintf( fOutput, "*(short*)(pResData+nOffset) ) );\n" ); - fprintf( fOutput, "\t\tnOffset += sizeof( short );\n" ); -} - -/****************** R s c E n u m ****************************************/ -/************************************************************************* -|* -|* RscEnum::RscEnum() -|* -*************************************************************************/ -RscEnum::RscEnum( Atom nId, sal_uInt32 nTypeId ) - : RscConst( nId, nTypeId ) -{ - nSize = ALIGNED_SIZE( sizeof( RscEnumInst ) ); -} - -/************************************************************************* -|* -|* RscEnum::SetConst() -|* -*************************************************************************/ -ERRTYPE RscEnum::SetConst( const RSCINST & rInst, Atom nConst, sal_Int32 /*nVal*/ ) -{ - sal_uInt32 i = 0; - - if( nEntries != (i = GetConstPos( nConst )) ) - { - ((RscEnumInst *)rInst.pData)->nValue = i; - ((RscEnumInst *)rInst.pData)->bDflt = sal_False; - return( ERR_OK ); - }; - - return( ERR_RSCENUM ); -} - -/************************************************************************* -|* -|* RscEnum::SetNumber() -|* -*************************************************************************/ -ERRTYPE RscEnum::SetNumber( const RSCINST & rInst, sal_Int32 lValue ) -{ - sal_uInt32 i = 0; - - for( i = 0; i < nEntries; i++ ){ - if( (sal_Int32)pVarArray[ i ].lValue == lValue ) - return( SetConst( rInst, pVarArray[ i ].nId, lValue ) ); - }; - - return( ERR_RSCENUM ); -} - -/************************************************************************* -|* -|* RscEnum::GetConst() -|* -*************************************************************************/ -ERRTYPE RscEnum::GetConst( const RSCINST & rInst, Atom * pH ){ - *pH = pVarArray[ ((RscEnumInst *)rInst.pData)->nValue ].nId; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscEnum::GetNumber() -|* -*************************************************************************/ -ERRTYPE RscEnum::GetNumber( const RSCINST & rInst, sal_Int32 * pNumber ){ - *pNumber = pVarArray[ ((RscEnumInst *)rInst.pData)->nValue ].lValue; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscEnum::Create() -|* -*************************************************************************/ -RSCINST RscEnum::Create( RSCINST * pInst, const RSCINST & rDflt, sal_Bool bOwnClass ){ - RSCINST aInst; - - if( !pInst ){ - aInst.pClass = this; - aInst.pData = (CLASS_DATA) - rtl_allocateMemory( sizeof( RscEnumInst ) ); - } - else - aInst = *pInst; - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - if( bOwnClass ) - memmove( aInst.pData, rDflt.pData, Size() ); - else{ - ((RscEnumInst *)aInst.pData)->nValue = 0; - ((RscEnumInst *)aInst.pData)->bDflt = sal_True; - } - - return( aInst ); -} - -/************************************************************************* -|* -|* RscEnum::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscEnum::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ){ - if( pDef ){ - if( ((RscEnumInst*)rInst.pData)->nValue == - ((RscEnumInst*)pDef)->nValue ) - { - return sal_True; - } - } - - return sal_False; -} - -/************************************************************************* -|* -|* RscEnum::WriteSrc() -|* -*************************************************************************/ -void RscEnum::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont *, sal_uInt32, const char * ) -{ - fprintf( fOutput, "%s", pHS->getString( - pVarArray[ ((RscEnumInst *)rInst.pData)->nValue ].nId ).getStr() ); -} - -/************************************************************************* -|* -|* RscEnum::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscEnum::WriteRc( const RSCINST & rInst, RscWriteRc & aMem, - RscTypCont *, sal_uInt32, sal_Bool ) -{ - aMem.Put( (sal_Int32)pVarArray[ ((RscEnumInst *)rInst.pData)->nValue ].lValue ); - return( ERR_OK ); -} - -RscLangEnum::RscLangEnum() - : RscEnum( pHS->getID( "LangEnum" ), RSC_NOTYPE ), - mnLangId( 0x400 ) -{ -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rsccont.cxx b/rsc/source/res/rsccont.cxx deleted file mode 100644 index 2858ff9180..0000000000 --- a/rsc/source/res/rsccont.cxx +++ /dev/null @@ -1,1030 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -// Programmabh�ngige Includes. -#include <rsccont.hxx> - -#include <tools/rcid.h> - -/****************** C O D E **********************************************/ -/****************** E N T R Y S T R U C T ********************************/ -/************************************************************************* -|* -|* ENTRYSTRUCT::Destroy() -|* -*************************************************************************/ -void ENTRY_STRUCT::Destroy() -{ - aName.Destroy(); - if( aInst.IsInst() ){ - aInst.pClass->Destroy( aInst ); - rtl_freeMemory( aInst.pData ); - }; -} - -/****************** R s c B a s e C o n t ********************************/ -/************************************************************************* -|* -|* RscBaseCont::RscBaseCont() -|* -*************************************************************************/ -RscBaseCont::RscBaseCont( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, - sal_Bool bNoIdent ) - : RscTop( nId, nTypeId, pSuper ), - nSize( 0 ) -{ - pTypeClass = NULL; - pTypeClass1 = NULL; - bNoId = bNoIdent; - nOffInstData = RscTop::Size(); - nSize = nOffInstData + ALIGNED_SIZE( sizeof( RscBaseContInst ) ); -} - -/************************************************************************* -|* -|* RscBaseCont::~RscBaseCont() -|* -*************************************************************************/ -RscBaseCont::~RscBaseCont() -{ -} - -/************************************************************************* -|* -|* RscBaseCont::GetClassType() -|* -*************************************************************************/ -RSCCLASS_TYPE RscBaseCont::GetClassType() const -{ - return RSCCLASS_COMPLEX; -} - -/************************************************************************* -|* -|* DestroyElements() -|* -*************************************************************************/ -void RscBaseCont::DestroyElements( RscBaseContInst * pClassData ) -{ - sal_uInt32 i = 0; - - if( pClassData->nEntries ){ - for( i = 0; i < pClassData->nEntries; i++ ){ - pClassData->pEntries[ i ].Destroy(); - }; - rtl_freeMemory( pClassData->pEntries ); - pClassData->pEntries = NULL; - pClassData->nEntries = 0; - }; -} - -/************************************************************************* -|* -|* RscBaseCont::Create() -|* -*************************************************************************/ -RSCINST RscBaseCont::Create( RSCINST * pInst, const RSCINST & rDflt, - sal_Bool bOwnClass ) -{ - sal_uInt32 i = 0; - RSCINST aInst; - RscBaseContInst * pClassData; - - if( !pInst ){ - aInst.pClass = this; - aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() ); - } - else - aInst = *pInst; - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - RscTop::Create( &aInst, rDflt, bOwnClass ); - - pClassData = (RscBaseContInst *)(aInst.pData + nOffInstData); - pClassData->nEntries = 0; - pClassData->pEntries = NULL; - pClassData->bDflt = sal_True; - - if( bOwnClass ){ - RscBaseContInst * pDfltClassData; - RSCINST aDfltI; - - pDfltClassData = (RscBaseContInst *)(rDflt.pData + nOffInstData); - - if( 0 != pDfltClassData->nEntries ){ - *pClassData = *pDfltClassData; - pClassData->pEntries = - (ENTRY_STRUCT *)rtl_allocateMemory( sizeof( ENTRY_STRUCT ) - * pClassData->nEntries ); - for( i = 0; i < pClassData->nEntries; i++ ){ - pClassData->pEntries[ i ].Create(); - pClassData->pEntries[ i ].aName = - pDfltClassData->pEntries[ i ].aName; - aDfltI = pDfltClassData->pEntries[ i ].aInst; - pClassData->pEntries[ i ].aInst = - aDfltI.pClass->Create( NULL, aDfltI ); - }; - }; - } - - return( aInst ); -} - -/************************************************************************* -|* -|* RscBaseCont::Destroy() -|* -*************************************************************************/ -void RscBaseCont::Destroy( const RSCINST & rInst ){ - RscBaseContInst * pClassData; - - RscTop::Destroy( rInst); - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - DestroyElements( pClassData ); -} - -/************************************************************************* -|* -|* RscBaseCont::SearchEle() -|* -*************************************************************************/ -RSCINST RscBaseCont::SearchElePos( const RSCINST & rInst, const RscId & rEleName, - RscTop * pClass, sal_uInt32 nPos ) -{ - sal_uInt32 i = 0; - RscBaseContInst * pClassData; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - if( !pClass ) - pClass = pTypeClass; - - if( rEleName.IsId() ){ - for( i = nPos; i < pClassData->nEntries; i++ ){ - if( pClassData->pEntries[ i ].aName == rEleName - && pClassData->pEntries[ i ].aInst.pClass == pClass ) - { - return( pClassData->pEntries[ i ].aInst ); - }; - }; - }; - return RSCINST(); -} - -/************************************************************************* -|* -|* RscBaseCont::SearchEle() -|* -*************************************************************************/ -RSCINST RscBaseCont::SearchEle( const RSCINST & rInst, const RscId & rEleName, - RscTop * pClass ) -{ - return SearchElePos( rInst, rEleName, pClass, 0 ); -} - -/************************************************************************* -|* -|* RscBaseCont::GetElement() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::GetElement( const RSCINST & rInst, const RscId & rEleName, - RscTop * pCreateClass, - const RSCINST & rCreateInst, RSCINST * pGetInst ) -{ - RscBaseContInst * pClassData; - RSCINST aTmpI; - ERRTYPE aError; - - if( !bNoId && !rEleName.IsId() ) - aError = WRN_CONT_NOID; - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - if( pCreateClass ){ - if( !pCreateClass->InHierarchy( pTypeClass ) ){ - if( pTypeClass1 ){ - if( !pCreateClass->InHierarchy( pTypeClass1 ) ){ - // Falscher Typ - return ERR_CONT_INVALIDTYPE; - } - } - else{ - // Falscher Typ - return ERR_CONT_INVALIDTYPE; - }; - }; - } - else - pCreateClass = pTypeClass; - - pClassData->bDflt = sal_False; - if( !bNoId ) - aTmpI = SearchEle( rInst, rEleName, pCreateClass ); - // Eintrag gefunden - if( aTmpI.IsInst() ){ - aError = WRN_CONT_DOUBLEID; - if( rCreateInst.IsInst() ){ - aTmpI.pClass->Destroy( aTmpI ); - aTmpI.pClass->Create( &aTmpI, rCreateInst ); - }; - } - else { - if( pClassData->pEntries ){ - pClassData->pEntries = - (ENTRY_STRUCT *)rtl_reallocateMemory( pClassData->pEntries, - sizeof( ENTRY_STRUCT ) * (pClassData->nEntries +1) ); - } - else { - pClassData->pEntries = - (ENTRY_STRUCT *)rtl_allocateMemory( sizeof( ENTRY_STRUCT ) - * (pClassData->nEntries +1) ); - }; - - pClassData->pEntries[ pClassData->nEntries ].Create(); - pClassData->pEntries[ pClassData->nEntries ].aName = rEleName; - - if( rCreateInst.IsInst() ){ - // Instanz mit CreateInst-Daten initialisieren - pClassData->pEntries[ pClassData->nEntries ].aInst = - pCreateClass->Create( NULL, rCreateInst ); - } - else { - pClassData->pEntries[ pClassData->nEntries ].aInst = - pCreateClass->Create( NULL, RSCINST() ); - }; - - pClassData->nEntries++; - aTmpI = pClassData->pEntries[ pClassData->nEntries -1 ].aInst; - } - - *pGetInst = aTmpI; - return aError; -} - -/************************************************************************* -|* -|* RscBaseCont::GetCount() -|* -*************************************************************************/ -sal_uInt32 RscBaseCont::GetCount( const RSCINST & rInst ){ - RscBaseContInst * pClassData; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - return( pClassData->nEntries ); -} - -/************************************************************************* -|* -|* RscBaseCont::GetPosEle() -|* -*************************************************************************/ -RSCINST RscBaseCont::GetPosEle( const RSCINST & rInst, sal_uInt32 nPos ){ - RscBaseContInst * pClassData; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - if( nPos < pClassData->nEntries ) - return( pClassData->pEntries[ nPos ].aInst ); - return RSCINST(); -} - -/************************************************************************* -|* -|* RscBaseCont::MovePosEle() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::MovePosEle( const RSCINST & rInst, sal_uInt32 nDestPos, - sal_uInt32 nSourcePos ) -{ - ERRTYPE aError; - RscBaseContInst * pClassData; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - if( (nDestPos < pClassData->nEntries) && (nSourcePos < pClassData->nEntries) ){ - ENTRY_STRUCT aEntry; - int nInc = 1; - sal_uInt32 i = 0; - - // Quelle Merken - aEntry = pClassData->pEntries[ nSourcePos ]; - // Richtung der for-Schleife bestimmen - if( nDestPos < nSourcePos ) - nInc = -1; - - for( i = nSourcePos; i != nDestPos; i += nInc ) - pClassData->pEntries[ i ] = pClassData->pEntries[ i + nInc ]; - - // Zuweisung Quelle auf Ziel - pClassData->pEntries[ nDestPos ] = aEntry; - } - else - aError = ERR_RSCCONT; - return aError; -} - -/************************************************************************* -|* -|* RscBaseCont::SetPosRscId() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos, - const RscId & rId ){ - RscBaseContInst * pClassData; - RSCINST aTmpI; - ERRTYPE aError; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - if( nPos < pClassData->nEntries ){ - if( ! (rId == pClassData->pEntries[ nPos ].aName) ) - aTmpI = SearchEle( rInst, rId, - pClassData->pEntries[ nPos ].aInst.pClass ); - if( !aTmpI.IsInst() ) - pClassData->pEntries[ nPos ].aName = rId; - else - aError = ERR_RSCCONT; - } - else - aError = ERR_RSCCONT; - return( aError ); -} - -/************************************************************************* -|* -|* RscBaseCont::GetInfoEle() -|* -*************************************************************************/ -SUBINFO_STRUCT RscBaseCont::GetInfoEle( const RSCINST & rInst, sal_uInt32 nPos ){ - RscBaseContInst * pClassData; - SUBINFO_STRUCT aInfo; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - if( nPos < pClassData->nEntries ){ - aInfo.aId = pClassData->pEntries[ nPos ].aName; - aInfo.nPos = nPos; - aInfo.pClass = pClassData->pEntries[ nPos ].aInst.pClass; - } - return( aInfo ); -} - -/************************************************************************* -|* -|* RscBaseCont::SetString() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::SetString( const RSCINST & rInst, const char * pStr ) -{ - RscBaseContInst * pClassData; - RSCINST aTmpI; - ERRTYPE aError; - char *pTmpStr; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - -//?B 040991 -//?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ){ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetString( aTmpI, pStr ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetString( aTmpI, pStr ); - } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; - - return( aError ); -} - -/************************************************************************* -|* -|* RscBaseCont::SetNumber() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::SetNumber( const RSCINST & rInst, sal_Int32 lValue ){ - RscBaseContInst * pClassData; - RSCINST aTmpI; - ERRTYPE aError; - sal_Int32 lNumber; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - -//?B 040991 -//?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ){ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetNumber( aTmpI, lValue ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetNumber( aTmpI, lValue ); - } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; - - return( aError ); -} - -//================================================================== -ERRTYPE RscBaseCont::SetBool -( - const RSCINST & rInst, - sal_Bool bValue -) -{ - RscBaseContInst * pClassData; - RSCINST aTmpI; - ERRTYPE aError; - sal_Bool bBool; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - -//?B 040991 -//?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ) -{ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetBool( aTmpI, &bBool ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetBool( aTmpI, bValue ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetBool( aTmpI, &bBool ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetBool( aTmpI, bValue ); - } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; - - return( aError ); -} - -//================================================================== -ERRTYPE RscBaseCont::SetConst -( - const RSCINST & rInst, - Atom nValueId, - sal_Int32 lValue -) -{ - RscBaseContInst * pClassData; - RSCINST aTmpI; - ERRTYPE aError; - Atom nConst; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - -//?B 040991 -//?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ){ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetConst( aTmpI, &nConst ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetConst( aTmpI, &nConst ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue ); - } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; - - return( aError ); -} - -/************************************************************************* -|* -|* RscBaseCont::SetRef() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::SetRef( const RSCINST & rInst, const RscId & rRefId ){ - RscBaseContInst * pClassData; - RSCINST aTmpI; - ERRTYPE aError; - RscId aId; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - -//?B 040991 -//?W 040991 sonst Endlosrekursion moeglich -if( RSC_NOTYPE == pTypeClass->GetTypId() ){ - aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetRef( aTmpI, &aId ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetRef( aTmpI, rRefId ); - else { - aError.Clear(); - DeletePos( rInst, pClassData->nEntries -1 ); - aError = GetElement( rInst, RscId(), pTypeClass1, RSCINST(), &aTmpI ); - aError = aTmpI.pClass->GetRef( aTmpI, &aId ); - if( aError.IsOk() ) - aError = aTmpI.pClass->SetNumber( aTmpI, rRefId ); - } - if( aError.IsError() ) - DeletePos( rInst, pClassData->nEntries -1 ); -} -else - aError = ERR_UNKNOWN_METHOD; - - return( aError ); -} - -/************************************************************************* -|* -|* RscBaseCont::IsConsistent() -|* -*************************************************************************/ -sal_Bool RscBaseCont::IsConsistent( const RSCINST & rInst ) { - sal_uInt32 i = 0; - RscBaseContInst * pClassData; - sal_Bool bRet; - - bRet = RscTop::IsConsistent( rInst ); - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - // auf doppelten Id Testen und Reihenfolge beibehalten - // Komplexitaet = n^2 / 2 - for( i = 0; i < pClassData->nEntries; i++ ){ - if( !bNoId ){ - if( (sal_Int32)pClassData->pEntries[ i ].aName > 0x7FFF - || (sal_Int32)pClassData->pEntries[ i ].aName < 1 ){ - bRet = sal_False; - } - else if( SearchElePos( rInst, pClassData->pEntries[ i ].aName, - pClassData->pEntries[ i ].aInst.pClass, i +1 ).IsInst() ) - { - bRet = sal_False; - }; - } - if( ! pClassData->pEntries[ i ].aInst.pClass-> - IsConsistent( pClassData->pEntries[ i ].aInst ) ) - bRet = sal_False; - }; - - return( bRet ); -} - -/************************************************************************* -|* -|* RscBaseCont::SetToDefault() -|* -*************************************************************************/ -void RscBaseCont::SetToDefault( const RSCINST & rInst ) -{ - sal_uInt32 i = 0; - RscBaseContInst * pClassData; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - for( i = 0; i < pClassData->nEntries; i++ ) - { - pClassData->pEntries[ i ].aInst.pClass-> - SetToDefault( pClassData->pEntries[ i ].aInst ); - }; - - RscTop::SetToDefault( rInst ); -} - -/************************************************************************* -|* -|* RscBaseCont::IsDefault() -|* -*************************************************************************/ -sal_Bool RscBaseCont::IsDefault( const RSCINST & rInst ){ - sal_uInt32 i = 0; - RscBaseContInst * pClassData; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - if( !pClassData->bDflt ) - return sal_False; - - for( i = 0; i < pClassData->nEntries; i++ ){ - if( ! pClassData->pEntries[ i ].aInst.pClass-> - IsDefault( pClassData->pEntries[ i ].aInst ) ) - { - return( sal_False ); - }; - }; - - return( RscTop::IsDefault( rInst ) ); -} - -/************************************************************************* -|* -|* RscBaseCont::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscBaseCont::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ) -{ - RscBaseContInst * pClassData; - - if( !RscTop::IsValueDefault( rInst, pDef ) ) - return sal_False; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - if( pClassData->nEntries ) - return sal_False; - else - return sal_True; -} - -/************************************************************************* -|* -|* RscBaseCont::Delete() -|* -*************************************************************************/ -void RscBaseCont::Delete( const RSCINST & rInst, RscTop * pClass, - const RscId & rId ) -{ - sal_uInt32 i = 0; - RscBaseContInst * pClassData; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - if( !pClass ) - pClass = pTypeClass; - - for( i = 0; i < pClassData->nEntries; i++ ){ - if( pClassData->pEntries[ i ].aName == rId ) - if( pClassData->pEntries[ i ].aInst.pClass == pClass || !pClass ){ - DeletePos( rInst, i ); - return; - }; - }; - -} - -/************************************************************************* -|* -|* RscBaseCont::DeletePos() -|* -*************************************************************************/ -void RscBaseCont::DeletePos( const RSCINST & rInst, sal_uInt32 nPos ){ - RscBaseContInst * pClassData; - sal_uInt32 i = 0; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - if( nPos < pClassData->nEntries ){ - if( 1 == pClassData->nEntries ) - DestroyElements( pClassData ); - else{ - pClassData->pEntries[ nPos ].Destroy(); - pClassData->nEntries--; - for( i = nPos; i < pClassData->nEntries; i++ ) - pClassData->pEntries[ i ] = pClassData->pEntries[ i + 1 ]; - }; - }; -} - -/************************************************************************* -|* -|* RscBaseCont::ContWriteSrc() -|* -*************************************************************************/ -void RscBaseCont::ContWriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const char * pVarName ) -{ - sal_uInt32 i = 0, t = 0; - RscBaseContInst * pClassData; - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - for( i = 0; i < pClassData->nEntries; i++ ) - { - for( t = 0; t < nTab; t++ ) - fputc( '\t', fOutput ); - pClassData->pEntries[ i ].aInst.pClass-> - WriteSrcHeader( pClassData->pEntries[ i ].aInst, - fOutput, pTC, nTab, - pClassData->pEntries[ i ].aName, pVarName ); - fprintf( fOutput, ";\n" ); - }; -} - -/************************************************************************* -|* -|* RscBaseCont::ContWriteRc() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::ContWriteRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) -{ - sal_uInt32 i = 0; - RscBaseContInst * pClassData; - ERRTYPE aError; - - if( bExtra || bNoId ) - { // Nur Subresourcen schreiben, wenn bExtra == sal_True - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ ){ - aError = pClassData->pEntries[ i ].aInst.pClass-> - WriteRcHeader( pClassData->pEntries[ i ].aInst, - rMem, pTC, - pClassData->pEntries[ i ].aName, - nDeep, bExtra ); - } - } - - return( aError ); -} - -//================================================================== -void RscBaseCont::ContWriteRcAccess -( - FILE * fOutput, - RscTypCont * pTC, - const char * pName, - sal_Bool bWriteSize -) -{ - if( (bNoId || bWriteSize) && !pTypeClass1 ) - { - fprintf( fOutput, "\t\tsal_uInt32 nItems = *(sal_uInt32 *)(pResData+nOffset) );\n" ); - fprintf( fOutput, "\t\tnOffset += sizeof( sal_uInt32 );\n" ); - - fprintf( fOutput, "\t\t// Items hinzufuegen\n" ); - fprintf( fOutput, "\t\tfor( sal_uInt32 i = 0; i < nItems; i++ )\n" ); - fprintf( fOutput, "\t\t{\n" ); - pTypeClass->WriteRcAccess( fOutput, pTC, "Item" ); - fprintf( fOutput, "\t\t}\n" ); - } - else - { - fprintf( fOutput, "\t\tSet%s( %s ", pName, pHS->getString( GetId() ).getStr() ); - fprintf( fOutput, "%s ", aCallPar2.GetBuffer() ); - fprintf( fOutput, "ResId( (RSHEADER_TYPE*)(pResData+nOffset) ) ) );\n" ); - fprintf( fOutput, "\t\tnOffset += GetObjSizeRes( (RSHEADER_TYPE*)(pResData+nOffset) );\n" ); - } -} - - -/************************************************************************* -|* -|* RscBaseCont::WriteSrc() -|* -*************************************************************************/ -void RscBaseCont::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const char * pVarName ) -{ - RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); - ContWriteSrc( rInst, fOutput, pTC, nTab, pVarName ); -} - -/************************************************************************* -|* -|* RscBaseCont::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) -{ - ERRTYPE aError; - - aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - if( aError.IsOk() ) - aError = ContWriteRc( rInst, rMem, pTC, nDeep, bExtra ); - - return( aError ); -} - -/************************************************************************* -|* -|* RscBaseCont::WriteHxx() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::WriteHxx( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rRscId ) -{ - sal_uInt32 i = 0; - RscBaseContInst * pClassData; - ERRTYPE aError; - - aError = RscTop::WriteHxx( rInst, fOutput, pTC, rRscId ); - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ ) - { - if( pClassData->pEntries[ i ].aName.IsId() - && pClassData->pEntries[ i ].aInst.pClass->IsCodeWriteable() ) - { - aError = pClassData->pEntries[ i ].aInst.pClass-> - WriteHxx( pClassData->pEntries[ i ].aInst, - fOutput, pTC, - pClassData->pEntries[ i ].aName ); - } - }; - - return( aError ); -} - -/************************************************************************* -|* -|* RscBaseCont::WriteCxx() -|* -*************************************************************************/ -ERRTYPE RscBaseCont::WriteCxx( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rRscId ) -{ - sal_uInt32 i = 0; - RscBaseContInst * pClassData; - ERRTYPE aError; - - aError = RscTop::WriteCxx( rInst, fOutput, pTC, rRscId ); - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - for( i = 0; i < pClassData->nEntries && aError.IsOk(); i++ ) - { - if( pClassData->pEntries[ i ].aName.IsId() - && pClassData->pEntries[ i ].aInst.pClass->IsCodeWriteable() ) - { - aError = pClassData->pEntries[ i ].aInst.pClass-> - WriteCxx( pClassData->pEntries[ i ].aInst, - fOutput, pTC, - pClassData->pEntries[ i ].aName ); - } - }; - - return( aError ); -} - -/*************** R s c C o n t W r i t e S r c ***************************/ -/************************************************************************* -|* -|* RscContWriteSrc::RscContWriteSrc() -|* -*************************************************************************/ -RscContWriteSrc::RscContWriteSrc( Atom nId, sal_uInt32 nTypeId, - RscTop * pSuper, sal_Bool bNoIdent ) - : RscBaseCont( nId, nTypeId, pSuper, bNoIdent ) -{} - -/************************************************************************* -|* -|* RscContWriteSrc::WriteSrc() -|* -*************************************************************************/ -void RscContWriteSrc::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const char * pVarName ) -{ - sal_uInt32 i; - - RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); - - fprintf( fOutput, "\n" ); - for( i = 0; i < nTab; i++ ) - fputc( '\t', fOutput ); - fprintf( fOutput, "{\n" ); - - ContWriteSrc( rInst, fOutput, pTC, nTab +1, pVarName ); - - for( i = 0; i < nTab; i++ ) - fputc( '\t', fOutput ); - fprintf( fOutput, "}" ); -} - -/*************** R s c C o n t *******************************************/ -/************************************************************************* -|* -|* RscCont::RscCont() -|* -*************************************************************************/ -RscCont::RscCont( Atom nId, sal_uInt32 nTypeId, RscTop * pSuper, sal_Bool bNoIdent ) - : RscContWriteSrc( nId, nTypeId, pSuper, bNoIdent ) -{} - -/************************************************************************* -|* -|* RscCont::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscCont::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) -{ - RscBaseContInst * pClassData; - ERRTYPE aError; - - aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - - pClassData = (RscBaseContInst *)(rInst.pData + nOffInstData); - - rMem.Put( pClassData->nEntries ); - - if( aError.IsOk() ) - aError = ContWriteRc( rInst, rMem, pTC, nDeep, bExtra ); - - return aError; -} - -//================================================================== -void RscCont::WriteRcAccess -( - FILE * fOutput, - RscTypCont * pTC, - const char * pName -) -{ - ContWriteRcAccess( fOutput, pTC, pName, sal_True ); -} - -/************************************************************************* -|* -|* RscContExtraData::RscContExtraData() -|* -*************************************************************************/ -RscContExtraData::RscContExtraData( Atom nId, sal_uInt32 nTypeId, - RscTop * pSuper, sal_Bool bNoIdent ) - : RscContWriteSrc( nId, nTypeId, pSuper, bNoIdent ) -{} - -/************************************************************************* -|* -|* RscContExtraData::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscContExtraData::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) -{ - ERRTYPE aError; - - if( bExtra ) - aError = RscContWriteSrc::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - else - aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - - return aError; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rscflag.cxx b/rsc/source/res/rscflag.cxx deleted file mode 100644 index 7f0fa276d9..0000000000 --- a/rsc/source/res/rscflag.cxx +++ /dev/null @@ -1,426 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -#include <rscflag.hxx> - -/****************** C O D E **********************************************/ -/****************** R s c F l a g ****************************************/ -/************************************************************************* -|* -|* RscFlag::RscFlag() -|* -*************************************************************************/ -RscFlag::RscFlag( Atom nId, sal_uInt32 nTypeId ) - : RscConst( nId, nTypeId ) -{} - -/************************************************************************* -|* -|* RscFlag::Size() -|* -|* Beschreibung Die Groe�e der Instanzdaten richtet sich nach -|* der Anzahl der Flags -|* -*************************************************************************/ -sal_uInt32 RscFlag::Size() -{ - return( ALIGNED_SIZE( sizeof( RscFlagInst ) * - ( 1 + (nEntries -1) / (sizeof( sal_uInt32 ) * 8) ) ) ); -} - -/************************************************************************* -|* -|* RscFlag::SetNotConst() -|* -*************************************************************************/ -ERRTYPE RscFlag::SetNotConst( const RSCINST & rInst, Atom nConst ) -{ - sal_uInt32 i = 0, nFlag = 0; - - if( nEntries != (i = GetConstPos( nConst )) ){ - nFlag = 1 << (i % (sizeof( sal_uInt32 ) * 8) ); - i = i / (sizeof( sal_uInt32 ) * 8); - ((RscFlagInst *)rInst.pData)[ i ].nFlags &= ~nFlag; - ((RscFlagInst *)rInst.pData)[ i ].nDfltFlags &= ~nFlag; - return( ERR_OK ); - }; - - return( ERR_RSCFLAG ); -} - -/************************************************************************* -|* -|* RscFlag::SetConst() -|* -*************************************************************************/ -ERRTYPE RscFlag::SetConst( const RSCINST & rInst, Atom nConst, sal_Int32 /*nVal*/ ) -{ - sal_uInt32 i = 0, nFlag = 0; - - if( nEntries != (i = GetConstPos( nConst )) ){ - nFlag = 1 << (i % (sizeof( sal_uInt32 ) * 8) ); - i = i / (sizeof( sal_uInt32 ) * 8); - ((RscFlagInst *)rInst.pData)[ i ].nFlags |= nFlag; - ((RscFlagInst *)rInst.pData)[ i ].nDfltFlags &= ~nFlag; - return( ERR_OK ); - }; - - return( ERR_RSCFLAG ); -} - -/************************************************************************* -|* -|* RscFlag::CreateBasic() -|* -*************************************************************************/ -RSCINST RscFlag::CreateBasic( RSCINST * pInst ) -{ - RSCINST aInst; - - if( !pInst ){ - aInst.pClass = this; - aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() ); - } - else - aInst = *pInst; - - return( aInst ); -} - -/************************************************************************* -|* -|* RscFlag::Create() -|* -*************************************************************************/ -RSCINST RscFlag::Create( RSCINST * pInst, const RSCINST & rDflt, sal_Bool bOwnClass ) -{ - RSCINST aInst = CreateBasic( pInst ); - sal_uInt32 i = 0; - - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - if( bOwnClass ) - memmove( aInst.pData, rDflt.pData, Size() ); - else - { - for( i = 0; i < Size() / sizeof( RscFlagInst ); i++ ) - { - ((RscFlagInst *)aInst.pData)[ i ].nFlags = 0; - ((RscFlagInst *)aInst.pData)[ i ].nDfltFlags = 0xFFFFFFFF; - } - }; - - return( aInst ); -} - -/************************************************************************* -|* -|* RscFlag::CreateClient() -|* -*************************************************************************/ -RSCINST RscFlag::CreateClient( RSCINST * pInst, const RSCINST & rDfltI, - sal_Bool bOwnClass, Atom nConstId ) -{ - RSCINST aInst = CreateBasic( pInst ); - sal_uInt32 i = 0, nFlag = 0; - - if( !bOwnClass && rDfltI.IsInst() ) - bOwnClass = rDfltI.pClass->InHierarchy( this ); - - if( nEntries != (i = GetConstPos( nConstId )) ){ - nFlag = 1 << (i % (sizeof( sal_uInt32 ) * 8) ); - i = i / (sizeof( sal_uInt32 ) * 8); - if( bOwnClass ){ - ((RscFlagInst *)aInst.pData)[ i ].nFlags &= - ~nFlag | ((RscFlagInst *)rDfltI.pData)[ i ].nFlags; - ((RscFlagInst *)aInst.pData)[ i ].nDfltFlags &= - ~nFlag | ((RscFlagInst *)rDfltI.pData)[ i ].nDfltFlags; - } - else{ - ((RscFlagInst *)aInst.pData)[ i ].nFlags &= ~nFlag; - ((RscFlagInst *)aInst.pData)[ i ].nDfltFlags |= nFlag; - } - } - - return( aInst ); -} - -/************************************************************************* -|* -|* RscFlag::SetToDefault() -|* -*************************************************************************/ -void RscFlag::SetToDefault( const RSCINST & rInst ) -{ - sal_uInt32 i = 0; - - for( i = 0; i < Size() / sizeof( RscFlagInst ); i++ ) - ((RscFlagInst *)rInst.pData)[ i ].nDfltFlags = 0xFFFFFFFF; -} - -/************************************************************************* -|* -|* RscFlag::IsDlft() -|* -*************************************************************************/ -sal_Bool RscFlag::IsDefault( const RSCINST & rInst ) -{ - sal_uInt32 i = 0; - - for( i = 0; i < Size() / sizeof( RscFlagInst ); i++ ) - if( ((RscFlagInst *)rInst.pData)[ i ].nDfltFlags != 0xFFFFFFFF ) - return( sal_False ); - return( sal_True ); -} - -sal_Bool RscFlag::IsDefault( const RSCINST & rInst, Atom nConstId ) -{ - sal_uInt32 i = 0, nFlag = 0; - - if( nEntries != (i = GetConstPos( nConstId )) ){ - nFlag = 1 << (i % (sizeof( sal_uInt32 ) * 8) ); - i = i / (sizeof( sal_uInt32 ) * 8); - if( ((RscFlagInst *)rInst.pData)[ i ].nDfltFlags & nFlag ) - return( sal_True ); - else - return( sal_False ); - }; - return( sal_True ); -} - -/************************************************************************* -|* -|* RscFlag::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscFlag::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef, - Atom nConstId ) -{ - sal_uInt32 i = 0, nFlag = 0; - - if( nEntries != (i = GetConstPos( nConstId )) ){ - nFlag = 1 << (i % (sizeof( sal_uInt32 ) * 8) ); - i = i / (sizeof( sal_uInt32 ) * 8); - - if( pDef ){ - if( (((RscFlagInst *)rInst.pData)[ i ].nFlags & nFlag) - == (((RscFlagInst *)pDef)[ i ].nFlags & nFlag) ) - { - return sal_True; - } - } - }; - - return sal_False; -} - -sal_Bool RscFlag::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ) -{ - sal_uInt32 i = 0; - - if( pDef ){ - sal_uInt32 Flag = 0, nIndex = 0; - - Flag = 1; - for( i = 0; i < nEntries; i++ ){ - nIndex = i / (sizeof( sal_uInt32 ) * 8); - if( (((RscFlagInst *)rInst.pData)[ nIndex ].nFlags & Flag) - != (((RscFlagInst *)pDef)[ nIndex ].nFlags & Flag) ) - { - return sal_False; - } - Flag <<= 1; - if( !Flag ) - Flag = 1; - }; - } - else - return sal_False; - - return sal_True; -} - -/************************************************************************* -|* -|* RscFlag::IsSet() -|* -*************************************************************************/ -sal_Bool RscFlag::IsSet( const RSCINST & rInst, Atom nConstId ) -{ - sal_uInt32 i = 0, nFlag = 0; - - if( nEntries != (i = GetConstPos( nConstId )) ){ - nFlag = 1 << (i % (sizeof( sal_uInt32 ) * 8) ); - i = i / (sizeof( sal_uInt32 ) * 8); - if( ((RscFlagInst *)rInst.pData)[ i ].nFlags & nFlag ) - return( sal_True ); - else - return( sal_False ); - }; - return( sal_True ); -} - -/************************************************************************* -|* -|* RscFlag::WriteSrc() -|* -*************************************************************************/ -void RscFlag::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont *, sal_uInt32, const char * ) -{ - sal_uInt32 i = 0, Flag = 0, nIndex = 0; - sal_Bool bComma = sal_False; - - Flag = 1; - for( i = 0; i < nEntries; i++ ){ - nIndex = i / (sizeof( sal_uInt32 ) * 8); - if( !( ((RscFlagInst *)rInst.pData)[ nIndex ].nDfltFlags & Flag) ){ - if( bComma ) - fprintf( fOutput, ", " ); - if( ((RscFlagInst *)rInst.pData)[ nIndex ].nFlags & Flag ) - fprintf( fOutput, "%s", pHS->getString( pVarArray[ i ].nId ).getStr() ); - else{ - fprintf( fOutput, "not " ); - fprintf( fOutput, "%s", pHS->getString( pVarArray[ i ].nId ).getStr() ); - } - bComma = sal_True; - } - Flag <<= 1; - if( !Flag ) - Flag = 1; - }; -} - -/************************************************************************* -|* -|* RscFlag::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscFlag::WriteRc( const RSCINST & rInst, RscWriteRc & aMem, - RscTypCont *, sal_uInt32, sal_Bool ) -{ - sal_Int32 lVal = 0; - sal_uInt32 i = 0, Flag = 0, nIndex = 0; - - Flag = 1; - for( i = 0; i < nEntries; i++ ){ - nIndex = i / (sizeof( sal_uInt32 ) * 8); - if( ((RscFlagInst *)rInst.pData)[ nIndex ].nFlags & Flag ) - lVal |= pVarArray[ i ].lValue; - - Flag <<= 1; - if( !Flag ) - Flag = 1; - }; - - aMem.Put( (sal_Int32)lVal ); - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscClient::RscClient() -|* -*************************************************************************/ -RscClient::RscClient( Atom nId, sal_uInt32 nTypeId, RscFlag * pClass, - Atom nConstantId ) - : RscTop ( nId, nTypeId ) -{ - pRefClass = pClass; - nConstId = nConstantId; -} - -/************************************************************************* -|* -|* RscClient::GetClassType() -|* -*************************************************************************/ -RSCCLASS_TYPE RscClient::GetClassType() const -{ - return RSCCLASS_BOOL; -} - -/************************************************************************* -|* -|* RscClient::WriteSrc() -|* -*************************************************************************/ -void RscClient::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont *, sal_uInt32, const char * ) -{ - if( pRefClass->IsSet( rInst, nConstId ) ) - fprintf( fOutput, "TRUE" ); - else - fprintf( fOutput, "FALSE" ); -} - -/************************************************************************* -|* -|* RscClient::Create() -|* -*************************************************************************/ -RSCINST RscClient::Create( RSCINST * pInst, const RSCINST & rDflt, - sal_Bool bOwnClass ) -{ - RSCINST aTmpI, aDfltI; - - if( pInst ){ - aTmpI.pClass = pRefClass; - aTmpI.pData = pInst->pData; - } - - if( !bOwnClass && rDflt.IsInst() ){ - bOwnClass = rDflt.pClass->InHierarchy( this ); - if( bOwnClass ){ - aDfltI.pClass = pRefClass; - aDfltI.pData = rDflt.pData; - } - } - - if( pInst ) - aTmpI = pRefClass->CreateClient( &aTmpI, aDfltI, - bOwnClass, nConstId ); - else - aTmpI = pRefClass->CreateClient( NULL, aDfltI, - bOwnClass, nConstId ); - aTmpI.pClass = this; - - return( aTmpI ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rscmgr.cxx b/rsc/source/res/rscmgr.cxx deleted file mode 100644 index 09f0a539c4..0000000000 --- a/rsc/source/res/rscmgr.cxx +++ /dev/null @@ -1,639 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> -#include <ctype.h> - -// Programmabhaengige Includes. -#include <rscmgr.hxx> -#include <rscdb.hxx> - -/****************** C O D E **********************************************/ -/****************** R s c M g r ******************************************/ -/************************************************************************* -|* -|* RscMgr::RscMgr() -|* -*************************************************************************/ -RscMgr::RscMgr( Atom nId, sal_uInt32 nTypeId, RscTop * pSuperCl ) - : RscClass( nId, nTypeId, pSuperCl ) -{ -} - -/************************************************************************* -|* -|* RscMgr::Size() -|* -*************************************************************************/ -sal_uInt32 RscMgr::Size() -{ - return RscClass::Size() + ALIGNED_SIZE( sizeof( RscMgrInst ) ); -} - -/************************************************************************* -|* -|* RscMgr::Create() -|* -*************************************************************************/ -RSCINST RscMgr::Create( RSCINST * pInst, const RSCINST & rDflt, sal_Bool bOwnClass ){ - RSCINST aInst; - RscMgrInst * pClassData; - - if( !pInst ){ - aInst.pClass = this; - aInst.pData = (CLASS_DATA) rtl_allocateMemory( Size() ); - } - else - aInst = *pInst; - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - RscClass::Create( &aInst, rDflt, bOwnClass ); - - pClassData = (RscMgrInst *)(aInst.pData + RscClass::Size() ); - pClassData->Create(); - - if( bOwnClass ){ - RscMgrInst * pDfltData = (RscMgrInst *)(rDflt.pData + RscClass::Size()); - *pClassData = *pDfltData; - }; - - return( aInst ); -} - -/************************************************************************* -|* -|* RscMgr::Destroy() -|* -*************************************************************************/ -void RscMgr::Destroy( const RSCINST & rInst ){ - RscMgrInst * pClassData; - - RscClass::Destroy( rInst ); - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - pClassData->Destroy(); -} - -/************************************************************************* -|* -|* RscMgr::SetToDefault() -|* -*************************************************************************/ -void RscMgr::SetToDefault( const RSCINST & rInst ) -{ - RscMgrInst * pClassData; - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - pClassData->bDflt = sal_True; - - RscClass::SetToDefault( rInst ); -} - -/************************************************************************* -|* -|* RscMgr::IsDefault() -|* -*************************************************************************/ -sal_Bool RscMgr::IsDefault( const RSCINST & rInst ){ - RscMgrInst * pClassData; - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - if( !pClassData->bDflt ) - return( sal_False ); - - return( RscClass::IsDefault( rInst ) ); -} - -/************************************************************************* -|* -|* RscMgr::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscMgr::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ){ - RscMgrInst * pClassData; - RscMgrInst * pDfltData; - - if( !RscClass::IsValueDefault( rInst, pDef ) ) - return sal_False; - - if( pDef ){ - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - pDfltData = (RscMgrInst *)(pDef + RscClass::Size()); - - if( !pClassData->aRefId.IsId() && !pDfltData->aRefId.IsId() ){ - return sal_True; - } - } - - return sal_False; -} - - -/************************************************************************* -|* -|* RscMgr::WriteSrcHeader() -|* -*************************************************************************/ -void RscMgr::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const RscId & rId, const char * pVarName ) -{ - RscMgrInst * pClassData; - sal_uInt32 i; - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - - fprintf( fOutput, "%s %s", - pHS->getString( rInst.pClass->GetId() ).getStr(), - (rId.GetName()).GetBuffer() ); - if( pClassData->aRefId.IsId() ) - fprintf( fOutput, ",%s", pClassData->aRefId.GetName().GetBuffer() ); - else - { - fprintf( fOutput, "\n" ); - for( i = 0; i < nTab; i++ ) - fputc( '\t', fOutput ); - fprintf( fOutput, "{\n" ); - - rInst.pClass->WriteSrc( rInst, fOutput, pTC, nTab +1, pVarName ); - - RscClass::WriteSrc( rInst, fOutput, pTC, nTab +1, pVarName); - - for( i = 0; i < nTab; i++ ) - fputc( '\t', fOutput ); - fprintf( fOutput, "}" ); - } -} - -/************************************************************************* -|* -|* RscMgr::WriteSrc() -|* -*************************************************************************/ -void RscMgr::WriteSrc( const RSCINST &, FILE *, RscTypCont *, sal_uInt32, - const char * ) -{ -} - -/************************************************************************* -|* -|* RscMgr::WriteRcHeader() -|* -*************************************************************************/ -ERRTYPE RscMgr::WriteRcHeader( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, const RscId &rId, - sal_uInt32 nDeep, sal_Bool bExtra ) -{ - RscMgrInst * pClassData; - ERRTYPE aError; - ObjNode * pObjNode = NULL; - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - - if( pClassData->aRefId.IsId() ) - { - //Erhoehen und abfragen um Endlosrekusion zu vermeiden - nDeep++; - if( nDeep > nRefDeep ) - aError = ERR_REFTODEEP; - else - pObjNode = rInst.pClass->GetRefClass()-> - GetObjNode( pClassData->aRefId ); - if( !pObjNode && pTC ) - { - ByteString aMsg( pHS->getString( rInst.pClass->GetId() ).getStr() ); - aMsg += ' '; - aMsg += pClassData->aRefId.GetName(); - aError = WRN_MGR_REFNOTFOUND; - pTC->pEH->Error( aError, rInst.pClass, rId, aMsg.GetBuffer() ); - } - } - - if( aError.IsOk() ) - { - if( pObjNode ) - { - RSCINST aRefI; - RscTop * pTmpRefClass = rInst.pClass->GetRefClass(); - - aRefI = RSCINST( rInst.pClass, pObjNode->GetRscObj() ); - if( pTmpRefClass == rInst.pClass ) - { - aError = aRefI.pClass->WriteRcHeader( aRefI, rMem, pTC, - rId, nDeep, bExtra ); - } - else - { - RSCINST aRefInst = rInst.pClass->Create( NULL, aRefI ); - aError = aRefI.pClass->WriteRcHeader( aRefInst, rMem, pTC, - rId, nDeep, bExtra ); - pTmpRefClass->Destroy( aRefInst ); - } - } - else - { - sal_uInt32 nOldSize; - sal_uInt32 nLocalSize; - - nOldSize = rMem.IncSize( 16 /*sizeof( RSHEADER_TYPE )*/ ); - - aError = rInst.pClass->WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - if( aError.IsOk() ) - aError = WriteInstRc( rInst, rMem, pTC, nDeep, bExtra ); - nLocalSize = rMem.Size(); - - if( aError.IsOk() ) - { - // RscClass wird uebersprungen - aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep, bExtra ); - }; - - /* - // Definition der Struktur, aus denen die Resource aufgebaut ist - struct RSHEADER_TYPE{ - RESOURCE_TYPE nRT; // Resource Typ - sal_uInt32 nRT; // Resource Typ - sal_uInt32 nGlobOff; // Globaler Offset - sal_uInt32 nLocalOff; // Lokaler Offset - }; - */ - sal_uInt32 nID = rId; - rMem.PutAt( nOldSize, nID ); - rMem.PutAt( nOldSize +4, (sal_uInt32)rInst.pClass->GetTypId() ); - rMem.PutAt( nOldSize +8, (sal_uInt32)(rMem.Size() - nOldSize) ); - rMem.PutAt( nOldSize +12, (sal_uInt32)(nLocalSize - nOldSize) ); - }; - }; - - return( aError ); -} - -/************************************************************************* -|* -|* RscMgr::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscMgr::WriteRc( const RSCINST &, RscWriteRc &, - RscTypCont *, sal_uInt32, sal_Bool ) - -{ - return( ERR_OK ); -} - - -static ByteString MakeSmartName( const ByteString & rDefName ) -{ - ByteString aSmartName; - if( rDefName.Len() ) - { - char * pStr = (char *)rDefName.GetBuffer(); - aSmartName = (char)toupper( *pStr ); - while( *++pStr ) - { - if( '_' == *pStr ) - { - if( *++pStr ) - aSmartName += (char)toupper( *pStr ); - else - break; - } - else - aSmartName += (char)tolower( *pStr ); - } - } - return aSmartName; -} - -static ByteString MakeName( RscTypCont * pTypCon, RscTop * pClass, - const ByteString & rName ) -{ - ByteString aRet; - if( !pTypCon->IsSmart() || isdigit( rName.GetChar(0) ) ) - { - aRet += pHS->getString( pClass->GetId() ).getStr(); - aRet += rName; - } - else - aRet += MakeSmartName( rName ); - return aRet; -} - -/************************************************************************* -|* -|* RscMgr::WriteHxxHeader() -|* -*************************************************************************/ -ERRTYPE RscMgr::WriteHxxHeader( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId &rId ) -{ - RscMgrInst * pClassData; - ERRTYPE aError; - ObjNode * pObjNode = NULL; - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - - if( pClassData->aRefId.IsId() ) - { - pObjNode = rInst.pClass->GetObjNode( pClassData->aRefId ); - if( !pObjNode && pTC ) - { - ByteString aMsg( pHS->getString( rInst.pClass->GetId() ).getStr() ); - aMsg += ' '; - aMsg += pClassData->aRefId.GetName(); - aError = WRN_MGR_REFNOTFOUND; - pTC->pEH->Error( aError, rInst.pClass, rId, aMsg.GetBuffer() ); - } - } - - if( pObjNode ) - { - RSCINST aRefI; - - aRefI = RSCINST( rInst.pClass, pObjNode->GetRscObj() ); - aError = aRefI.pClass->WriteHxxHeader( aRefI, fOutput, pTC, - rId ); - } - else if (pTC) - { - fprintf( fOutput, "class %s", - MakeName( pTC, rInst.pClass, - rId.GetName() ).GetBuffer() ); - fprintf( fOutput, " : public %s", - pHS->getString( rInst.pClass->GetId() ).getStr() ); - fprintf( fOutput, "\n{\nprotected:\n" ); - - aError = RscClass::WriteHxx( rInst, fOutput, pTC, rId ); - - RSCINST aExtraInst = rInst.pClass->GetCopyVar( rInst, nRsc_EXTRADATA ); - if( aExtraInst.IsInst() ) - { - if( aExtraInst.pClass->GetCount( aExtraInst ) ) - fprintf( fOutput, " char * pExtraData;\n" ); - } - if( aError.IsOk() ) - { - fprintf( fOutput, "public:\n " ); - fprintf( fOutput, "%s%s bFreeRes = TRUE )", - MakeName( pTC, rInst.pClass, - rId.GetName() ).GetBuffer(), - (rInst.pClass->aCallParType).GetBuffer() ); - fprintf( fOutput, ";\n};\n\n" ); - } - }; - return aError; -} - -/************************************************************************* -|* -|* RscMgr::WriteHxx() -|* -*************************************************************************/ -ERRTYPE RscMgr::WriteHxx( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rId ) -{ - fprintf( fOutput, " %s", pHS->getString( rInst.pClass->GetId() ).getStr() ); - fprintf( fOutput, " a%s;\n", - MakeName( pTC, rInst.pClass, rId.GetName() ).GetBuffer() ); - - return ERR_OK; -} - -/************************************************************************* -|* -|* RscClass::WriteCxxHeader() -|* -*************************************************************************/ -ERRTYPE RscMgr::WriteCxxHeader( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rId ) -{ - RscMgrInst * pClassData; - ERRTYPE aError; - ObjNode * pObjNode = NULL; - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - - if( pClassData->aRefId.IsId() ) - { - pObjNode = rInst.pClass->GetObjNode( pClassData->aRefId ); - if( !pObjNode && pTC ) - { - ByteString aMsg( pHS->getString( rInst.pClass->GetId() ).getStr() ); - aMsg += ' '; - aMsg += pClassData->aRefId.GetName(); - aError = WRN_MGR_REFNOTFOUND; - pTC->pEH->Error( aError, rInst.pClass, rId, aMsg.GetBuffer() ); - } - } - - if( pObjNode ) - { - RSCINST aRefI; - - aRefI = RSCINST( rInst.pClass, pObjNode->GetRscObj() ); - aError = aRefI.pClass->WriteCxxHeader( aRefI, fOutput, pTC, - rId ); - } - else if (pTC) - { - fprintf( fOutput, "%s::%s", - MakeName( pTC, rInst.pClass, rId.GetName() ).GetBuffer(), - MakeName( pTC, rInst.pClass, rId.GetName() ).GetBuffer() ); - fprintf( fOutput, "%s", (rInst.pClass->aCallParType).GetBuffer() ); - if( GetCount( rInst ) ) - fprintf( fOutput, " bFreeRes" ); - fprintf( fOutput, " )\n : %s", pHS->getString( rInst.pClass->GetId() ).getStr() ); - fprintf( fOutput, "%s", (rInst.pClass->aCallPar1).GetBuffer() ); - fprintf( fOutput, " rResId )" ); - - aError = RscClass::WriteCxx( rInst, fOutput, pTC, rId ); - - fprintf( fOutput, "\n{\n" ); - RSCINST aExtraInst = rInst.pClass->GetCopyVar( rInst, nRsc_EXTRADATA ); - if( aExtraInst.IsInst() ) - { - if( aExtraInst.pClass->GetCount( aExtraInst ) ) - { - fprintf( fOutput, " //read extra data\n" ); - fprintf( fOutput, " pExtraData = new char " - "[ GetRemainSizeRes() ];\n" ); - fprintf( fOutput, " memcpy( pExtraData, " - "GetClassRes(), GetRemainSizeRes() );\n" ); - fprintf( fOutput, " IncrementRes( GetRemainSizeRes() );\n" ); - } - } - - if( GetCount( rInst ) ) - { // Es gibt UnterResourcen - fprintf( fOutput, " if( bFreeRes ) FreeResource();\n" ); - } - else - { - fprintf( fOutput, - " // No subresources, automatic free resource\n" ); - } - fprintf( fOutput, "}\n\n" ); - } - return aError; -} - -/************************************************************************* -|* -|* RscClass::WriteCxx() -|* -*************************************************************************/ -ERRTYPE RscMgr::WriteCxx( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rId ) -{ - fprintf( fOutput, ",\n a%s", - MakeName( pTC, rInst.pClass, rId.GetName() ).GetBuffer() ); - fprintf( fOutput, "%s", (rInst.pClass->aCallPar2).GetBuffer() ); - fprintf( fOutput, " ResId( %s ) )", (rId.GetName()).GetBuffer() ); - - return ERR_OK; -} - -/************************************************************************* -|* -|* RscArray::IsConsistent() -|* -*************************************************************************/ -sal_Bool RscMgr::IsConsistent( const RSCINST & rInst ) -{ - sal_Bool bRet; - RscMgrInst * pClassData; - - bRet = RscClass::IsConsistent( rInst ); - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - if( pClassData->aRefId.IsId() && - ((pClassData->aRefId.GetNumber() < 1) - || (pClassData->aRefId.GetNumber() > 0x7FFF) - || IsToDeep( rInst ).IsError()) ) - { - bRet = sal_False; - } - - return( bRet ); -} - -/************************************************************************* -|* -|* RscMgr::GetRef() -|* -*************************************************************************/ -ERRTYPE RscMgr::GetRef( const RSCINST & rInst, RscId * pRscId ){ - RscMgrInst * pClassData; - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - *pRscId = pClassData->aRefId; - return ERR_OK; -} - -/************************************************************************* -|* -|* RscMgr::IsToDeep() -|* -*************************************************************************/ -ERRTYPE RscMgr::IsToDeep( const RSCINST & rInst, sal_uInt32 nDeep ) -{ - RscMgrInst * pClassData; - RscId aOldId, aId; - ERRTYPE aError; - RSCINST aTmpI = rInst; - ObjNode * pObjNode; - - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - - while( aTmpI.IsInst() && (nDeep < nRefDeep) && aError.IsOk() ) - { - // Referenz holen - aTmpI.pClass->GetRef( aTmpI, &aId ); - // Referenziertes Objekt holen - pObjNode = aTmpI.pClass->GetObjNode( aId ); - // Referenzierte Objekt gefunden ? - if( pObjNode ) - { - aTmpI.pData = pObjNode->GetRscObj(); - nDeep++; - } - else //aTmpI.IsInst() wird sal_False, Schleife beenden - aTmpI.pData = NULL; - } - - if( nDeep >= nRefDeep ) - { - pClassData->aRefId = aOldId; - aError = ERR_REFTODEEP; - } - - return( aError ); -} - -/************************************************************************* -|* -|* RscMgr::SetRef() -|* -*************************************************************************/ -ERRTYPE RscMgr::SetRef( const RSCINST & rInst, const RscId & rRefId ) -{ - RscMgrInst * pClassData; - RscId aOldId, aId; - ERRTYPE aError; - - if( rRefId.IsId() && - ((rRefId.GetNumber() < 1) || (rRefId.GetNumber() > 0x7FFF)) ) - { - aError = ERR_IDRANGE; - } - else - { - pClassData = (RscMgrInst *)(rInst.pData + RscClass::Size()); - aOldId = pClassData->aRefId;// Alten Wert merken - pClassData->aRefId = rRefId;// vorher eintragen, - // sonst Fehler bei rekursion - - - aError = IsToDeep( rInst ); - if( aError.IsOk() ) - pClassData->bDflt = sal_False; - else - pClassData->aRefId = aOldId; - } - - return( aError ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rscrange.cxx b/rsc/source/res/rscrange.cxx deleted file mode 100644 index 32a63541ae..0000000000 --- a/rsc/source/res/rscrange.cxx +++ /dev/null @@ -1,705 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -// Solar Definitionen -#include <tools/solar.h> - -// Programmabh�ngige Includes. -#include <rscrange.hxx> - -/****************** D E F I N E S ****************************************/ -/****************** C O D E **********************************************/ -/****************** R s c R a n g e **************************************/ -/************************************************************************* -|* -|* RscRange::RscRange() -|* -*************************************************************************/ -RscRange::RscRange( Atom nId, sal_uInt32 nTypeId ) - : RscTop( nId, nTypeId ) -{ - nMin = nMax = 0; - nSize = ALIGNED_SIZE( sizeof( RscRangeInst ) ); -} - -/************************************************************************* -|* -|* RscRange::GetClassType() -|* -*************************************************************************/ -RSCCLASS_TYPE RscRange::GetClassType() const -{ - return RSCCLASS_NUMBER; -} - -/************************************************************************* -|* -|* RscRange::SetRange() -|* -*************************************************************************/ -ERRTYPE RscRange::SetRange( sal_Int32 nMinimum, sal_Int32 nMaximum ) -{ - if( nMinimum > nMaximum ) - { - nMin = nMaximum; - nMax = nMinimum; - } - else - { - nMax = nMaximum; - nMin = nMinimum; - }; - - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscRange::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscRange::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ) -{ - if( pDef ) - { - if( ((RscRangeInst*)rInst.pData)->nValue == - ((RscRangeInst*)pDef)->nValue ) - { - return sal_True; - } - } - - return sal_False; -} - -/************************************************************************* -|* -|* RscRange::SetNumber() -|* -*************************************************************************/ -ERRTYPE RscRange::SetNumber( const RSCINST & rInst, sal_Int32 nValue ) -{ - if( nMax < nValue || nMin > nValue ) - return( ERR_RSCRANGE_OUTDEFSET ); - ((RscRangeInst *)rInst.pData)->nValue = (sal_uInt16)( nValue - nMin ); - ((RscRangeInst *)rInst.pData)->bDflt = sal_False; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscRange::GetNumber() -|* -*************************************************************************/ -ERRTYPE RscRange::GetNumber( const RSCINST & rInst, sal_Int32 * pN ) -{ - *pN = ((RscRangeInst *)rInst.pData)->nValue + nMin; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscRange::Create() -|* -*************************************************************************/ -RSCINST RscRange::Create( RSCINST * pInst, const RSCINST & rDflt, - sal_Bool bOwnClass ) -{ - RSCINST aInst; - - if( !pInst ) - { - aInst.pClass = this; - aInst.pData = (CLASS_DATA) - rtl_allocateMemory( sizeof( RscRangeInst ) ); - } - else - aInst = *pInst; - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - if( bOwnClass ) - memmove( aInst.pData, rDflt.pData, sizeof( RscRangeInst ) ); - else - { - if( 0L >= nMin && 0L <= nMax ) - ((RscRangeInst *)aInst.pData)->nValue = (sal_uInt16)(0L - nMin); - else - ((RscRangeInst *)aInst.pData)->nValue = 0; - ((RscRangeInst *)aInst.pData)->bDflt = sal_True; - } - - return( aInst ); -} - -/************************************************************************* -|* -|* RscRange::WriteSrc() -|* -*************************************************************************/ -void RscRange::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont *, sal_uInt32, const char * ) -{ - fprintf( fOutput, "%ld", long( ((RscRangeInst *)rInst.pData)->nValue + nMin ) ); -} - -/************************************************************************* -|* -|* RscRange::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscRange::WriteRc( const RSCINST & rInst, RscWriteRc & aMem, - RscTypCont *, sal_uInt32, sal_Bool ) -{ - if( nMin >= 0 ) - { - sal_uInt16 n; - n = (sal_uInt16)(((RscRangeInst *)rInst.pData)->nValue + nMin); - aMem.Put( n ); - } - else - { - sal_Int16 n; - n = (sal_Int16)(((RscRangeInst *)rInst.pData)->nValue + nMin); - aMem.Put( n ); - } - - return( ERR_OK ); -} - -//======================================================================= -void RscRange::WriteRcAccess -( - FILE * fOutput, - RscTypCont * /*pTC*/, - const char * pName -) -{ - fprintf( fOutput, "\t\tSet%s( ", pName ); - if( nMin >= 0 ) - fprintf( fOutput, "*(sal_uInt32 *)(pResData+nOffset) );\n" ); - else - fprintf( fOutput, "*(sal_Int32 *)(pResData+nOffset) );\n" ); - fprintf( fOutput, "\t\tnOffset += sizeof( sal_uInt32 );\n" ); -} - -/****************** R s c L o n g R a n g e ******************************/ -/************************************************************************* -|* -|* RscLongRange::RscLongRange() -|* -*************************************************************************/ -RscLongRange::RscLongRange( Atom nId, sal_uInt32 nTypeId ) - : RscTop( nId, nTypeId ) -{ - nMin = nMax = 0; - nSize = ALIGNED_SIZE( sizeof( RscLongRangeInst ) ); -} - -/************************************************************************* -|* -|* RscLongRange::GetClassType() -|* -*************************************************************************/ -RSCCLASS_TYPE RscLongRange::GetClassType() const -{ - return RSCCLASS_NUMBER; -} - -/************************************************************************* -|* -|* RscLongRange::SetRange() -|* -*************************************************************************/ -ERRTYPE RscLongRange::SetRange( sal_Int32 nMinimum, sal_Int32 nMaximum ) -{ - if( nMinimum > nMaximum ) - { - nMin = nMaximum; - nMax = nMinimum; - } - else - { - nMax = nMaximum; - nMin = nMinimum; - }; - - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscLongRange::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscLongRange::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ) -{ - if( pDef ) - return 0 == memcmp( &((RscLongRangeInst*)rInst.pData)->nValue, - &((RscLongRangeInst*)pDef)->nValue, - sizeof( sal_Int32 ) ); - - return sal_False; -} - -/************************************************************************* -|* -|* RscLongRange::SetNumber() -|* -*************************************************************************/ -ERRTYPE RscLongRange::SetNumber( const RSCINST & rInst, sal_Int32 nValue ) -{ - if( nMax < nValue || nMin > nValue ) - return( ERR_RSCRANGE_OUTDEFSET ); - void * pData = &((RscLongRangeInst*)rInst.pData)->nValue; - memmove( pData, &nValue, sizeof( sal_Int32 ) ); - ((RscLongRangeInst *)rInst.pData)->bDflt = sal_False; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscLongRange::GetNumber() -|* -*************************************************************************/ -ERRTYPE RscLongRange::GetNumber( const RSCINST & rInst, sal_Int32 * pN ) -{ - memmove( pN, &((RscLongRangeInst*)rInst.pData)->nValue, - sizeof( sal_Int32 ) ); - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscLongRange::Create() -|* -*************************************************************************/ -RSCINST RscLongRange::Create( RSCINST * pInst, const RSCINST & rDflt, - sal_Bool bOwnClass ) -{ - RSCINST aInst; - - if( !pInst ) - { - aInst.pClass = this; - aInst.pData = (CLASS_DATA) - rtl_allocateMemory( sizeof( RscLongRangeInst ) ); - } - else - aInst = *pInst; - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - if( bOwnClass ) - memmove( aInst.pData, rDflt.pData, sizeof( RscLongRangeInst ) ); - else - { - sal_Int32 lDflt; - if( 0L >= nMin && 0L <= nMax ) - lDflt = 0; - else - lDflt = nMin; - void * pData = &((RscLongRangeInst*)aInst.pData)->nValue; - memmove( pData, &lDflt, sizeof( sal_Int32 ) ); - ((RscLongRangeInst *)aInst.pData)->bDflt = sal_True; - } - - return( aInst ); -} - -/************************************************************************* -|* -|* RscLongRange::WriteSrc() -|* -*************************************************************************/ -void RscLongRange::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont *, sal_uInt32, const char * ) -{ - sal_Int32 lVal; - GetNumber( rInst, &lVal ); - fprintf( fOutput, "%d", static_cast<int>(lVal) ); -} - -/************************************************************************* -|* -|* RscLongRange::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscLongRange::WriteRc( const RSCINST & rInst, RscWriteRc & aMem, - RscTypCont *, sal_uInt32, sal_Bool ) -{ - sal_Int32 lVal; - - GetNumber( rInst, &lVal ); - aMem.Put( (sal_Int32)lVal ); - - return( ERR_OK ); -} - -//======================================================================= -void RscLongRange::WriteRcAccess -( - FILE * fOutput, - RscTypCont * /*pTC*/, - const char * pName -) -{ - fprintf( fOutput, "\t\tSet%s( ", pName ); - fprintf( fOutput, "GetLong( pResData+nOffset ) );\n" ); - fprintf( fOutput, "\t\tnOffset += sizeof( sal_Int32 );\n" ); -} - -/****************** R s c L o n g E n u m R a n g e *********************/ -/************************************************************************* -|* RscLongEnumRange::RscLongEnumRange() -|* -|* Beschreibung -*************************************************************************/ -RscLongEnumRange::RscLongEnumRange( Atom nId, sal_uInt32 nTypeId ) - : RscLongRange( nId, nTypeId ) -{ -} - -/************************************************************************* -|* RscLongEnumRange::SetConst() -|* -|* Beschreibung -*************************************************************************/ -ERRTYPE RscLongEnumRange::SetConst( const RSCINST & rInst, Atom /*nConst*/, - sal_Int32 nValue ) -{ - return SetNumber( rInst, nValue ); -} - -/****************** R s c I d R a n g e **********************************/ -/************************************************************************* -|* -|* RscIdRange::RscIdRange() -|* -*************************************************************************/ -RscIdRange::RscIdRange( Atom nId, sal_uInt32 nTypeId ) - : RscTop( nId, nTypeId ) -{ - nSize = ALIGNED_SIZE( sizeof( RscId ) ); - nMin = nMax = 0; -} - -/************************************************************************* -|* -|* RscIdRange::RscIdRange() -|* -*************************************************************************/ -RSCCLASS_TYPE RscIdRange::GetClassType() const -{ - return RSCCLASS_NUMBER; -} - -/************************************************************************* -|* -|* RscIdRange::Create() -|* -*************************************************************************/ -RSCINST RscIdRange::Create( RSCINST * pInst, const RSCINST & rDflt, sal_Bool bOwnClass ){ - RSCINST aInst; - RscId * pClassData; - - if( !pInst ){ - aInst.pClass = this; - aInst.pData = (CLASS_DATA)rtl_allocateMemory( sizeof( RscId ) ); - } - else - aInst = *pInst; - - - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - pClassData = (RscId *)aInst.pData; - - pClassData->Create(); - if( bOwnClass ) - *pClassData = *(RscId *)rDflt.pData; - else{ - *pClassData = RscId(); - if( 0 >= nMin && 0 <= nMax ) - *pClassData = RscId( (sal_Int32)0 ); - else - *pClassData = RscId( nMin ); - //cUnused wird fuer Defaultkennung verwendet - ((RscId *)aInst.pData)->aExp.cUnused = sal_True; - } - - return( aInst ); -} - -/************************************************************************* -|* -|* RscIdRange::Destroy() -|* -*************************************************************************/ -void RscIdRange :: Destroy( const RSCINST & rInst ){ - ((RscId *)rInst.pData)->Destroy(); -} - -/************************************************************************* -|* -|* RscIdRange::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscIdRange::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ){ - if( pDef ){ - if( ((RscId*)rInst.pData)->aExp.IsNumber() - && ((RscId*)pDef)->aExp.IsNumber() ) - { - if( ((RscId*)rInst.pData)->GetNumber() == - ((RscId*)pDef)->GetNumber() ) - { - return sal_True; - } - } - } - - return sal_False; -} - -/************************************************************************* -|* -|* RscIdRange::SetNumber() -|* -*************************************************************************/ -ERRTYPE RscIdRange::SetNumber( const RSCINST & rInst, sal_Int32 nValue ) -{ - if( nMax < nValue || nMin > nValue ) - return( ERR_RSCRANGE_OUTDEFSET ); - - *(RscId *)rInst.pData = RscId( nValue ); - ((RscId *)rInst.pData)->aExp.cUnused = sal_False; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscIdRange::GetNumber() -|* -*************************************************************************/ -ERRTYPE RscIdRange::GetNumber( const RSCINST & rInst, sal_Int32 * plValue ){ - *plValue = ((RscId *)rInst.pData)->GetNumber(); - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscIdRange::SetRef() -|* -*************************************************************************/ -ERRTYPE RscIdRange::SetRef( const RSCINST & rInst, const RscId & rRscId ){ - ERRTYPE aError; - if( rRscId.IsId() ){ - aError = SetNumber( rInst, rRscId ); - if( aError.IsOk() ){ - *(RscId *)rInst.pData = rRscId; - ((RscId *)rInst.pData)->aExp.cUnused = sal_False; - } - } - else - aError = ERR_RSCRANGE_OUTDEFSET; - - return( aError ); -} - -/************************************************************************* -|* -|* RscIdRange::GetRef() -|* -*************************************************************************/ -ERRTYPE RscIdRange::GetRef( const RSCINST & rInst, RscId * pRscId ){ - *pRscId = *(RscId *)rInst.pData; - - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscIdRange::WriteSrc() -|* -*************************************************************************/ -void RscIdRange::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont *, sal_uInt32, const char * ) -{ - fprintf( fOutput, "%s", ((RscId *)rInst.pData)->GetName().GetBuffer() ); -} - -/************************************************************************* -|* -|* RscIdRange::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscIdRange::WriteRc( const RSCINST & rInst, RscWriteRc & aMem, - RscTypCont *, sal_uInt32, sal_Bool ) -{ - sal_Int32 lVal = ((RscId*)rInst.pData)->GetNumber(); - - aMem.Put( (sal_Int32)lVal ); - - return( ERR_OK ); -} - -//======================================================================= -void RscIdRange::WriteRcAccess -( - FILE * fOutput, - RscTypCont * /*pTC*/, - const char * pName -) -{ - fprintf( fOutput, "\t\tSet%s( ", pName ); - fprintf( fOutput, "GetLong( pResData+nOffset ) );\n" ); - fprintf( fOutput, "\t\tnOffset += sizeof( sal_Int32 );\n" ); -} - -/************************************************************************* -|* -|* RscIdRange::IsConsistent() -|* -*************************************************************************/ -sal_Bool RscIdRange::IsConsistent( const RSCINST & rInst ) -{ - long nValue = ((RscId *)rInst.pData)->GetNumber(); - if( (nMax >= nValue) && (nMin <= nValue) ) - return sal_True; - else { - return sal_False; - } -} - -/****************** R s c B o o l ****************************************/ -/************************************************************************* -|* -|* RscBool::RscBool() -|* -*************************************************************************/ -RscBool::RscBool( Atom nId, sal_uInt32 nTypeId ) - : RscRange( nId, nTypeId ) -{ - RscRange::SetRange( 0, 1 ); -} - -/************************************************************************* -|* -|* RscBool::GetClassType() -|* -*************************************************************************/ -RSCCLASS_TYPE RscBool::GetClassType() const -{ - return RSCCLASS_BOOL; -} - -/************************************************************************* -|* -|* RscBool::WriteSrc() -|* -*************************************************************************/ -void RscBool::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont *, sal_uInt32, const char * ) -{ - sal_Int32 l; - - GetNumber( rInst, &l ); - if( l ) - fprintf( fOutput, "TRUE" ); - else - fprintf( fOutput, "FALSE" ); -} - -//======================================================================= -void RscBool::WriteRcAccess -( - FILE * fOutput, - RscTypCont * /*pTC*/, - const char * pName -) -{ - fprintf( fOutput, "\t\tSet%s( ", pName ); - fprintf( fOutput, "(sal_Bool)*(short *)(pResData+nOffset) );\n" ); - fprintf( fOutput, "\t\tnOffset += sizeof( short );\n" ); -} - -/****************** R s c B r e a k R a n g e ****************************/ -/************************************************************************* -|* -|* RscBreakRange::SetNumber() -|* -*************************************************************************/ -RscBreakRange :: RscBreakRange( Atom nId, sal_uInt32 nTypeId ) - : RscRange( nId, nTypeId ) -{ - nOutRange = 0xFFFFFFFF; -} - -/************************************************************************* -|* -|* RscBreakRange::SetNumber() -|* -*************************************************************************/ -ERRTYPE RscBreakRange::SetNumber( const RSCINST & rInst, sal_Int32 nValue ){ - if( nValue == nOutRange ) - return( ERR_RSCRANGE_OUTDEFSET ); - else - return( RscRange::SetNumber( rInst, nValue ) ); -} - -/************************************************************************* -|* -|* RscBreakRange::Create() -|* -*************************************************************************/ -RSCINST RscBreakRange::Create( RSCINST * pInst, const RSCINST & rDflt, - sal_Bool bOwnClass ) -{ - RSCINST aInst; - sal_Int32 l; - - aInst = RscRange::Create( pInst, rDflt, bOwnClass ); - - GetNumber( aInst, &l ); - if( l == nOutRange ) - ((RscRangeInst *)aInst.pData)->nValue++; - - return( aInst ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rscstr.cxx b/rsc/source/res/rscstr.cxx deleted file mode 100644 index 111d4a5b1d..0000000000 --- a/rsc/source/res/rscstr.cxx +++ /dev/null @@ -1,359 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -// Programmabh�ngige Includes. -#include <rscdb.hxx> -#include <rscstr.hxx> - -#include <rtl/textcvt.h> -#include <rtl/textenc.h> - -/****************** C O D E **********************************************/ -/****************** R s c S t r i n g ************************************/ -/************************************************************************* -|* -|* RscString::RscString() -|* -*************************************************************************/ -RscString::RscString( Atom nId, sal_uInt32 nTypeId ) - : RscTop( nId, nTypeId ) -{ - nSize = ALIGNED_SIZE( sizeof( RscStringInst ) ); - pRefClass = NULL; -} - -/************************************************************************* -|* -|* RscString::GetClassType() -|* -*************************************************************************/ -RSCCLASS_TYPE RscString::GetClassType() const -{ - return RSCCLASS_STRING; -} - -/************************************************************************* -|* -|* RscString::SetNumber() -|* -*************************************************************************/ -ERRTYPE RscString::SetString( const RSCINST & rInst, const char * pStr ){ - char * pTmp; - ERRTYPE aError; - - if( aError.IsOk() ){ - ((RscStringInst *)rInst.pData)->bDflt = sal_False; - - pTmp = ((RscStringInst *)rInst.pData)->pStr; - if( pTmp ){ - rtl_freeMemory( pTmp ); - pTmp = NULL; - } - - if( pStr ){ - sal_uInt32 nLen = strlen( pStr ) +1; - pTmp = (char *)rtl_allocateMemory( nLen ); - memcpy( pTmp, pStr, nLen ); - }; - - ((RscStringInst *)rInst.pData)->pStr = pTmp; - } - - return( aError ); -} - -/************************************************************************* -|* -|* RscString::GetString() -|* -*************************************************************************/ -ERRTYPE RscString::GetString( const RSCINST & rInst, char ** ppStr ){ - *ppStr = ((RscStringInst *)rInst.pData)->pStr; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscString::GetRef() -|* -*************************************************************************/ -ERRTYPE RscString::GetRef( const RSCINST & rInst, RscId * pRscId ){ - *pRscId = ((RscStringInst *)rInst.pData)->aRefId; - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscString::SetRef() -|* -*************************************************************************/ -ERRTYPE RscString::SetRef( const RSCINST & rInst, const RscId & rRefId ){ - if( pRefClass ){ - ((RscStringInst *)rInst.pData)->aRefId = rRefId; - ((RscStringInst *)rInst.pData)->bDflt = sal_False; - } - else - return( ERR_REFNOTALLOWED ); - - return ERR_OK; -} - -/************************************************************************* -|* -|* RscString::Create() -|* -*************************************************************************/ -RSCINST RscString::Create( RSCINST * pInst, const RSCINST & rDflt, - sal_Bool bOwnClass ) -{ - RSCINST aInst; - - if( !pInst ){ - aInst.pClass = this; - aInst.pData = (CLASS_DATA) - rtl_allocateMemory( sizeof( RscStringInst ) ); - } - else - aInst = *pInst; - if( !bOwnClass && rDflt.IsInst() ) - bOwnClass = rDflt.pClass->InHierarchy( this ); - - ((RscStringInst *)aInst.pData)->aRefId.Create(); - ((RscStringInst *)aInst.pData)->pStr = NULL; - ((RscStringInst *)aInst.pData)->bDflt = sal_True; - - if( bOwnClass ){ - ((RscStringInst *)aInst.pData)->aRefId = - ((RscStringInst *)rDflt.pData)->aRefId; - SetString( aInst, ((RscStringInst *)rDflt.pData)->pStr ); - ((RscStringInst *)aInst.pData)->bDflt = - ((RscStringInst *)rDflt.pData)->bDflt ; - } - - return( aInst ); -} - -/************************************************************************* -|* -|* RscString::Destroy() -|* -*************************************************************************/ -void RscString::Destroy( const RSCINST & rInst ){ - if( ((RscStringInst *)rInst.pData)->pStr ) - rtl_freeMemory( ((RscStringInst *)rInst.pData)->pStr ); - ((RscStringInst *)rInst.pData)->aRefId.Destroy(); -} - -/************************************************************************* -|* -|* RscString::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscString::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ){ - RscStringInst * pData = (RscStringInst*)rInst.pData; - RscStringInst * pDefData = (RscStringInst*)pDef; - - if( pDef ){ - if( pData->aRefId.IsId() || pDefData->aRefId.IsId() ) - { - if( pData->aRefId.aExp.IsNumber() - && pDefData->aRefId.aExp.IsNumber() ) - { - // Sind die Referenzidentifier gleich - if( pData->aRefId.GetNumber() == pDefData->aRefId.GetNumber() ) - { - return sal_True; - } - } - } - else { - sal_Bool bStrEmpty = sal_False; - sal_Bool bDefStrEmpty = sal_False; - - if( pData->pStr ){ - bStrEmpty = ('\0' == *pData->pStr); - } - else - bStrEmpty = sal_True; - - if( pDefData->pStr ){ - bDefStrEmpty = ('\0' == *pDefData->pStr); - } - else - bDefStrEmpty = sal_True; - - if( !bStrEmpty || !bDefStrEmpty ){ - return sal_False; - } - return sal_True; - } - } - - return sal_False; -} - -/************************************************************************* -|* -|* RscString::WriteSrc() -|* -*************************************************************************/ -void RscString::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont *, sal_uInt32, const char * ) -{ - if ( ((RscStringInst *)rInst.pData)->aRefId.IsId() ) - { - fprintf( fOutput, "%s", - ((RscStringInst *)rInst.pData)->aRefId.GetName().GetBuffer() ); - } - else - { - RscStringInst * pStrI = ((RscStringInst *)rInst.pData); - if( pStrI->pStr ){ - //char * pChangeTab = RscChar::GetChangeTab(); - sal_uInt32 n = 0; - sal_uInt32 nPos, nSlashPos; - - do { - fputc( '\"', fOutput ); - nSlashPos = nPos = 0; - while( pStrI->pStr[ n ] - && (nPos < 72 || nPos - nSlashPos <= 3) ) - { // nach \ mindesten 3 Zeichen wegeb \xa7 - fputc( pStrI->pStr[ n ], fOutput ); - if( pStrI->pStr[ n ] == '\\' ) - nSlashPos = nPos; - n++; - nPos++; - } - - fputc( '\"', fOutput ); - if( pStrI->pStr[ n ] ) //nocht nicht zu ende - fputc( '\n', fOutput ); - } while( pStrI->pStr[ n ] ); - } - else - fprintf( fOutput, "\"\"" ); - } -} - -/************************************************************************* -|* -|* RscString::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscString::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) -{ - ERRTYPE aError; - ObjNode * pObjNode = NULL; - - - if( ((RscStringInst *)rInst.pData)->aRefId.IsId() ){ - RscId aId( ((RscStringInst *)rInst.pData)->aRefId ); - RSCINST aTmpI; - - aTmpI.pClass = pRefClass; - - while( aError.IsOk() && aId.IsId() ){ - //Erhoehen und abfragen um Endlosrekusion zu vermeiden - nDeep++; - if( nDeep > nRefDeep ) - aError = ERR_REFTODEEP; - else - { - pObjNode = pRefClass->GetObjNode( aId ); - if( pObjNode ) - { - aTmpI.pData = pObjNode->GetRscObj(); - aError = pRefClass->GetRef( aTmpI, &aId ); - } - else - { - if( pTC ) - { - ByteString aMsg( pHS->getString( pRefClass->GetId() ).getStr() ); - aMsg += ' '; - aMsg += aId.GetName(); - aError = WRN_STR_REFNOTFOUND; - pTC->pEH->Error( aError, rInst.pClass, - RscId(), aMsg.GetBuffer() ); - } - break; - } - } - } - } - - if( aError.IsOk() ) - { - if( pObjNode ) - { - RSCINST aRefI; - - aRefI = RSCINST( pRefClass, pObjNode->GetRscObj() ); - aError = aRefI.pClass->WriteRc( aRefI, rMem, pTC, nDeep, bExtra ); - } - else - { - if( ((RscStringInst *)rInst.pData)->pStr && pTC ) - { - char * pStr = RscChar::MakeUTF8( ((RscStringInst *)rInst.pData)->pStr, - pTC->GetSourceCharSet() ); - rMem.PutUTF8( pStr ); - rtl_freeMemory( pStr ); - } - else - rMem.PutUTF8( ((RscStringInst *)rInst.pData)->pStr ); - }; - }; - return( aError ); -} - -//================================================================== -void RscString::WriteRcAccess -( - FILE * fOutput, - RscTypCont * /*pTC*/, - const char * pName -) -{ - fprintf( fOutput, "\t\tString aStr( (const char*)(pResData+nOffset) );\n" ); - fprintf( fOutput, "\t\tSet%s( aStr );\n", pName ); - fprintf( fOutput, "\t\tnOffset += GetStringSizeRes( aStr );\n" ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/res/rsctop.cxx b/rsc/source/res/rsctop.cxx deleted file mode 100644 index de1be9d0b1..0000000000 --- a/rsc/source/res/rsctop.cxx +++ /dev/null @@ -1,783 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdio.h> -#include <string.h> - -// Solar Definitionen -#include <tools/solar.h> -#include <rsctop.hxx> -/****************** C O D E **********************************************/ -/****************** R s c T o p ******************************************/ -/************************************************************************* -|* -|* RscTop::RscTop() -|* -*************************************************************************/ -RscTop::RscTop( Atom nId, sal_uInt32 nTypIdent, RscTop * pSuperCl ) - : RefNode( nId ) - , pSuperClass( pSuperCl ) - , nTypId( nTypIdent ) -{ - pRefClass = this; - if( pSuperClass ) - SetCallPar( pSuperClass->aCallPar1, pSuperClass->aCallPar2, - pSuperClass->aCallParType ); -} - -/************************************************************************* -|* -|* RscTop::SetCallPar() -|* -*************************************************************************/ -void RscTop::SetCallPar( const ByteString & rPar1, const ByteString & rPar2, - const ByteString & rParType ) -{ - aCallPar1 = rPar1; - aCallPar2 = rPar2; - aCallParType = rParType; -} - -/************************************************************************* -|* -|* RscTop::GetDefault() -|* -*************************************************************************/ -RSCINST RscTop::GetDefault() -{ - if( !aDfltInst.IsInst() ) - aDfltInst = this->Create( NULL, RSCINST() ); - return aDfltInst; -} - -/************************************************************************* -|* -|* RscTop::Pre_dtor() -|* -*************************************************************************/ -void RscTop :: Pre_dtor(){ - if( aDfltInst.IsInst() ){ - aDfltInst.pClass->Destroy( aDfltInst ); - rtl_freeMemory( aDfltInst.pData ); - aDfltInst = RSCINST(); - }; -} - -/************************************************************************* -|* -|* RscTop::GetConstant() -|* -*************************************************************************/ -Atom RscTop :: GetConstant( sal_uInt32 ){ - return InvalidAtom; -} - -/************************************************************************* -|* -|* RscTop::GetIndexType() -|* -*************************************************************************/ -RscTop * RscTop::GetTypeClass() const -{ - if( pSuperClass ) - return pSuperClass->GetTypeClass(); - else - return NULL; -} - -/************************************************************************* -|* -|* RscTop::Size() -|* -*************************************************************************/ -sal_uInt32 RscTop :: Size() -{ - if( pSuperClass ) - return pSuperClass->Size(); - else - return 0; -} - -/************************************************************************* -|* -|* RscTop::GetRef() -|* -*************************************************************************/ -ERRTYPE RscTop :: GetRef( const RSCINST & rInst, RscId * pRscId ){ - if( pSuperClass ) - return pSuperClass->GetRef( rInst, pRscId ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::InHierarchy() -|* -*************************************************************************/ -sal_Bool RscTop::InHierarchy( RscTop * pClass ){ - if( this == pClass ) - return( sal_True ); - if( pSuperClass ) - return( pSuperClass->InHierarchy( pClass ) ); - return( sal_False ); -} - -/************************************************************************* -|* -|* RscTop::SetVariable() -|* -*************************************************************************/ -ERRTYPE RscTop::SetVariable( Atom nVarName, RscTop * pClass, - RSCINST * pDflt, RSCVAR nVarType, sal_uInt32 nMask, - Atom nDataBaseName ) -{ - if( pSuperClass ) - return pSuperClass-> - SetVariable( nVarName, pClass, pDflt, - nVarType, nMask, nDataBaseName ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::EnumVariable() -|* -*************************************************************************/ -void RscTop::EnumVariables( void * pData, VarEnumCallbackProc pProc ) -{ - if( pSuperClass ) - pSuperClass->EnumVariables( pData, pProc ); -} - -/************************************************************************* -|* -|* RscTop::GetVariable() -|* -*************************************************************************/ -RSCINST RscTop::GetVariable -( - const RSCINST & rInst, - Atom nVarName, - const RSCINST & rInitInst, - sal_Bool bInitDflt, - RscTop * pCreateClass -) -{ - if( pSuperClass ) - return pSuperClass-> - GetVariable( rInst, nVarName, rInitInst, bInitDflt, pCreateClass ); - else - return RSCINST(); -} - -/************************************************************************* -|* -|* RscTop::GetCopyVar() -|* -*************************************************************************/ -RSCINST RscTop::GetCopyVar( const RSCINST & rInst, Atom nVarName ) -{ - if( pSuperClass ) - return pSuperClass-> - GetCopyVar( rInst, nVarName ); - else - return RSCINST(); -} - -/************************************************************************* -|* -|* RscTop::GetTupelVar() -|* -*************************************************************************/ -RSCINST RscTop::GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos, - const RSCINST & rInitInst ) -{ - if( pSuperClass ) - return pSuperClass->GetTupelVar( rInst, nPos, rInitInst ); - else - return RSCINST(); -} - -/************************************************************************* -|* -|* RscTop::GetElement() -|* -*************************************************************************/ -ERRTYPE RscTop::GetElement( const RSCINST & rInst, const RscId & rEleName, - RscTop *pCreateClass, const RSCINST & rCreateInst, - RSCINST * pGetInst ) -{ - if( pSuperClass ) - return pSuperClass-> - GetElement( rInst, rEleName, - pCreateClass, rCreateInst, - pGetInst ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::GetArrayEle() -|* -*************************************************************************/ -ERRTYPE RscTop::GetArrayEle -( - const RSCINST & rInst, - Atom nId, - RscTop * pCreateClass, - RSCINST * pGetInst -) -{ - if( pSuperClass ) - return pSuperClass->GetArrayEle( rInst, nId, pCreateClass, pGetInst ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::GetValueEle() -|* -*************************************************************************/ -ERRTYPE RscTop::GetValueEle -( - const RSCINST & rInst, - sal_Int32 lValue, - RscTop * pCreateClass, - RSCINST * pGetInst -) -{ - if( pSuperClass ) - return pSuperClass->GetValueEle( rInst, lValue, pCreateClass, pGetInst ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::SearchEle() -|* -*************************************************************************/ -RSCINST RscTop::SearchEle( const RSCINST & rInst, const RscId & rEleName, - RscTop * pClass ) -{ - if( pSuperClass ) - return pSuperClass-> - SearchEle( rInst, rEleName, pClass ); - else - return RSCINST(); -} - -/************************************************************************* -|* -|* RscTop::GetPosEle() -|* -*************************************************************************/ -RSCINST RscTop::GetPosEle( const RSCINST & rInst, sal_uInt32 nPos ){ - if( pSuperClass ) - return pSuperClass-> - GetPosEle( rInst, nPos ); - else - return RSCINST(); -} - -/************************************************************************* -|* -|* RscTop::MovePosEle() -|* -*************************************************************************/ -ERRTYPE RscTop::MovePosEle( const RSCINST & rInst, sal_uInt32 nDestPos, - sal_uInt32 nSourcePos ) -{ - if( pSuperClass ) - return pSuperClass-> - MovePosEle( rInst, nDestPos, nSourcePos ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::SetPosRscId() -|* -*************************************************************************/ -ERRTYPE RscTop::SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos, - const RscId & rRscId ) -{ - if( pSuperClass ) - return pSuperClass-> - SetPosRscId( rInst, nPos, rRscId ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::GetInfoEle() -|* -*************************************************************************/ -SUBINFO_STRUCT RscTop::GetInfoEle( const RSCINST & rInst, sal_uInt32 nPos ){ - if( pSuperClass ) - return pSuperClass-> - GetInfoEle( rInst, nPos ); - else - return SUBINFO_STRUCT(); -} - -/************************************************************************* -|* -|* RscTop::GetCount() -|* -*************************************************************************/ -sal_uInt32 RscTop::GetCount( const RSCINST & rInst ){ - if( pSuperClass ) - return pSuperClass->GetCount( rInst ); - else - return 0; -} - -/************************************************************************* -|* -|* RscTop::SetNumber() -|* -*************************************************************************/ -ERRTYPE RscTop::SetNumber( const RSCINST & rInst, sal_Int32 lValue ){ - if( pSuperClass ) - return pSuperClass-> - SetNumber( rInst, lValue ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::SetBool() -|* -*************************************************************************/ -ERRTYPE RscTop::SetBool( const RSCINST & rInst, sal_Bool bValue ){ - if( pSuperClass ) - return pSuperClass-> - SetBool( rInst, bValue ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::SetConst() -|* -*************************************************************************/ -ERRTYPE RscTop::SetConst( const RSCINST & rInst, Atom nId, sal_Int32 nVal ) -{ - if( pSuperClass ) - return pSuperClass->SetConst( rInst, nId, nVal ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::SetNotConst() -|* -*************************************************************************/ -ERRTYPE RscTop::SetNotConst( const RSCINST & rInst, Atom nId ){ - if( pSuperClass ) - return pSuperClass-> - SetNotConst( rInst, nId ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::SetString() -|* -*************************************************************************/ -ERRTYPE RscTop::SetString( const RSCINST & rInst, const char * pStr ){ - if( pSuperClass ) - return pSuperClass-> - SetString( rInst, pStr ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::GetNumber() -|* -*************************************************************************/ -ERRTYPE RscTop::GetNumber( const RSCINST & rInst, sal_Int32 * pN ){ - if( pSuperClass ) - return pSuperClass-> - GetNumber( rInst, pN ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::GetBool() -|* -*************************************************************************/ -ERRTYPE RscTop::GetBool( const RSCINST & rInst, sal_Bool * pB ){ - if( pSuperClass ) - return pSuperClass-> - GetBool( rInst, pB ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::GetCont() -|* -*************************************************************************/ -ERRTYPE RscTop::GetConst( const RSCINST & rInst, Atom * pH ){ - if( pSuperClass ) - return pSuperClass-> - GetConst( rInst, pH ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::GetString() -|* -*************************************************************************/ -ERRTYPE RscTop::GetString( const RSCINST & rInst, char ** ppStr ){ - if( pSuperClass ) - return pSuperClass-> - GetString( rInst, ppStr ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::Create() -|* -*************************************************************************/ -RSCINST RscTop::Create( RSCINST * pInst, const RSCINST & rDefInst, sal_Bool bOwnRange ) -{ - if( pSuperClass ) - return pSuperClass-> - Create( pInst, rDefInst, bOwnRange ); - else{ - if( pInst ) - return *pInst; - return RSCINST(); - } -} - -/************************************************************************* -|* -|* RscTop::Destroy() -|* -*************************************************************************/ -void RscTop::Destroy( const RSCINST & rInst ){ - if( pSuperClass ) - pSuperClass->Destroy( rInst ); -} - -/************************************************************************* -|* -|* RscTop::IsConsistent() -|* -*************************************************************************/ -sal_Bool RscTop::IsConsistent( const RSCINST & rInst ) -{ - if( pSuperClass ) - return pSuperClass->IsConsistent( rInst ); - else - return sal_True; -} - -/************************************************************************* -|* -|* RscTop::SetToDefault() -|* -*************************************************************************/ -void RscTop::SetToDefault( const RSCINST & rInst ) -{ - if( pSuperClass ) - pSuperClass->SetToDefault( rInst ); -} - -/************************************************************************* -|* -|* RscTop::IsDefault() -|* -*************************************************************************/ -sal_Bool RscTop::IsDefault( const RSCINST & rInst ){ - if( pSuperClass ) - return pSuperClass->IsDefault( rInst ); - else - return sal_True; -} - -/************************************************************************* -|* -|* RscTop::IsValueDefault() -|* -*************************************************************************/ -sal_Bool RscTop::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ){ - if( pSuperClass ) - return pSuperClass->IsValueDefault( rInst, pDef ); - else - return sal_True; -} - -/************************************************************************* -|* -|* RscTop::SetDefault() -|* -*************************************************************************/ -void RscTop::SetDefault( const RSCINST & rInst, Atom nVarId ){ - if( pSuperClass ) - pSuperClass->SetDefault( rInst, nVarId ); -} - -/************************************************************************* -|* -|* RscTop::GetDefault() -|* -*************************************************************************/ -RSCINST RscTop::GetDefault( Atom nVarId ){ - if( pSuperClass ) - return pSuperClass-> - GetDefault( nVarId ); - else - return RSCINST(); -} - -/************************************************************************* -|* -|* RscTop::Delete() -|* -*************************************************************************/ -void RscTop::Delete( const RSCINST & rInst, RscTop * pClass, - const RscId & rId ) -{ - if( pSuperClass ) - pSuperClass->Delete( rInst, pClass, rId ); -} - -/************************************************************************* -|* -|* RscTop::DeletePos() -|* -*************************************************************************/ -void RscTop::DeletePos( const RSCINST & rInst, sal_uInt32 nPos ) -{ - if( pSuperClass ) - pSuperClass->DeletePos( rInst, nPos ); -} - -/************************************************************************* -|* -|* RscTop::SetRef() -|* -*************************************************************************/ -ERRTYPE RscTop::SetRef( const RSCINST & rInst, const RscId & rRefId ){ - if( pSuperClass ) - return pSuperClass->SetRef( rInst, rRefId ); - else - return ERR_UNKNOWN_METHOD; -} - -/************************************************************************* -|* -|* RscTop::WriteHxxHeader() -|* -*************************************************************************/ -ERRTYPE RscTop::WriteHxxHeader( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rId ) -{ - if( pSuperClass ) - return pSuperClass->WriteHxxHeader( rInst, fOutput, pTC, rId ); - else - return rInst.pClass->WriteHxx( rInst, fOutput, pTC, rId ); -} - -/************************************************************************* -|* -|* RscTop::WriteHxx() -|* -*************************************************************************/ -ERRTYPE RscTop::WriteHxx( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rId ){ - if( pSuperClass ) - return pSuperClass->WriteHxx( rInst, fOutput, pTC, rId ); - else - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscTop::WriteCxxHeader() -|* -*************************************************************************/ -ERRTYPE RscTop::WriteCxxHeader( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rId ) -{ - if( pSuperClass ) - return pSuperClass->WriteCxxHeader( rInst, fOutput, pTC, rId ); - else - return rInst.pClass->WriteCxx( rInst, fOutput, pTC, rId ); -} - -/************************************************************************* -|* -|* RscTop::WriteCxx() -|* -*************************************************************************/ -ERRTYPE RscTop::WriteCxx( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, const RscId & rId ){ - if( pSuperClass ) - return pSuperClass->WriteCxx( rInst, fOutput, pTC, rId ); - else - return ERR_OK; -} - -/************************************************************************* -|* -|* RscTop::WriteSrcHeader() -|* -*************************************************************************/ -void RscTop::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, - const RscId & rId, const char * pVarName ) -{ - if( pSuperClass ) - pSuperClass->WriteSrcHeader( rInst, fOutput, pTC, nTab, rId, pVarName ); - else - rInst.pClass->WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); -} - -/************************************************************************* -|* -|* RscTop::WriteSrc() -|* -*************************************************************************/ -void RscTop::WriteSrc( const RSCINST & rInst, FILE * fOutput, - RscTypCont * pTC, sal_uInt32 nTab, const char * pVarName ) -{ - if( pSuperClass ) - pSuperClass->WriteSrc( rInst, fOutput, pTC, nTab, pVarName ); -} - -/************************************************************************* -|* -|* RscTop::WriteRcHeader() -|* -*************************************************************************/ -ERRTYPE RscTop::WriteRcHeader( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, const RscId & rId, - sal_uInt32 nDeep, sal_Bool bExtra ) -{ - if( pSuperClass ) - return( pSuperClass-> - WriteRcHeader( rInst, rMem, pTC, rId, nDeep, bExtra ) ); - else - return( rInst.pClass->WriteRc( rInst, rMem, pTC, nDeep, bExtra ) ); -} - -/************************************************************************* -|* -|* RscTop::WriteRc() -|* -*************************************************************************/ -ERRTYPE RscTop::WriteRc( const RSCINST & rInst, RscWriteRc & rMem, - RscTypCont * pTC, sal_uInt32 nDeep, sal_Bool bExtra ) -{ - if( pSuperClass ) - return( pSuperClass-> - WriteRc( rInst, rMem, pTC, nDeep, bExtra ) ); - else - return( ERR_OK ); -} - -/************************************************************************* -|* -|* RscTop::WriteSyntaxHeader() -|* -*************************************************************************/ -void RscTop::WriteSyntaxHeader( FILE * fOutput, RscTypCont * pTC ) -{ - if( GetId() != InvalidAtom ) - { - fprintf( fOutput, "class %s \n{\n", pHS->getString( GetId() ).getStr() ); - WriteSyntax( fOutput, pTC ); - fprintf( fOutput, "};\n\n" ); - } -} - -/************************************************************************* -|* -|* RscTop::WriteSyntax() -|* -*************************************************************************/ -void RscTop::WriteSyntax( FILE * fOutput, RscTypCont * pTC ) -{ - if( pSuperClass ) - pSuperClass->WriteSyntax( fOutput, pTC ); -} - -//======================================================================== -void RscTop::WriteRcAccess -( - FILE * fOutput, - RscTypCont * /*pTC*/, - const char * pName -) -{ - if( GetId() != InvalidAtom ) - { - fprintf( fOutput, "\t\t//%s %s\n", - pHS->getString( GetId() ).getStr(), pName ); - } -} - -//======================================================================== -void RscTop::WriteRcCtor( FILE * fOutput, RscTypCont * pTC ) -{ - if( pSuperClass ) - pSuperClass->WriteRcCtor( fOutput, pTC ); -} - - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rsc/makefile.mk b/rsc/source/rsc/makefile.mk deleted file mode 100644 index 95f7c84c9d..0000000000 --- a/rsc/source/rsc/makefile.mk +++ /dev/null @@ -1,41 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=rsc -TARGET=rscrsc - -# --- Settings ------------------------------------------------------- - -ENABLE_EXCEPTIONS=true - -.INCLUDE : settings.mk - -OBJFILES= $(OBJ)$/rsc.obj - -.INCLUDE : target.mk diff --git a/rsc/source/rsc/rsc.cxx b/rsc/source/rsc/rsc.cxx deleted file mode 100644 index 8b1c047f70..0000000000 --- a/rsc/source/rsc/rsc.cxx +++ /dev/null @@ -1,1274 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************************************************************/ -/* Include File */ -/****************************************************************/ - -#include <stdlib.h> -#include <stdio.h> -#include <fcntl.h> - -#ifdef UNX -#include <unistd.h> -#include <sys/wait.h> -#include <sys/stat.h> -#else -#include <io.h> -#include <process.h> -#include <direct.h> -#endif - -#include <string.h> -#include <ctype.h> -#include <errno.h> - -#include <tools/fsys.hxx> -#include <tools/stream.hxx> -#include <rscerror.h> -#include <rsctop.hxx> -#include <rscdb.hxx> -#include <rscpar.hxx> -#include <rscrsc.hxx> -#include <rschash.hxx> - -#include <osl/file.h> -#include <osl/file.hxx> -#include <osl/process.h> -#include <rtl/strbuf.hxx> -#include <rtl/tencinfo.h> -#include <rtl/textenc.h> - -#include <vector> -#include <algorithm> - - -using ::rtl::OUString; -using ::rtl::OString; -using ::rtl::OStringBuffer; -using ::rtl::OStringToOUString; - -/*************** F o r w a r d s *****************************************/ -/*************** G l o b a l e V a r i a b l e n **********************/ -ByteString* pStdParType = NULL; -ByteString* pStdPar1 = NULL; -ByteString* pStdPar2 = NULL; -ByteString* pWinParType = NULL; -ByteString* pWinPar1 = NULL; -ByteString* pWinPar2 = NULL; -sal_uInt32 nRefDeep = 10; -AtomContainer* pHS = NULL; - - -/*************** R s c C m d L i n e ************************************/ -/************************************************************************* -|* -|* RscCmdLine::Init() -|* -|* Beschreibung Kommandozeile interpretierten -|* -*************************************************************************/ -void RscCmdLine::Init() -{ - nCommands = 0; - nByteOrder = RSC_BIGENDIAN; - - DirEntry aEntry; - aPath = ByteString( aEntry.GetFull(), RTL_TEXTENCODING_ASCII_US ); //Immer im Aktuellen Pfad suchen - m_aOutputFiles.clear(); - m_aOutputFiles.push_back( OutputFile() ); -} - -/************************************************************************* -|* -|* RscCmdLine::RscCmdLine() -|* -|* Beschreibung Kommandozeile interpretierten -|* -*************************************************************************/ -RscCmdLine::RscCmdLine( int argc, char ** argv, RscError * pEH ) -{ - char * pStr; - char ** ppStr; - RscPtrPtr aCmdLine; // Kommandozeile - ByteString aString; - sal_uInt32 i; - sal_Bool bOutputSrsIsSet = sal_False; - - Init(); // Defaults setzen - - pStr = ::ResponseFile( &aCmdLine, argv, argc ); - if( pStr ) - pEH->FatalError( ERR_OPENFILE, RscId(), pStr ); - - /* check the inputted switches */ - ppStr = (char **)aCmdLine.GetBlock(); - ppStr++; - i = 1; - while( ppStr && i < (aCmdLine.GetCount() -1) ) - { -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "CmdLineArg: \"%s\"\n", *ppStr ); -#endif - if( '-' == **ppStr ) - { - if( !rsc_stricmp( (*ppStr) + 1, "h" ) - || !strcmp( (*ppStr) + 1, "?" ) ) - { // Hilfe - nCommands |= HELP_FLAG; - } - else if( !rsc_stricmp( (*ppStr) + 1, "syntax" ) ) - { // Hilfe - nCommands |= PRINTSYNTAX_FLAG; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "RefDeep", 7 ) ) - { // maximale Aufloesungtiefe fuer Referenzen - nRefDeep = ByteString( (*ppStr) +1 + strlen( "RefDeep" ) ).ToInt32(); - } - else if( !rsc_stricmp( (*ppStr) + 1, "p" ) ) - { // kein Preprozessor - nCommands |= NOPREPRO_FLAG; - } - else if( !rsc_stricmp( (*ppStr) + 1, "s" ) ) - { // nicht linken - nCommands |= NOLINK_FLAG; - } - else if( !rsc_stricmp( (*ppStr) + 1, "l" ) ) - { // Linken, keine Syntax und kein Prepro - nCommands |= NOPREPRO_FLAG; - nCommands |= NOSYNTAX_FLAG; - } - else if( !rsc_stricmp( (*ppStr) + 1, "r" ) ) - { // erzeugt kein .res-file - nCommands |= NORESFILE_FLAG; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "sub", 3 ) ) - { - const char* pEqual; - for( pEqual = (*ppStr)+4; *pEqual && *pEqual != '='; ++pEqual ) - ; - if( *pEqual ) - { - const ByteString aSPath( pEqual + 1 ); - DirEntry aSDir( String( aSPath, RTL_TEXTENCODING_ASCII_US ) ); - - m_aReplacements.push_back( std::pair< OString, OString >( OString( (*ppStr)+4, pEqual - *ppStr - 4 ), - ByteString( aSDir.GetFull(), RTL_TEXTENCODING_ASCII_US ) ) ); - } - } - else if( !rsc_stricmp( (*ppStr) + 1, "PreLoad" ) ) - { // Alle Ressourcen mit Preload - nCommands |= PRELOAD_FLAG; - } - else if( !rsc_stricmp( (*ppStr) + 1, "LITTLEENDIAN" ) ) - { // Byte Ordnung beim Schreiben - nByteOrder = RSC_LITTLEENDIAN; - } - else if( !rsc_stricmp( (*ppStr) + 1, "BIGENDIAN" ) ) - { // Byte Ordnung beim Schreiben - nByteOrder = RSC_BIGENDIAN; - } - else if( !rsc_stricmp( (*ppStr) + 1, "SMART" ) ) - { // Byte Ordnung beim Schreiben - nCommands |= SMART_FLAG; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "d", 1 ) ) - { // Symbole definieren - nCommands |= DEFINE_FLAG; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "i", 1 ) ) - { // Include-Pfade definieren - nCommands |= INCLUDE_FLAG; - if( aPath.Len() ) - aPath += ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ); - aPath += (*ppStr) + 2; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fs=", 3 ) ) - { // anderer Name fuer .rc-file - if( m_aOutputFiles.back().aOutputRc.Len() ) - m_aOutputFiles.push_back( OutputFile() ); - m_aOutputFiles.back().aOutputRc = (*ppStr) + 4; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "lip=", 4 ) ) - { // additional language specific include for system dependent files - const ByteString aSysSearchDir( (*ppStr)+5 ); - - // ignore empty -lip= arguments that we get lots of these days - if (aSysSearchDir.Len()) - { - DirEntry aSysDir( String( aSysSearchDir, RTL_TEXTENCODING_ASCII_US ) ); - m_aOutputFiles.back().aSysSearchDirs.push_back( - ByteString( aSysDir.GetFull(), RTL_TEXTENCODING_ASCII_US ) ); - if( m_aOutputFiles.back().aLangSearchPath.Len() ) - m_aOutputFiles.back().aLangSearchPath.Append( - ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ) ); - m_aOutputFiles.back().aLangSearchPath.Append( aSysSearchDir ); - } - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fp=", 3 ) ) - { // anderer Name fuer .srs-file - aOutputSrs = (*ppStr) + 4; - bOutputSrsIsSet = sal_True; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fl=", 3 ) ) - { // Name fuer listing-file - aOutputLst = (*ppStr) + 4; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fh=", 3 ) ) - { // Name fuer .hxx-file - aOutputHxx = (*ppStr) + 4; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fc=", 3 ) ) - { // Name fuer .cxx-file - aOutputCxx = (*ppStr) + 4; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fr=", 3 ) ) - { // Name fuer .cxx-file der Ressource Konstruktoren - aOutputRcCtor = (*ppStr) + 4; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "fx=", 3 ) ) - { // Name fuer .src-file - aOutputSrc = (*ppStr) + 4; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "ft=", 3 ) ) - { // touch file - aTouchFile = (*ppStr) + 4; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "oil=", 4 ) ) - { - aILDir = (*ppStr) + 5; - } - else if( !rsc_stricmp( (*ppStr) + 1, "NoSysResTest" ) ) - { // Bitmap, Pointers, Icons nicht ueberpruefen - nCommands |= NOSYSRESTEST_FLAG; - } - else if( !rsc_stricmp( (*ppStr) + 1, "SrsDefault" ) ) - { // Bitmap, Pointers, Icons nicht ueberpruefen - nCommands |= SRSDEFAULT_FLAG; - } - else if( !rsc_strnicmp( (*ppStr) + 1, "CHARSET_", 8 ) ) - { - // ignore (was an option once) - } - else if( !rsc_stricmp( (*ppStr) + 1, "lg" ) ) - { - m_aOutputFiles.back().aLangName = ByteString(); - } - else if( !rsc_strnicmp( (*ppStr) + 1, "lg", 2 ) ) - { - if( m_aOutputFiles.back().aLangName.Len() ) - m_aOutputFiles.push_back( OutputFile() ); - m_aOutputFiles.back().aLangName = ByteString( (*ppStr)+3 ); - } - else - pEH->FatalError( ERR_UNKNOWNSW, RscId(), *ppStr ); - } - else - { - // Eingabedatei - aInputList.push_back( new ByteString( *ppStr ) ); - } - ppStr++; - i++; - } - - if( nCommands & HELP_FLAG ) - pEH->FatalError( ERR_USAGE, RscId() ); - // was an inputted file specified - else if( !aInputList.empty() ) - { - ::std::list<OutputFile>::iterator it; - for( it = m_aOutputFiles.begin(); it != m_aOutputFiles.end(); ++it ) - { - if( ! it->aOutputRc.Len() ) - it->aOutputRc = ::OutputFile( *aInputList.front(), "rc" ); - } - if( ! bOutputSrsIsSet ) - aOutputSrs = ::OutputFile( *aInputList.front(), "srs" ); - } - else if( !(nCommands & PRINTSYNTAX_FLAG) ) - pEH->FatalError( ERR_NOINPUT, RscId() ); -} - -/************************************************************************* -|* -|* RscCmdLine::~RscCmdLine() -|* -|* Beschreibung dtor -|* -*************************************************************************/ -RscCmdLine::~RscCmdLine() -{ - for ( size_t i = 0, n = aInputList.size(); i < n; ++i ) - delete aInputList[ i ]; - aInputList.clear(); -} - -/************************************************************************* -|* -|* RscCmdLine::substitutePaths() -|* -*************************************************************************/ - -OString RscCmdLine::substitutePaths( const OString& rIn ) -{ - // prepare return value - OStringBuffer aRet( 256 ); - std::list< std::pair< OString, OString > >::const_iterator last_match = m_aReplacements.end(); - - // search for longest replacement match - for( std::list< std::pair< OString, OString > >::const_iterator repl = m_aReplacements.begin(); repl != m_aReplacements.end(); ++repl ) - { - if( rIn.compareTo( repl->second, repl->second.getLength() ) == 0 ) // path matches - { - if( last_match == m_aReplacements.end() || last_match->second.getLength() < repl->second.getLength() ) - last_match = repl; - } - } - - // copy replacement found and rest of rIn - sal_Int32 nIndex = 0; - if( last_match != m_aReplacements.end() ) - { - aRet.append( "%" ); - aRet.append( last_match->first ); - aRet.append( "%" ); - nIndex = last_match->second.getLength(); - } - aRet.append( rIn.copy( nIndex ) ); - - return aRet.makeStringAndClear(); -} - -/*************** R s c C o m p i l e r **********************************/ -/****************************************************************/ -/* */ -/* RscCompiler :: RscCompiler(int argc, char **argv) */ -/* */ -/* Parameters : argc - number of parameters on command line */ -/* argv - arry of pointers to input parameters */ -/* */ -/* Description : main calling routine. Calls functions to */ -/* check and assign the input parameters. It then builds the */ -/* command line to call the Glockenspiel preprocessor */ -/****************************************************************/ - -RscCompiler::RscCompiler( RscCmdLine * pLine, RscTypCont * pTypCont ) -{ - fListing = NULL; - fExitFile = NULL; - - //Kommandozeile setzen, TypContainer setzen - pCL = pLine; - pTC = pTypCont; - - if( pCL->aOutputLst.Len() ) - { - if ( NULL == (fListing = fopen( pCL->aOutputLst.GetBuffer(), "w" )) ) - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), pCL->aOutputLst.GetBuffer() ); - pTC->pEH->SetListFile( fListing ); - } -} - -/************************************************************************* -|* -|* RscCompiler :: RscCompiler() -|* -*************************************************************************/ -RscCompiler::~RscCompiler() -{ - pTC->pEH->SetListFile( NULL ); - - if( fListing ) - fclose( fListing ); - - if( fExitFile ) - fclose( fExitFile ); - if( aTmpOutputHxx.Len() ) - unlink( aTmpOutputHxx.GetBuffer() ); - if( aTmpOutputCxx.Len() ) - unlink( aTmpOutputCxx.GetBuffer() ); - if( aTmpOutputRcCtor.Len() ) - unlink( aTmpOutputRcCtor.GetBuffer() ); - if( aTmpOutputSrc.Len() ) - unlink( aTmpOutputSrc.GetBuffer() ); -} - -/************************************************************************* -|* -|* RscCompiler::Start() -|* -|* Beschreibung Datei in Kommandozeile aendern -|* -*************************************************************************/ -ERRTYPE RscCompiler::Start() -{ - ERRTYPE aError; - RscFile* pFName; - - if( PRINTSYNTAX_FLAG & pCL->nCommands ) - { - pTC->WriteSyntax( stdout ); - printf( "khg\n" ); - return ERR_OK; - } - - // Kein Parameter, dann Hilfe - if( pCL->aInputList.empty() ) - pTC->pEH->FatalError( ERR_NOINPUT, RscId() ); - - for( size_t i = 0, n = pCL->aInputList.size(); i < n; ++i ) - pTC->aFileTab.NewCodeFile( *pCL->aInputList[ i ] ); - - if( !(pCL->nCommands & NOSYNTAX_FLAG) ) - { - if( pCL->nCommands & NOPREPRO_FLAG ) - { - - pTC->pEH->SetListFile( NULL ); - - pFName = pTC->aFileTab.First(); - while( pFName && aError.IsOk() ) - { - if( !pFName->bScanned && !pFName->IsIncFile() ) - { - aError = IncludeParser( - pTC->aFileTab.GetIndex( pFName ) - ); - // Currentzeiger richtig setzen - pTC->aFileTab.Seek( pFName ); - }; - pFName = pTC->aFileTab.Next(); - }; - - pTC->pEH->SetListFile( fListing ); - } - }; - - if ( pTC->pEH->GetVerbosity() >= RscVerbosityVerbose ) - { - pTC->pEH->StdOut( "Files: " ); - pFName = pTC->aFileTab.First(); - while( pFName ) - { - pTC->pEH->StdOut( pFName->aFileName.GetBuffer() ); - pTC->pEH->StdOut( " " ); - pFName = pTC->aFileTab.Next(); - }; - pTC->pEH->StdOut( "\n" ); - } - - if( aError.IsOk() ) - aError = Link(); - - if( aError.IsOk() ) - EndCompile(); - - if( aError.IsError() ) - pTC->pEH->Error( ERR_ERROR, NULL, RscId() ); - - return( aError ); -} -/************************************************************************* -|* -|* RscCmdLine::EndCompile() -|* -|* Beschreibung Datei in Kommandozeile aendern -|* -*************************************************************************/ -void RscCompiler::EndCompile() -{ - if( pCL->aOutputSrs.Len() && (pCL->nCommands & NOLINK_FLAG) ) - { - pTC->pEH->StdOut( "Writing file ", RscVerbosityVerbose ); - pTC->pEH->StdOut( pCL->aOutputSrs.GetBuffer(), RscVerbosityVerbose ); - pTC->pEH->StdOut( ".\n", RscVerbosityVerbose ); - - // kopiere von TMP auf richtigen Namen - unlink( pCL->aOutputSrs.GetBuffer() ); // Zieldatei loeschen - if( !(pCL->nCommands & NOSYNTAX_FLAG) ) - { - FILE * foutput; - RscFile * pFN; - - if( NULL == (foutput = fopen( pCL->aOutputSrs.GetBuffer(), "w" )) ) - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), pCL->aOutputSrs.GetBuffer() ); - else - { - // Schreibe Datei - pFN = pTC->aFileTab.First(); - while( pFN ) - { - if( !pFN->IsIncFile() ) - { - pTC->WriteSrc( foutput, NOFILE_INDEX, - RTL_TEXTENCODING_UNICODE, sal_False ); - break; // ?T 281091MM nur eine Src-Datei - } - }; - - fclose( foutput ); - }; - }; - } - - if ( aTmpOutputHxx.Len() ) - { - pTC->pEH->StdOut( "Writing file ", RscVerbosityVerbose ); - pTC->pEH->StdOut( pCL->aOutputHxx.GetBuffer(), RscVerbosityVerbose ); - pTC->pEH->StdOut( ".\n", RscVerbosityVerbose ); - - // kopiere von TMP auf richtigen Namen - unlink( pCL->aOutputHxx.GetBuffer() ); // Zieldatei loeschen - Append( pCL->aOutputHxx, aTmpOutputHxx ); - unlink( aTmpOutputHxx.GetBuffer() );// TempDatei loeschen - aTmpOutputHxx = ByteString(); - } - - if( aTmpOutputCxx.Len() ) - { - pTC->pEH->StdOut( "Writing file ", RscVerbosityVerbose ); - pTC->pEH->StdOut( pCL->aOutputCxx.GetBuffer(), RscVerbosityVerbose ); - pTC->pEH->StdOut( ".\n", RscVerbosityVerbose ); - - // kopiere von TMP auf richtigen Namen - unlink( pCL->aOutputCxx.GetBuffer() ); // Zieldatei loeschen - Append( pCL->aOutputCxx, aTmpOutputCxx ); - unlink( aTmpOutputCxx.GetBuffer() );// TempDatei loeschen - aTmpOutputCxx = ByteString(); - } - - if( aTmpOutputRcCtor.Len() ) - { - pTC->pEH->StdOut( "Writing file ", RscVerbosityVerbose ); - pTC->pEH->StdOut( pCL->aOutputRcCtor.GetBuffer(), RscVerbosityVerbose ); - pTC->pEH->StdOut( ".\n", RscVerbosityVerbose ); - - // kopiere von TMP auf richtigen Namen - unlink( pCL->aOutputRcCtor.GetBuffer() ); // Zieldatei loeschen - Append( pCL->aOutputRcCtor, aTmpOutputRcCtor ); - unlink( aTmpOutputRcCtor.GetBuffer() );// TempDatei loeschen - aTmpOutputRcCtor = ByteString(); - } - - if( aTmpOutputSrc.Len() ) - { - // kopiere von TMP auf richtigen Namen - unlink( pCL->aOutputSrc.GetBuffer() ); // Zieldatei loeschen - Append( pCL->aOutputSrc, aTmpOutputSrc ); - unlink( aTmpOutputSrc.GetBuffer() );// TempDatei loeschen - aTmpOutputSrc = ByteString(); - } - - if( pCL->aTouchFile.Len() ) - { - FILE* fp = fopen( pCL->aTouchFile.GetBuffer(), "w" ); - if( fp ) - { - fprintf( fp, "Done\n" ); - fclose( fp ); - } - else - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), pCL->aTouchFile.GetBuffer() ); - } -} - -/************************************************************************* -|* -|* RscCompiler::IncludeParser() -|* -*************************************************************************/ -ERRTYPE RscCompiler :: IncludeParser( sal_uLong lFileKey ) -{ - FILE * finput; - RscFile * pFName; - ERRTYPE aError; - - pFName = pTC->aFileTab.Get( lFileKey ); - if( !pFName ) - aError = ERR_ERROR; - else if( !pFName->bScanned ) - { - finput = fopen( pFName->aPathName.GetBuffer(), "r" ); - if( !finput ) - { - aError = ERR_OPENFILE; - pTC->pEH->Error( aError, NULL, RscId(), - pFName->aPathName.GetBuffer() ); - } - else - { - RscFile * pFNTmp; - ByteString aPathName; - RscDepend * pDep; - RscFileInst aFileInst( pTC, lFileKey, lFileKey, finput ); - - pFName->bScanned = sal_True; - ::IncludeParser( &aFileInst ); - fclose( finput ); - - // Include-Pfad durchsuchen - for ( size_t i = 0, n = pFName->aDepLst.size(); i < n; ++i ) - { - pDep = pFName->aDepLst[ i ]; - pFNTmp = pTC->aFileTab.GetFile( pDep->GetFileKey() ); - } - - for ( size_t i = 0, n = pFName->aDepLst.size(); i < n; ++i ) - { - pDep = pFName->aDepLst[ i ]; - pFNTmp = pTC->aFileTab.GetFile( pDep->GetFileKey() ); - // Kein Pfad und Include Datei - if( pFNTmp && !pFNTmp->bLoaded ) - { - UniString aUniFileName( pFNTmp->aFileName, RTL_TEXTENCODING_ASCII_US ); - DirEntry aFullName( aUniFileName ); - if ( aFullName.Find( UniString( pCL->aPath, RTL_TEXTENCODING_ASCII_US ) ) ) - pFNTmp->aPathName = ByteString( aFullName.GetFull(), RTL_TEXTENCODING_ASCII_US ); - else - aError = ERR_OPENFILE; - } - }; - }; - }; - - return aError; -} - -/************************************************************************* -|* -|* RscCompiler :: ParseOneFile() -|* -*************************************************************************/ -ERRTYPE RscCompiler :: ParseOneFile( sal_uLong lFileKey, - const RscCmdLine::OutputFile* pOutputFile, - const WriteRcContext* pContext ) -{ - FILE * finput = NULL; - ERRTYPE aError; - RscFile * pFName; - - pFName = pTC->aFileTab.Get( lFileKey ); - if( !pFName ) - aError = ERR_ERROR; - else if( !pFName->bLoaded ) - { - RscDepend * pDep; - - //Include-Dateien vorher lesen - pFName->bLoaded = sal_True; //Endlos Rekursion vermeiden - - for ( size_t i = 0; i < pFName->aDepLst.size() && aError.IsOk(); ++i ) - { - pDep = pFName->aDepLst[ i ]; - aError = ParseOneFile( pDep->GetFileKey(), pOutputFile, pContext ); - } - - if( aError.IsError() ) - pFName->bLoaded = sal_False; //bei Fehler nicht geladenen - else - { - String aTmpName( ::GetTmpFileName(), RTL_TEXTENCODING_ASCII_US ); - DirEntry aTmpPath( aTmpName ), aSrsPath( String( pFName->aPathName.GetBuffer(), RTL_TEXTENCODING_ASCII_US ) ); - - aTmpPath.ToAbs(); - aSrsPath.ToAbs(); - - if( pContext && pOutputFile ) - PreprocessSrsFile( *pOutputFile, *pContext, aSrsPath, aTmpPath ); - else - aSrsPath.CopyTo( aTmpPath, FSYS_ACTION_COPYFILE ); - - ByteString aParseFile( aTmpPath.GetFull(), RTL_TEXTENCODING_ASCII_US ); - finput = fopen( aParseFile.GetBuffer(), "r" ); - - if( !finput ) - { - pTC->pEH->Error( ERR_OPENFILE, NULL, RscId(), pFName->aPathName.GetBuffer() ); - aError = ERR_OPENFILE; - } - else - { - RscFileInst aFileInst( pTC, lFileKey, lFileKey, finput ); - - pTC->pEH->StdOut( "reading file ", RscVerbosityVerbose ); - pTC->pEH->StdOut( aParseFile.GetBuffer(), RscVerbosityVerbose ); - pTC->pEH->StdOut( " ", RscVerbosityVerbose ); - - aError = ::parser( &aFileInst ); - if( aError.IsError() ) - pTC->Delete( lFileKey );//Resourceobjekte loeschen - pTC->pEH->StdOut( "\n", RscVerbosityVerbose ); - fclose( finput ); - }; - - aTmpPath.Kill(); - }; - }; - - return( aError ); -} - -/************************************************************************* -|* -|* RscCompiler :: Link() -|* -*************************************************************************/ - -namespace -{ - using namespace ::osl; - class RscIoError { }; - static inline OUString lcl_getAbsoluteUrl(const OUString& i_sBaseUrl, const OString& i_sPath) - { - OUString sRelUrl, sAbsUrl; - if(FileBase::getFileURLFromSystemPath(OStringToOUString(i_sPath, RTL_TEXTENCODING_MS_1252), sRelUrl) != FileBase::E_None) - throw RscIoError(); - if(FileBase::getAbsoluteFileURL(i_sBaseUrl, sRelUrl, sAbsUrl) != FileBase::E_None) - throw RscIoError(); - return sAbsUrl; - }; - static inline OString lcl_getSystemPath(const OUString& i_sUrl) - { - OUString sSys; - if(FileBase::getSystemPathFromFileURL(i_sUrl, sSys) != FileBase::E_None) - throw RscIoError(); - OSL_TRACE("temporary file: %s", OUStringToOString(sSys, RTL_TEXTENCODING_UTF8).getStr()); - return OUStringToOString(sSys, RTL_TEXTENCODING_MS_1252); - }; - static inline OString lcl_getTempFile(OUString& sTempDirUrl) - { - // get a temp file name for the rc file - OUString sTempUrl; - if(FileBase::createTempFile(&sTempDirUrl, NULL, &sTempUrl) != FileBase::E_None) - throw RscIoError(); - OSL_TRACE("temporary url: %s", OUStringToOString(sTempUrl, RTL_TEXTENCODING_UTF8).getStr()); - return lcl_getSystemPath(sTempUrl); - }; -} - -ERRTYPE RscCompiler::Link() -{ - FILE * foutput; - ERRTYPE aError; - RscFile* pFName; - - if( !(pCL->nCommands & NOLINK_FLAG) ) - { - ::std::list<RscCmdLine::OutputFile>::const_iterator it; - - for( it = pCL->m_aOutputFiles.begin(); it != pCL->m_aOutputFiles.end(); ++it ) - { - // cleanup nodes - for( pFName = pTC->aFileTab.First(); pFName && aError.IsOk(); pFName = pTC->aFileTab.Next() ) - { - if( !pFName->IsIncFile() ) - { - pTC->Delete( pTC->aFileTab.GetIndex( pFName ) ); - pTC->aFileTab.Seek( pFName ); - pFName->bLoaded = sal_False; - } - } - - - // get two temp file urls - OString aRcTmp, aSysListTmp, aSysList; - try - { - OUString sPwdUrl; - osl_getProcessWorkingDir( &sPwdUrl.pData ); - OUString sRcUrl = lcl_getAbsoluteUrl(sPwdUrl, it->aOutputRc); - // TempDir is either the directory where the rc file is located or pwd - OUString sTempDirUrl = sRcUrl.copy(0,sRcUrl.lastIndexOf('/')); - OSL_TRACE("rc directory URL: %s", OUStringToOString(sTempDirUrl, RTL_TEXTENCODING_UTF8).getStr()); - - aRcTmp = lcl_getTempFile(sTempDirUrl); - OSL_TRACE("temporary rc file: %s", aRcTmp.getStr()); - - OUString sOilDirUrl; - if(pCL->aILDir.Len()) - sOilDirUrl = lcl_getAbsoluteUrl(sPwdUrl, pCL->aILDir); - else - sOilDirUrl = sTempDirUrl; - OSL_TRACE("ilst directory URL: %s", OUStringToOString(sOilDirUrl, RTL_TEXTENCODING_UTF8).getStr()); - - aSysListTmp = lcl_getTempFile(sOilDirUrl); - OSL_TRACE("temporary ilst file: %s", aSysListTmp.getStr()); - - OUString sIlstUrl, sIlstSys; - sIlstUrl = sRcUrl.copy(sRcUrl.lastIndexOf('/')+1); - sIlstUrl = sIlstUrl.copy(0,sIlstUrl.lastIndexOf('.')); - sIlstUrl += OUString(RTL_CONSTASCII_USTRINGPARAM(".ilst")); - sIlstUrl = lcl_getAbsoluteUrl(sOilDirUrl, OUStringToOString(sIlstUrl, RTL_TEXTENCODING_UTF8)); - - aSysList = lcl_getSystemPath(sIlstUrl); - OSL_TRACE("ilst file: %s", aSysList.getStr()); - } - catch (RscIoError&) - { - OString sMsg("Error with paths:\n"); - sMsg += "temporary rc file: " + aRcTmp + "\n"; - sMsg += "temporary ilst file: " + aSysListTmp + "\n"; - sMsg += "ilst file: " + aSysList + "\n"; - pTC->pEH->FatalError(ERR_OPENFILE, RscId(), sMsg); - } - if ( NULL == (fExitFile = foutput = fopen( aRcTmp.getStr(), "wb" )) ) - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), aRcTmp.getStr() ); - - // Schreibe Datei - sal_Char cSearchDelim = ByteString( DirEntry::GetSearchDelimiter(), RTL_TEXTENCODING_ASCII_US ).GetChar( 0 ); - sal_Char cAccessDelim = ByteString( DirEntry::GetAccessDelimiter(), RTL_TEXTENCODING_ASCII_US ).GetChar( 0 ); - pTC->ChangeLanguage( it->aLangName ); - pTC->SetSourceCharSet( RTL_TEXTENCODING_UTF8 ); - pTC->ClearSysNames(); - ByteString aSysSearchPath( it->aLangSearchPath ); - xub_StrLen nIndex = 0; - ByteString aSearchPath = pTC->GetSearchPath(); - while( nIndex != STRING_NOTFOUND ) - { - ByteString aToken = aSearchPath.GetToken( 0, cSearchDelim, nIndex ); - if( aSysSearchPath.Len() ) - aSysSearchPath.Append( cSearchDelim ); - aSysSearchPath.Append( aToken ); - aSysSearchPath.Append( cAccessDelim ); - aSysSearchPath.Append( it->aLangName ); - aSysSearchPath.Append( cSearchDelim ); - aSysSearchPath.Append( aToken ); - } - OSL_TRACE( "setting search path for language %s: %s\n", it->aLangName.GetBuffer(), aSysSearchPath.GetBuffer() ); - pTC->SetSysSearchPath( aSysSearchPath ); - - WriteRcContext aContext; - - aContext.fOutput = foutput; - aContext.aOutputRc = it->aOutputRc; - aContext.aOutputSysList = aSysListTmp; - aContext.pCmdLine = pCL; - - // create empty sys list - if( aContext.aOutputSysList.getLength() ) - { - FILE* pSysListFile = fopen( aContext.aOutputSysList.getStr(), "wb" ); - - if( !pSysListFile ) - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), aContext.aOutputSysList.getStr() ); - else - fclose( pSysListFile ); - } - - // parse files for specific language - for( pFName = pTC->aFileTab.First(); pFName && aError.IsOk(); pFName = pTC->aFileTab.Next() ) - { - if( !pFName->IsIncFile() ) - { - aError = ParseOneFile( pTC->aFileTab.GetIndex( pFName ), &*it, &aContext ); - pTC->aFileTab.Seek( pFName ); - } - }; - - aError = pTC->WriteRc( aContext ); - - fclose( foutput ); - fExitFile = NULL; - unlink( it->aOutputRc.GetBuffer() ); - if( rename( aRcTmp.getStr(), it->aOutputRc.GetBuffer() ) ) - { - OStringBuffer aBuf; - aBuf.append( aRcTmp ); - aBuf.append( " -> " ); - aBuf.append( it->aOutputRc ); - pTC->pEH->FatalError( ERR_RENAMEFILE, RscId(), aBuf.getStr() ); - } - else - { -#ifdef UNX - chmod( it->aOutputRc.GetBuffer(), S_IRWXU | S_IRWXG | S_IROTH ); -#endif - } - - unlink( aSysList.getStr() ); - if( rename( aSysListTmp.getStr(), aSysList.getStr() ) ) - { - OStringBuffer aBuf; - aBuf.append( aSysListTmp ); - aBuf.append( " -> " ); - aBuf.append( aSysList ); - pTC->pEH->FatalError( ERR_RENAMEFILE, RscId(), aBuf.getStr() ); - } - else - { -#ifdef UNX - chmod( aSysList.getStr(), S_IRWXU | S_IRWXG | S_IROTH ); -#endif - } - } - } - else - { - // parse files - for( pFName = pTC->aFileTab.First(); pFName && aError.IsOk(); pFName = pTC->aFileTab.Next() ) - { - if( !pFName->IsIncFile() ) - { - aError = ParseOneFile( pTC->aFileTab.GetIndex( pFName ), NULL, NULL ); - pTC->aFileTab.Seek( pFName ); - } - }; - } - - // hxx-Datei schreiben - if( pCL->aOutputHxx.Len() && aError.IsOk() ) - { - aTmpOutputHxx = ::GetTmpFileName(); - if ( NULL == (fExitFile = foutput = fopen( aTmpOutputHxx.GetBuffer(), "w" )) ) - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), aTmpOutputHxx.GetBuffer() ); - - pTC->pEH->StdOut( "Generating .hxx file\n" ); - - // Schreibe Datei - aError = pTC->WriteHxx( foutput, NOFILE_INDEX ); - - fclose( foutput ); - fExitFile = NULL; - } - - // cxx-Datei schreiben - if( pCL->aOutputCxx.Len() && aError.IsOk() ) - { - aTmpOutputCxx = ::GetTmpFileName(); - if ( NULL == (fExitFile = foutput = fopen( aTmpOutputCxx.GetBuffer(), "w" )) ) - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), aTmpOutputCxx.GetBuffer() ); - - pTC->pEH->StdOut( "Generating .cxx file\n" ); - - ByteString aHxx = pCL->aOutputHxx; - if( !aHxx.Len() ) - { - UniString aUniOutputCxx( pCL->aOutputCxx, RTL_TEXTENCODING_ASCII_US ); - aHxx = ByteString( DirEntry( aUniOutputCxx ).GetBase(), RTL_TEXTENCODING_ASCII_US ); - aHxx += ".hxx"; - } - - // Schreibe Datei - aError = pTC->WriteCxx( foutput, NOFILE_INDEX, aHxx ); - - fclose( foutput ); - fExitFile = NULL; - } - - // RcCtor-Datei schreiben - if( pCL->aOutputRcCtor.Len() && aError.IsOk() ) - { - aTmpOutputRcCtor = ::GetTmpFileName(); - if ( NULL == (fExitFile = foutput = fopen( aTmpOutputRcCtor.GetBuffer(), "w" )) ) - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), aTmpOutputRcCtor.GetBuffer() ); - - pTC->pEH->StdOut( "Generating .cxx ressource constructor file\n" ); - - // Schreibe Datei - pTC->WriteRcCtor( foutput ); - - fclose( foutput ); - fExitFile = NULL; - } - - // src-Datei schreiben - if( pCL->aOutputSrc.Len() && aError.IsOk() ) - { - aTmpOutputSrc = ::GetTmpFileName(); - if ( NULL == (fExitFile = foutput = fopen( aTmpOutputSrc.GetBuffer(), "w" )) ) - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), aTmpOutputSrc.GetBuffer() ); - - // Schreibe Datei - pTC->WriteSrc( foutput, NOFILE_INDEX, RTL_TEXTENCODING_UNICODE ); - - fclose( foutput ); - fExitFile = NULL; - }; - - return( aError ); -} - -/********************************************************************/ -/* */ -/* Function : Append( ) */ -/* */ -/* Parameters : psw - pointer to a preprocessor switch */ -/* */ -/* Description : appends text files */ -/********************************************************************/ -void RscCompiler::Append( const ByteString& rOutputSrs, - const ByteString& rTmpFile ) -{ - if( !::Append( rOutputSrs, rTmpFile ) ) - { - ByteString aTemp = rOutputSrs; - aTemp += " or "; - aTemp += rTmpFile; - pTC->pEH->FatalError( ERR_OPENFILE, RscId(), aTemp.GetBuffer() ); - } -} - -/************************************************************************* -|* -|* GetImageFilePath() -|* -|*************************************************************************/ - -bool RscCompiler::GetImageFilePath( const RscCmdLine::OutputFile& rOutputFile, - const WriteRcContext& rContext, - const ByteString& rBaseFileName, - ByteString& rImagePath, - FILE* pSysListFile ) -{ - ::std::list< ByteString > aFileNames; - bool bFound = false; - - ByteString aFileName( rBaseFileName ); - aFileNames.push_back( aFileName += ".png" ); - - aFileName = rBaseFileName; - aFileNames.push_back( aFileName += ".bmp" ); - - ::std::list< ByteString >::iterator aFileIter( aFileNames.begin() ); - - while( ( aFileIter != aFileNames.end() ) && !bFound ) - { - ::std::list< ByteString >::const_iterator aDirIter( rOutputFile.aSysSearchDirs.begin() ); - - while( ( aDirIter != rOutputFile.aSysSearchDirs.end() ) && !bFound ) - { - const DirEntry aPath( String( *aDirIter, RTL_TEXTENCODING_ASCII_US ) ); - DirEntry aRelPath( aPath ); - DirEntry aAbsPath( aRelPath += DirEntry( String( *aFileIter, RTL_TEXTENCODING_ASCII_US ) ) ); - - aAbsPath.ToAbs(); - const FileStat aFS( aAbsPath.GetFull() ); - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "Searching image: %s\n", ByteString( aRelPath.GetFull(), RTL_TEXTENCODING_ASCII_US ).GetBuffer() ); -#endif - - if( aFS.IsKind( FSYS_KIND_FILE ) ) - { - std::list< std::pair< OString, OString > >::const_iterator aReplIter( rContext.pCmdLine->m_aReplacements.begin() ); - String aStr( aRelPath.GetFull() ); - OString aRelPathStr( aStr.GetBuffer(), aStr.Len(), RTL_TEXTENCODING_ASCII_US ); - - while( ( aReplIter != rContext.pCmdLine->m_aReplacements.end() ) && !bFound ) - { - ByteString aSearch( aReplIter->second ); - aSearch.ToLowerAscii(); - ByteString aSearchIn( aRelPathStr ); - aSearchIn.ToLowerAscii(); - if( aSearchIn.Search( aSearch ) == 0 ) - { - sal_Int32 nCopyPos = aReplIter->second.getLength(), nLength = aRelPathStr.getLength(); - const sal_Char* pChars = aRelPathStr.getStr(); - - while( ( nCopyPos < nLength ) && ( pChars[ nCopyPos ] == '/' || pChars[ nCopyPos ] == '\\' || pChars[ nCopyPos ] == ':' ) ) - { - ++nCopyPos; - } - - if( nCopyPos < nLength ) - rImagePath = aRelPathStr.copy( nCopyPos ).replace( '\\', '/' ); - - bFound = true; - } - - ++aReplIter; - } - - if( bFound && pSysListFile ) - { - DirEntry aSysPath( String( *aDirIter, RTL_TEXTENCODING_ASCII_US ) ); - String aSysPathFull( ( aSysPath += DirEntry( String( *aFileIter, RTL_TEXTENCODING_ASCII_US ) ) ).GetFull() ); - OString aSysPathStr( aSysPathFull.GetBuffer(), aSysPathFull.Len(), RTL_TEXTENCODING_ASCII_US ); - - fprintf( pSysListFile, "%s\n", rContext.pCmdLine->substitutePaths( aSysPathStr ).getStr() ); - } - -#if OSL_DEBUG_LEVEL > 1 - fprintf( stderr, "ImagePath to add: %s\n", rImagePath.GetBuffer() ); -#endif - } - - ++aDirIter; - } - - ++aFileIter; - } - - return bFound; -} - -// ------------------------------------------------------------------------------ - -void RscCompiler::PreprocessSrsFile( const RscCmdLine::OutputFile& rOutputFile, - const WriteRcContext& rContext, - const DirEntry& rSrsInPath, - const DirEntry& rSrsOutPath ) -{ - SvFileStream aIStm( rSrsInPath.GetFull(), STREAM_READ ); - SvFileStream aOStm( rSrsOutPath.GetFull(), STREAM_WRITE | STREAM_TRUNC ); - ::std::vector< ByteString > aMissingImages; - FILE* pSysListFile = rContext.aOutputSysList.getLength() ? fopen( rContext.aOutputSysList.getStr(), "ab" ) : NULL; - - if( !aIStm.GetError() && !aOStm.GetError() ) - { - ByteString aLine, aFilePath; - - while( aIStm.ReadLine( aLine ) ) - { - if( ( aLine.GetTokenCount( '=' ) == 2 ) && - ( aLine.GetToken( 0, '=' ).Search( "File" ) != STRING_NOTFOUND ) ) - { - ByteString aBaseFileName( aLine.GetToken( 1, '"' ).GetToken( 0, '.' ) ); - - if( GetImageFilePath( rOutputFile, rContext, aBaseFileName, aFilePath, pSysListFile ) ) - ( ( aLine = "File = \"" ) += aFilePath ) += "\";"; - else - aMissingImages.push_back( aBaseFileName ); - - aOStm.WriteLine( aLine ); - } - else if( aLine.Search( "ImageList" ) != STRING_NOTFOUND ) - { - ::std::vector< ::std::pair< ByteString, sal_Int32 > > aEntryVector; - - aOStm.WriteLine( aLine ); - - if( aLine.Search( ';' ) == STRING_NOTFOUND ) - { - const sal_uInt32 nImgListStartPos = aIStm.Tell(); - - do - { - if( !aIStm.ReadLine( aLine ) ) - break; - } - while( aLine.Search( "Prefix" ) == STRING_NOTFOUND ); - - const ByteString aPrefix( aLine.GetToken( 1, '"' ) ); - aIStm.Seek( nImgListStartPos ); - - do - { - if (!aIStm.ReadLine( aLine ) ) - break; - } - while( aLine.Search( "IdList" ) == STRING_NOTFOUND ); - - // scan all ids and collect images - while( aLine.Search( '}' ) == STRING_NOTFOUND ) - { - if( !aIStm.ReadLine( aLine ) ) - break; - - aLine.EraseLeadingChars( ' ' ); - aLine.EraseLeadingChars( '\t' ); - aLine.EraseAllChars( ';' ); - - if( aLine.IsNumericAscii() ) - { - ByteString aBaseFileName( aPrefix ); - sal_Int32 nNumber = atoi( aLine.GetBuffer() ); - - if( nNumber < 10000 ) - aBaseFileName += '0'; - - if( GetImageFilePath( rOutputFile, rContext, aBaseFileName += aLine , aFilePath, pSysListFile ) ) - aEntryVector.push_back( ::std::pair< ByteString, sal_Int32 >( aFilePath, nNumber ) ); - else - aMissingImages.push_back( aBaseFileName ); - } - } - - const sal_uInt32 nImgListEndPos = aIStm.Tell(); - aIStm.Seek( nImgListStartPos ); - while( aIStm.Tell() < nImgListEndPos ) - { - aIStm.ReadLine( aLine ); - - if( aLine.Search( "IdList" ) != STRING_NOTFOUND ) - { - while( aLine.Search( '}' ) == STRING_NOTFOUND ) - aIStm.ReadLine( aLine ); - } - else - aOStm.WriteLine( aLine ); - } - - aOStm.WriteLine( "FileList = {" ); - - for( sal_uInt32 i = 0; i < aEntryVector.size(); ++i ) - { - rtl::OStringBuffer aEntryString( - RTL_CONSTASCII_STRINGPARAM("< \"")); - - aEntryString.append(aEntryVector[i].first); - aEntryString.append(RTL_CONSTASCII_STRINGPARAM("\"; ")); - aEntryString.append(static_cast<sal_Int32>(aEntryVector[ i ].second)); - aEntryString.append(RTL_CONSTASCII_STRINGPARAM("; >;")); - - aOStm.WriteLine(aEntryString.makeStringAndClear()); - } - - aOStm.WriteLine( "};" ); - } - else - aOStm.WriteLine( aLine ); - } - else - aOStm.WriteLine( aLine ); - } - } - - if( aMissingImages.size() > 0 ) - { - ByteString aImagesStr; - - for( sal_uInt32 i = 0; i < aMissingImages.size(); ++i ) - { - if( i ) - aImagesStr += ' '; - - aImagesStr += aMissingImages[ i ]; - } - - pTC->pEH->FatalError( ERR_NOIMAGE, RscId(), aImagesStr.GetBuffer() ); - } - - if( pSysListFile ) - fclose( pSysListFile ); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/cpp.h b/rsc/source/rscpp/cpp.h deleted file mode 100644 index 199622dab8..0000000000 --- a/rsc/source/rscpp/cpp.h +++ /dev/null @@ -1,418 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - - -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -/* in cpp1.c: file-pointer auf stdout oder file */ -extern FILE *pCppOut; /* BP */ -#define PUTCHAR( d ) fprintf( pCppOut, "%c", (d) ) /* BP */ -#if OSL_DEBUG_LEVEL > 1 -extern FILE *pDefOut; /* ER */ -#ifdef EVALDEFS -#define NEVALBUF 2048 -#endif -#endif - -/* limit for reading commandfiles */ -#define PARALIMIT 100 - -#ifndef EOS -/* - * This is predefined in Decus C - */ -#define EOS '\0' /* End of string */ -#endif -#define EOF_CHAR 0 /* Returned by get() on eof */ -#define NULLST ((char *) NULL) /* Pointer to nowhere (linted) */ -#define DEF_NOARGS (-1) /* #define foo vs #define foo() */ - -/* - * The following may need to change if the host system doesn't use ASCII. - */ -#define DEF_MAGIC 0x1D /* Magic for #defines */ -#define TOK_SEP 0x1E /* Token concatenation delim. */ -#define COM_SEP 0x1F /* Magic comment separator */ - -#ifdef EBCDIC -#define HT 0x05 /* horizontal tab */ -#define NL 0x15 /* new line */ -#define CR 0x0D /* carriage return */ -#define DEL 0x07 -#else -#define HT 0x09 /* horizontal tab */ -#define NL 0x0A /* new line */ -#define CR 0x0D /* carriage return */ -#define DEL 0x7F -#endif - - -#ifdef SOLAR -#define MAC_PARM 0x01 /* Macro formals start here */ -#else -/* - * Note -- in Ascii, the following will map macro formals onto DEL + the - * C1 control character region (decimal 128 .. (128 + PAR_MAC)) which will - * be ok as long as PAR_MAC is less than 33). Note that the last PAR_MAC - * value is reserved for string substitution. - */ - -#define MAC_PARM DEL /* Macro formals start here */ -#if PAR_MAC >= 33 - assertion fails -- PAR_MAC is not less than 33 -#endif -#endif -#define LASTPARM (PAR_MAC - 1) - -/* - * Character type codes. - */ - -#define INV 0 /* Invalid, must be zero */ -#define OP_EOE INV /* End of expression */ -#define DIG 1 /* Digit */ -#define LET 2 /* Identifier start */ -#define FIRST_BINOP OP_ADD -#define OP_ADD 3 -#define OP_SUB 4 -#define OP_MUL 5 -#define OP_DIV 6 -#define OP_MOD 7 -#define OP_ASL 8 -#define OP_ASR 9 -#define OP_AND 10 /* &, not && */ -#define OP_OR 11 /* |, not || */ -#define OP_XOR 12 -#define OP_EQ 13 -#define OP_NE 14 -#define OP_LT 15 -#define OP_LE 16 -#define OP_GE 17 -#define OP_GT 18 -#define OP_ANA 19 /* && */ -#define OP_ORO 20 /* || */ -#define OP_QUE 21 /* ? */ -#define OP_COL 22 /* : */ -#define OP_CMA 23 /* , (relevant?) */ -#define LAST_BINOP OP_CMA /* Last binary operand */ -/* - * The following are unary. - */ -#define FIRST_UNOP OP_PLU /* First Unary operand */ -#define OP_PLU 24 /* + (draft ANSI standard) */ -#define OP_NEG 25 /* - */ -#define OP_COM 26 /* ~ */ -#define OP_NOT 27 /* ! */ -#define LAST_UNOP OP_NOT -#define OP_LPA 28 /* ( */ -#define OP_RPA 29 /* ) */ -#define OP_END 30 /* End of expression marker */ -#define OP_MAX (OP_END + 1) /* Number of operators */ -#define OP_FAIL (OP_END + 1) /* For error returns */ - -/* - * The following are for lexical scanning only. - */ - -#define QUO 65 /* Both flavors of quotation */ -#define DOT 66 /* . might start a number */ -#define SPA 67 /* Space and tab */ -#define BSH 68 /* Just a backslash */ -#define END 69 /* EOF */ - -/* - * These bits are set in ifstack[] - */ -#define WAS_COMPILING 1 /* TRUE if compile set at entry */ -#define ELSE_SEEN 2 /* TRUE when #else processed */ -#define TRUE_SEEN 4 /* TRUE when #if TRUE processed */ - -/* - * Define bits for the basic types and their adjectives - */ - -#define T_CHAR 1 -#define T_INT 2 -#define T_FLOAT 4 -#define T_DOUBLE 8 -#define T_SHORT 16 -#define T_LONG 32 -#define T_SIGNED 64 -#define T_UNSIGNED 128 -#define T_PTR 256 /* Pointer */ -#define T_FPTR 512 /* Pointer to functions */ - -/* - * The DEFBUF structure stores information about #defined - * macros. Note that the defbuf->repl information is always - * in malloc storage. - */ - -typedef struct defbuf { - struct defbuf *link; /* Next define in chain */ - char *repl; /* -> replacement */ - int hash; /* Symbol table hash */ - int nargs; /* For define(args) */ - char name[1]; /* #define name */ -} DEFBUF; - -/* - * The FILEINFO structure stores information about open files - * and macros being expanded. - */ - -typedef struct fileinfo { - char *bptr; /* Buffer pointer */ - int line; /* for include or macro */ - FILE *fp; /* File if non-null */ - struct fileinfo *parent; /* Link to includer */ - char *filename; /* File/macro name */ - char *progname; /* From #line statement */ - unsigned int unrecur; /* For macro recursion */ - char buffer[1]; /* current input line */ -} FILEINFO; - -/* - * The SIZES structure is used to store the values for #if sizeof - */ - -typedef struct sizes { - short bits; /* If this bit is set, */ - int size; /* this is the datum size value */ - int psize; /* this is the pointer size */ -} SIZES; -/* - * nomacarg is a built-in #define on Decus C. - */ - -#ifdef nomacarg -#define cput output /* cput concatenates tokens */ -#else -#if COMMENT_INVISIBLE -#define cput(c) { if (c != TOK_SEP && c != COM_SEP) PUTCHAR(c); } -#else -#define cput(c) { if (c != TOK_SEP) PUTCHAR(c); } -#endif -#endif - -#ifndef nomacarg -#define streq(s1, s2) (strcmp(s1, s2) == 0) -#endif - -/* - * Error codes. VMS uses system definitions. - * Decus C codes are defined in stdio.h. - * Others are cooked to order. - */ - -#if HOST == SYS_VMS -#include <ssdef.h> -#include <stsdef.h> -#define IO_NORMAL (SS$_NORMAL | STS$M_INHIB_MSG) -#define IO_ERROR SS$_ABORT -#endif -/* - * Note: IO_NORMAL and IO_ERROR are defined in the Decus C stdio.h file - */ -#ifndef IO_NORMAL -#define IO_NORMAL 0 -#endif -#ifndef IO_ERROR -#define IO_ERROR 1 -#endif - -/* - * Externs - */ - -extern int line; /* Current line number */ -extern int wrongline; /* Force #line to cc pass 1 */ -extern char type[]; /* Character classifier */ -extern char token[IDMAX + 1]; /* Current input token */ -extern int instring; /* TRUE if scanning string */ -extern int inmacro; /* TRUE if scanning #define */ -extern int errors; /* Error counter */ -extern int recursion; /* Macro depth counter */ -extern char ifstack[BLK_NEST]; /* #if information */ -#define compiling ifstack[0] -extern char *ifptr; /* -> current ifstack item */ -extern char *incdir[NINCLUDE]; /* -i directories */ -extern char **incend; /* -> active end of incdir */ -extern int cflag; /* -C option (keep comments) */ -extern int eflag; /* -E option (ignore errors) */ -extern int nflag; /* -N option (no pre-defines) */ -extern int rec_recover; /* unwind recursive macros */ -extern char *preset[]; /* Standard predefined symbols */ -extern char *magic[]; /* Magic predefined symbols */ -extern FILEINFO *infile; /* Current input file */ -extern char work[NWORK + 1]; /* #define scratch */ -extern char *workp; /* Free space in work */ -#if OSL_DEBUG_LEVEL > 1 -extern int debug; /* Debug level */ -/* ER dump & evaluate #define's */ -extern int bDumpDefs; /* TRUE if #define's dump req. */ -extern int bIsInEval; /* TRUE if #define dumping now */ -#ifdef EVALDEFS -extern char EvalBuf[NEVALBUF + 1]; /* evaluation buffer */ -extern int nEvalOff; /* offset to free buffer pos */ -#endif -#endif -extern int keepcomments; /* Don't remove comments if set */ -extern SIZES size_table[]; /* For #if sizeof sizes */ - -#ifdef NOMAIN /* BP */ -#ifndef _NO_PROTO -int rscpp_main( int argc, char **argv ); -#endif -#define MAIN rscpp_main /* fuer die cpp.lib muss main() geandert werden */ -#else -#ifdef WNT -#define MAIN __cdecl main -#else -#define MAIN main -#endif -#endif - - -void InitCpp1(); -void InitCpp2(); -void InitCpp3(); -void InitCpp4(); -void InitCpp5(); -void InitCpp6(); - -#define HELLO() fprintf( stderr, "[Hello at %s, %d] ", __FILE__, __LINE__ ) - -#ifndef _STDIO_H -#include <stdio.h> -#endif - -#ifndef _STDLIB_H -#include <stdlib.h> -#endif - -#ifndef _STRING_H -#include <string.h> -#endif - -/* cpp1.c */ -void output( int c ); -void sharp(); -void cppmain(); -#if OSL_DEBUG_LEVEL > 1 -#ifdef EVALDEFS -int outputEval( int c ); -#endif -#endif - - -/* cpp2.c */ -int control( int counter ); -void doinclude(); -void dodefine(); -void doif( int hash ); -int openinclude( char *, int ); -int hasdirectory(char *, char * ); -int openfile( char * ); - -/* cpp3.c */ -int openfiles( char *filename ); -void addfile( FILE *fp, char *filename ); -void setincdirs(); -int AddInclude( char *pIncStr ); -int getredirection( int argc, char **argv ); -void zap_uc( char *ap ); - -void initdefines(); -int dooptions( int argc, char *argv[] ); -int readoptions(char* filename, char*** pfargv); - -/* cpp4.c */ -void dodefines(); -void checkparm( int c, DEFBUF *dp ); -int expcollect(); -void expstuff( DEFBUF *dp ); - -#if STRING_FORMAL -void stparmscan( int delim, DEFBUF *dp); -#else -void stparmscan( int delim); -#endif -#if OSL_DEBUG_LEVEL > 1 -void dumpparm( char *why ); -#endif - -void doundef(); -void textput( char *text ); -void charput( int c ); -void expand( DEFBUF *tokenp ); - -/* cpp5.c */ -int eval(); -int evallex(int); -int *evaleval(int *, int, int ); -int evalchar(int); -int dosizeof(); -int evalnum( int c ); -int bittest( int ); - -/* cpp6.c */ - -void skipnl(); -int skipws(); -void scanid( int c ); -int macroid( int c ); -int catenate(); -int scanstring( int c, void (*outfun)( int c ) ); -void scannumber( int c, void (*outfun)( int c ) ); -void save( int c ); -char *savestring( char *text ); -FILEINFO *getfile( int bufsize, char *name); -char *getmem( int size ); -DEFBUF *lookid( int c ); -DEFBUF *defendel( char *name, int delete ); -void dunpdef( char *why ); -void dumpadef( char *why, DEFBUF *dp); -int get(); -int cget(); -void unget(); -void ungetstring( char *text ); -void cerror( char *format, char *sarg); -void cwarn( char *format, char *sarg); -void cfatal( char *format, char *sarg); -void cierror( char *format, int n); -void ciwarn( char *format, int n); -#if OSL_DEBUG_LEVEL > 1 -void dumpdef( char *why ); -void dumpadef( char *why, DEFBUF *dp ); -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/cpp1.c b/rsc/source/rscpp/cpp1.c deleted file mode 100644 index 70c1101f89..0000000000 --- a/rsc/source/rscpp/cpp1.c +++ /dev/null @@ -1,601 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#define NOMAIN - -#include <stdio.h> -#include <ctype.h> -#include "cppdef.h" -#include "cpp.h" - -FILE *pCppOut = NULL; -FILE *pCppIn = NULL; - -#if OSL_DEBUG_LEVEL > 1 -FILE *pDefOut = NULL; /* ER evtl. #define's dump */ -#endif - -#ifdef B200 -/* einzige Moeglichkeit unter BC Stack und Heap festzusetzen */ -extern unsigned _stklen = 24000; -extern unsigned _heaplen = 30000; -#endif - - - -/* - * Commonly used global variables: - * line is the current input line number. - * wrongline is set in many places when the actual output - * line is out of sync with the numbering, e.g, - * when expanding a macro with an embedded newline. - * - * token holds the last identifier scanned (which might - * be a candidate for macro expansion). - * errors is the running cpp error counter. - * infile is the head of a linked list of input files (extended by - * #include and macros being expanded). infile always points - * to the current file/macro. infile->parent to the includer, - * etc. infile->fd is NULL if this input stream is a macro. - */ -int line; /* Current line number */ -int wrongline; /* Force #line to compiler */ -char token[IDMAX + 1]; /* Current input token */ -int errors; /* cpp error counter */ -FILEINFO *infile = NULL; /* Current input file */ -#if OSL_DEBUG_LEVEL > 1 -int debug; /* TRUE if debugging now */ -int bDumpDefs; /* TRUE if #define's dump req. */ -#ifdef EVALDEFS -int bIsInEval; /* TRUE if #define eval now */ -char EvalBuf[NEVALBUF + 1]; /* evaluation buffer */ -int nEvalOff = 0; /* offset to free buffer pos */ -#endif -#endif -/* - * This counter is incremented when a macro expansion is initiated. - * If it exceeds a built-in value, the expansion stops -- this tests - * for a runaway condition: - * #define X Y - * #define Y X - * X - * This can be disabled by falsifying rec_recover. (Nothing does this - * currently: it is a hook for an eventual invocation flag.) - */ -int recursion; /* Infinite recursion counter */ -int rec_recover = TRUE; /* Unwind recursive macros */ - -/* - * instring is set TRUE when a string is scanned. It modifies the - * behavior of the "get next character" routine, causing all characters - * to be passed to the caller (except <DEF_MAGIC>). Note especially that - * comments and \<newline> are not removed from the source. (This - * prevents cpp output lines from being arbitrarily long). - * - * inmacro is set by #define -- it absorbs comments and converts - * form-feed and vertical-tab to space, but returns \<newline> - * to the caller. Strictly speaking, this is a bug as \<newline> - * shouldn't delimit tokens, but we'll worry about that some other - * time -- it is more important to prevent infinitly long output lines. - * - * instring and inmarcor are parameters to the get() routine which - * were made global for speed. - */ -int instring = FALSE; /* TRUE if scanning string */ -int inmacro = FALSE; /* TRUE if #defining a macro */ - -/* - * work[] and workp are used to store one piece of text in a temporay - * buffer. To initialize storage, set workp = work. To store one - * character, call save(c); (This will fatally exit if there isn't - * room.) To terminate the string, call save(EOS). Note that - * the work buffer is used by several subroutines -- be sure your - * data won't be overwritten. The extra byte in the allocation is - * needed for string formal replacement. - */ -char work[NWORK + 1]; /* Work buffer */ -char *workp; /* Work buffer pointer */ - -/* - * keepcomments is set TRUE by the -C option. If TRUE, comments - * are written directly to the output stream. This is needed if - * the output from cpp is to be passed to lint (which uses commands - * embedded in comments). cflag contains the permanent state of the - * -C flag. keepcomments is always falsified when processing #control - * commands and when compilation is supressed by a false #if - * - * If eflag is set, CPP returns "success" even if non-fatal errors - * were detected. - * - * If nflag is non-zero, no symbols are predefined except __LINE__. - * __FILE__, and __DATE__. If nflag > 1, absolutely no symbols - * are predefined. - */ -int keepcomments = FALSE; /* Write out comments flag */ -int cflag = FALSE; /* -C option (keep comments) */ -int eflag = FALSE; /* -E option (never fail) */ -int nflag = 0; /* -N option (no predefines) */ - -/* - * ifstack[] holds information about nested #if's. It is always - * accessed via *ifptr. The information is as follows: - * WAS_COMPILING state of compiling flag at outer level. - * ELSE_SEEN set TRUE when #else seen to prevent 2nd #else. - * TRUE_SEEN set TRUE when #if or #elif succeeds - * ifstack[0] holds the compiling flag. It is TRUE if compilation - * is currently enabled. Note that this must be initialized TRUE. - */ -char ifstack[BLK_NEST] = { TRUE }; /* #if information */ -char *ifptr = ifstack; /* -> current ifstack[] */ - -/* - * incdir[] stores the -i directories (and the system-specific - * #include <...> directories. - */ -char *incdir[NINCLUDE]; /* -i directories */ -char **incend = incdir; /* -> free space in incdir[] */ - -/* - * This is the table used to predefine target machine and operating - * system designators. It may need hacking for specific circumstances. - * Note: it is not clear that this is part of the Ansi Standard. - * The -N option supresses preset definitions. - */ -char *preset[] = { /* names defined at cpp start */ -#ifdef MACHINE - MACHINE, -#endif -#ifdef SYSTEM - SYSTEM, -#endif -#ifdef COMPILER - COMPILER, -#endif -#if OSL_DEBUG_LEVEL > 1 - "decus_cpp", /* Ourselves! */ -#endif - NULL /* Must be last */ -}; - -/* - * The value of these predefined symbols must be recomputed whenever - * they are evaluated. The order must not be changed. - */ -char *magic[] = { /* Note: order is important */ - "__LINE__", - "__FILE__", - NULL /* Must be last */ -}; - -static char *sharpfilename = NULL; - -int nRunde = 0; - -void InitCpp1() -{ - int i; - /* in der LIB-Version muessen alle Variablen initialisiert werden */ - - line = wrongline = errors = recursion = 0; - for( i = 0; i < IDMAX; i++ ) - token[ i ] = 0; - - for( i = 0; i < NWORK; i++ ) - work[ i ] = 0; - - for( i = 0; i < NINCLUDE; i++ ) - incdir[ i ] = NULL; - - workp = NULL; - for( i = 0; i < BLK_NEST; i++ ) - ifstack[ i ] = TRUE; - ifptr = ifstack; - - pCppOut = stdout; - pCppIn = stdin; -#if OSL_DEBUG_LEVEL > 1 - debug = 0; - bDumpDefs = 0; - pDefOut = stdout; -#ifdef EVALDEFS - bIsInEval = 0; - for( i = 0; i < NEVALBUF; i++ ) - EvalBuf[ i ] = 0; - nEvalOff = 0; -#endif -#endif - rec_recover = TRUE; - infile = NULL; - instring = inmacro = keepcomments = cflag = eflag = FALSE; - nflag = 0; - incend = incdir; - sharpfilename = NULL; -} - -int MAIN(int argc, char** argv) -{ - register int i; - char **useargv, **pfargv; - - -if( nRunde == 0 ) -{ - pCppIn = stdin; - pCppOut = stdout; -} - -nRunde++; - InitCpp1(); - InitCpp2(); - InitCpp3(); - InitCpp4(); - InitCpp5(); - InitCpp6(); - -#if HOST == SYS_VMS - argc = getredirection(argc, argv); /* vms >file and <file */ -#endif - initdefines(); /* O.S. specific def's */ - if ( argv[argc-1][0] == '@' ) - { - i = readoptions( argv[1], &pfargv ); /* Command file */ - useargv=pfargv; - } - else - { - i = dooptions(argc, argv); /* Command line -flags */ - useargv=argv; - } - switch (i) { -#if OSL_DEBUG_LEVEL > 1 - case 4: - if ( bDumpDefs ) - { - /* - * Get defBase file, "-" means use stdout. - */ - if (!streq(useargv[3], "-")) { -#if HOST == SYS_VMS - /* - * On vms, reopen stdout with "vanilla rms" attributes. - */ - if ((i = creat(useargv[3], 0, "rat=cr", "rfm=var")) == -1 - || dup2(i, fileno(stdout)) == -1) { -#else - pDefOut = fopen( useargv[3], "w" ); - if( pDefOut == NULL ) { -#endif - perror(useargv[3]); - cerror("Can't open output file \"%s\"", useargv[3]); - exit(IO_ERROR); - } - } /* Continue by opening output */ - } -#endif - case 3: - /* - * Get output file, "-" means use stdout. - */ - if (!streq(useargv[2], "-")) { -#if HOST == SYS_VMS - /* - * On vms, reopen stdout with "vanilla rms" attributes. - */ - if ((i = creat(useargv[2], 0, "rat=cr", "rfm=var")) == -1 - || dup2(i, fileno(stdout)) == -1) { -#else - pCppOut = fopen( useargv[2], "w" ); - if( pCppOut == NULL ) { -#endif - perror(useargv[2]); - cerror("Can't open output file \"%s\"", useargv[2]); - exit(IO_ERROR); - } - } /* Continue by opening input */ - case 2: /* One file -> stdin */ - /* - * Open input file, "-" means use stdin. - */ - if (!streq(useargv[1], "-")) { - pCppIn = fopen( useargv[1], "r" ); - if( pCppIn == NULL) { - perror(useargv[1]); - cerror("Can't open input file \"%s\"", useargv[1]); - exit(IO_ERROR); - } - strcpy(work, useargv[1]); /* Remember input filename */ - break; - } /* Else, just get stdin */ - case 0: /* No args? */ - case 1: /* No files, stdin -> stdout */ -#if (HOST == SYS_UNIX) || (HOST == SYS_UNKNOWN) - work[0] = EOS; /* Unix can't find stdin name */ -#else - fgetname(stdin, work); /* Vax-11C, Decus C know name */ -#endif - break; - - default: - exit(IO_ERROR); /* Can't happen */ - } - - setincdirs(); /* Setup -I include directories */ - addfile( pCppIn, work); /* "open" main input file */ -#if OSL_DEBUG_LEVEL > 1 - if (debug > 0 || bDumpDefs) - dumpdef("preset #define symbols"); -#endif - if( pCppIn != stdin ) - rewind( pCppIn ); - - cppmain(); /* Process main file */ - - if ((i = (ifptr - &ifstack[0])) != 0) { -#if OLD_PREPROCESSOR - ciwarn("Inside #ifdef block at end of input, depth = %d", i); -#else - cierror("Inside #ifdef block at end of input, depth = %d", i); -#endif - } -#if OSL_DEBUG_LEVEL > 1 - if( pDefOut != stdout && pDefOut != stderr ) - fclose( pDefOut ); -#endif - if( pCppOut != stdout && pCppOut != stderr ) - fclose( pCppOut ); - - if (errors > 0) { - fprintf(stderr, (errors == 1) - ? "%d error in preprocessor\n" - : "%d errors in preprocessor\n", errors); - if (!eflag) - exit(IO_ERROR); - } -#ifdef NOMAIN /* BP */ /* kein exit im der LIB-Version */ - return( IO_NORMAL ); -#else - exit(IO_NORMAL); /* No errors or -E option set */ -#endif - -} - -FILE_LOCAL -void cppmain() -/* - * Main process for cpp -- copies tokens from the current input - * stream (main file, include file, or a macro) to the output - * file. - */ -{ - register int c; /* Current character */ - register int counter; /* newlines and spaces */ - - /* - * Explicitly output a #line at the start of cpp output so - * that lint (etc.) knows the name of the original source - * file. If we don't do this explicitly, we may get - * the name of the first #include file instead. - * We also seem to need a blank line following that first #line. - */ -#ifdef EVALDEFS - if ( !bIsInEval ) -#endif - { - sharp(); - PUTCHAR('\n'); - } - /* - * This loop is started "from the top" at the beginning of each line - * wrongline is set TRUE in many places if it is necessary to write - * a #line record. (But we don't write them when expanding macros.) - * - * The counter variable has two different uses: at - * the start of a line, it counts the number of blank lines that - * have been skipped over. These are then either output via - * #line records or by outputting explicit blank lines. - * When expanding tokens within a line, the counter remembers - * whether a blank/tab has been output. These are dropped - * at the end of the line, and replaced by a single blank - * within lines. - */ - for (;;) { - counter = 0; /* Count empty lines */ - for (;;) { /* For each line, ... */ - while (type[(c = get())] == SPA) /* Skip leading blanks */ - ; /* in this line. */ - if (c == '\n') /* If line's all blank, */ - ++counter; /* Do nothing now */ - else if (c == '#') { /* Is 1st non-space '#' */ - keepcomments = FALSE; /* Don't pass comments */ - counter = control(counter); /* Yes, do a #command */ - keepcomments = (cflag && compiling); - } - else if (c == EOF_CHAR) /* At end of file? */ - { - break; - } - else if (!compiling) { /* #ifdef false? */ - skipnl(); /* Skip to newline */ - counter++; /* Count it, too. */ - } - else { - break; /* Actual token */ - } - } - if (c == EOF_CHAR) /* Exit process at */ - break; /* End of file */ - /* - * If the loop didn't terminate because of end of file, we - * know there is a token to compile. First, clean up after - * absorbing newlines. counter has the number we skipped. - */ - if ((wrongline && infile->fp != NULL) || counter > 4) - sharp(); /* Output # line number */ - else { /* If just a few, stuff */ - while (--counter >= 0) /* them out ourselves */ - PUTCHAR('\n'); - } - /* - * Process each token on this line. - */ - unget(); /* Reread the char. */ - for (;;) { /* For the whole line, */ - do { /* Token concat. loop */ - for (counter = 0; (type[(c = get())] == SPA);) { -#if COMMENT_INVISIBLE - if (c != COM_SEP) - counter++; -#else - counter++; /* Skip over blanks */ -#endif - } - if (c == EOF_CHAR || c == '\n') - goto end_line; /* Exit line loop */ - else if (counter > 0) /* If we got any spaces */ - PUTCHAR(' '); /* Output one space */ - c = macroid(c); /* Grab the token */ - } while (type[c] == LET && catenate()); - if (c == EOF_CHAR || c == '\n') /* From macro exp error */ - goto end_line; /* Exit line loop */ - switch (type[c]) { - case LET: - fputs(token, pCppOut); /* Quite ordinary token */ -#ifdef EVALDEFS - { - int len; - if ( bIsInEval - && nEvalOff + (len=strlen(token)) < NEVALBUF ) - { - strcpy( &EvalBuf[nEvalOff], token ); - nEvalOff += len; - } - } -#endif - break; - - - case DIG: /* Output a number */ - case DOT: /* Dot may begin floats */ -#ifdef EVALDEFS - if ( bIsInEval ) - scannumber(c, outputEval); - else - scannumber(c, output); -#else - scannumber(c, output); -#endif - break; - - case QUO: /* char or string const */ - scanstring(c, output); /* Copy it to output */ - break; - - default: /* Some other character */ - cput(c); /* Just output it */ -#ifdef EVALDEFS - if ( bIsInEval && nEvalOff < NEVALBUF ) - EvalBuf[nEvalOff++] = c; -#endif - break; - } /* Switch ends */ - } /* Line for loop */ -end_line: if (c == '\n') { /* Compiling at EOL? */ - PUTCHAR('\n'); /* Output newline, if */ - if (infile->fp == NULL) /* Expanding a macro, */ - wrongline = TRUE; /* Output # line later */ - } - } /* Continue until EOF */ -#ifdef EVALDEFS - if ( bIsInEval ) - EvalBuf[nEvalOff++] = '\0'; -#endif -} - -void output(int c) -/* - * Output one character to stdout -- output() is passed as an - * argument to scanstring() - */ -{ -#if COMMENT_INVISIBLE - if (c != TOK_SEP && c != COM_SEP) -#else - if (c != TOK_SEP) -#endif - PUTCHAR(c); -} - -#ifdef EVALDEFS -outputEval(c) -int c; -/* - * Output one character to stdout -- output() is passed as an - * argument to scanstring() - */ -{ -#if COMMENT_INVISIBLE - if (c != TOK_SEP && c != COM_SEP) -#else - if (c != TOK_SEP) -#endif - { - PUTCHAR(c); - if ( bIsInEval && nEvalOff < NEVALBUF ) - EvalBuf[nEvalOff++] = c; - } -} -#endif - - -FILE_LOCAL -void sharp() -/* - * Output a line number line. - */ -{ - register char *name; - - if (keepcomments) /* Make sure # comes on */ - PUTCHAR('\n'); /* a fresh, new line. */ - fprintf( pCppOut, "#%s %d", LINE_PREFIX, line); - if (infile->fp != NULL) { - name = (infile->progname != NULL) - ? infile->progname : infile->filename; - if (sharpfilename == NULL - || (sharpfilename != NULL && !streq(name, sharpfilename)) ) { - if (sharpfilename != NULL) - free(sharpfilename); - sharpfilename = savestring(name); - fprintf( pCppOut, " \"%s\"", name); - } - } - PUTCHAR('\n'); - wrongline = FALSE; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/cpp2.c b/rsc/source/rscpp/cpp2.c deleted file mode 100644 index 6561758365..0000000000 --- a/rsc/source/rscpp/cpp2.c +++ /dev/null @@ -1,627 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <stdio.h> -#include <ctype.h> -#include "cppdef.h" -#include "cpp.h" -#if HOST == SYS_VMS -/* - * Include the rms stuff. (We can't just include rms.h as it uses the - * VaxC-specific library include syntax that Decus CPP doesn't support. - * By including things by hand, we can CPP ourself.) - */ -#include <nam.h> -#include <fab.h> -#include <rab.h> -#include <rmsdef.h> -#endif - -/* - * Generate (by hand-inspection) a set of unique values for each control - * operator. Note that this is not guaranteed to work for non-Ascii - * machines. CPP won't compile if there are hash conflicts. - */ - -#define L_assert ('a' + ('s' << 1)) -#define L_define ('d' + ('f' << 1)) -#define L_elif ('e' + ('i' << 1)) -#define L_else ('e' + ('s' << 1)) -#define L_endif ('e' + ('d' << 1)) -#define L_if ('i' + (EOS << 1)) -#define L_ifdef ('i' + ('d' << 1)) -#define L_ifndef ('i' + ('n' << 1)) -#define L_include ('i' + ('c' << 1)) -#define L_line ('l' + ('n' << 1)) -#define L_nogood (EOS + (EOS << 1)) /* To catch #i */ -#define L_pragma ('p' + ('a' << 1)) -#define L_undef ('u' + ('d' << 1)) -#define L_error ('e' + ('r' << 1)) /* BP 5.3.92, #error */ -#define MAXLINE 80 /* BP 5.3.92, #error */ -#if OSL_DEBUG_LEVEL > 1 -#define L_debug ('d' + ('b' << 1)) /* #debug */ -#define L_nodebug ('n' + ('d' << 1)) /* #nodebug */ -#endif - - -void InitCpp2() -{ - -} - - -int -control(int counter) -/* - * Process #control lines. Simple commands are processed inline, - * while complex commands have their own subroutines. - * - * The counter is used to force out a newline before #line, and - * #pragma commands. This prevents these commands from ending up at - * the end of the previous line if cpp is invoked with the -C option. - */ -{ - register int c; - register char *tp; - register int hash; - char *ep; - - c = skipws(); - if (c == '\n' || c == EOF_CHAR) - return (counter + 1); - if (!isdigit(c)) - scanid(c); /* Get #word to token[] */ - else { - unget(); /* Hack -- allow #123 as a */ - strcpy(token, "line"); /* synonym for #line 123 */ - } - hash = (token[1] == EOS) ? L_nogood : (token[0] + (token[2] << 1)); - switch (hash) { - case L_assert: tp = "assert"; break; - case L_define: tp = "define"; break; - case L_elif: tp = "elif"; break; - case L_else: tp = "else"; break; - case L_endif: tp = "endif"; break; - case L_if: tp = "if"; break; - case L_ifdef: tp = "ifdef"; break; - case L_ifndef: tp = "ifndef"; break; - case L_include: tp = "include"; break; - case L_line: tp = "line"; break; - case L_pragma: tp = "pragma"; break; - case L_undef: tp = "undef"; break; - case L_error: tp = "error"; break; -#if OSL_DEBUG_LEVEL > 1 - case L_debug: tp = "debug"; break; - case L_nodebug: tp = "nodebug"; break; -#endif - default: hash = L_nogood; - case L_nogood: tp = ""; break; - } - if (!streq(tp, token)) - hash = L_nogood; - /* - * hash is set to a unique value corresponding to the - * control keyword (or L_nogood if we think it's nonsense). - */ - if (infile->fp == NULL) - cwarn("Control line \"%s\" within macro expansion", token); - if (!compiling) { /* Not compiling now */ - switch (hash) { - case L_if: /* These can't turn */ - case L_ifdef: /* compilation on, but */ - case L_ifndef: /* we must nest #if's */ - if (++ifptr >= &ifstack[BLK_NEST]) - goto if_nest_err; - *ifptr = 0; /* !WAS_COMPILING */ - case L_line: /* Many */ - /* - * Are pragma's always processed? - */ - case L_pragma: /* options */ - case L_include: /* are uninteresting */ - case L_define: /* if we */ - case L_undef: /* aren't */ - case L_assert: /* compiling. */ - case L_error: /* BP 5.3.92, #error */ -dump_line: skipnl(); /* Ignore rest of line */ - return (counter + 1); - } - } - /* - * Make sure that #line and #pragma are output on a fresh line. - */ - if (counter > 0 && (hash == L_line || hash == L_pragma)) { - PUTCHAR('\n'); - counter--; - } - switch (hash) { - case L_line: - /* - * Parse the line to update the line number and "progname" - * field and line number for the next input line. - * Set wrongline to force it out later. - */ - c = skipws(); - workp = work; /* Save name in work */ - while (c != '\n' && c != EOF_CHAR) { - save(c); - c = get(); - } - unget(); - save(EOS); - /* - * Split #line argument into <line-number> and <name> - * We subtract 1 as we want the number of the next line. - */ - line = atoi(work) - 1; /* Reset line number */ - for (tp = work; isdigit(*tp) || type[(int)*tp] == SPA; tp++) - ; /* Skip over digits */ - if (*tp != EOS) { /* Got a filename, so: */ - if (*tp == '"' && (ep = strrchr(tp + 1, '"')) != NULL) { - tp++; /* Skip over left quote */ - *ep = EOS; /* And ignore right one */ - } - if (infile->progname != NULL) /* Give up the old name */ - free(infile->progname); /* if it's allocated. */ - infile->progname = savestring(tp); - } - wrongline = TRUE; /* Force output later */ - break; - - case L_include: - doinclude(); - break; - - case L_define: - dodefine(); - break; - - case L_undef: - doundef(); - break; - - case L_else: - if (ifptr == &ifstack[0]) - goto nest_err; - else if ((*ifptr & ELSE_SEEN) != 0) - goto else_seen_err; - *ifptr |= ELSE_SEEN; - if ((*ifptr & WAS_COMPILING) != 0) { - if (compiling || (*ifptr & TRUE_SEEN) != 0) - compiling = FALSE; - else { - compiling = TRUE; - } - } - break; - - case L_elif: - if (ifptr == &ifstack[0]) - goto nest_err; - else if ((*ifptr & ELSE_SEEN) != 0) { -else_seen_err: cerror("#%s may not follow #else", token); - goto dump_line; - } - if ((*ifptr & (WAS_COMPILING | TRUE_SEEN)) != WAS_COMPILING) { - compiling = FALSE; /* Done compiling stuff */ - goto dump_line; /* Skip this clause */ - } - doif(L_if); - break; - - case L_if: - case L_ifdef: - case L_ifndef: - if (++ifptr >= &ifstack[BLK_NEST]) -if_nest_err: cfatal("Too many nested #%s statements", token); - *ifptr = WAS_COMPILING; - doif(hash); - break; - - case L_endif: - if (ifptr == &ifstack[0]) { -nest_err: cerror("#%s must be in an #if", token); - goto dump_line; - } - if (!compiling && (*ifptr & WAS_COMPILING) != 0) - wrongline = TRUE; - compiling = ((*ifptr & WAS_COMPILING) != 0); - --ifptr; - break; - - case L_assert: - if (eval() == 0) - cerror("Preprocessor assertion failure", NULLST); - break; - - case L_pragma: - /* - * #pragma is provided to pass "options" to later - * passes of the compiler. cpp doesn't have any yet. - */ - fprintf( pCppOut, "#pragma "); - while ((c = get()) != '\n' && c != EOF_CHAR) - cput(c); - unget(); - break; - -#if OSL_DEBUG_LEVEL > 1 - case L_debug: - if (debug == 0) - dumpdef("debug set on"); - debug++; - break; - - case L_nodebug: - debug--; - break; -#endif - case L_error: /* BP 5.3.92, #error */ - { - fprintf( pCppOut, "cpp: line %u, Error directive: ", line ); - while ((c = get()) != '\n' && c != EOF_CHAR) - cput(c); - fprintf( pCppOut, "\n" ); - exit( 1 ); - break; - } - default: - /* - * Undefined #control keyword. - * Note: the correct behavior may be to warn and - * pass the line to a subsequent compiler pass. - * This would allow #asm or similar extensions. - */ - cerror("Illegal # command \"%s\"", token); - break; - } - if (hash != L_include) { -#if OLD_PREPROCESSOR - /* - * Ignore the rest of the #control line so you can write - * #if foo - * #endif foo - */ - goto dump_line; /* Take common exit */ -#else - if (skipws() != '\n') { - cwarn("Unexpected text in #control line ignored", NULLST); - skipnl(); - } -#endif - } - return (counter + 1); -} - -FILE_LOCAL -void doif(int hash) -/* - * Process an #if, #ifdef, or #ifndef. The latter two are straightforward, - * while #if needs a subroutine of its own to evaluate the expression. - * - * doif() is called only if compiling is TRUE. If false, compilation - * is always supressed, so we don't need to evaluate anything. This - * supresses unnecessary warnings. - */ -{ - register int c; - register int found; - - if ((c = skipws()) == '\n' || c == EOF_CHAR) { - unget(); - goto badif; - } - if (hash == L_if) { - unget(); - found = (eval() != 0); /* Evaluate expr, != 0 is TRUE */ - hash = L_ifdef; /* #if is now like #ifdef */ - } - else { - if (type[c] != LET) /* Next non-blank isn't letter */ - goto badif; /* ... is an error */ - found = (lookid(c) != NULL); /* Look for it in symbol table */ - } - if (found == (hash == L_ifdef)) { - compiling = TRUE; - *ifptr |= TRUE_SEEN; - } - else { - compiling = FALSE; - } - return; - -badif: cerror("#if, #ifdef, or #ifndef without an argument", NULLST); -#if !OLD_PREPROCESSOR - skipnl(); /* Prevent an extra */ - unget(); /* Error message */ -#endif - return; -} - -FILE_LOCAL -void doinclude() -/* - * Process the #include control line. - * There are three variations: - * #include "file" search somewhere relative to the - * current source file, if not found, - * treat as #include <file>. - * #include <file> Search in an implementation-dependent - * list of places. - * #include token Expand the token, it must be one of - * "file" or <file>, process as such. - * - * Note: the November 12 draft forbids '>' in the #include <file> format. - * This restriction is unnecessary and not implemented. - */ -{ - register int c; - register int delim; -#if HOST == SYS_VMS - char def_filename[NAM$C_MAXRSS + 1]; -#endif - - delim = macroid(skipws()); - if (delim != '<' && delim != '"') - goto incerr; - if (delim == '<') - delim = '>'; - workp = work; - instring = TRUE; /* Accept all characters */ -#ifdef CONTROL_COMMENTS_NOT_ALLOWED - while ((c = get()) != '\n' && c != EOF_CHAR) - save(c); /* Put it away. */ - unget(); /* Force nl after includee */ - /* - * The draft is unclear if the following should be done. - */ - while (--workp >= work && *workp == ' ') - ; /* Trim blanks from filename */ - if (*workp != delim) - goto incerr; -#else - while ((c = get()) != delim && c != EOF_CHAR) - save(c); -#endif - *workp = EOS; /* Terminate filename */ - instring = FALSE; -#if HOST == SYS_VMS - /* - * Assume the default .h filetype. - */ - if (!vmsparse(work, ".H", def_filename)) { - perror(work); /* Oops. */ - goto incerr; - } - else if (openinclude(def_filename, (delim == '"'))) - return; -#else - if (openinclude(work, (delim == '"'))) - return; -#endif - /* - * No sense continuing if #include file isn't there. - */ - cfatal("Cannot open include file \"%s\"", work); - -incerr: cerror("#include syntax error", NULLST); - return; -} - -FILE_LOCAL int -openinclude(char* filename, int searchlocal) -/* - * Actually open an include file. This routine is only called from - * doinclude() above, but was written as a separate subroutine for - * programmer convenience. It searches the list of directories - * and actually opens the file, linking it into the list of - * active files. Returns TRUE if the file was opened, FALSE - * if openinclude() fails. No error message is printed. - */ -{ - register char **incptr; -#if HOST == SYS_VMS -#if NFWORK < (NAM$C_MAXRSS + 1) - << error, NFWORK is not greater than NAM$C_MAXRSS >> -#endif -#endif - char tmpname[NFWORK]; /* Filename work area */ - - if (searchlocal) { - /* - * Look in local directory first - */ -#if HOST == SYS_UNIX - /* - * Try to open filename relative to the directory of the current - * source file (as opposed to the current directory). (ARF, SCK). - */ - if (filename[0] != '/' - && hasdirectory(infile->filename, tmpname)) - strcat(tmpname, filename); - else { - strcpy(tmpname, filename); - } -#else - if (!hasdirectory(filename, tmpname) - && hasdirectory(infile->filename, tmpname)) - strcat(tmpname, filename); - else { - strcpy(tmpname, filename); - } -#endif - if (openfile(tmpname)) - return (TRUE); - } - /* - * Look in any directories specified by -I command line - * arguments, then in the builtin search list. - */ - for (incptr = incdir; incptr < incend; incptr++) { - if (strlen(*incptr) + strlen(filename) >= (NFWORK - 1)) - cfatal("Filename work buffer overflow", NULLST); - else { -#if HOST == SYS_UNIX - if (filename[0] == '/') - strcpy(tmpname, filename); - else { - sprintf(tmpname, "%s/%s", *incptr, filename); - } -#elif HOST == SYS_UNKNOWN - if (filename[0] == '\\') - strcpy(tmpname, filename); - else { - sprintf(tmpname, "%s\\%s", *incptr, filename); - } -#else - if (!hasdirectory(filename, tmpname)) - sprintf(tmpname, "%s%s", *incptr, filename); -#endif - if (openfile(tmpname)) - return (TRUE); - } - } - return (FALSE); -} - -FILE_LOCAL int -hasdirectory(char* source, char* result) -/* - * If a device or directory is found in the source filename string, the - * node/device/directory part of the string is copied to result and - * hasdirectory returns TRUE. Else, nothing is copied and it returns FALSE. - */ -{ -#if HOST == SYS_UNIX - register char *tp; - - if ((tp = strrchr(source, '/')) == NULL) - return (FALSE); - else { - strncpy(result, source, tp - source + 1); - result[tp - source + 1] = EOS; - return (TRUE); - } -#else -#if HOST == SYS_VMS - if (vmsparse(source, NULLST, result) - && result[0] != EOS) - return (TRUE); - else { - return (FALSE); - } -#else - /* - * Random DEC operating system (RSX, RT11, RSTS/E) - */ - register char *tp; - - if ((tp = strrchr(source, ']')) == NULL - && (tp = strrchr(source, ':')) == NULL) - return (FALSE); - else { - strncpy(result, source, tp - source + 1); - result[tp - source + 1] = EOS; - return (TRUE); - } -#endif -#endif -} - -#if HOST == SYS_VMS - -/* - * EXP_DEV is set if a device was specified, EXP_DIR if a directory - * is specified. (Both set indicate a file-logical, but EXP_DEV - * would be set by itself if you are reading, say, SYS$INPUT:) - */ -#define DEVDIR (NAM$M_EXP_DEV | NAM$M_EXP_DIR) - -FILE_LOCAL int -vmsparse(source, defstring, result) -char *source; -char *defstring; /* non-NULL -> default string. */ -char *result; /* Size is at least NAM$C_MAXRSS + 1 */ -/* - * Parse the source string, applying the default (properly, using - * the system parse routine), storing it in result. - * TRUE if it parsed, FALSE on error. - * - * If defstring is NULL, there are no defaults and result gets - * (just) the node::[directory] part of the string (possibly "") - */ -{ - struct FAB fab = cc$rms_fab; /* File access block */ - struct NAM nam = cc$rms_nam; /* File name block */ - char fullname[NAM$C_MAXRSS + 1]; - register char *rp; /* Result pointer */ - - fab.fab$l_nam = &nam; /* fab -> nam */ - fab.fab$l_fna = source; /* Source filename */ - fab.fab$b_fns = strlen(source); /* Size of source */ - fab.fab$l_dna = defstring; /* Default string */ - if (defstring != NULLST) - fab.fab$b_dns = strlen(defstring); /* Size of default */ - nam.nam$l_esa = fullname; /* Expanded filename */ - nam.nam$b_ess = NAM$C_MAXRSS; /* Expanded name size */ - if (sys$parse(&fab) == RMS$_NORMAL) { /* Parse away */ - fullname[nam.nam$b_esl] = EOS; /* Terminate string */ - result[0] = EOS; /* Just in case */ - rp = &result[0]; - /* - * Remove stuff added implicitly, accepting node names and - * dev:[directory] strings (but not process-permanent files). - */ - if ((nam.nam$l_fnb & NAM$M_PPF) == 0) { - if ((nam.nam$l_fnb & NAM$M_NODE) != 0) { - strncpy(result, nam.nam$l_node, nam.nam$b_node); - rp += nam.nam$b_node; - *rp = EOS; - } - if ((nam.nam$l_fnb & DEVDIR) == DEVDIR) { - strncpy(rp, nam.nam$l_dev, nam.nam$b_dev + nam.nam$b_dir); - rp += nam.nam$b_dev + nam.nam$b_dir; - *rp = EOS; - } - } - if (defstring != NULLST) { - strncpy(rp, nam.nam$l_name, nam.nam$b_name + nam.nam$b_type); - rp += nam.nam$b_name + nam.nam$b_type; - *rp = EOS; - if ((nam.nam$l_fnb & NAM$M_EXP_VER) != 0) { - strncpy(rp, nam.nam$l_ver, nam.nam$b_ver); - rp[nam.nam$b_ver] = EOS; - } - } - return (TRUE); - } - return (FALSE); -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/cpp3.c b/rsc/source/rscpp/cpp3.c deleted file mode 100644 index e6d1ade9a9..0000000000 --- a/rsc/source/rscpp/cpp3.c +++ /dev/null @@ -1,587 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -#include <stdio.h> -#ifdef UNX -#include <stdlib.h> -#endif -#include <ctype.h> -#include "cppdef.h" -#include "cpp.h" - -#include "time.h" /* BP */ - -#ifndef _STRING_H -#include <string.h> -#endif - -#ifndef _NO_PROTO -int AddInclude( char *pIncStr ); /* BP, 11.09.91, Forward-Deklaration */ -#endif - -#if (OSL_DEBUG_LEVEL > 1) && (HOST == SYS_VMS || HOST == SYS_UNIX) -#include <signal.h> -#endif - -void InitCpp3() -{ -} - - -int -openfile(char* filename) -/* - * Open a file, add it to the linked list of open files. - * This is called only from openfile() above. - */ -{ - register FILE *fp; - - if ((fp = fopen(filename, "r")) == NULL) { -#if OSL_DEBUG_LEVEL > 1 - if ( debug || !bDumpDefs ) - perror(filename); -#endif - return (FALSE); - } -#if OSL_DEBUG_LEVEL > 1 - if (debug) - fprintf(stderr, "Reading from \"%s\"\n", filename); -#endif - addfile(fp, filename); - return (TRUE); -} - -void addfile(FILE* fp, char* filename) -/* - * Initialize tables for this open file. This is called from openfile() - * above (for #include files), and from the entry to cpp to open the main - * input file. It calls a common routine, getfile() to build the FILEINFO - * structure which is used to read characters. (getfile() is also called - * to setup a macro replacement.) - */ -{ - register FILEINFO *file; - extern FILEINFO *getfile( int bufsize, char *filename ); - file = getfile(NBUFF, filename); - file->fp = fp; /* Better remember FILE * */ - file->buffer[0] = EOS; /* Initialize for first read */ - line = 1; /* Working on line 1 now */ - wrongline = TRUE; /* Force out initial #line */ -} - -void setincdirs() -/* - * Append system-specific directories to the include directory list. - * Called only when cpp is started. - */ -{ - -#ifdef CPP_INCLUDE - *incend++ = CPP_INCLUDE; -#define IS_INCLUDE 1 -#else -#define IS_INCLUDE 0 -#endif - -#if HOST == SYS_UNIX - *incend++ = "/usr/include"; -#define MAXINCLUDE (NINCLUDE - 1 - IS_INCLUDE) -#endif - -#if HOST == SYS_VMS - extern char *getenv(); - - if (getenv("C$LIBRARY") != NULL) - *incend++ = "C$LIBRARY:"; - *incend++ = "SYS$LIBRARY:"; -#define MAXINCLUDE (NINCLUDE - 2 - IS_INCLUDE) -#endif - -#if HOST == SYS_RSX - extern int $$rsts; /* TRUE on RSTS/E */ - extern int $$pos; /* TRUE on PRO-350 P/OS */ - extern int $$vms; /* TRUE on VMS compat. */ - - if ($$pos) { /* P/OS? */ - *incend++ = "SY:[ZZDECUSC]"; /* C #includes */ - *incend++ = "LB:[1,5]"; /* RSX library */ - } - else if ($$rsts) { /* RSTS/E? */ - *incend++ = "SY:@"; /* User-defined account */ - *incend++ = "C:"; /* Decus-C library */ - *incend++ = "LB:[1,1]"; /* RSX library */ - } - else if ($$vms) { /* VMS compatibility? */ - *incend++ = "C:"; - } - else { /* Plain old RSX/IAS */ - *incend++ = "LB:[1,1]"; - } -#define MAXINCLUDE (NINCLUDE - 3 - IS_INCLUDE) -#endif - -#if HOST == SYS_RT11 - extern int $$rsts; /* RSTS/E emulation? */ - - if ($$rsts) - *incend++ = "SY:@"; /* User-defined account */ - *incend++ = "C:"; /* Decus-C library disk */ - *incend++ = "SY:"; /* System (boot) disk */ -#define MAXINCLUDE (NINCLUDE - 3 - IS_INCLUDE) -#endif - -#if HOST == SYS_UNKNOWN -/* - * Kontext: GenMake - * Unter DOS wird nun auch die Environment-Variable INCLUDE ausgewetet. - * Es kommt erschwerend hinzu, dass alle Eintraege, die mit ';' getrennt - * sind, mit in die Liste aufenommen werden muessen. - * Dies wird mit der Funktion strtok() realisiert. - * Vorsicht bei der Benutzung von malloc !!! - * In savestring wird naemlich getmem() verwendet. Vermutlich kommen sich - * die beiden Funktion in die Quere. Als ich malloc statt savestring - * verwendete knallte es in strcpy() ! - */ - -#if !defined( WNT ) && ! defined UNX - extern char *getenv( char *pStr ); /* BP */ -#endif - char *pIncGetEnv = NULL; /* Pointer auf INCLUDE */ - - if ( ( pIncGetEnv = getenv("INCLUDE") ) != NULL ) - AddInclude( pIncGetEnv ); - -#define MAXINCLUDE (NINCLUDE - 3 - IS_INCLUDE) -#endif - - -} - -/* Kontext: Erweiterung des INCLUDE-Services - * Bislang konnte der cpp keine Include-Angaben in der Kommandozeile - * vertragen, bei denen die directries mit ';' getrennt wurden. - * Dies ist auch verstaendlich, da dieses cpp fuer UNIX-Systeme - * massgeschneidert wurde und in UNI die ';' als Zeichen zum Abschluss - * von Kommandos gilt. - */ - -int AddInclude( char* pIncStr ) -{ - char *pIncEnv = NULL; /* Kopie des INCLUDE */ - char *pIncPos; /* wandert zum naechsten */ - - pIncEnv = savestring( pIncStr ); - pIncPos = strtok( pIncEnv, ";" ); - - while( pIncPos != NULL ) - { - if (incend >= &incdir[MAXINCLUDE]) - cfatal("Too many include directories", NULLST); - *incend++ = pIncPos; - pIncPos = strtok( NULL, ";" ); - } - return( 1 ); -} - -int -dooptions(int argc, char** argv) -/* - * dooptions is called to process command line arguments (-Detc). - * It is called only at cpp startup. - */ -{ - register char *ap; - register DEFBUF *dp; - register int c; - int i, j; - char *arg; - SIZES *sizp; /* For -S */ - int size; /* For -S */ - int isdatum; /* FALSE for -S* */ - int endtest; /* For -S */ - - for (i = j = 1; i < argc; i++) { - arg = ap = argv[i]; - - if (*ap++ != '-' || *ap == EOS) - { - argv[j++] = argv[i]; - } - else { - c = *ap++; /* Option byte */ - if (islower(c)) /* Normalize case */ - c = toupper(c); - switch (c) { /* Command character */ - case 'C': /* Keep comments */ - cflag = TRUE; - keepcomments = TRUE; - break; - - case 'D': /* Define symbol */ - /* - * If the option is just "-Dfoo", make it -Dfoo=1 - */ - while (*ap != EOS && *ap != '=') - ap++; - if (*ap == EOS) - ap = "1"; - else - *ap++ = EOS; - /* - * Now, save the word and its definition. - */ - dp = defendel(argv[i] + 2, FALSE); - dp->repl = savestring(ap); - dp->nargs = DEF_NOARGS; - break; - - case 'E': /* Ignore non-fatal */ - eflag = TRUE; /* errors. */ - break; - - case 'I': /* Include directory */ - AddInclude( ap ); /* BP, 11.09.91 */ - break; - - case 'N': /* No predefineds */ - nflag++; /* Repeat to undefine */ - break; /* __LINE__, etc. */ - - case 'S': - sizp = size_table; - if (0 != (isdatum = (*ap != '*'))) /* If it's just -S, */ - endtest = T_FPTR; /* Stop here */ - else { /* But if it's -S* */ - ap++; /* Step over '*' */ - endtest = 0; /* Stop at end marker */ - } - while (sizp->bits != endtest && *ap != EOS) { - if (!isdigit(*ap)) { /* Skip to next digit */ - ap++; - continue; - } - size = 0; /* Compile the value */ - while (isdigit(*ap)) { - size *= 10; - size += (*ap++ - '0'); - } - if (isdatum) - sizp->size = size; /* Datum size */ - else - sizp->psize = size; /* Pointer size */ - sizp++; - } - if (sizp->bits != endtest) - cwarn("-S, too few values specified in %s", argv[i]); - else if (*ap != EOS) - cwarn("-S, too many values, \"%s\" unused", ap); - break; - - case 'U': /* Undefine symbol */ - if (defendel(ap, TRUE) == NULL) - cwarn("\"%s\" wasn't defined", ap); - break; - -#if OSL_DEBUG_LEVEL > 1 - case 'X': /* Debug */ - debug = (isdigit(*ap)) ? atoi(ap) : 1; -#if (HOST == SYS_VMS || HOST == SYS_UNIX) - signal(SIGINT, (void (*)(int)) abort); /* Trap "interrupt" */ -#endif - fprintf(stderr, "Debug set to %d\n", debug); - break; -#endif - -#if OSL_DEBUG_LEVEL > 1 - case 'P': /* #define's dump */ - bDumpDefs = 1; - fprintf(stderr, "Dump #define's is on\n"); - break; -#endif - - default: /* What is this one? */ - cwarn("Unknown option \"%s\"", arg); - fprintf(stderr, "The following options are valid:\n\ - -C\t\t\tWrite source file comments to output\n\ - -Dsymbol=value\tDefine a symbol with the given (optional) value\n\ - -Idirectory\t\tAdd a directory to the #include search list\n\ - -N\t\t\tDon't predefine target-specific names\n\ - -Stext\t\tSpecify sizes for #if sizeof\n\ - -Usymbol\t\tUndefine symbol\n"); -#if OSL_DEBUG_LEVEL > 1 - fprintf(stderr, " -Xvalue\t\tSet internal debug flag\n"); - fprintf(stderr, " -P\t\t\tdump #define's\n"); -#endif - break; - } /* Switch on all options */ - } /* If it's a -option */ - } /* For all arguments */ -#if OSL_DEBUG_LEVEL > 1 - if ( (bDumpDefs ? j > 4 : j > 3) ) { -#else - if (j > 3) { -#endif - cerror( - "Too many file arguments. Usage: cpp [input [output]]", - NULLST); - } - return (j); /* Return new argc */ -} - -int -readoptions(char* filename, char*** pfargv) -{ - FILE *fp; - int c; - int bInQuotes = 0; - char optbuff[1024], *poptbuff; - int fargc=0, back; - char *fargv[PARALIMIT], **pfa; - - pfa=*pfargv=malloc(sizeof(fargv)); - - poptbuff=&optbuff[0]; - filename++; - if ((fp = fopen(filename, "r")) == NULL) { -#if OSL_DEBUG_LEVEL > 1 - if ( debug || !bDumpDefs ) - perror(filename); -#endif - return (FALSE); - } - do - { - /* - * #i27914# double ticks '"' now have a duplicate function: - * 1. they define a string ( e.g. -DFOO="baz" ) - * 2. a string can contain spaces, so -DFOO="baz zum" defines one - * argument no two ! - */ - c=fgetc(fp); - if ( c != ' ' && c != CR && c != NL && c != HT && c != EOF) - { - *poptbuff++=(char)c; - if( c == '"' ) - bInQuotes = ~bInQuotes; - } - else - { - if( c != EOF && bInQuotes ) - *poptbuff++=(char)c; - else - { - *poptbuff=EOS; - if (strlen(optbuff)>0) - { - pfa[fargc+1]=malloc(strlen(optbuff)+1); - strcpy(pfa[fargc+1],optbuff); - fargc++; - pfa[fargc+1]=0; - poptbuff=&optbuff[0]; - } - } - } - } - while ( c != EOF ); - - fclose(fp); - back=dooptions(fargc+1,pfa); - - return (back); -} - -#if HOST != SYS_UNIX -FILE_LOCAL void -zap_uc(char* ap) -/* - * Dec operating systems mangle upper-lower case in command lines. - * This routine forces the -D and -U arguments to uppercase. - * It is called only on cpp startup by dooptions(). - */ -{ - while (*ap != EOS) { - /* - * Don't use islower() here so it works with Multinational - */ - if (*ap >= 'a' && *ap <= 'z') - *ap = (char)toupper(*ap); - ap++; - } -} -#endif - -void initdefines() -/* - * Initialize the built-in #define's. There are two flavors: - * #define decus 1 (static definitions) - * #define __FILE__ ?? (dynamic, evaluated by magic) - * Called only on cpp startup. - * - * Note: the built-in static definitions are supressed by the -N option. - * __LINE__, __FILE__, and __DATE__ are always present. - */ -{ - register char **pp; - register char *tp; - register DEFBUF *dp; - int i; - time_t tvec; - -#if !defined( WNT ) && !defined(G3) - extern char *ctime(); -#endif - - /* - * Predefine the built-in symbols. Allow the - * implementor to pre-define a symbol as "" to - * eliminate it. - */ - if (nflag == 0) { - for (pp = preset; *pp != NULL; pp++) { - if (*pp[0] != EOS) { - dp = defendel(*pp, FALSE); - dp->repl = savestring("1"); - dp->nargs = DEF_NOARGS; - } - } - } - /* - * The magic pre-defines (__FILE__ and __LINE__ are - * initialized with negative argument counts. expand() - * notices this and calls the appropriate routine. - * DEF_NOARGS is one greater than the first "magic" definition. - */ - if (nflag < 2) { - for (pp = magic, i = DEF_NOARGS; *pp != NULL; pp++) { - dp = defendel(*pp, FALSE); - dp->nargs = --i; - } -#if OK_DATE - /* - * Define __DATE__ as today's date. - */ - dp = defendel("__DATE__", FALSE); - dp->repl = tp = getmem(27); - dp->nargs = DEF_NOARGS; - time( &tvec); - *tp++ = '"'; - strcpy(tp, ctime(&tvec)); - tp[24] = '"'; /* Overwrite newline */ -#endif - } -} - -#if HOST == SYS_VMS -/* - * getredirection() is intended to aid in porting C programs - * to VMS (Vax-11 C) which does not support '>' and '<' - * I/O redirection. With suitable modification, it may - * useful for other portability problems as well. - */ - -int -getredirection(argc, argv) -int argc; -char **argv; -/* - * Process vms redirection arg's. Exit if any error is seen. - * If getredirection() processes an argument, it is erased - * from the vector. getredirection() returns a new argc value. - * - * Warning: do not try to simplify the code for vms. The code - * presupposes that getredirection() is called before any data is - * read from stdin or written to stdout. - * - * Normal usage is as follows: - * - * main(argc, argv) - * int argc; - * char *argv[]; - * { - * argc = getredirection(argc, argv); - * } - */ -{ - register char *ap; /* Argument pointer */ - int i; /* argv[] index */ - int j; /* Output index */ - int file; /* File_descriptor */ - extern int errno; /* Last vms i/o error */ - - for (j = i = 1; i < argc; i++) { /* Do all arguments */ - switch (*(ap = argv[i])) { - case '<': /* <file */ - if (freopen(++ap, "r", stdin) == NULL) { - perror(ap); /* Can't find file */ - exit(errno); /* Is a fatal error */ - } - break; - - case '>': /* >file or >>file */ - if (*++ap == '>') { /* >>file */ - /* - * If the file exists, and is writable by us, - * call freopen to append to the file (using the - * file's current attributes). Otherwise, create - * a new file with "vanilla" attributes as if the - * argument was given as ">filename". - * access(name, 2) returns zero if we can write on - * the specified file. - */ - if (access(++ap, 2) == 0) { - if (freopen(ap, "a", stdout) != NULL) - break; /* Exit case statement */ - perror(ap); /* Error, can't append */ - exit(errno); /* After access test */ - } /* If file accessable */ - } - /* - * On vms, we want to create the file using "standard" - * record attributes. creat(...) creates the file - * using the caller's default protection mask and - * "variable length, implied carriage return" - * attributes. dup2() associates the file with stdout. - */ - if ((file = creat(ap, 0, "rat=cr", "rfm=var")) == -1 - || dup2(file, fileno(stdout)) == -1) { - perror(ap); /* Can't create file */ - exit(errno); /* is a fatal error */ - } /* If '>' creation */ - break; /* Exit case test */ - - default: - argv[j++] = ap; /* Not a redirector */ - break; /* Exit case test */ - } - } /* For all arguments */ - argv[j] = NULL; /* Terminate argv[] */ - return (j); /* Return new argc */ -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/cpp4.c b/rsc/source/rscpp/cpp4.c deleted file mode 100644 index 81b7dd03ad..0000000000 --- a/rsc/source/rscpp/cpp4.c +++ /dev/null @@ -1,634 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <stdio.h> -#include <ctype.h> -#include "cppdef.h" -#include "cpp.h" -/* - * parm[], parmp, and parlist[] are used to store #define() argument - * lists. nargs contains the actual number of parameters stored. - */ -static char parm[NPARMWORK + 1]; /* define param work buffer */ -static char *parmp; /* Free space in parm */ -static char *parlist[LASTPARM]; /* -> start of each parameter */ -static int nargs; /* Parameters for this macro */ - -void InitCpp4() -{ - int i; - for( i = 0; i < NPARMWORK; i++ ) - parm[ i ] = 0; - for( i = 0; i < LASTPARM; i++ ) - parlist[ i ] = NULL; - - nargs = 0; -} - - -void dodefine() -/* - * Called from control when a #define is scanned. This module - * parses formal parameters and the replacement string. When - * the formal parameter name is encountered in the replacement - * string, it is replaced by a character in the range 128 to - * 128+NPARAM (this allows up to 32 parameters within the - * Dec Multinational range). If cpp is ported to an EBCDIC - * machine, you will have to make other arrangements. - * - * There is some special case code to distinguish - * #define foo bar - * from #define foo() bar - * - * Also, we make sure that - * #define foo foo - * expands to "foo" but doesn't put cpp into an infinite loop. - * - * A warning message is printed if you redefine a symbol to a - * different text. I.e, - * #define foo 123 - * #define foo 123 - * is ok, but - * #define foo 123 - * #define foo +123 - * is not. - * - * The following subroutines are called from define(): - * checkparm called when a token is scanned. It checks through the - * array of formal parameters. If a match is found, the - * token is replaced by a control byte which will be used - * to locate the parameter when the macro is expanded. - * textput puts a string in the macro work area (parm[]), updating - * parmp to point to the first free byte in parm[]. - * textput() tests for work buffer overflow. - * charput puts a single character in the macro work area (parm[]) - * in a manner analogous to textput(). - */ -{ - register int c; - register DEFBUF *dp; /* -> new definition */ - int isredefine; /* TRUE if redefined */ - char *old = 0; /* Remember redefined */ - - if (type[(c = skipws())] != LET) - goto bad_define; - isredefine = FALSE; /* Set if redefining */ - if ((dp = lookid(c)) == NULL) /* If not known now */ - dp = defendel(token, FALSE); /* Save the name */ - else { /* It's known: */ - isredefine = TRUE; /* Remember this fact */ - old = dp->repl; /* Remember replacement */ - dp->repl = NULL; /* No replacement now */ - } - parlist[0] = parmp = parm; /* Setup parm buffer */ - if ((c = get()) == '(') { /* With arguments? */ - nargs = 0; /* Init formals counter */ - do { /* Collect formal parms */ - if (nargs >= LASTPARM) - cfatal("Too many arguments for macro", NULLST); - else if ((c = skipws()) == ')') - break; /* Got them all */ - else if (type[c] != LET) /* Bad formal syntax */ - goto bad_define; - scanid(c); /* Get the formal param */ - parlist[nargs++] = parmp; /* Save its start */ - textput(token); /* Save text in parm[] */ - } while ((c = skipws()) == ','); /* Get another argument */ - if (c != ')') /* Must end at ) */ - goto bad_define; - c = ' '; /* Will skip to body */ - } - else { - /* - * DEF_NOARGS is needed to distinguish between - * "#define foo" and "#define foo()". - */ - nargs = DEF_NOARGS; /* No () parameters */ - } - if (type[c] == SPA) /* At whitespace? */ - c = skipws(); /* Not any more. */ - workp = work; /* Replacement put here */ - inmacro = TRUE; /* Keep \<newline> now */ - while (c != EOF_CHAR && c != '\n') { /* Compile macro body */ -#if OK_CONCAT -#if COMMENT_INVISIBLE - if (c == COM_SEP) { /* Token concatenation? */ - save(TOK_SEP); /* Stuff a delimiter */ - c = get(); -#else - if (c == '#') { /* Token concatenation? */ - while (workp > work && type[(int)workp[-1]] == SPA) - --workp; /* Erase leading spaces */ - save(TOK_SEP); /* Stuff a delimiter */ - c = skipws(); /* Eat whitespace */ -#endif - if (type[c] == LET) /* Another token here? */ - ; /* Stuff it normally */ - else if (type[c] == DIG) { /* Digit string after? */ - while (type[c] == DIG) { /* Stuff the digits */ - save(c); - c = get(); - } - save(TOK_SEP); /* Delimit 2nd token */ - } - else { -#if ! COMMENT_INVISIBLE - ciwarn("Strange character after # (%d.)", c); -#endif - } - continue; - } -#endif - switch (type[c]) { - case LET: - checkparm(c, dp); /* Might be a formal */ - break; - - case DIG: /* Number in mac. body */ - case DOT: /* Maybe a float number */ - scannumber(c, save); /* Scan it off */ - break; - - case QUO: /* String in mac. body */ -#if STRING_FORMAL - stparmscan(c, dp); /* Do string magic */ -#else - stparmscan(c); -#endif - break; - - case BSH: /* Backslash */ - save('\\'); - if ((c = get()) == '\n') - wrongline = TRUE; - save(c); - break; - - case SPA: /* Absorb whitespace */ - /* - * Note: the "end of comment" marker is passed on - * to allow comments to separate tokens. - */ - if (workp[-1] == ' ') /* Absorb multiple */ - break; /* spaces */ - else if (c == '\t') - c = ' '; /* Normalize tabs */ - /* Fall through to store character */ - default: /* Other character */ - save(c); - break; - } - c = get(); - } - inmacro = FALSE; /* Stop newline hack */ - unget(); /* For control check */ - if (workp > work && workp[-1] == ' ') /* Drop trailing blank */ - workp--; - *workp = EOS; /* Terminate work */ - dp->repl = savestring(work); /* Save the string */ - dp->nargs = nargs; /* Save arg count */ -#if OSL_DEBUG_LEVEL > 1 - if (debug) - dumpadef("macro definition", dp); - else if (bDumpDefs) - dumpadef(NULL, dp); -#endif - if (isredefine) { /* Error if redefined */ - if ((old != NULL && dp->repl != NULL && !streq(old, dp->repl)) - || (old == NULL && dp->repl != NULL) - || (old != NULL && dp->repl == NULL)) { -#ifdef STRICT_UNDEF - cerror("Redefining defined variable \"%s\"", dp->name); -#else - cwarn("Redefining defined variable \"%s\"", dp->name); -#endif - } - if (old != NULL) /* We don't need the */ - free(old); /* old definition now. */ - } - return; - -bad_define: - cerror("#define syntax error", NULLST); - inmacro = FALSE; /* Stop <newline> hack */ -} - -void checkparm(int c, DEFBUF* dp) -/* - * Replace this param if it's defined. Note that the macro name is a - * possible replacement token. We stuff DEF_MAGIC in front of the token - * which is treated as a LETTER by the token scanner and eaten by - * the output routine. This prevents the macro expander from - * looping if someone writes "#define foo foo". - */ -{ - register int i; - register char *cp; - - scanid(c); /* Get parm to token[] */ - for (i = 0; i < nargs; i++) { /* For each argument */ - if (streq(parlist[i], token)) { /* If it's known */ -#ifdef SOLAR - save(DEL); -#endif - save(i + MAC_PARM); /* Save a magic cookie */ - return; /* And exit the search */ - } - } - if (streq(dp->name, token)) /* Macro name in body? */ - save(DEF_MAGIC); /* Save magic marker */ - for (cp = token; *cp != EOS;) /* And save */ - save(*cp++); /* The token itself */ -} - -#if STRING_FORMAL -void stparmscan(delim, dp) -int delim; -register DEFBUF *dp; -/* - * Scan the string (starting with the given delimiter). - * The token is replaced if it is the only text in this string or - * character constant. The algorithm follows checkparm() above. - * Note that scanstring() has approved of the string. - */ -{ - register int c; - - /* - * Warning -- this code hasn't been tested for a while. - * It exists only to preserve compatibility with earlier - * implementations of cpp. It is not part of the Draft - * ANSI Standard C language. - */ - save(delim); - instring = TRUE; - while ((c = get()) != delim - && c != '\n' - && c != EOF_CHAR) { - if (type[c] == LET) /* Maybe formal parm */ - checkparm(c, dp); - else { - save(c); - if (c == '\\') - save(get()); - } - } - instring = FALSE; - if (c != delim) - cerror("Unterminated string in macro body", NULLST); - save(c); -} -#else -void stparmscan(int delim) -/* - * Normal string parameter scan. - */ -{ - register char *wp; - register int i; - - wp = workp; /* Here's where it starts */ - if (!scanstring(delim, save)) - return; /* Exit on scanstring error */ - workp[-1] = EOS; /* Erase trailing quote */ - wp++; /* -> first string content byte */ - for (i = 0; i < nargs; i++) { - if (streq(parlist[i], wp)) { -#ifdef SOLAR - *wp++ = DEL; - *wp++ = MAC_PARM + PAR_MAC; /* Stuff a magic marker */ - *wp++ = (char)(i + MAC_PARM); /* Make a formal marker */ - *wp = wp[-4]; /* Add on closing quote */ - workp = wp + 1; /* Reset string end */ -#else - *wp++ = MAC_PARM + PAR_MAC; /* Stuff a magic marker */ - *wp++ = (i + MAC_PARM); /* Make a formal marker */ - *wp = wp[-3]; /* Add on closing quote */ - workp = wp + 1; /* Reset string end */ -#endif - return; - } - } - workp[-1] = wp[-1]; /* Nope, reset end quote. */ -} -#endif - -void doundef() -/* - * Remove the symbol from the defined list. - * Called from the #control processor. - */ -{ - register int c; - - if (type[(c = skipws())] != LET) - cerror("Illegal #undef argument", NULLST); - else { - scanid(c); /* Get name to token[] */ - if (defendel(token, TRUE) == NULL) { -#ifdef STRICT_UNDEF - cwarn("Symbol \"%s\" not defined in #undef", token); -#endif - } - } -} - -void textput(char* text) -/* - * Put the string in the parm[] buffer. - */ -{ - register int size; - - size = strlen(text) + 1; - if ((parmp + size) >= &parm[NPARMWORK]) - cfatal("Macro work area overflow", NULLST); - else { - strcpy(parmp, text); - parmp += size; - } -} - -void charput(int c) -/* - * Put the byte in the parm[] buffer. - */ -{ - if (parmp >= &parm[NPARMWORK]) - cfatal("Macro work area overflow", NULLST); - else { - *parmp++ = (char)c; - } -} - -/* - * M a c r o E x p a n s i o n - */ - -static DEFBUF *macro; /* Catches start of infinite macro */ - -void expand(DEFBUF* tokenp) -/* - * Expand a macro. Called from the cpp mainline routine (via subroutine - * macroid()) when a token is found in the symbol table. It calls - * expcollect() to parse actual parameters, checking for the correct number. - * It then creates a "file" containing a single line containing the - * macro with actual parameters inserted appropriately. This is - * "pushed back" onto the input stream. (When the get() routine runs - * off the end of the macro line, it will dismiss the macro itself.) - */ -{ - register int c; - register FILEINFO *file; - extern FILEINFO *getfile(); - -#if OSL_DEBUG_LEVEL > 1 - if (debug) - dumpadef("expand entry", tokenp); -#endif - /* - * If no macro is pending, save the name of this macro - * for an eventual error message. - */ - if (recursion++ == 0) - macro = tokenp; - else if (recursion == RECURSION_LIMIT) { - cerror("Recursive macro definition of \"%s\"", tokenp->name); - fprintf(stderr, "(Defined by \"%s\")\n", macro->name); - if (rec_recover) { - do { - c = get(); - } while (infile != NULL && infile->fp == NULL); - unget(); - recursion = 0; - return; - } - } - /* - * Here's a macro to expand. - */ - nargs = 0; /* Formals counter */ - parmp = parm; /* Setup parm buffer */ - switch (tokenp->nargs) { - case (-2): /* __LINE__ */ - sprintf(work, "%d", line); - ungetstring(work); - break; - - case (-3): /* __FILE__ */ - for (file = infile; file != NULL; file = file->parent) { - if (file->fp != NULL) { - sprintf(work, "\"%s\"", (file->progname != NULL) - ? file->progname : file->filename); - ungetstring(work); - break; - } - } - break; - - default: - /* - * Nothing funny about this macro. - */ - if (tokenp->nargs < 0) - cfatal("Bug: Illegal __ macro \"%s\"", tokenp->name); - while ((c = skipws()) == '\n') /* Look for (, skipping */ - wrongline = TRUE; /* spaces and newlines */ - if (c != '(') { - /* - * If the programmer writes - * #define foo() ... - * ... - * foo [no ()] - * just write foo to the output stream. - */ - unget(); - cwarn("Macro \"%s\" needs arguments", tokenp->name); - fputs(tokenp->name, pCppOut ); - return; - } - else if (expcollect()) { /* Collect arguments */ - if (tokenp->nargs != nargs) { /* Should be an error? */ - cwarn("Wrong number of macro arguments for \"%s\"", - tokenp->name); - } -#if OSL_DEBUG_LEVEL > 1 - if (debug) - dumpparm("expand"); -#endif - } /* Collect arguments */ - case DEF_NOARGS: /* No parameters just stuffs */ - expstuff(tokenp); /* Do actual parameters */ - } /* nargs switch */ -} - -FILE_LOCAL int -expcollect() -/* - * Collect the actual parameters for this macro. TRUE if ok. - */ -{ - register int c; - register int paren; /* For embedded ()'s */ - for (;;) { - paren = 0; /* Collect next arg. */ - while ((c = skipws()) == '\n') /* Skip over whitespace */ - wrongline = TRUE; /* and newlines. */ - if (c == ')') { /* At end of all args? */ - /* - * Note that there is a guard byte in parm[] - * so we don't have to check for overflow here. - */ - *parmp = EOS; /* Make sure terminated */ - break; /* Exit collection loop */ - } - else if (nargs >= LASTPARM) - cfatal("Too many arguments in macro expansion", NULLST); - parlist[nargs++] = parmp; /* At start of new arg */ - for (;; c = cget()) { /* Collect arg's bytes */ - if (c == EOF_CHAR) { - cerror("end of file within macro argument", NULLST); - return (FALSE); /* Sorry. */ - } - else if (c == '\\') { /* Quote next character */ - charput(c); /* Save the \ for later */ - charput(cget()); /* Save the next char. */ - continue; /* And go get another */ - } - else if (type[c] == QUO) { /* Start of string? */ - scanstring(c, charput); /* Scan it off */ - continue; /* Go get next char */ - } - else if (c == '(') /* Worry about balance */ - paren++; /* To know about commas */ - else if (c == ')') { /* Other side too */ - if (paren == 0) { /* At the end? */ - unget(); /* Look at it later */ - break; /* Exit arg getter. */ - } - paren--; /* More to come. */ - } - else if (c == ',' && paren == 0) /* Comma delimits args */ - break; - else if (c == '\n') /* Newline inside arg? */ - wrongline = TRUE; /* We'll need a #line */ - charput(c); /* Store this one */ - } /* Collect an argument */ - charput(EOS); /* Terminate argument */ -#if OSL_DEBUG_LEVEL > 1 - if (debug) - fprintf( pCppOut, "parm[%d] = \"%s\"\n", nargs, parlist[nargs - 1]); -#endif - } /* Collect all args. */ - return (TRUE); /* Normal return */ -} - -FILE_LOCAL -void expstuff(DEFBUF* tokenp) -/* - * Stuff the macro body, replacing formal parameters by actual parameters. - */ -{ - register int c; /* Current character */ - register char *inp; /* -> repl string */ - register char *defp; /* -> macro output buff */ - int size; /* Actual parm. size */ - char *defend; /* -> output buff end */ - int string_magic; /* String formal hack */ - FILEINFO *file; /* Funny #include */ - extern FILEINFO *getfile(); - - file = getfile(NBUFF, tokenp->name); - inp = tokenp->repl; /* -> macro replacement */ - defp = file->buffer; /* -> output buffer */ - defend = defp + (NBUFF - 1); /* Note its end */ - if (inp != NULL) { - while ((c = (*inp++ & 0xFF)) != EOS) { -#ifdef SOLAR - if (c == DEL) { - c = (*inp++ & 0xFF); -#else - if (c >= MAC_PARM && c <= (MAC_PARM + PAR_MAC)) { -#endif - string_magic = (c == (MAC_PARM + PAR_MAC)); - if (string_magic) - c = (*inp++ & 0xFF); - /* - * Replace formal parameter by actual parameter string. - */ - if ((c -= MAC_PARM) < nargs) { - size = strlen(parlist[c]); - if ((defp + size) >= defend) - goto nospace; - /* - * Erase the extra set of quotes. - */ - if (string_magic && defp[-1] == parlist[c][0]) { - strcpy(defp-1, parlist[c]); - defp += (size - 2); - } - else { - strcpy(defp, parlist[c]); - defp += size; - } - } - } - else if (defp >= defend) { -nospace: cfatal("Out of space in macro \"%s\" arg expansion", - tokenp->name); - } - else { - *defp++ = (char)c; - } - } - } - *defp = EOS; -#if OSL_DEBUG_LEVEL > 1 - if (debug > 1) - fprintf( pCppOut, "macroline: \"%s\"\n", file->buffer); -#endif -} - -#if OSL_DEBUG_LEVEL > 1 -void dumpparm(char* why) -/* - * Dump parameter list. - */ -{ - register int i; - - fprintf( pCppOut, "dump of %d parameters (%d bytes total) %s\n", - nargs, parmp - parm, why); - for (i = 0; i < nargs; i++) { - fprintf( pCppOut, "parm[%d] (%d) = \"%s\"\n", - i + 1, (int)strlen(parlist[i]), parlist[i]); - } -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/cpp5.c b/rsc/source/rscpp/cpp5.c deleted file mode 100644 index 1ee3ed56eb..0000000000 --- a/rsc/source/rscpp/cpp5.c +++ /dev/null @@ -1,928 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <stdio.h> -#include <ctype.h> -#include "cppdef.h" -#include "cpp.h" - -/* - * Evaluate an #if expression. - */ - -static char *opname[] = { /* For debug and error messages */ -"end of expression", "val", "id", - "+", "-", "*", "/", "%", - "<<", ">>", "&", "|", "^", - "==", "!=", "<", "<=", ">=", ">", - "&&", "||", "?", ":", ",", - "unary +", "unary -", "~", "!", "(", ")", "(none)", -}; - -/* - * opdope[] has the operator precedence: - * Bits - * 7 Unused (so the value is always positive) - * 6-2 Precedence (000x .. 017x) - * 1-0 Binary op. flags: - * 01 The binop flag should be set/cleared when this op is seen. - * 10 The new value of the binop flag. - * Note: Expected, New binop - * constant 0 1 Binop, end, or ) should follow constants - * End of line 1 0 End may not be preceeded by an operator - * binary 1 0 Binary op follows a value, value follows. - * unary 0 0 Unary op doesn't follow a value, value follows - * ( 0 0 Doesn't follow value, value or unop follows - * ) 1 1 Follows value. Op follows. - */ - -static char opdope[OP_MAX] = { - 0001, /* End of expression */ - 0002, /* Digit */ - 0000, /* Letter (identifier) */ - 0141, 0141, 0151, 0151, 0151, /* ADD, SUB, MUL, DIV, MOD */ - 0131, 0131, 0101, 0071, 0071, /* ASL, ASR, AND, OR, XOR */ - 0111, 0111, 0121, 0121, 0121, 0121, /* EQ, NE, LT, LE, GE, GT */ - 0061, 0051, 0041, 0041, 0031, /* ANA, ORO, QUE, COL, CMA */ -/* - * Unary op's follow - */ - 0160, 0160, 0160, 0160, /* NEG, PLU, COM, NOT */ - 0170, 0013, 0023, /* LPA, RPA, END */ -}; -/* - * OP_QUE and OP_RPA have alternate precedences: - */ -#define OP_RPA_PREC 0013 -#define OP_QUE_PREC 0034 - -/* - * S_ANDOR and S_QUEST signal "short-circuit" boolean evaluation, so that - * #if FOO != 0 && 10 / FOO ... - * doesn't generate an error message. They are stored in optab.skip. - */ -#define S_ANDOR 2 -#define S_QUEST 1 - -typedef struct optab { - char op; /* Operator */ - char prec; /* Its precedence */ - char skip; /* Short-circuit: TRUE to skip */ -} OPTAB; -static int evalue; /* Current value from evallex() */ - -#ifdef nomacargs -FILE_LOCAL int -isbinary(op) -register int op; -{ - return (op >= FIRST_BINOP && op <= LAST_BINOP); -} - -FILE_LOCAL int -isunary(op) -register int op; -{ - return (op >= FIRST_UNOP && op <= LAST_UNOP); -} -#else -#define isbinary(op) (op >= FIRST_BINOP && op <= LAST_BINOP) -#define isunary(op) (op >= FIRST_UNOP && op <= LAST_UNOP) -#endif - -/* - * The following definitions are used to specify basic variable sizes. - */ - -#ifndef S_CHAR -#define S_CHAR (sizeof (char)) -#endif -#ifndef S_SINT -#define S_SINT (sizeof (short int)) -#endif -#ifndef S_INT -#define S_INT (sizeof (int)) -#endif -#ifndef S_LINT -#define S_LINT (sizeof (long int)) -#endif -#ifndef S_FLOAT -#define S_FLOAT (sizeof (float)) -#endif -#ifndef S_DOUBLE -#define S_DOUBLE (sizeof (double)) -#endif -#ifndef S_PCHAR -#define S_PCHAR (sizeof (char *)) -#endif -#ifndef S_PSINT -#define S_PSINT (sizeof (short int *)) -#endif -#ifndef S_PINT -#define S_PINT (sizeof (int *)) -#endif -#ifndef S_PLINT -#define S_PLINT (sizeof (long int *)) -#endif -#ifndef S_PFLOAT -#define S_PFLOAT (sizeof (float *)) -#endif -#ifndef S_PDOUBLE -#define S_PDOUBLE (sizeof (double *)) -#endif -#ifndef S_PFPTR -#define S_PFPTR (sizeof (int (*)())) -#endif - -typedef struct types { - short type; /* This is the bit if */ - char *name; /* this is the token word */ -} TYPES; - -static TYPES basic_types[] = { - { T_CHAR, "char", }, - { T_INT, "int", }, - { T_FLOAT, "float", }, - { T_DOUBLE, "double", }, - { T_SHORT, "short", }, - { T_LONG, "long", }, - { T_SIGNED, "signed", }, - { T_UNSIGNED, "unsigned", }, - { 0, NULL, }, /* Signal end */ -}; - -/* - * Test_table[] is used to test for illegal combinations. - */ -static short test_table[] = { - T_FLOAT | T_DOUBLE | T_LONG | T_SHORT, - T_FLOAT | T_DOUBLE | T_CHAR | T_INT, - T_FLOAT | T_DOUBLE | T_SIGNED | T_UNSIGNED, - T_LONG | T_SHORT | T_CHAR, - 0 /* end marker */ -}; - -/* - * The order of this table is important -- it is also referenced by - * the command line processor to allow run-time overriding of the - * built-in size values. The order must not be changed: - * char, short, int, long, float, double (func pointer) - */ -SIZES size_table[] = { - { T_CHAR, S_CHAR, S_PCHAR }, /* char */ - { T_SHORT, S_SINT, S_PSINT }, /* short int */ - { T_INT, S_INT, S_PINT }, /* int */ - { T_LONG, S_LINT, S_PLINT }, /* long */ - { T_FLOAT, S_FLOAT, S_PFLOAT }, /* float */ - { T_DOUBLE, S_DOUBLE, S_PDOUBLE }, /* double */ - { T_FPTR, 0, S_PFPTR }, /* int (*()) */ - { 0, 0, 0 }, /* End of table */ -}; - -void InitCpp5() -{ - -} - - - -int -eval() -/* - * Evaluate an expression. Straight-forward operator precedence. - * This is called from control() on encountering an #if statement. - * It calls the following routines: - * evallex Lexical analyser -- returns the type and value of - * the next input token. - * evaleval Evaluate the current operator, given the values on - * the value stack. Returns a pointer to the (new) - * value stack. - * For compatiblity with older cpp's, this return returns 1 (TRUE) - * if a syntax error is detected. - */ -{ - register int op; /* Current operator */ - register int *valp; /* -> value vector */ - register OPTAB *opp; /* Operator stack */ - int prec; /* Op precedence */ - int binop; /* Set if binary op. needed */ - int op1; /* Operand from stack */ - int skip; /* For short-circuit testing */ - int value[NEXP]; /* Value stack */ - OPTAB opstack[NEXP]; /* Operand stack */ - extern int *evaleval(); /* Does actual evaluation */ - valp = value; - opp = opstack; - opp->op = OP_END; /* Mark bottom of stack */ - opp->prec = opdope[OP_END]; /* And its precedence */ - opp->skip = 0; /* Not skipping now */ - binop = 0; -again: ; -#ifdef DEBUG_EVAL - fprintf( pCppOut, "In #if at again: skip = %d, binop = %d, line is: %s", - opp->skip, binop, infile->bptr); -#endif - if ((op = evallex(opp->skip)) == OP_SUB && binop == 0) - op = OP_NEG; /* Unary minus */ - else if (op == OP_ADD && binop == 0) - op = OP_PLU; /* Unary plus */ - else if (op == OP_FAIL) - return (1); /* Error in evallex */ -#ifdef DEBUG_EVAL - fprintf( pCppOut, "op = %s, opdope = %03o, binop = %d, skip = %d\n", - opname[op], opdope[op], binop, opp->skip); -#endif - if (op == DIG) { /* Value? */ - if (binop != 0) { - cerror("misplaced constant in #if", NULLST); - return (1); - } - else if (valp >= &value[NEXP-1]) { - cerror("#if value stack overflow", NULLST); - return (1); - } - else { -#ifdef DEBUG_EVAL - fprintf( pCppOut, "pushing %d onto value stack[%d]\n", - evalue, valp - value); -#endif - *valp++ = evalue; - binop = 1; - } - goto again; - } - else if (op > OP_END) { - cerror("Illegal #if line", NULLST); - return (1); - } - prec = opdope[op]; - if (binop != (prec & 1)) { - cerror("Operator %s in incorrect context", opname[op]); - return (1); - } - binop = (prec & 2) >> 1; - for (;;) { -#ifdef DEBUG_EVAL - fprintf( pCppOut, "op %s, prec %d., stacked op %s, prec %d, skip %d\n", - opname[op], prec, opname[opp->op], opp->prec, opp->skip); -#endif - if (prec > opp->prec) { - if (op == OP_LPA) - prec = OP_RPA_PREC; - else if (op == OP_QUE) - prec = OP_QUE_PREC; - op1 = opp->skip; /* Save skip for test */ - /* - * Push operator onto op. stack. - */ - opp++; - if (opp >= &opstack[NEXP]) { - cerror("expression stack overflow at op \"%s\"", - opname[op]); - return (1); - } - opp->op = (char)op; - opp->prec = (char)prec; - skip = (valp[-1] != 0); /* Short-circuit tester */ - /* - * Do the short-circuit stuff here. Short-circuiting - * stops automagically when operators are evaluated. - */ - if ((op == OP_ANA && !skip) - || (op == OP_ORO && skip)) - opp->skip = S_ANDOR; /* And/or skip starts */ - else if (op == OP_QUE) /* Start of ?: operator */ - opp->skip = (char)((op1 & S_ANDOR) | ((!skip) ? S_QUEST : 0)); - else if (op == OP_COL) { /* : inverts S_QUEST */ - opp->skip = (char)((op1 & S_ANDOR) - | (((op1 & S_QUEST) != 0) ? 0 : S_QUEST)); - } - else { /* Other ops leave */ - opp->skip = (char)op1; /* skipping unchanged. */ - } -#ifdef DEBUG_EVAL - fprintf( pCppOut, "stacking %s, valp[-1] == %d at %s", - opname[op], valp[-1], infile->bptr); - dumpstack(opstack, opp, value, valp); -#endif - goto again; - } - /* - * Pop operator from op. stack and evaluate it. - * End of stack and '(' are specials. - */ - skip = opp->skip; /* Remember skip value */ - switch ((op1 = opp->op)) { /* Look at stacked op */ - case OP_END: /* Stack end marker */ - if (op == OP_EOE) - return (valp[-1]); /* Finished ok. */ - goto again; /* Read another op. */ - - case OP_LPA: /* ( on stack */ - if (op != OP_RPA) { /* Matches ) on input */ - cerror("unbalanced paren's, op is \"%s\"", opname[op]); - return (1); - } - opp--; /* Unstack it */ - /* goto again; -- Fall through */ - - case OP_QUE: - goto again; /* Evaluate true expr. */ - - case OP_COL: /* : on stack. */ - opp--; /* Unstack : */ - if (opp->op != OP_QUE) { /* Matches ? on stack? */ - cerror("Misplaced '?' or ':', previous operator is %s", - opname[(int)opp->op]); - return (1); - } - /* - * Evaluate op1. - */ - default: /* Others: */ - opp--; /* Unstack the operator */ -#ifdef DEBUG_EVAL - fprintf( pCppOut, "Stack before evaluation of %s\n", opname[op1]); - dumpstack(opstack, opp, value, valp); -#endif - valp = evaleval(valp, op1, skip); -#ifdef DEBUG_EVAL - fprintf( pCppOut, "Stack after evaluation\n"); - dumpstack(opstack, opp, value, valp); -#endif - } /* op1 switch end */ - } /* Stack unwind loop */ -} - -FILE_LOCAL int -evallex(int skip) -/* - * Return next eval operator or value. Called from eval(). It - * calls a special-purpose routines for 'char' strings and - * numeric values: - * evalchar called to evaluate 'x' - * evalnum called to evaluate numbers. - */ -{ - register int c, c1, t; - -again: do { /* Collect the token */ - c = skipws(); - if ((c = macroid(c)) == EOF_CHAR || c == '\n') { - unget(); - return (OP_EOE); /* End of expression */ - } - } while ((t = type[c]) == LET && catenate()); - if (t == INV) { /* Total nonsense */ - if (!skip) { - if (isascii(c) && isprint(c)) - cierror("illegal character '%c' in #if", c); - else - cierror("illegal character (%d decimal) in #if", c); - } - return (OP_FAIL); - } - else if (t == QUO) { /* ' or " */ - if (c == '\'') { /* Character constant */ - evalue = evalchar(skip); /* Somewhat messy */ -#ifdef DEBUG_EVAL - fprintf( pCppOut, "evalchar returns %d.\n", evalue); -#endif - return (DIG); /* Return a value */ - } - cerror("Can't use a string in an #if", NULLST); - return (OP_FAIL); - } - else if (t == LET) { /* ID must be a macro */ - if (streq(token, "defined")) { /* Or defined name */ - c1 = c = skipws(); - if (c == '(') /* Allow defined(name) */ - c = skipws(); - if (type[c] == LET) { - evalue = (lookid(c) != NULL); - if (c1 != '(' /* Need to balance */ - || skipws() == ')') /* Did we balance? */ - return (DIG); /* Parsed ok */ - } - cerror("Bad #if ... defined() syntax", NULLST); - return (OP_FAIL); - } - else if (streq(token, "sizeof")) /* New sizeof hackery */ - return (dosizeof()); /* Gets own routine */ - /* - * The Draft ANSI C Standard says that an undefined symbol - * in an #if has the value zero. We are a bit pickier, - * warning except where the programmer was careful to write - * #if defined(foo) ? foo : 0 - */ -#ifdef STRICT_UNDEF - if (!skip) - cwarn("undefined symbol \"%s\" in #if, 0 used", token); -#endif - evalue = 0; - return (DIG); - } - else if (t == DIG) { /* Numbers are harder */ - evalue = evalnum(c); -#ifdef DEBUG_EVAL - fprintf( pCppOut, "evalnum returns %d.\n", evalue); -#endif - } - else if (strchr("!=<>&|\\", c) != NULL) { - /* - * Process a possible multi-byte lexeme. - */ - c1 = cget(); /* Peek at next char */ - switch (c) { - case '!': - if (c1 == '=') - return (OP_NE); - break; - - case '=': - if (c1 != '=') { /* Can't say a=b in #if */ - unget(); - cerror("= not allowed in #if", NULLST); - return (OP_FAIL); - } - return (OP_EQ); - - case '>': - case '<': - if (c1 == c) - return ((c == '<') ? OP_ASL : OP_ASR); - else if (c1 == '=') - return ((c == '<') ? OP_LE : OP_GE); - break; - - case '|': - case '&': - if (c1 == c) - return ((c == '|') ? OP_ORO : OP_ANA); - break; - - case '\\': - if (c1 == '\n') /* Multi-line if */ - goto again; - cerror("Unexpected \\ in #if", NULLST); - return (OP_FAIL); - } - unget(); - } - return (t); -} - -FILE_LOCAL int -dosizeof() -/* - * Process the sizeof (basic type) operation in an #if string. - * Sets evalue to the size and returns - * DIG success - * OP_FAIL bad parse or something. - */ -{ - register int c; - register TYPES *tp; - register SIZES *sizp; - register short *testp; - short typecode; - - if ((c = skipws()) != '(') - goto nogood; - /* - * Scan off the tokens. - */ - typecode = 0; - while (0 != (c = skipws())) { - if ((c = macroid(c)) == EOF_CHAR || c == '\n') - goto nogood; /* End of line is a bug */ - else if (c == '(') { /* thing (*)() func ptr */ - if (skipws() == '*' - && skipws() == ')') { /* We found (*) */ - if (skipws() != '(') /* Let () be optional */ - unget(); - else if (skipws() != ')') - goto nogood; - typecode |= T_FPTR; /* Function pointer */ - } - else { /* Junk is a bug */ - goto nogood; - } - } - else if (type[c] != LET) /* Exit if not a type */ - break; - else if (!catenate()) { /* Maybe combine tokens */ - /* - * Look for this unexpandable token in basic_types. - * The code accepts "int long" as well as "long int" - * which is a minor bug as bugs go (and one shared with - * a lot of C compilers). - */ - for (tp = basic_types; tp->name != NULLST; tp++) { - if (streq(token, tp->name)) - break; - } - if (tp->name == NULLST) { - cerror("#if sizeof, unknown type \"%s\"", token); - return (OP_FAIL); - } - typecode |= tp->type; /* Or in the type bit */ - } - } - /* - * We are at the end of the type scan. Chew off '*' if necessary. - */ - if (c == '*') { - typecode |= T_PTR; - c = skipws(); - } - if (c == ')') { /* Last syntax check */ - for (testp = test_table; *testp != 0; testp++) { - if (!bittest(typecode & *testp)) { - cerror("#if ... sizeof: illegal type combination", NULLST); - return (OP_FAIL); - } - } - /* - * We assume that all function pointers are the same size: - * sizeof (int (*)()) == sizeof (float (*)()) - * We assume that signed and unsigned don't change the size: - * sizeof (signed int) == (sizeof unsigned int) - */ - if ((typecode & T_FPTR) != 0) /* Function pointer */ - typecode = T_FPTR | T_PTR; - else { /* Var or var * datum */ - typecode &= ~(T_SIGNED | T_UNSIGNED); - if ((typecode & (T_SHORT | T_LONG)) != 0) - typecode &= ~T_INT; - } - if ((typecode & ~T_PTR) == 0) { - cerror("#if sizeof() error, no type specified", NULLST); - return (OP_FAIL); - } - /* - * Exactly one bit (and possibly T_PTR) may be set. - */ - for (sizp = size_table; sizp->bits != 0; sizp++) { - if ((typecode & ~T_PTR) == sizp->bits) { - evalue = ((typecode & T_PTR) != 0) - ? sizp->psize : sizp->size; - return (DIG); - } - } /* We shouldn't fail */ - cierror("#if ... sizeof: bug, unknown type code 0x%x", typecode); - return (OP_FAIL); - } - -nogood: unget(); - cerror("#if ... sizeof() syntax error", NULLST); - return (OP_FAIL); -} - -FILE_LOCAL int -bittest(int value) -/* - * TRUE if value is zero or exactly one bit is set in value. - */ -{ -#if (4096 & ~(-4096)) == 0 - return ((value & ~(-value)) == 0); -#else - /* - * Do it the hard way (for non 2's complement machines) - */ - return (value == 0 || value ^ (value - 1) == (value * 2 - 1)); -#endif -} - -FILE_LOCAL int -evalnum(int c) -/* - * Expand number for #if lexical analysis. Note: evalnum recognizes - * the unsigned suffix, but only returns a signed int value. - */ -{ - register int value; - register int base; - register int c1; - - if (c != '0') - base = 10; - else if ((c = cget()) == 'x' || c == 'X') { - base = 16; - c = cget(); - } - else base = 8; - value = 0; - for (;;) { - c1 = c; - if (isascii(c) && isupper(c1)) - c1 = tolower(c1); -#ifdef EBCDIC - if (c1 <= 'f') -#else - if (c1 >= 'a') -#endif - c1 -= ('a' - 10); - else c1 -= '0'; - if (c1 < 0 || c1 >= base) - break; - value *= base; - value += c1; - c = cget(); - } - if (c == 'u' || c == 'U') /* Unsigned nonsense */ - c = cget(); - unget(); - return (value); -} - -FILE_LOCAL int -evalchar(int skip) -/* - * Get a character constant - */ -{ - register int c; - register int value; - register int count; - - instring = TRUE; - if ((c = cget()) == '\\') { - switch ((c = cget())) { - case 'a': /* New in Standard */ -#if ('a' == '\a' || '\a' == ALERT) - value = ALERT; /* Use predefined value */ -#else - value = '\a'; /* Use compiler's value */ -#endif - break; - - case 'b': - value = '\b'; - break; - - case 'f': - value = '\f'; - break; - - case 'n': - value = '\n'; - break; - - case 'r': - value = '\r'; - break; - - case 't': - value = '\t'; - break; - - case 'v': /* New in Standard */ -#if ('v' == '\v' || '\v' == VT) - value = VT; /* Use predefined value */ -#else - value = '\v'; /* Use compiler's value */ -#endif - break; - - case 'x': /* '\xFF' */ - count = 3; - value = 0; - while ((((c = get()) >= '0' && c <= '9') - || (c >= 'a' && c <= 'f') - || (c >= 'A' && c <= 'F')) - && (--count >= 0)) { - value *= 16; -#ifdef EBCDIC - value += (c <= '9') ? (c - '0') : ((c & 0xF) + 9); -#else - value += (c >= '0') ? (c - '0') : ((c & 0xF) + 9); -#endif - } - unget(); - break; - - default: - if (c >= '0' && c <= '7') { - count = 3; - value = 0; - while (c >= '0' && c <= '7' && --count >= 0) { - value *= 8; - value += (c - '0'); - c = get(); - } - unget(); - } - else value = c; - break; - } - } - else if (c == '\'') - value = 0; - else value = c; - /* - * We warn on multi-byte constants and try to hack - * (big|little)endian machines. - */ -#if BIG_ENDIAN - count = 0; -#endif - while ((c = get()) != '\'' && c != EOF_CHAR && c != '\n') { - if (!skip) - ciwarn("multi-byte constant '%c' isn't portable", c); -#if BIG_ENDIAN - count += BITS_CHAR; - value += (c << count); -#else - value <<= BITS_CHAR; - value += c; -#endif - } - instring = FALSE; - return (value); -} - -FILE_LOCAL int * -evaleval(int* valp, int op, int skip) -/* - * Apply the argument operator to the data on the value stack. - * One or two values are popped from the value stack and the result - * is pushed onto the value stack. - * - * OP_COL is a special case. - * - * evaleval() returns the new pointer to the top of the value stack. - */ -{ - register int v1, v2 = 0; - - if (isbinary(op)) - v2 = *--valp; - v1 = *--valp; -#ifdef DEBUG_EVAL - fprintf( pCppOut, "%s op %s", (isbinary(op)) ? "binary" : "unary", - opname[op]); - if (isbinary(op)) - fprintf( pCppOut, ", v2 = %d.", v2); - fprintf( pCppOut, ", v1 = %d.\n", v1); -#endif - switch (op) { - case OP_EOE: - break; - - case OP_ADD: - v1 += v2; - break; - - case OP_SUB: - v1 -= v2; - break; - - case OP_MUL: - v1 *= v2; - break; - - case OP_DIV: - case OP_MOD: - if (v2 == 0) { - if (!skip) { - cwarn("%s by zero in #if, zero result assumed", - (op == OP_DIV) ? "divide" : "mod"); - } - v1 = 0; - } - else if (op == OP_DIV) - v1 /= v2; - else - v1 %= v2; - break; - - case OP_ASL: - v1 <<= v2; - break; - - case OP_ASR: - v1 >>= v2; - break; - - case OP_AND: - v1 &= v2; - break; - - case OP_OR: - v1 |= v2; - break; - - case OP_XOR: - v1 ^= v2; - break; - - case OP_EQ: - v1 = (v1 == v2); - break; - - case OP_NE: - v1 = (v1 != v2); - break; - - case OP_LT: - v1 = (v1 < v2); - break; - - case OP_LE: - v1 = (v1 <= v2); - break; - - case OP_GE: - v1 = (v1 >= v2); - break; - - case OP_GT: - v1 = (v1 > v2); - break; - - case OP_ANA: - v1 = (v1 && v2); - break; - - case OP_ORO: - v1 = (v1 || v2); - break; - - case OP_COL: - /* - * v1 has the "true" value, v2 the "false" value. - * The top of the value stack has the test. - */ - v1 = (*--valp) ? v1 : v2; - break; - - case OP_NEG: - v1 = (-v1); - break; - - case OP_PLU: - break; - - case OP_COM: - v1 = ~v1; - break; - - case OP_NOT: - v1 = !v1; - break; - - default: - cierror("#if bug, operand = %d.", op); - v1 = 0; - } - *valp++ = v1; - return (valp); -} - -#ifdef DEBUG_EVAL -dumpstack(opstack, opp, value, valp) -OPTAB opstack[NEXP]; /* Operand stack */ -register OPTAB *opp; /* Operator stack */ -int value[NEXP]; /* Value stack */ -register int *valp; /* -> value vector */ -{ - fprintf( pCppOut, "index op prec skip name -- op stack at %s", infile->bptr); - while (opp > opstack) { - fprintf( pCppOut, " [%2d] %2d %03o %d %s\n", opp - opstack, - opp->op, opp->prec, opp->skip, opname[opp->op]); - opp--; - } - while (--valp >= value) { - fprintf( pCppOut, "value[%d] = %d\n", (valp - value), *valp); - } -} -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/cpp6.c b/rsc/source/rscpp/cpp6.c deleted file mode 100644 index b6ac712faa..0000000000 --- a/rsc/source/rscpp/cpp6.c +++ /dev/null @@ -1,1142 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -#include <stdio.h> -#include <ctype.h> -#include <string.h> -#include "cppdef.h" -#include "cpp.h" - -/*ER evaluate macros to pDefOut */ - -/* - * skipnl() skips over input text to the end of the line. - * skipws() skips over "whitespace" (spaces or tabs), but - * not skip over the end of the line. It skips over - * TOK_SEP, however (though that shouldn't happen). - * scanid() reads the next token (C identifier) into token[]. - * The caller has already read the first character of - * the identifier. Unlike macroid(), the token is - * never expanded. - * macroid() reads the next token (C identifier) into token[]. - * If it is a #defined macro, it is expanded, and - * macroid() returns TRUE, otherwise, FALSE. - * catenate() Does the dirty work of token concatenation, TRUE if it did. - * scanstring() Reads a string from the input stream, calling - * a user-supplied function for each character. - * This function may be output() to write the - * string to the output file, or save() to save - * the string in the work buffer. - * scannumber() Reads a C numeric constant from the input stream, - * calling the user-supplied function for each - * character. (output() or save() as noted above.) - * save() Save one character in the work[] buffer. - * savestring() Saves a string in malloc() memory. - * getfile() Initialize a new FILEINFO structure, called when - * #include opens a new file, or a macro is to be - * expanded. - * getmem() Get a specified number of bytes from malloc memory. - * output() Write one character to stdout (calling PUTCHAR) -- - * implemented as a function so its address may be - * passed to scanstring() and scannumber(). - * lookid() Scans the next token (identifier) from the input - * stream. Looks for it in the #defined symbol table. - * Returns a pointer to the definition, if found, or NULL - * if not present. The identifier is stored in token[]. - * defnedel() Define enter/delete subroutine. Updates the - * symbol table. - * get() Read the next byte from the current input stream, - * handling end of (macro/file) input and embedded - * comments appropriately. Note that the global - * instring is -- essentially -- a parameter to get(). - * cget() Like get(), but skip over TOK_SEP. - * unget() Push last gotten character back on the input stream. - * cerror(), cwarn(), cfatal(), cierror(), ciwarn() - * These routines format an print messages to the user. - * cerror & cwarn take a format and a single string argument. - * cierror & ciwarn take a format and a single int (char) argument. - * cfatal takes a format and a single string argument. - */ - -/* - * This table must be rewritten for a non-Ascii machine. - * - * Note that several "non-visible" characters have special meaning: - * Hex 1D DEF_MAGIC -- a flag to prevent #define recursion. - * Hex 1E TOK_SEP -- a delimiter for token concatenation - * Hex 1F COM_SEP -- a zero-width whitespace for comment concatenation - */ -#if TOK_SEP != 0x1E || COM_SEP != 0x1F || DEF_MAGIC != 0x1D - << error type table is not correct >> -#endif - -#if OK_DOLLAR -#define DOL LET -#else -#define DOL 000 -#endif - -#ifdef EBCDIC - -char type[256] = { /* Character type codes Hex */ - END, 000, 000, 000, 000, SPA, 000, 000, /* 00 */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 08 */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 10 */ - 000, 000, 000, 000, 000, LET, 000, SPA, /* 18 */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 20 */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 28 */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 30 */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 38 */ - SPA, 000, 000, 000, 000, 000, 000, 000, /* 40 */ - 000, 000, 000, DOT, OP_LT,OP_LPA,OP_ADD, OP_OR, /* 48 .<(+| */ -OP_AND, 000, 000, 000, 000, 000, 000, 000, /* 50 & */ - 000, 000,OP_NOT, DOL,OP_MUL,OP_RPA, 000,OP_XOR, /* 58 !$*);^ */ -OP_SUB,OP_DIV, 000, 000, 000, 000, 000, 000, /* 60 -/ */ - 000, 000, 000, 000,OP_MOD, LET, OP_GT,OP_QUE, /* 68 ,%_>? */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 70 */ - 000, 000,OP_COL, 000, 000, QUO, OP_EQ, QUO, /* 78 `:#@'=" */ - 000, LET, LET, LET, LET, LET, LET, LET, /* 80 abcdefg */ - LET, LET, 000, 000, 000, 000, 000, 000, /* 88 hi */ - 000, LET, LET, LET, LET, LET, LET, LET, /* 90 jklmnop */ - LET, LET, 000, 000, 000, 000, 000, 000, /* 98 qr */ - 000,OP_NOT, LET, LET, LET, LET, LET, LET, /* A0 ~stuvwx */ - LET, LET, 000, 000, 000, 000, 000, 000, /* A8 yz [ */ - 000, 000, 000, 000, 000, 000, 000, 000, /* B0 */ - 000, 000, 000, 000, 000, 000, 000, 000, /* B8 ] */ - 000, LET, LET, LET, LET, LET, LET, LET, /* C0 {ABCDEFG */ - LET, LET, 000, 000, 000, 000, 000, 000, /* C8 HI */ - 000, LET, LET, LET, LET, LET, LET, LET, /* D0 }JKLMNOP */ - LET, LET, 000, 000, 000, 000, 000, 000, /* D8 QR */ - BSH, 000, LET, LET, LET, LET, LET, LET, /* E0 \ STUVWX */ - LET, LET, 000, 000, 000, 000, 000, 000, /* E8 YZ */ - DIG, DIG, DIG, DIG, DIG, DIG, DIG, DIG, /* F0 01234567 */ - DIG, DIG, 000, 000, 000, 000, 000, 000, /* F8 89 */ -}; - -#else - -char type[256] = { /* Character type codes Hex */ - END, 000, 000, 000, 000, 000, 000, 000, /* 00 */ - 000, SPA, 000, 000, 000, 000, 000, 000, /* 08 */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 10 */ - 000, 000, 000, 000, 000, LET, 000, SPA, /* 18 */ - SPA,OP_NOT, QUO, 000, DOL,OP_MOD,OP_AND, QUO, /* 20 !"#$%&' */ -OP_LPA,OP_RPA,OP_MUL,OP_ADD, 000,OP_SUB, DOT,OP_DIV, /* 28 ()*+,-./ */ - DIG, DIG, DIG, DIG, DIG, DIG, DIG, DIG, /* 30 01234567 */ - DIG, DIG,OP_COL, 000, OP_LT, OP_EQ, OP_GT,OP_QUE, /* 38 89:;<=>? */ - 000, LET, LET, LET, LET, LET, LET, LET, /* 40 @ABCDEFG */ - LET, LET, LET, LET, LET, LET, LET, LET, /* 48 HIJKLMNO */ - LET, LET, LET, LET, LET, LET, LET, LET, /* 50 PQRSTUVW */ - LET, LET, LET, 000, BSH, 000,OP_XOR, LET, /* 58 XYZ[\]^_ */ - 000, LET, LET, LET, LET, LET, LET, LET, /* 60 `abcdefg */ - LET, LET, LET, LET, LET, LET, LET, LET, /* 68 hijklmno */ - LET, LET, LET, LET, LET, LET, LET, LET, /* 70 pqrstuvw */ - LET, LET, LET, 000, OP_OR, 000,OP_NOT, 000, /* 78 xyz{|}~ */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ - 000, 000, 000, 000, 000, 000, 000, 000, /* 80 .. FF */ -}; - -#endif - -/* - * C P P S y m b o l T a b l e s - */ - -/* - * SBSIZE defines the number of hash-table slots for the symbol table. - * It must be a power of 2. - */ -#ifndef SBSIZE -#define SBSIZE 64 -#endif -#define SBMASK (SBSIZE - 1) -#if (SBSIZE ^ SBMASK) != ((SBSIZE * 2) - 1) - << error, SBSIZE must be a power of 2 >> -#endif - - -static DEFBUF *symtab[SBSIZE]; /* Symbol table queue headers */ - -void InitCpp6() -{ - int i; - for( i = 0; i < SBSIZE; i++ ) - symtab[ i ] = NULL; -} - - - -void skipnl() -/* - * Skip to the end of the current input line. - */ -{ - register int c; - - do { /* Skip to newline */ - c = get(); - } while (c != '\n' && c != EOF_CHAR); -} - -int -skipws() -/* - * Skip over whitespace - */ -{ - register int c; - - do { /* Skip whitespace */ - c = get(); -#if COMMENT_INVISIBLE - } while (type[c] == SPA || c == COM_SEP); -#else - } while (type[c] == SPA); -#endif - return (c); -} - -void scanid(int c) -/* - * Get the next token (an id) into the token buffer. - * Note: this code is duplicated in lookid(). - * Change one, change both. - */ -{ - register char *bp; - - if (c == DEF_MAGIC) /* Eat the magic token */ - c = get(); /* undefiner. */ - bp = token; - do { - if (bp < &token[IDMAX]) /* token dim is IDMAX+1 */ - *bp++ = (char)c; - c = get(); - } while (type[c] == LET || type[c] == DIG); - unget(); - *bp = EOS; -} - -int -macroid(int c) -/* - * If c is a letter, scan the id. if it's #defined, expand it and scan - * the next character and try again. - * - * Else, return the character. If type[c] is a LET, the token is in token. - */ -{ - register DEFBUF *dp; - - if (infile != NULL && infile->fp != NULL) - recursion = 0; - while (type[c] == LET && (dp = lookid(c)) != NULL) { - expand(dp); - c = get(); - } - return (c); -} - -int -catenate() -/* - * A token was just read (via macroid). - * If the next character is TOK_SEP, concatenate the next token - * return TRUE -- which should recall macroid after refreshing - * macroid's argument. If it is not TOK_SEP, unget() the character - * and return FALSE. - */ -{ - register int c; - register char *token1; - -#if OK_CONCAT - if (get() != TOK_SEP) { /* Token concatenation */ - unget(); - return (FALSE); - } - else { - token1 = savestring(token); /* Save first token */ - c = macroid(get()); /* Scan next token */ - switch(type[c]) { /* What was it? */ - case LET: /* An identifier, ... */ - if (strlen(token1) + strlen(token) >= NWORK) - cfatal("work buffer overflow doing %s #", token1); - sprintf(work, "%s%s", token1, token); - break; - - case DIG: /* A digit string */ - strcpy(work, token1); - workp = work + strlen(work); - do { - save(c); - } while ((c = get()) != TOK_SEP); - /* - * The trailing TOK_SEP is no longer needed. - */ - save(EOS); - break; - - default: /* An error, ... */ -#if ! COMMENT_INVISIBLE - if (isprint(c)) - cierror("Strange character '%c' after #", c); - else - cierror("Strange character (%d.) after #", c); -#endif - strcpy(work, token1); - unget(); - break; - } - /* - * work has the concatenated token and token1 has - * the first token (no longer needed). Unget the - * new (concatenated) token after freeing token1. - * Finally, setup to read the new token. - */ - free(token1); /* Free up memory */ - ungetstring(work); /* Unget the new thing, */ - return (TRUE); - } -#else - return (FALSE); /* Not supported */ -#endif -} - -int -scanstring(int delim, -#ifndef _NO_PROTO -void (*outfun)( int ) /* BP */ /* Output function */ -#else -void (*outfun)() /* BP */ -#endif -) -/* - * Scan off a string. Warning if terminated by newline or EOF. - * outfun() outputs the character -- to a buffer if in a macro. - * TRUE if ok, FALSE if error. - */ -{ - register int c; - - instring = TRUE; /* Don't strip comments */ - (*outfun)(delim); - while ((c = get()) != delim - && c != '\n' - && c != EOF_CHAR) { - - if (c != DEF_MAGIC) - (*outfun)(c); - if (c == '\\') - (*outfun)(get()); - } - instring = FALSE; - if (c == delim) { - (*outfun)(c); - return (TRUE); - } - else { - cerror("Unterminated string", NULLST); - unget(); - return (FALSE); - } -} - -void scannumber(int c, -#ifndef _NO_PROTO -register void (*outfun)( int ) /* BP */ /* Output/store func */ -#else -register void (*outfun)() /* BP */ -#endif -) -/* - * Process a number. We know that c is from 0 to 9 or dot. - * Algorithm from Dave Conroy's Decus C. - */ -{ - register int radix; /* 8, 10, or 16 */ - int expseen; /* 'e' seen in floater */ - int signseen; /* '+' or '-' seen */ - int octal89; /* For bad octal test */ - int dotflag; /* TRUE if '.' was seen */ - - expseen = FALSE; /* No exponent seen yet */ - signseen = TRUE; /* No +/- allowed yet */ - octal89 = FALSE; /* No bad octal yet */ - radix = 10; /* Assume decimal */ - if ((dotflag = (c == '.')) != FALSE) { /* . something? */ - (*outfun)('.'); /* Always out the dot */ - if (type[(c = get())] != DIG) { /* If not a float numb, */ - unget(); /* Rescan strange char */ - return; /* All done for now */ - } - } /* End of float test */ - else if (c == '0') { /* Octal or hex? */ - (*outfun)(c); /* Stuff initial zero */ - radix = 8; /* Assume it's octal */ - c = get(); /* Look for an 'x' */ - if (c == 'x' || c == 'X') { /* Did we get one? */ - radix = 16; /* Remember new radix */ - (*outfun)(c); /* Stuff the 'x' */ - c = get(); /* Get next character */ - } - } - for (;;) { /* Process curr. char. */ - /* - * Note that this algorithm accepts "012e4" and "03.4" - * as legitimate floating-point numbers. - */ - if (radix != 16 && (c == 'e' || c == 'E')) { - if (expseen) /* Already saw 'E'? */ - break; /* Exit loop, bad nbr. */ - expseen = TRUE; /* Set exponent seen */ - signseen = FALSE; /* We can read '+' now */ - radix = 10; /* Decimal exponent */ - } - else if (radix != 16 && c == '.') { - if (dotflag) /* Saw dot already? */ - break; /* Exit loop, two dots */ - dotflag = TRUE; /* Remember the dot */ - radix = 10; /* Decimal fraction */ - } - else if (c == '+' || c == '-') { /* 1.0e+10 */ - if (signseen) /* Sign in wrong place? */ - break; /* Exit loop, not nbr. */ - /* signseen = TRUE; */ /* Remember we saw it */ - } - else { /* Check the digit */ - switch (c) { - case '8': case '9': /* Sometimes wrong */ - octal89 = TRUE; /* Do check later */ - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - break; /* Always ok */ - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - if (radix == 16) /* Alpha's are ok only */ - break; /* if reading hex. */ - default: /* At number end */ - goto done; /* Break from for loop */ - } /* End of switch */ - } /* End general case */ - (*outfun)(c); /* Accept the character */ - signseen = TRUE; /* Don't read sign now */ - c = get(); /* Read another char */ - } /* End of scan loop */ - /* - * When we break out of the scan loop, c contains the first - * character (maybe) not in the number. If the number is an - * integer, allow a trailing 'L' for long and/or a trailing 'U' - * for unsigned. If not those, push the trailing character back - * on the input stream. Floating point numbers accept a trailing - * 'L' for "long double". - */ -done: if (dotflag || expseen) { /* Floating point? */ - if (c == 'l' || c == 'L') { - (*outfun)(c); - get(); /* Ungotten later */ - } - } - else { /* Else it's an integer */ - /* - * We know that dotflag and expseen are both zero, now: - * dotflag signals "saw 'L'", and - * expseen signals "saw 'U'". - */ - for (;;) { - switch (c) { - case 'l': - case 'L': - if (dotflag) - goto nomore; - dotflag = TRUE; - break; - - case 'u': - case 'U': - if (expseen) - goto nomore; - expseen = TRUE; - break; - - default: - goto nomore; - } - (*outfun)(c); /* Got 'L' or 'U'. */ - c = get(); /* Look at next, too. */ - } - } -nomore: unget(); /* Not part of a number */ - if (octal89 && radix == 8) - cwarn("Illegal digit in octal number", NULLST); -} - -void save(int c) -{ - if (workp >= &work[NWORK]) { - work[NWORK-1] = '\0'; - cfatal("Work buffer overflow: %s", work); - } - else *workp++ = (char)c; -} - -char * -savestring(char* text) -/* - * Store a string into free memory. - */ -{ - register char *result; - - result = getmem(strlen(text) + 1); - strcpy(result, text); - return (result); -} - -FILEINFO * -getfile(int bufsize, char* name) -/* - * Common FILEINFO buffer initialization for a new file or macro. - */ -{ - register FILEINFO *file; - register int size; - - size = strlen(name); /* File/macro name */ - file = (FILEINFO *) getmem(sizeof (FILEINFO) + bufsize + size); - file->parent = infile; /* Chain files together */ - file->fp = NULL; /* No file yet */ - file->filename = savestring(name); /* Save file/macro name */ - file->progname = NULL; /* No #line seen yet */ - file->unrecur = 0; /* No macro fixup */ - file->bptr = file->buffer; /* Initialize line ptr */ - file->buffer[0] = EOS; /* Force first read */ - file->line = 0; /* (Not used just yet) */ - if (infile != NULL) /* If #include file */ - infile->line = line; /* Save current line */ - infile = file; /* New current file */ - line = 1; /* Note first line */ - return (file); /* All done. */ -} - -char * -getmem(int size) -/* - * Get a block of free memory. - */ -{ - register char *result; - - if ((result = malloc((unsigned) size)) == NULL) - cfatal("Out of memory", NULLST); - return (result); -} - -DEFBUF * -lookid(int c) -/* - * Look for the next token in the symbol table. Returns token in "token". - * If found, returns the table pointer; Else returns NULL. - */ -{ - register int nhash; - register DEFBUF *dp; - register char *np; - int temp = 0; - int isrecurse; /* For #define foo foo */ - - np = token; - nhash = 0; - if (0 != (isrecurse = (c == DEF_MAGIC))) /* If recursive macro */ - c = get(); /* hack, skip DEF_MAGIC */ - do { - if (np < &token[IDMAX]) { /* token dim is IDMAX+1 */ - *np++ = (char)c; /* Store token byte */ - nhash += c; /* Update hash value */ - } - c = get(); /* And get another byte */ - } while (type[c] == LET || type[c] == DIG); - unget(); /* Rescan terminator */ - *np = EOS; /* Terminate token */ - if (isrecurse) /* Recursive definition */ - return (NULL); /* undefined just now */ - nhash += (np - token); /* Fix hash value */ - dp = symtab[nhash & SBMASK]; /* Starting bucket */ - while (dp != (DEFBUF *) NULL) { /* Search symbol table */ - if (dp->hash == nhash /* Fast precheck */ - && (temp = strcmp(dp->name, token)) >= 0) - break; - dp = dp->link; /* Nope, try next one */ - } - return ((temp == 0) ? dp : NULL); -} - -DEFBUF * -defendel(char* name, int delete) -/* - * Enter this name in the lookup table (delete = FALSE) - * or delete this name (delete = TRUE). - * Returns a pointer to the define block (delete = FALSE) - * Returns NULL if the symbol wasn't defined (delete = TRUE). - */ -{ - register DEFBUF *dp; - register DEFBUF **prevp; - register char *np; - int nhash; - int temp; - int size; - - for (nhash = 0, np = name; *np != EOS;) - nhash += *np++; - size = (np - name); - nhash += size; - prevp = &symtab[nhash & SBMASK]; - while ((dp = *prevp) != (DEFBUF *) NULL) { - if (dp->hash == nhash - && (temp = strcmp(dp->name, name)) >= 0) { - if (temp > 0) - dp = NULL; /* Not found */ - else { - *prevp = dp->link; /* Found, unlink and */ - if (dp->repl != NULL) /* Free the replacement */ - free(dp->repl); /* if any, and then */ - free((char *) dp); /* Free the symbol */ - } - break; - } - prevp = &dp->link; - } - if (!delete) { - dp = (DEFBUF *) getmem(sizeof (DEFBUF) + size); - dp->link = *prevp; - *prevp = dp; - dp->hash = nhash; - dp->repl = NULL; - dp->nargs = 0; - strcpy(dp->name, name); - } - return (dp); -} - -#if OSL_DEBUG_LEVEL > 1 - -void dumpdef(char *why) -{ - register DEFBUF *dp; - register DEFBUF **syp; - FILE *pRememberOut = NULL; - - if ( bDumpDefs ) /*ER */ - { - pRememberOut = pCppOut; - pCppOut = pDefOut; - } - fprintf( pCppOut, "CPP symbol table dump %s\n", why); - for (syp = symtab; syp < &symtab[SBSIZE]; syp++) { - if ((dp = *syp) != (DEFBUF *) NULL) { - fprintf( pCppOut, "symtab[%d]\n", (syp - symtab)); - do { - dumpadef((char *) NULL, dp); - } while ((dp = dp->link) != (DEFBUF *) NULL); - } - } - if ( bDumpDefs ) - { - fprintf( pCppOut, "\n"); - pCppOut = pRememberOut; - } -} - -void dumpadef(char *why, register DEFBUF *dp) -{ - register char *cp; - register int c; - FILE *pRememberOut = NULL; - -/*ER dump #define's to pDefOut */ - if ( bDumpDefs ) - { - pRememberOut = pCppOut; - pCppOut = pDefOut; - } - fprintf( pCppOut, " \"%s\" [%d]", dp->name, dp->nargs); - if (why != NULL) - fprintf( pCppOut, " (%s)", why); - if (dp->repl != NULL) { - fprintf( pCppOut, " => "); - for (cp = dp->repl; (c = *cp++ & 0xFF) != EOS;) { -#ifdef SOLAR - if (c == DEL) { - c = *cp++ & 0xFF; - if( c == EOS ) break; - fprintf( pCppOut, "<%%%d>", c - MAC_PARM); - } -#else - if (c >= MAC_PARM && c <= (MAC_PARM + PAR_MAC)) - fprintf( pCppOut, "<%%%d>", c - MAC_PARM); -#endif - else if (isprint(c) || c == '\n' || c == '\t') - PUTCHAR(c); - else if (c < ' ') - fprintf( pCppOut, "<^%c>", c + '@'); - else - fprintf( pCppOut, "<\\0%o>", c); - } -/*ER evaluate macros to pDefOut */ -#ifdef EVALDEFS - if ( bDumpDefs && !bIsInEval && dp->nargs <= 0 ) - { - FILEINFO *infileSave = infile; - char *tokenSave = savestring( token ); - char *workSave = savestring( work ); - int lineSave = line; - int wronglineSave = wrongline; - int recursionSave = recursion; - FILEINFO *file; - EVALTYPE valEval; - - bIsInEval = 1; - infile = NULL; /* start from scrap */ - line = 0; - wrongline = 0; - *token = EOS; - *work = EOS; - recursion = 0; - file = getfile( strlen( dp->repl ), dp->name ); - strcpy( file->buffer, dp->repl ); - fprintf( pCppOut, " ===> "); - nEvalOff = 0; - cppmain(); /* get() frees also *file */ - valEval = 0; - if ( 0 == evaluate( EvalBuf, &valEval ) ) - { -#ifdef EVALFLOATS - if ( valEval != (EVALTYPE)((long)valEval ) ) - fprintf( pCppOut, " ==eval=> %f", valEval ); - else -#endif - fprintf( pCppOut, " ==eval=> %ld", (long)valEval ); - } - recursion = recursionSave; - wrongline = wronglineSave; - line = lineSave; - strcpy( work, workSave ); - free( workSave ); - strcpy( token, tokenSave ); - free( tokenSave ); - infile = infileSave; - bIsInEval = 0; - } -#endif - } - else { - fprintf( pCppOut, ", no replacement."); - } - PUTCHAR('\n'); - if ( bDumpDefs ) - pCppOut = pRememberOut; -} -#endif - -/* - * G E T - */ - -int -get() -/* - * Return the next character from a macro or the current file. - * Handle end of file from #include files. - */ -{ - register int c; - register FILEINFO *file; - register int popped; /* Recursion fixup */ - - popped = 0; -get_from_file: - if ((file = infile) == NULL) - return (EOF_CHAR); -newline: - - /* - * Read a character from the current input line or macro. - * At EOS, either finish the current macro (freeing temp. - * storage) or read another line from the current input file. - * At EOF, exit the current file (#include) or, at EOF from - * the cpp input file, return EOF_CHAR to finish processing. - */ - if ((c = *file->bptr++ & 0xFF) == EOS) { - /* - * Nothing in current line or macro. Get next line (if - * input from a file), or do end of file/macro processing. - * In the latter case, jump back to restart from the top. - */ - if (file->fp == NULL) { /* NULL if macro */ - popped++; - recursion -= file->unrecur; - if (recursion < 0) - recursion = 0; - infile = file->parent; /* Unwind file chain */ - } - else { /* Else get from a file */ - if ((file->bptr = fgets(file->buffer, NBUFF, file->fp)) - != NULL) { -#if OSL_DEBUG_LEVEL > 1 - if (debug > 1) { /* Dump it to stdout */ - fprintf( pCppOut, "\n#line %d (%s), %s", - line, file->filename, file->buffer); - } -#endif - goto newline; /* process the line */ - } - else { - if( file->fp != stdin ) - fclose(file->fp); /* Close finished file */ - if ((infile = file->parent) != NULL) { - /* - * There is an "ungotten" newline in the current - * infile buffer (set there by doinclude() in - * cpp1.c). Thus, we know that the mainline code - * is skipping over blank lines and will do a - * #line at its convenience. - */ - wrongline = TRUE; /* Need a #line now */ - } - } - } - /* - * Free up space used by the (finished) file or macro and - * restart input from the parent file/macro, if any. - */ - free(file->filename); /* Free name and */ - if (file->progname != NULL) /* if a #line was seen, */ - free(file->progname); /* free it, too. */ - free((char *) file); /* Free file space */ - if (infile == NULL) /* If at end of file */ - return (EOF_CHAR); /* Return end of file */ - line = infile->line; /* Reset line number */ - goto get_from_file; /* Get from the top. */ - } - /* - * Common processing for the new character. - */ - if (c == DEF_MAGIC && file->fp != NULL) /* Don't allow delete */ - goto newline; /* from a file */ - if (file->parent != NULL) { /* Macro or #include */ - if (popped != 0) - file->parent->unrecur += popped; - else { - recursion -= file->parent->unrecur; - if (recursion < 0) - recursion = 0; - file->parent->unrecur = 0; - } - } -#if (HOST == SYS_UNIX) -/*ER*/ if (c == '\r') -/*ER*/ return get(); /* DOS fuck */ -#endif - if (c == '\n') /* Maintain current */ - ++line; /* line counter */ - if (instring) /* Strings just return */ - return (c); /* the character. */ - else if (c == '/') { /* Comment? */ - instring = TRUE; /* So get() won't loop */ -/*MM c++ comments */ -/*MM*/ c = get(); -/*MM*/ if ((c != '*') && (c != '/')) { /* Next byte '*'? */ - instring = FALSE; /* Nope, no comment */ - unget(); /* Push the char. back */ - return ('/'); /* Return the slash */ - } - if (keepcomments) { /* If writing comments */ - PUTCHAR('/'); /* Write out the */ - /* initializer */ -/*MM*/ if( '*' == c ) - PUTCHAR('*'); -/*MM*/ else -/*MM*/ PUTCHAR('/'); - - } -/*MM*/ if( '*' == c ){ - for (;;) { /* Eat a comment */ - c = get(); - test: if (keepcomments && c != EOF_CHAR) - cput(c); - switch (c) { - case EOF_CHAR: - cerror("EOF in comment", NULLST); - return (EOF_CHAR); - - case '/': - if ((c = get()) != '*') /* Don't let comments */ - goto test; /* Nest. */ -#ifdef STRICT_COMMENTS - cwarn("Nested comments", NULLST); -#endif - /* Fall into * stuff */ - case '*': - if ((c = get()) != '/') /* If comment doesn't */ - goto test; /* end, look at next */ - instring = FALSE; /* End of comment, */ - if (keepcomments) { /* Put out the comment */ - cput(c); /* terminator, too */ - } - /* - * A comment is syntactically "whitespace" -- - * however, there are certain strange sequences - * such as - * #define foo(x) (something) - * foo|* comment *|(123) - * these are '/' ^ ^ - * where just returning space (or COM_SEP) will cause - * problems. This can be "fixed" by overwriting the - * '/' in the input line buffer with ' ' (or COM_SEP) - * but that may mess up an error message. - * So, we peek ahead -- if the next character is - * "whitespace" we just get another character, if not, - * we modify the buffer. All in the name of purity. - */ - if (*file->bptr == '\n' - || type[*file->bptr & 0xFF] == SPA) - goto newline; -#if COMMENT_INVISIBLE - /* - * Return magic (old-fashioned) syntactic space. - */ - return ((file->bptr[-1] = COM_SEP)); -#else - return ((file->bptr[-1] = ' ')); -#endif - - case '\n': /* we'll need a #line */ - if (!keepcomments) - wrongline = TRUE; /* later... */ - default: /* Anything else is */ - break; /* Just a character */ - } /* End switch */ - } /* End comment loop */ - } - else{ /* c++ comment */ -/*MM c++ comment*/ - for (;;) { /* Eat a comment */ - c = get(); - if (keepcomments && c != EOF_CHAR) - cput(c); - if( EOF_CHAR == c ) - return (EOF_CHAR); - else if( '\n' == c ){ - instring = FALSE; /* End of comment, */ - return( c ); - } - } - } - } /* End if in comment */ - else if (!inmacro && c == '\\') { /* If backslash, peek */ - if ((c = get()) == '\n') { /* for a <nl>. If so, */ - wrongline = TRUE; - goto newline; - } - else { /* Backslash anything */ - unget(); /* Get it later */ - return ('\\'); /* Return the backslash */ - } - } - else if (c == '\f' || c == VT) /* Form Feed, Vertical */ - c = ' '; /* Tab are whitespace */ - else if (c == 0xef) /* eat up UTF-8 BOM */ - { - if((c = get()) == 0xbb) - { - if((c = get()) == 0xbf) - { - c = get(); - return c; - } - else - { - unget(); - unget(); - return 0xef; - } - } - else - { - unget(); - return 0xef; - } - } - return (c); /* Just return the char */ -} - -void unget() -/* - * Backup the pointer to reread the last character. Fatal error - * (code bug) if we backup too far. unget() may be called, - * without problems, at end of file. Only one character may - * be ungotten. If you need to unget more, call ungetstring(). - */ -{ - register FILEINFO *file; - - if ((file = infile) == NULL) - return; /* Unget after EOF */ - if (--file->bptr < file->buffer) - cfatal("Too much pushback", NULLST); - if (*file->bptr == '\n') /* Ungetting a newline? */ - --line; /* Unget the line number, too */ -} - -void ungetstring(char* text) -/* - * Push a string back on the input stream. This is done by treating - * the text as if it were a macro. - */ -{ - register FILEINFO *file; - extern FILEINFO *getfile(); - file = getfile(strlen(text) + 1, ""); - strcpy(file->buffer, text); -} - -int -cget() -/* - * Get one character, absorb "funny space" after comments or - * token concatenation - */ -{ - register int c; - - do { - c = get(); -#if COMMENT_INVISIBLE - } while (c == TOK_SEP || c == COM_SEP); -#else - } while (c == TOK_SEP); -#endif - return (c); -} - -/* - * Error messages and other hacks. The first byte of severity - * is 'S' for string arguments and 'I' for int arguments. This - * is needed for portability with machines that have int's that - * are shorter than char *'s. - */ - -static void domsg(char* severity, char* format, void* arg) -/* - * Print filenames, macro names, and line numbers for error messages. - */ -{ - register char *tp; - register FILEINFO *file; - - fprintf(stderr, "%sline %d, %s: ", MSG_PREFIX, line, &severity[1]); - if (*severity == 'S') - fprintf(stderr, format, (char *)arg); - else - fprintf(stderr, format, *((int *)arg) ); - putc('\n', stderr); - if ((file = infile) == NULL) - return; /* At end of file */ - if (file->fp != NULL) { - tp = file->buffer; /* Print current file */ - fprintf(stderr, "%s", tp); /* name, making sure */ - if (tp[strlen(tp) - 1] != '\n') /* there's a newline */ - putc('\n', stderr); - } - while ((file = file->parent) != NULL) { /* Print #includes, too */ - if (file->fp == NULL) - fprintf(stderr, "from macro %s\n", file->filename); - else { - tp = file->buffer; - fprintf(stderr, "from file %s, line %d:\n%s", - (file->progname != NULL) - ? file->progname : file->filename, - file->line, tp); - if (tp[strlen(tp) - 1] != '\n') - putc('\n', stderr); - } - } -} - -void cerror(char* format, char* sarg) -/* - * Print a normal error message, string argument. - */ -{ - domsg("SError", format, sarg); - errors++; -} - -void cierror(char* format, int narg) -/* - * Print a normal error message, numeric argument. - */ -{ - domsg("IError", format, &narg); - errors++; -} - -void cfatal(char* format, char* sarg) -/* - * A real disaster - */ -{ - domsg("SFatal error", format, sarg); - exit(IO_ERROR); -} - -void cwarn(char* format, char* sarg) -/* - * A non-fatal error, string argument. - */ -{ - domsg("SWarning", format, sarg); -} - -void ciwarn(char* format, int narg) -/* - * A non-fatal error, numeric argument. - */ -{ - domsg("IWarning", format, &narg); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/cppdef.h b/rsc/source/rscpp/cppdef.h deleted file mode 100644 index 379dd34fdb..0000000000 --- a/rsc/source/rscpp/cppdef.h +++ /dev/null @@ -1,343 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -/* - * This redundant definition of TRUE and FALSE works around - * a limitation of Decus C. - */ -#ifndef TRUE -#define TRUE 1 -#define FALSE 0 -#endif - -/* - * Define the HOST operating system. This is needed so that - * cpp can use appropriate filename conventions. - */ -#define SYS_UNKNOWN 0 -#define SYS_UNIX 1 -#define SYS_VMS 2 -#define SYS_RSX 3 -#define SYS_RT11 4 -#define SYS_LATTICE 5 -#define SYS_ONYX 6 -#define SYS_68000 7 - -#ifndef HOST -#ifdef unix -#define HOST SYS_UNIX -#else -#ifdef vms -#define HOST SYS_VMS -#else -#ifdef rsx -#define HOST SYS_RSX -#else -#ifdef rt11 -#define HOST SYS_RT11 -#endif -#endif -#endif -#endif -#endif - -#ifndef HOST -#define HOST SYS_UNKNOWN -#endif - -/* - * We assume that the target is the same as the host system - */ -#ifndef TARGET -#define TARGET HOST -#endif - -/* - * In order to predefine machine-dependent constants, - * several strings are defined here: - * - * MACHINE defines the target cpu (by name) - * SYSTEM defines the target operating system - * COMPILER defines the target compiler - * - * The above may be #defined as "" if they are not wanted. - * They should not be #defined as NULL. - * - * LINE_PREFIX defines the # output line prefix, if not "line" - * This should be defined as "" if cpp is to replace - * the "standard" C pre-processor. - * - * FILE_LOCAL marks functions which are referenced only in the - * file they reside. Some C compilers allow these - * to be marked "static" even though they are referenced - * by "extern" statements elsewhere. - * - * OK_DOLLAR Should be set TRUE if $ is a valid alphabetic character - * in identifiers (default), or zero if $ is invalid. - * Default is TRUE. - * - * OK_CONCAT Should be set TRUE if # may be used to concatenate - * tokens in macros (per the Ansi Draft Standard) or - * FALSE for old-style # processing (needed if cpp is - * to process assembler source code). - * - * OK_DATE Predefines the compilation date if set TRUE. - * Not permitted by the Nov. 12, 1984 Draft Standard. - * - * S_CHAR etc. Define the sizeof the basic TARGET machine word types. - * By default, sizes are set to the values for the HOST - * computer. If this is inappropriate, see the code in - * cpp3.c for details on what to change. Also, if you - * have a machine where sizeof (signed int) differs from - * sizeof (unsigned int), you will have to edit code and - * tables in cpp3.c (and extend the -S option definition.) - * - * CPP_LIBRARY May be defined if you have a site-specific include directory - * which is to be searched *before* the operating-system - * specific directories. - */ - -#if TARGET == SYS_LATTICE -/* - * We assume the operating system is pcdos for the IBM-PC. - * We also assume the small model (just like the PDP-11) - */ -#define MACHINE "i8086" -#define SYSTEM "pcdos" -#endif - -#if TARGET == SYS_ONYX -#define MACHINE "z8000" -#define SYSTEM "unix" -#endif - -#if TARGET == SYS_VMS -#define MACHINE "vax" -#define SYSTEM "vms" -#define COMPILER "vax11c" -#endif - -#if TARGET == SYS_RSX -#define MACHINE "pdp11" -#define SYSTEM "rsx" -#define COMPILER "decus" -#endif - -#if TARGET == SYS_RT11 -#define MACHINE "pdp11" -#define SYSTEM "rt11" -#define COMPILER "decus" -#endif - -#if TARGET == SYS_68000 || defined(M68000) || defined(m68000) || defined(m68k) -/* - * All three machine designators have been seen in various systems. - * Warning -- compilers differ as to sizeof (int). cpp3 assumes that - * sizeof (int) == 2 - */ -#define MACHINE "M68000", "m68000", "m68k" -#define SYSTEM "unix" -#endif - -#if TARGET == SYS_UNIX -#define SYSTEM "unix" -#ifdef pdp11 -#define MACHINE "pdp11" -#endif -#ifdef vax -#define MACHINE "vax" -#endif -#endif - -/* - * defaults - */ - -#ifndef MSG_PREFIX -#define MSG_PREFIX "cpp: " -#endif - -#ifndef LINE_PREFIX -#define LINE_PREFIX "" -#endif - -/* - * OLD_PREPROCESSOR forces the definition of OK_DOLLAR, OK_CONCAT, - * COMMENT_INVISIBLE, and STRING_FORMAL to values appropriate for - * an old-style preprocessor. - */ - -#ifndef OLD_PREPROCESSOR -#define OLD_PREPROCESSOR FALSE -#endif - -#if OLD_PREPROCESSOR -#define OK_DOLLAR FALSE -#define OK_CONCAT TRUE -#define COMMENT_INVISIBLE TRUE -#define STRING_FORMAL TRUE -#define IDMAX 63 /* actually, seems to be unlimited */ -#endif - -/* - * RECURSION_LIMIT may be set to -1 to disable the macro recursion test. - */ -#ifndef RECURSION_LIMIT -#define RECURSION_LIMIT 1000 -#endif - -/* - * BITS_CHAR may be defined to set the number of bits per character. - * it is needed only for multi-byte character constants. - */ -#ifndef BITS_CHAR -#define BITS_CHAR 8 -#endif - -/* - * BIG_ENDIAN is set TRUE on machines (such as the IBM 360 series) - * where 'ab' stores 'a' in the high-bits and 'b' in the low-bits. - * It is set FALSE on machines (such as the PDP-11 and Vax-11) - * where 'ab' stores 'a' in the low-bits and 'b' in the high-bits. - * (Or is it the other way around?) -- Warning: BIG_ENDIAN code is untested. - */ -#ifndef BIG_ENDIAN -#define BIG_ENDIAN FALSE -#endif - -/* - * COMMENT_INVISIBLE may be defined to allow "old-style" comment - * processing, whereby the comment becomes a zero-length token - * delimiter. This permitted tokens to be concatenated in macro - * expansions. This was removed from the Draft Ansi Standard. - */ -#ifndef COMMENT_INVISIBLE -#define COMMENT_INVISIBLE FALSE -#endif - -/* - * STRING_FORMAL may be defined to allow recognition of macro parameters - * anywhere in replacement strings. This was removed from the Draft Ansi - * Standard and a limited recognition capability added. - */ -#ifndef STRING_FORMAL -#define STRING_FORMAL FALSE -#endif - -/* - * OK_DOLLAR enables use of $ as a valid "letter" in identifiers. - * This is a permitted extension to the Ansi Standard and is required - * for e.g., VMS, RSX-11M, etc. It should be set FALSE if cpp is - * used to preprocess assembler source on Unix systems. OLD_PREPROCESSOR - * sets OK_DOLLAR FALSE for that reason. - */ -#ifndef OK_DOLLAR -#define OK_DOLLAR TRUE -#endif - -/* - * OK_CONCAT enables (one possible implementation of) token concatenation. - * If cpp is used to preprocess Unix assembler source, this should be - * set FALSE as the concatenation character, #, is used by the assembler. - */ -#ifndef OK_CONCAT -#define OK_CONCAT TRUE -#endif - -/* - * OK_DATE may be enabled to predefine today's date as a string - * at the start of each compilation. This is apparently not permitted - * by the Draft Ansi Standard. - */ -#ifndef OK_DATE -#define OK_DATE TRUE -#endif - -/* - * The following definitions are used to allocate memory for - * work buffers. In general, they should not be modified - * by implementors. - * - * PAR_MAC The maximum number of #define parameters (31 per Standard) - * Note: we need another one for strings. - * IDMAX The longest identifier, 31 per Ansi Standard - * NBUFF Input buffer size - * NWORK Work buffer size -- the longest macro - * must fit here after expansion. - * NEXP The nesting depth of #if expressions - * NINCLUDE The number of directories that may be specified - * on a per-system basis, or by the -I option. - * BLK_NEST The number of nested #if's permitted. - * NFWORK FileNameWorkBuffer (added by erAck, was NWORK) - */ - -#ifndef IDMAX -#define IDMAX 127 -#endif -#ifdef SOLAR -#define PAR_MAC (253 + 1) -#else -#define PAR_MAC (31 + 1) -#endif -/* NWORK wg. grooossen Makros in *.src erhoeht, - da wir bald 10 Sprachen haben werden gleich ordentlich reingehauen.. */ -#define NWORK 128000 -#define NBUFF NWORK -#define NFWORK 1024 -#define NEXP 128 -#define NINCLUDE 100 -#define NPARMWORK (NWORK * 2) -#define BLK_NEST 32 - - -#ifndef ALERT -#ifdef EBCDIC -#define ALERT '\057' -#else -#define ALERT '\007' /* '\a' is "Bell" */ -#endif -#endif - -#ifndef VT -#define VT '\013' /* Vertical Tab CTRL/K */ -#endif - - -#ifndef FILE_LOCAL -#ifdef decus -#define FILE_LOCAL static -#else -#ifdef vax11c -#define FILE_LOCAL static -#else -#define FILE_LOCAL /* Others are global */ -#endif -#endif -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/rscpp/makefile.mk b/rsc/source/rscpp/makefile.mk deleted file mode 100644 index dc78ee53f8..0000000000 --- a/rsc/source/rscpp/makefile.mk +++ /dev/null @@ -1,79 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* -PRJ=..$/.. - -TARGETTYPE=CUI -NO_DEFAULT_STL=TRUE - -PRJNAME=rsc -TARGET=rscpp - -.IF "$(cpp)" != "" -PRJNAME=CPP -TARGET=cpp -.ENDIF - -# --- Settings ----------------------------------------------------- - -.INCLUDE : settings.mk - -.IF "$(BUILD_TYPE)"=="$(BUILD_TYPE:s/DESKTOP//)" -ALL: - @echo No need for this on non-desktop OSes -.ENDIF - -CDEFS+=-DSOLAR - -.IF "$(cpp)" != "" -CDEFS+=-DNOMAIN -.ENDIF - -# --- Files -------------------------------------------------------- - -OBJFILES= \ - $(OBJ)$/cpp1.obj \ - $(OBJ)$/cpp2.obj \ - $(OBJ)$/cpp3.obj \ - $(OBJ)$/cpp4.obj \ - $(OBJ)$/cpp5.obj \ - $(OBJ)$/cpp6.obj \ - -.IF "$(GUI)"=="UNX" -CDEFS+=-Dunix -.ENDIF - -.IF "$(OS)$(CPU)"=="SOLARISI" -# cc: Sun C 5.5 Patch 112761-10 2004/08/10 -# Solaris x86 compiler ICE -# "cpp6.c", [get]:ube: internal error -# remove after compiler upgrade -NOOPTFILES=$(OBJ)$/cpp6.obj -.ENDIF - -# --- Targets ------------------------------------------------------ - -.INCLUDE : target.mk diff --git a/rsc/source/tools/makefile.mk b/rsc/source/tools/makefile.mk deleted file mode 100644 index a7e79abd1f..0000000000 --- a/rsc/source/tools/makefile.mk +++ /dev/null @@ -1,50 +0,0 @@ -#************************************************************************* -# -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# Copyright 2000, 2010 Oracle and/or its affiliates. -# -# OpenOffice.org - a multi-platform office productivity suite -# -# This file is part of OpenOffice.org. -# -# OpenOffice.org is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License version 3 -# only, as published by the Free Software Foundation. -# -# OpenOffice.org is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Lesser General Public License version 3 for more details -# (a copy is included in the LICENSE file that accompanied this code). -# -# You should have received a copy of the GNU Lesser General Public License -# version 3 along with OpenOffice.org. If not, see -# <http://www.openoffice.org/license.html> -# for a copy of the LGPLv3 License. -# -#************************************************************************* - -PRJ=..$/.. - -PRJNAME=rsc -TARGET=rsctoo - -# --- Settings ------------------------------------------------------ - -ENABLE_EXCEPTIONS=true - -.INCLUDE : settings.mk - -.IF "$(BUILD_TYPE)"=="$(BUILD_TYPE:s/DESKTOP//)" -ALL: - @echo No need for this on non-desktop OSes -.ENDIF - -OBJFILES= $(OBJ)$/rschash.obj \ - $(OBJ)$/rsctree.obj \ - $(OBJ)$/rsctools.obj \ - $(OBJ)$/rscchar.obj \ - $(OBJ)$/rscdef.obj - -.INCLUDE : target.mk diff --git a/rsc/source/tools/rscchar.cxx b/rsc/source/tools/rscchar.cxx deleted file mode 100644 index 64e31c09d5..0000000000 --- a/rsc/source/tools/rscchar.cxx +++ /dev/null @@ -1,193 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ -#include <stdio.h> -#include <string.h> -#include <ctype.h> - -#include <tools/table.hxx> - -// Solar Definitionen -#include <tools/solar.h> -#include <rsctools.hxx> - -#include <rtl/textcvt.h> -#include <rtl/textenc.h> -#include <rtl/alloc.h> - -/************************************************************************* -|* -|* RscChar::MakeChar() -|* -|* Beschreibung Der String wird nach C-Konvention umgesetzt -|* -*************************************************************************/ -char * RscChar::MakeUTF8( char * pStr, sal_uInt16 nTextEncoding ) -{ - sal_Size nMaxUniCodeBuf = strlen( pStr ) + 1; - if( nMaxUniCodeBuf * 6 > 0x0FFFFF ) - RscExit( 10 ); - - char * pOrgStr = new char[ nMaxUniCodeBuf ]; - sal_uInt32 nOrgLen = 0; - - char cOld = '1'; - while( cOld != 0 ) - { - char c; - - if( *pStr == '\\' ) - { - ++pStr; - switch( *pStr ) - { - case 'a': - c = '\a'; - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'v': - c = '\v'; - break; - case '\\': - c = '\\'; - break; - case '?': - c = '\?'; - break; - case '\'': - c = '\''; - break; - case '\"': - c = '\"'; - break; - default: - { - if( '0' <= *pStr && '7' >= *pStr ) - { - sal_uInt16 nChar = 0; - int i = 0; - while( '0' <= *pStr && '7' >= *pStr && i != 3 ) - { - nChar = nChar * 8 + (sal_uInt8)*pStr - (sal_uInt8)'0'; - ++pStr; - i++; - } - if( nChar > 255 ) - { - // Wert zu gross, oder kein 3 Ziffern - delete [] pOrgStr; - return( NULL ); - } - c = (char)nChar; - pStr--; - } - else if( 'x' == *pStr ) - { - sal_uInt16 nChar = 0; - int i = 0; - ++pStr; - while( isxdigit( *pStr ) && i != 2 ) - { - if( isdigit( *pStr ) ) - nChar = nChar * 16 + (sal_uInt8)*pStr - (sal_uInt8)'0'; - else if( isupper( *pStr ) ) - nChar = nChar * 16 + (sal_uInt8)*pStr - (sal_uInt8)'A' +10; - else - nChar = nChar * 16 + (sal_uInt8)*pStr - (sal_uInt8)'a' +10; - ++pStr; - i++; - } - c = (char)nChar; - pStr--; - } - else - c = *pStr; - }; - } - } - else - c = *pStr; - pOrgStr[ nOrgLen++ ] = c; - cOld = *pStr; - pStr++; - } - - sal_Unicode * pUniCode = new sal_Unicode[ nMaxUniCodeBuf ]; - rtl_TextToUnicodeConverter hConv = rtl_createTextToUnicodeConverter( nTextEncoding ); - - sal_uInt32 nInfo; - sal_Size nSrcCvtBytes; - sal_Size nUniSize = rtl_convertTextToUnicode( hConv, 0, - pOrgStr, nOrgLen, - pUniCode, nMaxUniCodeBuf, - RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_DEFAULT - | RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_DEFAULT - | RTL_TEXTTOUNICODE_FLAGS_INVALID_DEFAULT - | RTL_TEXTTOUNICODE_FLAGS_FLUSH, - &nInfo, - &nSrcCvtBytes ); - - rtl_destroyTextToUnicodeConverter( hConv ); - delete[] pOrgStr, pOrgStr = 0; - - hConv = rtl_createUnicodeToTextConverter( RTL_TEXTENCODING_UTF8 ); - // factor fo 6 is the maximum size of an UNICODE character as utf8 - char * pUtf8 = (char *)rtl_allocateMemory( nUniSize * 6 ); - rtl_convertUnicodeToText( hConv, 0, - pUniCode, nUniSize, - pUtf8, nUniSize * 6, - RTL_UNICODETOTEXT_FLAGS_UNDEFINED_DEFAULT - | RTL_UNICODETOTEXT_FLAGS_INVALID_DEFAULT - | RTL_UNICODETOTEXT_FLAGS_FLUSH, - &nInfo, - &nSrcCvtBytes ); - - rtl_destroyTextToUnicodeConverter( hConv ); - delete[] pUniCode, pUniCode = 0; - - return pUtf8; -}; - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/tools/rscdef.cxx b/rsc/source/tools/rscdef.cxx deleted file mode 100644 index f6d65a7f23..0000000000 --- a/rsc/source/tools/rscdef.cxx +++ /dev/null @@ -1,900 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// Programmuebergreifende Includes. -#include <rscdef.hxx> - -/****************** C o d e **********************************************/ -/****************** R s c I d ********************************************/ -sal_Bool RscId::bNames = sal_True; - -/************************************************************************* -|* -|* static RscId::SetNames -|* static RscId::SetNoNames -|* -*************************************************************************/ -void RscId::SetNames( sal_Bool bSet ) { bNames = bSet; } - -/************************************************************************* -|* -|* RscId::GetNumber -|* -*************************************************************************/ -sal_Int32 RscId::GetNumber() const{ - sal_Int32 lVal; - aExp.Evaluate( &lVal ); - return lVal; -} - -/************************************************************************* -|* -|* RscId::Create() -|* -*************************************************************************/ -void RscId::Create( const RscExpType & rExpType ) -{ - aExp = rExpType; - if( aExp.IsDefinition() ) - aExp.aExp.pDef->IncRef(); - else if( aExp.IsExpression() ){ - sal_Int32 lValue; - - aExp.Evaluate( &lValue ); - aExp.SetLong( lValue ); - } -} - -/************************************************************************* -|* -|* RscId::Destroy() -|* -*************************************************************************/ -void RscId::Destroy(){ - if( aExp.IsDefinition() ) - aExp.aExp.pDef->DecRef(); - aExp.cType = RSCEXP_NOTHING; -} - -/************************************************************************* -|* -|* RscId::RscId() -|* -*************************************************************************/ -RscId::RscId( const RscId& rRscId ){ - aExp = rRscId.aExp; - if( aExp.IsDefinition() ) - aExp.aExp.pDef->IncRef(); -} - -/************************************************************************* -|* -|* RscId::RscId() -|* -*************************************************************************/ -RscId::RscId( RscDefine * pDef ){ - RscExpType aExpType; - - aExpType.aExp.pDef = pDef; - aExpType.cType = RSCEXP_DEF; - Create( aExpType ); -} - -/************************************************************************* -|* -|* RscId:: = -|* -*************************************************************************/ -RscId& RscId::operator = ( const RscId& rRscId ){ - if( rRscId.aExp.IsDefinition() ) - rRscId.aExp.aExp.pDef->IncRef(); - Destroy(); - aExp = rRscId.aExp; - return *this; -} - -/************************************************************************* -|* -|* RscId::operator == -|* -*************************************************************************/ -sal_Bool RscId::operator == ( const RscId& rRscId ) const -{ - return( GetNumber() == rRscId.GetNumber() ); -} - -/************************************************************************* -|* -|* RscId::operator < -|* -*************************************************************************/ -sal_Bool RscId::operator < ( const RscId& rRscId ) const -{ - return( GetNumber() < rRscId.GetNumber() ); -} - -/************************************************************************* -|* -|* RscId::operator > -|* -*************************************************************************/ -sal_Bool RscId::operator > ( const RscId& rRscId ) const -{ - return( GetNumber() > rRscId.GetNumber() ); -} - -/************************************************************************* -|* -|* RscId::sal_Int32() -|* -*************************************************************************/ -RscId::operator sal_Int32() const -{ - return( GetNumber() ); -} - -/************************************************************************* -|* -|* RscId::GetNames() -|* -*************************************************************************/ -ByteString RscId::GetName() const -{ - rtl::OStringBuffer aStr; - - if ( !aExp.IsNothing() ) - { - if( bNames ) - aExp.AppendMacro(aStr); - else - aStr.append(GetNumber()); - } - - return aStr.makeStringAndClear(); -} - -/****************** R s c D e f i n e ************************************/ -/************************************************************************* -|* -|* RscDefine::RscDefine() -|* -*************************************************************************/ -RscDefine::RscDefine( sal_uLong lKey, const ByteString & rDefName, sal_Int32 lDefId ) - : StringNode( rDefName ) -{ - nRefCount = 0; - lFileKey = lKey; - lId = lDefId; - pExp = NULL; -} - -RscDefine::RscDefine( sal_uLong lKey, const ByteString & rDefName, - RscExpression * pExpression ) - : StringNode( rDefName ) -{ - nRefCount = 0; - lFileKey = lKey; - pExpression->Evaluate( &lId ); - pExp = pExpression; -} - -/************************************************************************* -|* -|* RscDefine::~RscDefine() -|* -*************************************************************************/ -RscDefine::~RscDefine(){ - if( pExp ) - delete pExp; - if( nRefCount ) - RscExit( 14 ); -} - -/************************************************************************* -|* -|* RscDefine::DecRef() -|* -*************************************************************************/ -void RscDefine::DecRef(){ - nRefCount--; - if( 0 == nRefCount ){ - delete this; - } -} - -/************************************************************************* -|* -|* RscDefine::DefineToNumber() -|* -*************************************************************************/ -void RscDefine::DefineToNumber() -{ - if( pExp ) - delete pExp; - pExp = NULL; - SetName(rtl::OString::valueOf(lId)); -} - -/************************************************************************* -|* -|* RscDefine::Evaluate() -|* -*************************************************************************/ -sal_Bool RscDefine::Evaluate(){ - sal_Bool bRet = sal_True; - - if( pExp ) - bRet = !pExp->Evaluate( &lId ); - - return bRet; -} - -/************************************************************************* -|* -|* RscDefine::Search() -|* -*************************************************************************/ -RscDefine * RscDefine::Search( const char * pStr ){ - return (RscDefine *)StringNode::Search( pStr ); -} - -/************************************************************************* -|* -|* RscDefine::GetMacro() -|* -*************************************************************************/ -ByteString RscDefine::GetMacro() -{ - if( pExp ) - return pExp->GetMacro(); - return rtl::OString::valueOf(lId); -} - -/****************** R s c D e f i n e L i s t ****************************/ -/************************************************************************* -|* -|* RscDefineList::New() -|* -*************************************************************************/ -RscDefine * RscDefineList::New( sal_uLong lFileKey, const ByteString & rDefName, - sal_Int32 lDefId, size_t lPos ) -{ - RscDefine * pDef; - - pDef = new RscDefine( lFileKey, rDefName, lDefId ); - pDef->IncRef(); - if ( lPos < maList.size() ) - { - RscSubDefList::iterator it = maList.begin(); - ::std::advance( it, lPos ); - maList.insert( it, pDef ); - } else { - maList.push_back( pDef ); - } - return pDef; -} - -RscDefine * RscDefineList::New( sal_uLong lFileKey, const ByteString & rDefName, - RscExpression * pExpression, size_t lPos ) -{ - RscDefine * pDef; - - pDef = new RscDefine( lFileKey, rDefName, pExpression ); - pDef->IncRef(); - if ( lPos < maList.size() ) - { - RscSubDefList::iterator it = maList.begin(); - ::std::advance( it, lPos ); - maList.insert( it, pDef ); - } else { - maList.push_back( pDef ); - } - return pDef; -} - -sal_Bool RscDefineList::Remove() { - if ( maList.empty() ) - return sal_False; - - maList[ 0 ]->DefineToNumber(); - maList[ 0 ]->DecRef(); - maList.erase( maList.begin() ); - return sal_True; -} - -/************************************************************************* -|* -|* RscDefineList::WriteAll() -|* -*************************************************************************/ -void RscDefineList::WriteAll( FILE * fOutput ) -{ - for ( size_t i = 0, n = maList.size(); i < n; ++i ) { - RscDefine* pDefEle = maList[ i ]; - fprintf( fOutput, "#define %s %s\n", - pDefEle->GetName().GetBuffer(), - pDefEle->GetMacro().GetBuffer() - ); - }; -} - -/****************** R s c E x p T y p e **********************************/ -/************************************************************************* -|* -|* RscExpType::Evaluate() -|* -*************************************************************************/ -sal_Bool RscExpType::Evaluate( sal_Int32 * plValue ) const{ - if( IsDefinition() ){ - aExp.pDef->Evaluate(); - // Eventuellen Fehler ignorieren - *plValue = aExp.pDef->GetNumber(); - } - else if( IsExpression() ) - return( aExp.pExp->Evaluate( plValue ) ); - else if( IsNothing() ) - *plValue = 0; - else - *plValue = GetLong(); - - return sal_True; -} - -void RscExpType::AppendMacro(rtl::OStringBuffer& rStr) const -{ - if( IsDefinition() ) - rStr.append(aExp.pDef->GetName()); - else if( IsExpression() ) - rStr.append(aExp.pExp->GetMacro()); - else if( IsNumber() ) - rStr.append(GetLong()); -} - - -/****************** R s c E x p r e s s i o n ****************************/ -/************************************************************************* -|* -|* RscExpression::RscExpression() -|* -*************************************************************************/ -RscExpression::RscExpression( RscExpType aLE, char cOp, RscExpType aRE ) -{ - aLeftExp = aLE; - cOperation = cOp; - aRightExp = aRE; - if( aLeftExp.IsDefinition() ) - aLeftExp.aExp.pDef->IncRef(); - if( aRightExp.IsDefinition() ) - aRightExp.aExp.pDef->IncRef(); -} - -/************************************************************************* -|* -|* RscExpression::~RscExpression() -|* -*************************************************************************/ -RscExpression::~RscExpression(){ - if( aLeftExp.IsDefinition() ) - aLeftExp.aExp.pDef->DecRef(); - else if( aLeftExp.IsExpression() ) - delete aLeftExp.aExp.pExp; - - if( aRightExp.IsDefinition() ) - aRightExp.aExp.pDef->DecRef(); - else if( aRightExp.IsExpression() ) - delete aRightExp.aExp.pExp; -} - -/************************************************************************* -|* -|* RscExpression::Evaluate() -|* -*************************************************************************/ -sal_Bool RscExpression::Evaluate( sal_Int32 * plValue ){ - sal_Int32 lLeft; - sal_Int32 lRight; - - // linken und rechten Zweig auswerten - if( aLeftExp.Evaluate( &lLeft ) && aRightExp.Evaluate( &lRight ) ){ - if( cOperation == '&' ) - *plValue = lLeft & lRight; - else if( cOperation == '|' ) - *plValue = lLeft | lRight; - else if( cOperation == '+' ) - *plValue = lLeft + lRight; - else if( cOperation == '-' ) - *plValue = lLeft - lRight; - else if( cOperation == '*' ) - *plValue = lLeft * lRight; - else if( cOperation == 'r' ) - *plValue = lLeft >> lRight; - else if( cOperation == 'l' ) - *plValue = lLeft << lRight; - else{ - if( 0L == lRight ) - return sal_False; - *plValue = lLeft / lRight; - }; - return sal_True; - } - return sal_False; -} - -/************************************************************************* -|* -|* RscExpression::GetMacro() -|* -*************************************************************************/ -ByteString RscExpression::GetMacro() -{ - rtl::OStringBuffer aLeft; - - // Ausgabeoptimierung - if( aLeftExp.IsNothing() ) - { - if ( '-' == cOperation ) - { - aLeft.append('('); - aLeft.append('-'); - } - aRightExp.AppendMacro(aLeft); - if( '-' == cOperation ) - aLeft.append(')'); - } - else if( aRightExp.IsNothing() ) - aLeftExp.AppendMacro(aLeft); - else{ - aLeft.append('('); - // linken Zweig auswerten - aLeftExp.AppendMacro(aLeft); - - aLeft.append(cOperation); - - aLeft.append('('); - // rechten Zweig auswerten - aRightExp.AppendMacro(aLeft); - aLeft.append(')'); - - aLeft.append(')'); - } - - return aLeft.makeStringAndClear(); -} - -/****************** R s c F i l e ****************************************/ -/************************************************************************* -|* -|* RscFile::RscFile() -|* -*************************************************************************/ -RscFile :: RscFile(){ - bLoaded = sal_False; - bIncFile = sal_False; - bDirty = sal_False; - bScanned = sal_False; -} - -/************************************************************************* -|* -|* RscFile::~RscFile() -|* -*************************************************************************/ -RscFile :: ~RscFile() { - for ( size_t i = 0, n = aDepLst.size(); i < n; ++i ) - delete aDepLst[ i ]; - aDepLst.clear(); - - //von hinten nach vorne ist besser wegen der Abhaengigkeiten - //Objekte zerstoeren sich, wenn Referenzzaehler NULL - while( aDefLst.Remove() ) ; -} - -/************************************************************************* -|* -|* RscFile::Depend() -|* -|* Beschreibung Diese Methode gibt sal_True zurueck, wenn lDepend -|* existiert und hinter lFree steht, oder wenn -|* lDepend nicht existiert. -|* -*************************************************************************/ -sal_Bool RscFile::Depend( sal_uLong lDepend, sal_uLong lFree ){ - RscDepend * pDep; - - for ( size_t i = aDepLst.size(); i > 0; ) - { - pDep = aDepLst[ --i ]; - if( pDep->GetFileKey() == lDepend ) { - for ( size_t j = i ? --i : 0; j > 0; ) - { - pDep = aDepLst[ --j ]; - if( pDep->GetFileKey() == lFree ) - return sal_True; - } - return sal_False; - } - } - return sal_True; -} - -/************************************************************************* -|* -|* RscFile::InsertDependFile() -|* -*************************************************************************/ -sal_Bool RscFile :: InsertDependFile( sal_uLong lIncFile, size_t lPos ) -{ - for ( size_t i = 0, n = aDepLst.size(); i < n; ++i ) - { - RscDepend* pDep = aDepLst[ i ]; - if( pDep->GetFileKey() == lIncFile ) - return sal_True; - } - - // Current-Zeiger steht auf letztem Element - if( lPos >= aDepLst.size() ) { //letztes Element muss immer letztes bleiben - // Abhaengigkeit vor der letzten Position eintragen - aDepLst.push_back( new RscDepend( lIncFile ) ); - } - else { - RscDependList::iterator it = aDepLst.begin(); - ::std::advance( it, lPos ); - aDepLst.insert( it, new RscDepend( lIncFile ) ); - } - return sal_True; -} - -/****************** R s c D e f T r e e **********************************/ -/************************************************************************* -|* -|* RscDefTree::~RscDefTree() -|* -*************************************************************************/ -RscDefTree::~RscDefTree(){ - Remove(); -} - -/************************************************************************* -|* -|* RscDefTree::Remove() -|* -*************************************************************************/ -void RscDefTree::Remove(){ - RscDefine * pDef; - while( pDefRoot ){ - pDef = pDefRoot; - pDefRoot = (RscDefine *)pDefRoot->Remove( pDefRoot ); - pDef->DecRef(); - } -} - -/************************************************************************* -|* -|* RscDefTree::~Search() -|* -*************************************************************************/ -RscDefine * RscDefTree::Search( const char * pName ){ - if( pDefRoot ) - return pDefRoot->Search( pName ); - return NULL; -} - -/************************************************************************* -|* -|* RscDefTree::Insert() -|* -*************************************************************************/ -void RscDefTree::Insert( RscDefine * pDef ){ - if( pDefRoot ) - pDefRoot->Insert( pDef ); - else - pDefRoot = pDef; - pDef->IncRef(); -} - -/************************************************************************* -|* -|* RscDefTree::Remove() -|* -*************************************************************************/ -void RscDefTree::Remove( RscDefine * pDef ){ - if( pDefRoot ){ - //falls pDef == pDefRoot - pDefRoot = (RscDefine *)pDefRoot->Remove( pDef ); - } - pDef->DecRef(); -} - -/************************************************************************* -|* -|* RscDefTree::Evaluate() -|* -*************************************************************************/ -sal_Bool RscDefTree::Evaluate( RscDefine * pDef ){ - if( pDef ){ - if( !Evaluate( (RscDefine *)pDef->Left() ) ) - return sal_False; - if( !Evaluate( (RscDefine *)pDef->Right() ) ) - return sal_False; - }; - return sal_True; -} - -/****************** R s c F i l e T a b **********************************/ -/************************************************************************* -|* -|* RscFileTab::RscFileTab() -|* -*************************************************************************/ -RscFileTab::RscFileTab(){ -} - -/************************************************************************* -|* -|* RscFileTab::~RscFileTab() -|* -*************************************************************************/ -RscFileTab :: ~RscFileTab(){ - RscFile * pFile; - - aDefTree.Remove(); - - pFile = Last(); - while( pFile ){ - Remove( GetIndex( pFile ) ); - delete pFile; - pFile = Prev(); - }; -} - -/************************************************************************* -|* -|* RscFileTab::Find() -|* -*************************************************************************/ -sal_uLong RscFileTab :: Find( const ByteString & rName ) -{ - RscFile * pFName; - - pFName = First(); - while( pFName && (pFName->aFileName != rName) ) - pFName = Next(); - - if( pFName ) - return( GetIndex( pFName ) ); - else - return( NOFILE_INDEX ); -} - -/************************************************************************* -|* -|* RscFileTab::FindDef() -|* -*************************************************************************/ -RscDefine * RscFileTab::FindDef( const char * pName ){ - return aDefTree.Search( pName ); -} - -/************************************************************************* -|* -|* RscFileTab::Depend() -|* -*************************************************************************/ -sal_Bool RscFileTab::Depend( sal_uLong lDepend, sal_uLong lFree ){ - if( lDepend == lFree ) - return sal_True; - - RscFile * pFile = First(); - while( pFile ){ - if( !pFile->IsIncFile() ){ - if( !pFile->Depend( lDepend, lFree ) ) - return sal_False; - }; - pFile = Next(); - }; - - return sal_True; -} - -/************************************************************************* -|* -|* RscFileTab::TestDef() -|* -*************************************************************************/ -sal_Bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos, - const RscDefine * pDefDec ) -{ - if( lFileKey == pDefDec->GetFileKey() ) { - RscFile * pFile = GetFile( pDefDec->GetFileKey() ); - if( pFile && (lPos <= pFile->aDefLst.GetPos( (RscDefine *)pDefDec )) - && (lPos != ULONG_MAX ) ) - return sal_False; - } - else if( !Depend( lFileKey, pDefDec->GetFileKey() ) ) - return sal_False; - - return TestDef( lFileKey, lPos, pDefDec->pExp ); -} - -/************************************************************************* -|* -|* RscFileTab::TestDef() -|* -*************************************************************************/ -sal_Bool RscFileTab::TestDef( sal_uLong lFileKey, size_t lPos, - const RscExpression * pExpDec ) -{ - if( !pExpDec ) - return sal_True; - - if( pExpDec->aLeftExp.IsExpression() ) - if( !TestDef( lFileKey, lPos, pExpDec->aLeftExp.aExp.pExp ) ) - return sal_False; - - if( pExpDec->aLeftExp.IsDefinition() ) - if( !TestDef( lFileKey, lPos, pExpDec->aLeftExp.aExp.pDef ) ) - return sal_False; - - if( pExpDec->aRightExp.IsExpression() ) - if( !TestDef( lFileKey, lPos, pExpDec->aRightExp.aExp.pExp ) ) - return sal_False; - - if( pExpDec->aRightExp.IsDefinition() ) - if( !TestDef( lFileKey, lPos, pExpDec->aRightExp.aExp.pDef ) ) - return sal_False; - - return sal_True; -} - -/************************************************************************* -|* -|* RscFileTab::NewDef() -|* -*************************************************************************/ -RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const ByteString & rDefName, - sal_Int32 lId, sal_uLong lPos ) -{ - RscDefine * pDef = FindDef( rDefName ); - - if( !pDef ){ - RscFile * pFile = GetFile( lFileKey ); - - if( pFile ){ - pDef = pFile->aDefLst.New( lFileKey, rDefName, lId, lPos ); - aDefTree.Insert( pDef ); - } - } - else - pDef = NULL; - - return( pDef ); -} - -/************************************************************************* -|* -|* RscFileTab::NewDef() -|* -*************************************************************************/ -RscDefine * RscFileTab::NewDef( sal_uLong lFileKey, const ByteString & rDefName, - RscExpression * pExp, sal_uLong lPos ) -{ - RscDefine * pDef = FindDef( rDefName ); - - if( !pDef ){ - //Macros in den Expressions sind definiert ? - if( TestDef( lFileKey, lPos, pExp ) ){ - RscFile * pFile = GetFile( lFileKey ); - - if( pFile ){ - pDef = pFile->aDefLst.New( lFileKey, rDefName, pExp, lPos ); - aDefTree.Insert( pDef ); - } - } - } - else - pDef = NULL; - - if( !pDef ){ - // pExp wird immer Eigentum und muss, wenn es nicht benoetigt wird - // geloescht werden - delete pExp; - } - return( pDef ); -} - -/************************************************************************* -|* -|* RscFileTab::DeleteFileContext() -|* -*************************************************************************/ -void RscFileTab :: DeleteFileContext( sal_uLong lFileKey ){ - RscFile * pFName; - - pFName = GetFile( lFileKey ); - if( pFName ){ - RscDefine * pDef; - - for ( size_t i = 0, n = pFName->aDefLst.maList.size(); i < n; ++i ) { - pDef = pFName->aDefLst.maList[ i ]; - aDefTree.Remove( pDef ); - }; - while( pFName->aDefLst.Remove() ) ; - } -} - -/************************************************************************* -|* -|* RscFileTab::NewCodeFile() -|* -*************************************************************************/ -sal_uLong RscFileTab :: NewCodeFile( const ByteString & rName ) -{ - sal_uLong lKey; - RscFile * pFName; - - lKey = Find( rName ); - if( UNIQUEINDEX_ENTRY_NOTFOUND == lKey ) - { - pFName = new RscFile(); - pFName->aFileName = rName; - pFName->aPathName = rName; - lKey = Insert( pFName ); - pFName->InsertDependFile( lKey, ULONG_MAX ); - } - return lKey; -} - -/************************************************************************* -|* -|* RscFileTab::NewIncFile() -|* -*************************************************************************/ -sal_uLong RscFileTab :: NewIncFile( const ByteString & rName, - const ByteString & rPath ) -{ - sal_uLong lKey; - RscFile * pFName; - - lKey = Find( rName ); - if( UNIQUEINDEX_ENTRY_NOTFOUND == lKey ) - { - pFName = new RscFile(); - pFName->aFileName = rName; - pFName->aPathName = rPath; - pFName->SetIncFlag(); - lKey = Insert( pFName ); - pFName->InsertDependFile( lKey, ULONG_MAX ); - } - return lKey; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/tools/rschash.cxx b/rsc/source/tools/rschash.cxx deleted file mode 100644 index cefed47043..0000000000 --- a/rsc/source/tools/rschash.cxx +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -#include <rschash.hxx> - -using ::rtl::OString; -using ::rtl::OStringHash; - -AtomContainer::AtomContainer() -{ - m_aStringToID[ OString() ] = 0; - m_aIDToString[ 0 ] = OString(); - m_nNextID = 1; -} - -AtomContainer::~AtomContainer() -{ -} - -Atom AtomContainer::getID( const OString& rStr, bool bOnlyIfExists ) -{ - OString aKey = rStr.toAsciiLowerCase(); - boost::unordered_map< OString, Atom, OStringHash >::const_iterator it = - m_aStringToID.find( aKey ); - if( it != m_aStringToID.end() ) - return it->second; - - if( bOnlyIfExists ) - return InvalidAtom; - - Atom aRet = m_nNextID; - m_aStringToID[ aKey ] = m_nNextID; - m_aIDToString[ m_nNextID ] = rStr; - m_nNextID++; - return aRet; -} - -const OString& AtomContainer::getString( Atom nAtom ) -{ - boost::unordered_map< Atom, OString >::const_iterator it = - m_aIDToString.find( nAtom ); - return (it != m_aIDToString.end()) ? it->second : m_aIDToString[0]; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/tools/rsctools.cxx b/rsc/source/tools/rsctools.cxx deleted file mode 100644 index 6573302fef..0000000000 --- a/rsc/source/tools/rsctools.cxx +++ /dev/null @@ -1,424 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#if defined (WNT ) -#include <direct.h> -#endif -#include <string.h> -#include <ctype.h> - -#include <tools/fsys.hxx> - -// Include -#include <rscdef.hxx> -#include <rsctools.hxx> - -#include <osl/file.h> -#include <rtl/alloc.h> -#include <rtl/memory.h> - -using ::rtl::OUString; -using ::rtl::OUStringToOString; - -/****************** C o d e **********************************************/ -/************************************************************************* -|* -|* rsc_strnicmp() -|* -|* Beschreibung Vergleicht zwei Strings Case-Unabhaengig bis zu -|* einer bestimmten Laenge -|* -*************************************************************************/ -int rsc_strnicmp( const char *string1, const char *string2, size_t count ) -{ - size_t i; - - for( i = 0; ( i < count ) && string1[ i ] && string2[ i ] ; i++ ) - { - if( tolower( string1[ i ] ) < tolower( string2[ i ] ) ) - return( -1 ); - else if( tolower( string1[ i ] ) > tolower( string2[ i ] ) ) - return( 1 ); - } - if( i == count ) - return( 0 ); - else if( tolower( string1[ i ] ) < tolower( string2[ i ] ) ) - return( -1 ); - else if( tolower( string1[ i ] ) > tolower( string2[ i ] ) ) - return( 1 ); - return( 0 ); -} - -/************************************************************************* -|* -|* rsc_strnicmp() -|* -|* Beschreibung Vergleicht zwei Strings Case-Unabhaengig -|* -*************************************************************************/ -int rsc_stricmp( const char *string1, const char *string2 ){ - int i; - - for( i = 0; string1[ i ] && string2[ i ]; i++ ){ - if( tolower( string1[ i ] ) < tolower( string2[ i ] ) ) - return( -1 ); - else if( tolower( string1[ i ] ) > tolower( string2[ i ] ) ) - return( 1 ); - } - if( tolower( string1[ i ] ) < tolower( string2[ i ] ) ) - return( -1 ); - else if( tolower( string1[ i ] ) > tolower( string2[ i ] ) ) - return( 1 ); - return( 0 ); -} - -char* rsc_strdup( const char* pStr ) -{ - int nLen = strlen( pStr ); - char* pBuffer = (char*)rtl_allocateMemory( nLen+1 ); - rtl_copyMemory( pBuffer, pStr, nLen+1 ); - return pBuffer; -} - -/************************************************************************* -|* -|* GetTmpFileName() -|* -|* Beschreibung Gibt einen String eines eindeutigen Dateinamens -|* zurueck. Der Speicher fuer den String wird mit -|* malloc allokiert -|* -*************************************************************************/ -ByteString GetTmpFileName() -{ - OUString aTmpURL, aTmpFile; - osl_createTempFile( NULL, NULL, &aTmpURL.pData ); - osl_getSystemPathFromFileURL( aTmpURL.pData, &aTmpFile.pData ); - return OUStringToOString( aTmpFile, RTL_TEXTENCODING_MS_1252 ); -} - -/********************************************************************/ -/* */ -/* Function : Append( ) */ -/* */ -/* Parameters : psw - pointer to a preprocessor switch */ -/* */ -/* Description : appends text files */ -/********************************************************************/ -sal_Bool Append( FILE * fDest, ByteString aTmpFile ) -{ -#define MAX_BUF 4096 - FILE *fSource = fopen( aTmpFile.GetBuffer(), "rb" ); - if( !fDest || !fSource ) - { - if( fSource ) - fclose( fSource ); - return sal_False; - } - else - { - char szBuf[ MAX_BUF ]; - int nItems; - - do //appemd - { - nItems = fread( szBuf, sizeof( char ), MAX_BUF, fSource ); - fwrite( szBuf, sizeof( char ), nItems, fDest ); - } while( MAX_BUF == nItems ); - - fclose( fSource ); - }; - return sal_True; -} - -sal_Bool Append( ByteString aOutputSrs, ByteString aTmpFile ) -{ - FILE * fDest = fopen( aOutputSrs.GetBuffer(), "ab" ); - - sal_Bool bRet = Append( fDest, aTmpFile ); - - if( fDest ) - fclose( fDest ); - - return bRet; -} - -/************************************************************************* -|* -|* OutputFile -|* -|* Beschreibung Ersetzt Extension durch eine andere -|* Parameter: input, der Input-Dateiname. -|* pExt, die Extension des Ausgabenamens -|* -*************************************************************************/ -ByteString OutputFile ( ByteString aInput, const char * pExt ) -{ - UniString aUniInput( aInput, RTL_TEXTENCODING_ASCII_US ); - DirEntry aFileName( aUniInput ); - - UniString aExt( pExt, RTL_TEXTENCODING_ASCII_US ); - aFileName.SetExtension( aExt ); - - return ByteString( aFileName.GetFull(), RTL_TEXTENCODING_ASCII_US ); -} - -/************************************************************************* -|* -|* ::ResonseFile() -|* -|* Beschreibung Kommandozeile aufbereiten -|* -*************************************************************************/ -char * ResponseFile( RscPtrPtr * ppCmd, char ** ppArgv, sal_uInt32 nArgc ) -{ - FILE *fFile; - int nItems; - char szBuffer[4096]; // file buffer - sal_uInt32 i; - bool bInQuotes = false; - - // Programmname - ppCmd->Append( rsc_strdup( *ppArgv ) ); - for( i = 1; i < nArgc; i++ ) - { - if( '@' == **(ppArgv +i) ){ // wenn @, dann Response-Datei - if( NULL == (fFile = fopen( (*(ppArgv +i)) +1, "r" )) ) - return( (*(ppArgv +i)) ); - nItems = fread( &szBuffer[ 0 ], 1, sizeof( char ), fFile ); - while( nItems ) - { - if( !isspace( szBuffer[ 0 ] ) ) - { - /* - * #i27914# double ticks '"' now have a duplicate function: - * 1. they define a string ( e.g. -DFOO="baz" ) - * 2. a string can contain spaces, so -DFOO="baz zum" defines one - * argument no two ! - */ - unsigned int n = 0; - while( nItems && (!isspace( szBuffer[ n ] ) || bInQuotes) && - n +1 < sizeof( szBuffer ) ) - { - n++; - nItems = fread( &szBuffer[ n ], 1, - sizeof( char ), fFile ); - if( szBuffer[n] == '"' ) - bInQuotes = !bInQuotes; - } - szBuffer[ n ] = '\0'; - ppCmd->Append( rsc_strdup( szBuffer ) ); - } - nItems = fread( &szBuffer[ 0 ], 1, sizeof( char ), fFile ); - }; - - fclose( fFile ); - } - else - ppCmd->Append( rsc_strdup( *(ppArgv +i) ) ); - }; - ppCmd->Append( (void *)0 ); - return( NULL ); -} - - -/*************** R s c P t r P t r **************************************/ -/************************************************************************* -|* -|* RscPtrPtr :: RscPtrPtr() -|* -|* Beschreibung Eine Tabelle mit Zeigern -|* -*************************************************************************/ -RscPtrPtr :: RscPtrPtr(){ - nCount = 0; - pMem = NULL; -} - -/************************************************************************* -|* -|* RscPtrPtr :: ~RscPtrPtr() -|* -|* Beschreibung Zerst�rt eine Tabelle mit Zeigern, die Zeiger werde -|* ebenfalls freigegebn -|* -*************************************************************************/ -RscPtrPtr :: ~RscPtrPtr(){ - Reset(); -} - -/************************************************************************* -|* -|* RscPtrPtr :: Reset() -|* -*************************************************************************/ -void RscPtrPtr :: Reset(){ - sal_uInt32 i; - - if( pMem ){ - for( i = 0; i < nCount; i++ ){ - if( pMem[ i ] ) - rtl_freeMemory( pMem[ i ] ); - } - rtl_freeMemory( (void *)pMem ); - }; - nCount = 0; - pMem = NULL; -} - -/************************************************************************* -|* -|* RscPtrPtr :: Append() -|* -|* Beschreibung Haengt einen Eintrag an. -|* -*************************************************************************/ -sal_uInt32 RscPtrPtr :: Append( void * pBuffer ){ - if( !pMem ) - pMem = (void **)rtl_allocateMemory( (nCount +1) * sizeof( void * ) ); - else - pMem = (void **)rtl_reallocateMemory( (void *)pMem, - ((nCount +1) * sizeof( void * ) - ) ); - pMem[ nCount ] = pBuffer; - return( nCount++ ); -} - -/************************************************************************* -|* -|* RscPtrPtr :: GetEntry() -|* -|* Beschreibung Liefert einen Eintrag, NULL wenn nicht vorhanden. -|* -*************************************************************************/ -void * RscPtrPtr :: GetEntry( sal_uInt32 nEntry ){ - if( nEntry < nCount ) - return( pMem[ nEntry ] ); - return( NULL ); -} - -/****************** R S C W R I T E R C **********************************/ -/************************************************************************* -|* -|* RscWriteRc :: RscWriteRc() -|* -*************************************************************************/ -RscWriteRc::RscWriteRc( RSCBYTEORDER_TYPE nOrder ) -{ - short nSwapTest = 1; - RSCBYTEORDER_TYPE nMachineOrder; - - bSwap = sal_False; - if( nOrder != RSC_SYSTEMENDIAN ) - { - if( (sal_uInt8)*(sal_uInt8 *)&nSwapTest ) - nMachineOrder = RSC_LITTLEENDIAN; - else - nMachineOrder = RSC_BIGENDIAN; - bSwap = nOrder != nMachineOrder; - } - nByteOrder = nOrder; - nLen = 0; - pMem = NULL; -} - -/************************************************************************* -|* -|* RscWriteRc :: ~RscWriteRc() -|* -*************************************************************************/ -RscWriteRc :: ~RscWriteRc() -{ - if( pMem ) - rtl_freeMemory( pMem ); -} - -/************************************************************************* -|* -|* RscWriteRc :: IncSize() -|* -*************************************************************************/ -sal_uInt32 RscWriteRc :: IncSize( sal_uInt32 nSize ) -{ - nLen += nSize; - if( pMem ) - pMem = (char*)rtl_reallocateMemory( pMem, nLen ); - return( nLen - nSize ); -} - -/************************************************************************* -|* -|* RscWriteRc :: GetPointer() -|* -*************************************************************************/ -char * RscWriteRc :: GetPointer( sal_uInt32 nSize ) -{ - if( !pMem ) - pMem = (char *)rtl_allocateMemory( nLen ); - return( pMem + nSize ); -} - - -/************************************************************************* -|* -|* RscWriteRc :: Put() -|* -*************************************************************************/ -void RscWriteRc :: Put( sal_uInt16 nVal ) -{ - sal_uInt32 nOldLen; - - nOldLen = IncSize( sizeof( nVal ) ); - PutAt( nOldLen, nVal ); -} - -void RscWriteRc :: PutUTF8( char * pStr ) -{ - sal_uInt32 nStrLen = 0; - if( pStr ) - nStrLen = strlen( pStr ); - - sal_uInt32 n = nStrLen +1; - if( n % 2 ) - // align to 2 - n++; - - sal_uInt32 nOldLen = IncSize( n ); - rtl_copyMemory( GetPointer( nOldLen ), pStr, nStrLen ); - // 0 terminated - pMem[ nOldLen + nStrLen ] = '\0'; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/rsc/source/tools/rsctree.cxx b/rsc/source/tools/rsctree.cxx deleted file mode 100644 index 4bb2234810..0000000000 --- a/rsc/source/tools/rsctree.cxx +++ /dev/null @@ -1,477 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2000, 2010 Oracle and/or its affiliates. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * <http://www.openoffice.org/license.html> - * for a copy of the LGPLv3 License. - * - ************************************************************************/ - -// MARKER(update_precomp.py): autogen include statement, do not remove -#include "precompiled_rsc.hxx" -/****************** I N C L U D E S **************************************/ - -// C and C++ Includes. -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -// Programmabh�ngige Includes. -#include <tools/link.hxx> -#include <rsctree.hxx> - -/****************** C O D E **********************************************/ - -/****************** B i N o d e ******************************************/ -/************************************************************************* -|* -|* BiNode::BiNode() -|* -*************************************************************************/ -BiNode::BiNode(){ - pLeft = pRight = NULL; -} - -/************************************************************************* -|* -|* BiNode::~BiNode() -|* -*************************************************************************/ -BiNode::~BiNode(){ -} - -/************************************************************************* -|* -|* BiNode::EnumNodes() -|* -*************************************************************************/ -void BiNode::EnumNodes( Link aLink ) const{ - if( Left() ) - Left()->EnumNodes( aLink ); - aLink.Call( (BiNode *)this ); - if( Right() ) - Right()->EnumNodes( aLink ); -} - -/************************************************************************* -|* -|* BiNode::ChangeDLListBTree() -|* -*************************************************************************/ -BiNode * BiNode::ChangeDLListBTree( BiNode * pList ){ - BiNode * pRightNode; - BiNode * pMiddle; - BiNode * pTmp; - sal_uInt32 nEle, i; - - if( pList ){ - while( pList->Left() ) - pList = pList->Left(); - pTmp = pList; - for( nEle = 0; pTmp->Right(); nEle++ ) - pTmp = pTmp->Right(); - pMiddle = pList; - if( nEle / 2 ) - for( i = 0; i < (nEle / 2); i++ ) - pMiddle = pMiddle->Right(); - else - pList = (BiNode *)0; - - if( NULL != (pTmp = pMiddle->Left()) ) // rechten Zeiger auf Null - pTmp->pRight = (BiNode *)0; - - // linken Zeiger auf Null - if( NULL != (pRightNode = pMiddle->Right()) ) - pRightNode->pLeft = (BiNode *)0; - - pMiddle->pLeft = ChangeDLListBTree( pList ); - pMiddle->pRight = ChangeDLListBTree( pRightNode ); - - return( pMiddle ); - } - return( pList ); -} - -/************************************************************************* -|* -|* BiNode::ChangeBTreeDLList() -|* -*************************************************************************/ -BiNode * BiNode::ChangeBTreeDLList(){ - BiNode * pList; - BiNode * pLL_RN; // linke Liste rechter Knoten - - if( Right() ){ - pList = Right()->ChangeBTreeDLList(); - pRight = pList; - pList->pLeft = this; - } - pList = this; - if( Left() ){ - pLL_RN = pList = Left()->ChangeBTreeDLList(); - while( pLL_RN->Right() ) - pLL_RN = pLL_RN->Right(); - pLeft = pLL_RN; - pLL_RN->pRight = this; - } - return( pList ); -} - -/****************** N a m e N o d e **************************************/ -/************************************************************************* -|* -|* NameNode::Remove() -|* -*************************************************************************/ -NameNode * NameNode::Remove( NameNode * pRemove ){ - NameNode * pRoot = this; - NameNode * pParent = SearchParent( pRemove ); - - if( pParent ){ - if( pParent->Left() - && (EQUAL == pRemove->Compare( pParent->Left() ) ) ){ - pParent->pLeft = pRemove->Left(); - if( pRemove->Right() ) - pParent->Insert( pRemove->Right() ); - } - else if( pParent->Right() - && (EQUAL == pRemove->Compare( pParent->Right() ) ) ){ - pParent->pRight = pRemove->Right(); - if( pRemove->Left() ) - pParent->Insert( pRemove->Left() ); - } - } - else if( EQUAL == this->Compare( pRemove ) ){ - if( Right() ){ - pRoot = Right(); - if( Left() ) - Right()->Insert( Left() ); - } - else{ - pRoot = Left(); - } - } - pRemove->pLeft = pRemove->pRight = NULL; - - return pRoot; -} - - -/************************************************************************* -|* -|* NameNode::Compare -|* -*************************************************************************/ -COMPARE NameNode::Compare( const NameNode * pCompare ) const{ - if( (long)this < (long)pCompare ) - return LESS; - else if( (long)this > (long)pCompare ) - return GREATER; - else - return EQUAL; -} - -COMPARE NameNode::Compare( const void * pCompare ) const{ - if( (long)this < (long)pCompare ) - return LESS; - else if( (long)this > (long)pCompare ) - return GREATER; - else - return EQUAL; -} - -/************************************************************************* -|* -|* NameNode::SearchParent -|* -*************************************************************************/ -NameNode* NameNode::SearchParent( const NameNode * pSearch ) const{ -// search for a parent node. -// return a pointer to the parent node if found. -// otherwise return 0. - int nCmp = Compare( pSearch ); - - if( nCmp == GREATER ){ - if( Left() ){ - if( ((NameNode *)Left())->Compare( pSearch ) == EQUAL ) - return (NameNode *)this; - return ((NameNode *)Left())->SearchParent( pSearch ); - }; - } - else if( nCmp == LESS ){ - if( Right() ){ - if( ((NameNode *)Right())->Compare( pSearch ) == EQUAL ) - return (NameNode *)this; - return ((NameNode *)Right())->SearchParent( pSearch ); - } - }; - return( (NameNode *)NULL ); -} - -/************************************************************************* -|* -|* NameNode::Search -|* -*************************************************************************/ -NameNode* NameNode::Search( const NameNode * pSearch ) const{ -// search for a node. -// return a pointer to the node if found. -// otherwise return 0. - int nCmp = Compare( pSearch ); - - if( nCmp == GREATER ){ - if( Left() ) - return ((NameNode *)Left())->Search( pSearch ); - } - else if( nCmp == LESS ){ - if( Right() ) - return ((NameNode *)Right())->Search( pSearch ); - } - else - return( (NameNode *)this ); - - return( NULL ); -} - -NameNode* NameNode::Search( const void * pSearch ) const{ -// search for a node. -// return a pointer to the node if found. -// otherwise return 0. - int nCmp = Compare( pSearch ); - - if( nCmp == GREATER ){ - if( Left() ) - return ((NameNode *)Left())->Search( pSearch ); - } - else if( nCmp == LESS ){ - if( Right() ) - return ((NameNode *)Right())->Search( pSearch ); - } - else - return( (NameNode *)this ); - - return( NULL ); -} - -/************************************************************************* -|* -|* NameNode::Insert() -|* -*************************************************************************/ -sal_Bool NameNode::Insert( NameNode * pTN, sal_uInt32* pnDepth ){ -// Ein Knoten wird in den Baum eingefuegt -// Gibt es einen Knoten mit dem gleichen Namen, dann return sal_False -// sonst return sal_True. Der Knoten wird auf jeden Fall eingefuegt. - - sal_Bool bRet = sal_True; - int nCmp = Compare( pTN ); - - *pnDepth += 1; - if( nCmp == GREATER ){ - if( Left() ) - bRet = ((NameNode *)Left())->Insert( pTN, pnDepth ); - else - pLeft = pTN; - } - else{ - if( Right() ) - bRet = ((NameNode *)Right())->Insert( pTN, pnDepth ); - else - pRight = pTN; - if( nCmp == EQUAL ) - bRet = sal_False; - }; - return( bRet ); -} - -/************************************************************************* -|* -|* NameNode::Insert() -|* -*************************************************************************/ -sal_Bool NameNode::Insert( NameNode * pTN ){ -// insert a node in the tree. -// if the node with the same name is in, return sal_False and no insert. -// if not return true. - sal_uInt32 nDepth = 0; - sal_Bool bRet; - - bRet = Insert( pTN, &nDepth ); - if( bRet ){ - if( nDepth > 20 ){ - if( Left() ) - pLeft = ChangeDLListBTree( Left()->ChangeBTreeDLList() ); - if( Right() ) - pRight = ChangeDLListBTree( Right()->ChangeBTreeDLList() ); - } - } - - return( bRet ); -} - -/************************************************************************* -|* -|* NameNode::OrderTree() -|* -*************************************************************************/ -void NameNode::OrderTree(){ - NameNode * pTmpLeft = (NameNode *)Left(); - NameNode * pTmpRight = (NameNode *)Right(); - - pLeft = NULL; - pRight = NULL; - SubOrderTree( pTmpLeft ); - SubOrderTree( pTmpRight ); -} - -void NameNode::SubOrderTree( NameNode * pOrderNode ){ - if( pOrderNode ){ - NameNode * pTmpLeft = (NameNode *)pOrderNode->Left(); - NameNode * pTmpRight = (NameNode *)pOrderNode->Right(); - pOrderNode->pLeft = NULL; - pOrderNode->pRight = NULL; - Insert( pOrderNode ); - SubOrderTree( pTmpLeft ); - SubOrderTree( pTmpRight ); - } -} - -/************************************************************************* -|* -|* NameNode::IdOrderTree() -|* -*************************************************************************/ -class OrderCtrl { - sal_Bool bOrder; - NameNode * pName; - DECL_LINK( CallBackFunc, NameNode * ); -public: - OrderCtrl() { bOrder = sal_False; pName = NULL; } - sal_Bool IsOrder( const NameNode * pRoot ) - { - bOrder = sal_True; - pName = NULL; - pRoot->EnumNodes( LINK( this, OrderCtrl, CallBackFunc ) ); - return bOrder; - }; -}; -IMPL_LINK_INLINE_START( OrderCtrl, CallBackFunc, NameNode *, pNext ) -{ - if( pName && pName->Compare( pNext ) != LESS ) - bOrder = sal_False; - pName = pNext; - return 0; -} -IMPL_LINK_INLINE_END( OrderCtrl, CallBackFunc, NameNode *, pNext ) - -sal_Bool NameNode::IsOrderTree() const{ - OrderCtrl aOrder; - - return aOrder.IsOrder( this ); -} - -/****************** I d N o d e ******************************************/ -/************************************************************************* -|* -|* IdNode::Search() -|* -*************************************************************************/ -IdNode * IdNode::Search( sal_uInt32 nTypeName ) const{ - return( (IdNode *)NameNode::Search( (const void *)&nTypeName ) ); -} - -/************************************************************************* -|* -|* IdNode::Compare() -|* -*************************************************************************/ -COMPARE IdNode::Compare( const NameNode * pSearch ) const -{ - if( GetId() < (sal_uInt32)(((const IdNode *)pSearch)->GetId()) ) - return LESS; - else if( GetId() > (sal_uInt32)(((const IdNode *)pSearch)->GetId()) ) - return GREATER; - else - return EQUAL; -} - -COMPARE IdNode::Compare( const void * pSearch ) const{ -// pSearch ist ein Zeiger auf sal_uInt32 - - if( GetId() < *((const sal_uInt32 *)pSearch) ) - return LESS; - else if( GetId() > *((const sal_uInt32 *)pSearch) ) - return GREATER; - else - return EQUAL; -} - -/************************************************************************* -|* -|* IdNode::GetId() -|* -*************************************************************************/ -sal_uInt32 IdNode::GetId() const -{ - return( 0xFFFFFFFF ); -} - -/************************************************************************* -|* -|* StringNode::Search() -|* -*************************************************************************/ -StringNode * StringNode::Search( const char * pSearch ) const{ - return (StringNode *)NameNode::Search( (const void *)pSearch ); -} - -/************************************************************************* -|* -|* StringNode::Compare() -|* -*************************************************************************/ -COMPARE StringNode::Compare( const NameNode * pSearch ) const -{ - int nCmp = strcmp( aName.GetBuffer(), - ((const StringNode *)pSearch)->aName.GetBuffer() ); - if( nCmp < 0 ) - return LESS; - else if( nCmp > 0 ) - return GREATER; - else - return EQUAL; -} - -COMPARE StringNode::Compare( const void * pSearch ) const -{ -// pSearch ist ein Zeiger auf const char * - int nCmp = strcmp( aName.GetBuffer(), (const char *)pSearch ); - - if( nCmp < 0 ) - return LESS; - else if( nCmp > 0 ) - return GREATER; - else - return EQUAL; -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |