1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: rscyacc.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_rsc.hxx"
39 #include <rsctools.hxx>
40 #include <rscclass.hxx>
41 #include <rsccont.hxx>
42 #include <rsctree.hxx>
49 /************** V a r i a b l e n ****************************************/
55 /************** H i l f s F u n k t i o n e n ****************************/
56 RSCINST
GetVarInst( const RSCINST
& rInst
, const char * pVarName
)
60 aInst
= rInst
.pClass
->GetVariable( rInst
, pHS
->getID( pVarName
),
64 pTC
->pEH
->Error( ERR_NOVARIABLENAME
, rInst
.pClass
, RscId() );
69 void SetNumber( const RSCINST
& rInst
, const char * pVarName
, INT32 lValue
)
73 aInst
= GetVarInst( rInst
, pVarName
);
77 aError
= aInst
.pClass
->SetNumber( aInst
, lValue
);
79 if( aError
.IsError() )
80 pTC
->pEH
->Error( aError
, aInst
.pClass
, RscId() );
84 void SetConst( const RSCINST
& rInst
, const char * pVarName
,
85 Atom nValueId
, INT32 nVal
)
89 aInst
= GetVarInst( rInst
, pVarName
);
93 aError
= aInst
.pClass
->SetConst( aInst
, nValueId
, nVal
);
95 if( aError
.IsError() )
96 pTC
->pEH
->Error( aError
, aInst
.pClass
, RscId() );
100 void SetString( const RSCINST
& rInst
, const char * pVarName
, const char * pStr
)
104 aInst
= GetVarInst( rInst
, pVarName
);
107 aError
= aInst
.pClass
->SetString( aInst
, pStr
);
109 if( aError
.IsError() )
110 pTC
->pEH
->Error( aError
, aInst
.pClass
, RscId() );
114 RscId
MakeRscId( RscExpType aExpType
)
116 if( !aExpType
.IsNothing() ){
119 if( !aExpType
.Evaluate( &lValue
) )
120 pTC
->pEH
->Error( ERR_ZERODIVISION
, NULL
, RscId() );
121 if( lValue
< 1 || lValue
> (INT32
)0x7FFF )
123 pTC
->pEH
->Error( ERR_IDRANGE
, NULL
, RscId(),
124 ByteString::CreateFromInt32( lValue
).GetBuffer() );
127 if( aExpType
.IsDefinition() )
128 return RscId( aExpType
.aExp
.pDef
);
130 return RscId( lValue
);
135 BOOL
DoClassHeader( RSCHEADER
* pHeader
, BOOL bMember
)
138 RscId aName1
= MakeRscId( pHeader
->nName1
);
139 RscId aName2
= MakeRscId( pHeader
->nName2
);
141 if( pHeader
->pRefClass
)
142 aCopyInst
.pClass
= pHeader
->pRefClass
;
144 aCopyInst
.pClass
= pHeader
->pClass
;
146 if( TYPE_COPY
== pHeader
->nTyp
)
148 ObjNode
* pCopyObj
= aCopyInst
.pClass
->GetObjNode( aName2
);
152 ByteString
aMsg( pHS
->getString( aCopyInst
.pClass
->GetId() ) );
154 aMsg
+= aName2
.GetName();
155 pTC
->pEH
->Error( ERR_NOCOPYOBJ
, pHeader
->pClass
, aName1
,
159 aCopyInst
.pData
= pCopyObj
->GetRscObj();
164 // Angabe von Superklassen oder abgeleiteten Klassen ist jetzt erlaubt
165 if( S
.Top().pClass
->InHierarchy( pHeader
->pClass
)
166 || pHeader
->pClass
->InHierarchy( S
.Top().pClass
) )
168 if( aCopyInst
.IsInst() )
170 RSCINST
aTmpI( S
.Top() );
171 aTmpI
.pClass
->Destroy( aTmpI
);
172 aTmpI
.pClass
->Create( &aTmpI
, aCopyInst
);
176 pTC
->pEH
->Error( ERR_FALSETYPE
, S
.Top().pClass
, aName1
,
177 pHS
->getString( pHeader
->pClass
->GetId() ) );
183 if( (INT32
)aName1
< 256 )
184 pTC
->pEH
->Error( WRN_GLOBALID
, pHeader
->pClass
, aName1
);
186 if( aCopyInst
.IsInst() )
187 S
.Push( pHeader
->pClass
->Create( NULL
, aCopyInst
) );
189 S
.Push( pHeader
->pClass
->Create( NULL
, RSCINST() ) );
191 ObjNode
* pNode
= new ObjNode( aName1
, S
.Top().pData
,
192 pFI
->GetFileIndex() );
193 pTC
->pEH
->StdOut( ".", RscVerbosityVerbose
);
196 pTC
->pEH
->Error( ERR_IDEXPECTED
, pHeader
->pClass
, aName1
);
197 else if( !pHeader
->pClass
->PutObjNode( pNode
) )
198 pTC
->pEH
->Error( ERR_DOUBLEID
, pHeader
->pClass
, aName1
);
205 if( (INT32
)aName1
>= 256 && aName1
.IsId() )
206 pTC
->pEH
->Error( WRN_LOCALID
, pHeader
->pClass
, aName1
);
207 aError
= S
.Top().pClass
->GetElement( S
.Top(), aName1
,
208 pHeader
->pClass
, aCopyInst
, &aTmpI
);
210 if( aError
.IsWarning() )
211 pTC
->pEH
->Error( aError
, pHeader
->pClass
, aName1
);
212 else if( aError
.IsError() )
214 if( ERR_CONT_INVALIDTYPE
== aError
)
215 pTC
->pEH
->Error( aError
, S
.Top().pClass
, aName1
,
216 pHS
->getString( pHeader
->pClass
->GetId() ) );
218 pTC
->pEH
->Error( aError
, S
.Top().pClass
, aName1
);
219 S
.Top().pClass
->GetElement( S
.Top(), RscId(),
220 pHeader
->pClass
, RSCINST(), &aTmpI
);
222 if( !aTmpI
.IsInst() )
228 if( TYPE_REF
== pHeader
->nTyp
)
232 aError
= S
.Top().pClass
->SetRef( S
.Top(), aName2
);
233 pTC
->pEH
->Error( aError
, S
.Top().pClass
, aName1
);
239 RSCINST
GetFirstTupelEle( const RSCINST
& rTop
)
240 { // Aufwaertskompatible, Tupel probieren
244 aErr
= rTop
.pClass
->GetElement( rTop
, RscId(), NULL
, RSCINST(), &aInst
);
245 if( !aErr
.IsError() )
246 aInst
= aInst
.pClass
->GetTupelVar( aInst
, 0, RSCINST() );
250 /************** Y a c c C o d e ****************************************/
257 #define YYMAXDEPTH 2000
260 #define YYMAXDEPTH 300
262 #define YYMAXDEPTH 800
267 #pragma warning(push, 1)
268 #pragma warning(disable:4129 4273 4701)
270 #include "yyrscyacc.cxx"