summaryrefslogtreecommitdiff
path: root/rsc/inc/rsctop.hxx
blob: 2c7a98d3f18ccf4e1fd4f0121bb7953959457317 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */
#ifndef INCLUDED_RSC_INC_RSCTOP_HXX
#define INCLUDED_RSC_INC_RSCTOP_HXX

#include <rscerror.h>
#include <rsctools.hxx>
#include <rschash.hxx>
#include <rscclobj.hxx>
#include <rsc/rscsfx.hxx>
#include <o3tl/typed_flags_set.hxx>
#include <tools/resid.hxx>

enum class RSCVAR {
    NONE        = 0x0000,
    Pointer     = 0x0001,
    Hidden      = 0x0002,
    NoDataInst  = 0x0004,
    NoRc        = 0x0008,
    SvDynamic   = 0x0010,
    NoEnum      = 0x0020
};
namespace o3tl {
    template<> struct typed_flags<RSCVAR> : is_typed_flags<RSCVAR, 0x007f> {};
}

class RscTop : public RefNode
{
    RscTop *        pSuperClass;
    RSCINST         aDfltInst;
    sal_uInt32          nTypId;
    RscTop *        pRefClass;

protected:
                    RscTop( Atom nId, RESOURCE_TYPE nTypIdent,
                            RscTop * pSuperCl = nullptr );

public:
         OString    aCallPar1;      // class call without types until ResId
         OString    aCallPar2;      // class call without types staring at ResId
         OString    aCallParType;   // class call with types

            RscTop* GetSuperClass() const
                    { return pSuperClass; }
                    // returns the type identifier
            sal_uInt32  GetTypId() const
                    { return nTypId; };
                    // returns the super class
            bool    InHierarchy( RscTop * pClass );
            void    SetCallPar( const OString& rPar1, const OString& rPar2,
                                const OString& rParType );
            RscTop* GetRefClass() const { return pRefClass; }
    virtual RSCCLASS_TYPE GetClassType() const = 0;
            RSCINST const & GetDefault();

                    // preparation fro the destructor call
                    // given that classes can have mutual dependencies,
                    // we cannot assume in destructor that all class pointer
                    // are still valid
    virtual void    Pre_dtor();

    virtual RscTop* GetTypeClass() const;

                    // returns the class size in bytes
    virtual sal_uInt32  Size() const;

                    // returns the reference
    virtual ERRTYPE GetRef( const RSCINST & rInst, RscId * );

                    // sets the reference
    virtual ERRTYPE SetRef( const RSCINST & rInst, const RscId & rRefId );

                    // sets the variable
    virtual ERRTYPE SetVariable( Atom nVarName, RscTop * pClass,
                                 RSCINST * pDflt = nullptr,
                                 RSCVAR nVarType = RSCVAR::NONE, sal_uInt32 nMask = 0,
                                 Atom nDataBaseName = InvalidAtom );

                    // enumerate all variables
    virtual void    EnumVariables( void * pData, VarEnumCallbackProc );

                    // returns variable instance
                    // returned pData, pClass may be NULL
    virtual RSCINST GetVariable( const RSCINST & rInst, Atom nVarName,
                                 const RSCINST & rInitInst,
                                 bool bInitDflt = false,
                                 RscTop * pCreateClass = nullptr );
    virtual RSCINST GetCopyVar( const RSCINST & rInst, Atom nVarName );

    virtual RSCINST GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos,
                                 const RSCINST & rInitInst );

                    // returns instance from a field
                    // returned pGetInst may be NULL
    virtual ERRTYPE GetElement( const RSCINST & rInst, const RscId & rEleName,
                                RscTop *pCreateClass, const RSCINST & rCreateInst,
                                RSCINST * pGetInst );

                    // returns instance from a value
                    // returned pGetInst may be NULL
    virtual ERRTYPE GetValueEle( const RSCINST & rInst, sal_Int32 lValue,
                                RscTop * pCreateClass,
                                RSCINST * pGetInst );

                    // returns instance from an array
                    // returned pGetInst may be NULL
    virtual ERRTYPE GetArrayEle( const RSCINST & rInst, Atom nId,
                                RscTop * pCreateClass,
                                RSCINST * pGetInst );

    virtual RSCINST SearchEle( const RSCINST & rInst, const RscId & rEleName,
                               RscTop * pClass );

                    // returns instance at the position
    virtual RSCINST GetPosEle( const RSCINST & rInst, sal_uInt32 nPos );

                    // move an instance
    virtual ERRTYPE MovePosEle( const RSCINST & rInst, sal_uInt32 nDestPos,
                                sal_uInt32 nSourcePos );

                    // changes RscId at position
    virtual ERRTYPE SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos,
                                 const RscId & rRscId);

                    // returns instance information at position
    virtual SUBINFO_STRUCT GetInfoEle( const RSCINST & rInst, sal_uInt32 nPos );

                    // number of entries
    virtual sal_uInt32 GetCount( const RSCINST & rInst );

                    // an assignment to a variable
    virtual ERRTYPE SetNumber( const RSCINST & rInst, sal_Int32 lValue );

                    // an assignment to a variable
    virtual ERRTYPE SetBool( const RSCINST & rInst, bool bValue );

                    // an assignment to a variable
    virtual ERRTYPE SetConst( const RSCINST & rInst, Atom nValueId,
                              sal_Int32 nValue );

                    // an assignment to a variable
    virtual ERRTYPE SetNotConst( const RSCINST & rInst, Atom nId );

    virtual ERRTYPE SetString( const RSCINST & rInst, const char * pStr );

    virtual ERRTYPE GetNumber( const RSCINST & rInst, sal_Int32 * pN );

    virtual ERRTYPE GetBool( const RSCINST & rInst, bool * pB );

    virtual ERRTYPE GetConst( const RSCINST & rInst, Atom * pH );

    virtual ERRTYPE GetString( const RSCINST & rInst, char ** ppStr );

    virtual RSCINST Create( RSCINST * pInst,
                            const RSCINST & rDefInst, bool bOwnClass = false );

                    // destroys instance
    virtual void    Destroy( const RSCINST & rInst );

                    // checks consistency
    virtual bool    IsConsistent( const RSCINST & rInst );

                    // sets all default values
    virtual void    SetToDefault( const RSCINST & rInst );

                    // wether input is equal to default
    virtual bool    IsDefault( const RSCINST & rInst );

                    // sets value to default
    virtual bool    IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef );

                    // sets intance to default
    virtual void    SetDefault( const RSCINST & rInst, Atom nVarId );

                    // returns a variable default
    virtual RSCINST GetDefault( Atom nVarId );

    virtual void    Delete( const RSCINST & rInst, RscTop * pClass,
                            const RscId & rId );

    virtual void    DeletePos( const RSCINST & rInst, sal_uInt32 nPos );

                    // writes header and footer of a resource script file
    virtual void    WriteSrcHeader( const RSCINST & rInst, FILE * fOutput,
                                    RscTypCont * pTC, sal_uInt32 nTab,
                                    const RscId & aId, const char * );
    virtual void    WriteSrc( const RSCINST & rInst, FILE * fOutput,
                              RscTypCont * pTC, sal_uInt32 nTab,const char * );
    virtual ERRTYPE WriteRcHeader( const RSCINST & rInst, RscWriteRc & aMem,
                                   RscTypCont * pTC, const RscId & aId,
                                    sal_uInt32 nDeep );
    virtual ERRTYPE WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
                             RscTypCont * pTC, sal_uInt32 nDeep );
};

#endif // INCLUDED_RSC_INC_RSCTOP_HXX

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */