1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_rsc.hxx"
36 #include <rsctools.hxx>
37 #include <rscclass.hxx>
38 #include <rsccont.hxx>
39 #include <rsctree.hxx>
46 /************** V a r i a b l e n ****************************************/
52 /************** H i l f s F u n k t i o n e n ****************************/
53 RSCINST
GetVarInst( const RSCINST
& rInst
, const char * pVarName
)
57 aInst
= rInst
.pClass
->GetVariable( rInst
, pHS
->getID( pVarName
),
61 pTC
->pEH
->Error( ERR_NOVARIABLENAME
, rInst
.pClass
, RscId() );
66 void SetNumber( const RSCINST
& rInst
, const char * pVarName
, sal_Int32 lValue
)
70 aInst
= GetVarInst( rInst
, pVarName
);
74 aError
= aInst
.pClass
->SetNumber( aInst
, lValue
);
76 if( aError
.IsError() )
77 pTC
->pEH
->Error( aError
, aInst
.pClass
, RscId() );
81 void SetConst( const RSCINST
& rInst
, const char * pVarName
,
82 Atom nValueId
, sal_Int32 nVal
)
86 aInst
= GetVarInst( rInst
, pVarName
);
90 aError
= aInst
.pClass
->SetConst( aInst
, nValueId
, nVal
);
92 if( aError
.IsError() )
93 pTC
->pEH
->Error( aError
, aInst
.pClass
, RscId() );
97 void SetString( const RSCINST
& rInst
, const char * pVarName
, const char * pStr
)
101 aInst
= GetVarInst( rInst
, pVarName
);
104 aError
= aInst
.pClass
->SetString( aInst
, pStr
);
106 if( aError
.IsError() )
107 pTC
->pEH
->Error( aError
, aInst
.pClass
, RscId() );
111 RscId
MakeRscId( RscExpType aExpType
)
113 if( !aExpType
.IsNothing() ){
116 if( !aExpType
.Evaluate( &lValue
) )
117 pTC
->pEH
->Error( ERR_ZERODIVISION
, NULL
, RscId() );
118 if( lValue
< 1 || lValue
> (sal_Int32
)0x7FFF )
120 pTC
->pEH
->Error( ERR_IDRANGE
, NULL
, RscId(),
121 ByteString::CreateFromInt32( lValue
).GetBuffer() );
124 if( aExpType
.IsDefinition() )
125 return RscId( aExpType
.aExp
.pDef
);
127 return RscId( lValue
);
132 sal_Bool
DoClassHeader( RSCHEADER
* pHeader
, sal_Bool bMember
)
135 RscId aName1
= MakeRscId( pHeader
->nName1
);
136 RscId aName2
= MakeRscId( pHeader
->nName2
);
138 if( pHeader
->pRefClass
)
139 aCopyInst
.pClass
= pHeader
->pRefClass
;
141 aCopyInst
.pClass
= pHeader
->pClass
;
143 if( TYPE_COPY
== pHeader
->nTyp
)
145 ObjNode
* pCopyObj
= aCopyInst
.pClass
->GetObjNode( aName2
);
149 ByteString
aMsg( pHS
->getString( aCopyInst
.pClass
->GetId() ) );
151 aMsg
+= aName2
.GetName();
152 pTC
->pEH
->Error( ERR_NOCOPYOBJ
, pHeader
->pClass
, aName1
,
156 aCopyInst
.pData
= pCopyObj
->GetRscObj();
161 // Angabe von Superklassen oder abgeleiteten Klassen ist jetzt erlaubt
162 if( S
.Top().pClass
->InHierarchy( pHeader
->pClass
)
163 || pHeader
->pClass
->InHierarchy( S
.Top().pClass
) )
165 if( aCopyInst
.IsInst() )
167 RSCINST
aTmpI( S
.Top() );
168 aTmpI
.pClass
->Destroy( aTmpI
);
169 aTmpI
.pClass
->Create( &aTmpI
, aCopyInst
);
173 pTC
->pEH
->Error( ERR_FALSETYPE
, S
.Top().pClass
, aName1
,
174 pHS
->getString( pHeader
->pClass
->GetId() ) );
180 if( (sal_Int32
)aName1
< 256 )
181 pTC
->pEH
->Error( WRN_GLOBALID
, pHeader
->pClass
, aName1
);
183 if( aCopyInst
.IsInst() )
184 S
.Push( pHeader
->pClass
->Create( NULL
, aCopyInst
) );
186 S
.Push( pHeader
->pClass
->Create( NULL
, RSCINST() ) );
188 ObjNode
* pNode
= new ObjNode( aName1
, S
.Top().pData
,
189 pFI
->GetFileIndex() );
190 pTC
->pEH
->StdOut( ".", RscVerbosityVerbose
);
193 pTC
->pEH
->Error( ERR_IDEXPECTED
, pHeader
->pClass
, aName1
);
194 else if( !pHeader
->pClass
->PutObjNode( pNode
) )
195 pTC
->pEH
->Error( ERR_DOUBLEID
, pHeader
->pClass
, aName1
);
202 if( (sal_Int32
)aName1
>= 256 && aName1
.IsId() )
203 pTC
->pEH
->Error( WRN_LOCALID
, pHeader
->pClass
, aName1
);
204 aError
= S
.Top().pClass
->GetElement( S
.Top(), aName1
,
205 pHeader
->pClass
, aCopyInst
, &aTmpI
);
207 if( aError
.IsWarning() )
208 pTC
->pEH
->Error( aError
, pHeader
->pClass
, aName1
);
209 else if( aError
.IsError() )
211 if( ERR_CONT_INVALIDTYPE
== aError
)
212 pTC
->pEH
->Error( aError
, S
.Top().pClass
, aName1
,
213 pHS
->getString( pHeader
->pClass
->GetId() ) );
215 pTC
->pEH
->Error( aError
, S
.Top().pClass
, aName1
);
216 S
.Top().pClass
->GetElement( S
.Top(), RscId(),
217 pHeader
->pClass
, RSCINST(), &aTmpI
);
219 if( !aTmpI
.IsInst() )
225 if( TYPE_REF
== pHeader
->nTyp
)
229 aError
= S
.Top().pClass
->SetRef( S
.Top(), aName2
);
230 pTC
->pEH
->Error( aError
, S
.Top().pClass
, aName1
);
236 RSCINST
GetFirstTupelEle( const RSCINST
& rTop
)
237 { // Aufwaertskompatible, Tupel probieren
241 aErr
= rTop
.pClass
->GetElement( rTop
, RscId(), NULL
, RSCINST(), &aInst
);
242 if( !aErr
.IsError() )
243 aInst
= aInst
.pClass
->GetTupelVar( aInst
, 0, RSCINST() );
247 /************** Y a c c C o d e ****************************************/
254 #define YYMAXDEPTH 2000
256 #define YYMAXDEPTH 800
260 #pragma warning(push, 1)
261 #pragma warning(disable:4129 4273 4701)
263 #include "yyrscyacc.cxx"