xref: /aoo41x/main/rsc/inc/rscflag.hxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 #ifndef _RSCFLAG_HXX
28 #define _RSCFLAG_HXX
29 
30 #include <rscall.h>
31 #include <rscerror.h>
32 #include <rschash.hxx>
33 #include <rscconst.hxx>
34 
35 /******************* R s c F l a g ***************************************/
36 class RscFlag : public RscConst {
37     struct RscFlagInst{
38         sal_uInt32  nFlags;
39         sal_uInt32  nDfltFlags;
40     };
41     RSCINST         CreateBasic( RSCINST * pInst );
42 public:
43                     RscFlag( Atom nId, sal_uInt32 nTypId );
44     RSCINST         Create( RSCINST * pInst, const RSCINST & rDflt, sal_Bool );
45     RSCINST         CreateClient( RSCINST * pInst, const RSCINST & rDflt,
46                                   sal_Bool bOwnClass, Atom nConsId );
47     sal_uInt32          Size();
48 
49 	virtual void	SetToDefault( const RSCINST & rInst );
50     sal_Bool            IsDefault( const RSCINST & rInst );
51     sal_Bool            IsDefault( const RSCINST & rInst, Atom nConstId );
52 
53                     // Ist das Flag gesetzt
54     sal_Bool            IsSet( const RSCINST & rInst, Atom nConstId );
55 
56                     // Als Default setzen
57     sal_Bool            IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef );
58     sal_Bool            IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef,
59                                     Atom nConstId );
60 
61     ERRTYPE         SetConst( const RSCINST & rInst, Atom nValueId,
62 							  sal_Int32 nValue );
63     ERRTYPE         SetNotConst( const RSCINST & rInst, Atom nConstId );
64     void            WriteSrc( const RSCINST & rInst, FILE * fOutput,
65                               RscTypCont * pTC, sal_uInt32 nTab, const char * );
66     ERRTYPE         WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
67                              RscTypCont * pTC, sal_uInt32, sal_Bool bExtra );
68 };
69 
70 /******************* R s c C l i e n t ***********************************/
71 class RscClient : public RscTop
72 {
73     RscFlag *   pRefClass;  //Klasse die als Server benutzt wird
74     Atom      nConstId;   //Id des zu setzenden Wertes
75 public:
76                     RscClient( Atom nId, sal_uInt32 nTypId, RscFlag * pClass,
77                                Atom nConstantId );
78 	virtual RSCCLASS_TYPE   GetClassType() const;
79     RSCINST         Create( RSCINST * pInst, const RSCINST & rDflt, sal_Bool );
80     sal_uInt32          Size(){ return( pRefClass->Size() ); };
81 
82                     // Eine Zuweisung an eine Variable
83     sal_Bool            IsDefault( const RSCINST & rInst ){
84                         return( pRefClass->IsDefault( rInst, nConstId ) );
85                     };
86                     // Als Default setzen
87     sal_Bool            IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ){
88                         return pRefClass->IsValueDefault( rInst,
89                                                     pDef, nConstId );
90                     }
91     ERRTYPE         SetBool( const RSCINST & rInst, sal_Bool bValue ){
92                         if( bValue )
93                             return( pRefClass->SetConst( rInst, nConstId, bValue ) );
94                         else
95                             return( pRefClass->
96                                     SetNotConst( rInst, nConstId ) );
97                     };
98     ERRTYPE         GetBool( const RSCINST & rInst, sal_Bool * pB ){
99                         *pB = pRefClass->IsSet( rInst, nConstId );
100                         return( ERR_OK );
101                     };
102     void            WriteSrc( const RSCINST & rInst, FILE * fOutput,
103                               RscTypCont * pTC, sal_uInt32 nTab, const char * );
104 };
105 
106 #endif // _RSCFLAG_HXX
107