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"
30 /****************** I N C L U D E S **************************************/
32 // C and C++ Includes.
37 #include <rscflag.hxx>
39 /****************** C O D E **********************************************/
40 /****************** R s c F l a g ****************************************/
41 /*************************************************************************
46 |* Ersterstellung MM 03.04.91
47 |* Letzte Aenderung MM 03.04.91
49 *************************************************************************/
50 RscFlag::RscFlag( Atom nId
, sal_uInt32 nTypeId
)
51 : RscConst( nId
, nTypeId
)
54 /*************************************************************************
58 |* Beschreibung Die Groe�e der Instanzdaten richtet sich nach
59 |* der Anzahl der Flags
60 |* Ersterstellung MM 03.04.91
61 |* Letzte Aenderung MM 03.04.91
63 *************************************************************************/
64 sal_uInt32
RscFlag::Size()
66 return( ALIGNED_SIZE( sizeof( RscFlagInst
) *
67 ( 1 + (nEntries
-1) / (sizeof( sal_uInt32
) * 8) ) ) );
70 /*************************************************************************
72 |* RscFlag::SetNotConst()
75 |* Ersterstellung MM 03.04.91
76 |* Letzte Aenderung MM 03.04.91
78 *************************************************************************/
79 ERRTYPE
RscFlag::SetNotConst( const RSCINST
& rInst
, Atom nConst
)
81 sal_uInt32 i
= 0, nFlag
= 0;
83 if( nEntries
!= (i
= GetConstPos( nConst
)) ){
84 nFlag
= 1 << (i
% (sizeof( sal_uInt32
) * 8) );
85 i
= i
/ (sizeof( sal_uInt32
) * 8);
86 ((RscFlagInst
*)rInst
.pData
)[ i
].nFlags
&= ~nFlag
;
87 ((RscFlagInst
*)rInst
.pData
)[ i
].nDfltFlags
&= ~nFlag
;
91 return( ERR_RSCFLAG
);
94 /*************************************************************************
96 |* RscFlag::SetConst()
99 |* Ersterstellung MM 03.04.91
100 |* Letzte Aenderung MM 03.04.91
102 *************************************************************************/
103 ERRTYPE
RscFlag::SetConst( const RSCINST
& rInst
, Atom nConst
, sal_Int32
/*nVal*/ )
105 sal_uInt32 i
= 0, nFlag
= 0;
107 if( nEntries
!= (i
= GetConstPos( nConst
)) ){
108 nFlag
= 1 << (i
% (sizeof( sal_uInt32
) * 8) );
109 i
= i
/ (sizeof( sal_uInt32
) * 8);
110 ((RscFlagInst
*)rInst
.pData
)[ i
].nFlags
|= nFlag
;
111 ((RscFlagInst
*)rInst
.pData
)[ i
].nDfltFlags
&= ~nFlag
;
115 return( ERR_RSCFLAG
);
118 /*************************************************************************
120 |* RscFlag::CreateBasic()
123 |* Ersterstellung MM 16.01.92
124 |* Letzte Aenderung MM 16.01.92
126 *************************************************************************/
127 RSCINST
RscFlag::CreateBasic( RSCINST
* pInst
)
133 aInst
.pData
= (CLASS_DATA
) rtl_allocateMemory( Size() );
141 /*************************************************************************
146 |* Ersterstellung MM 03.04.91
147 |* Letzte Aenderung MM 16.01.92
149 *************************************************************************/
150 RSCINST
RscFlag::Create( RSCINST
* pInst
, const RSCINST
& rDflt
, sal_Bool bOwnClass
)
152 RSCINST aInst
= CreateBasic( pInst
);
155 if( !bOwnClass
&& rDflt
.IsInst() )
156 bOwnClass
= rDflt
.pClass
->InHierarchy( this );
159 memmove( aInst
.pData
, rDflt
.pData
, Size() );
162 for( i
= 0; i
< Size() / sizeof( RscFlagInst
); i
++ )
164 ((RscFlagInst
*)aInst
.pData
)[ i
].nFlags
= 0;
165 ((RscFlagInst
*)aInst
.pData
)[ i
].nDfltFlags
= 0xFFFFFFFF;
172 /*************************************************************************
174 |* RscFlag::CreateClient()
177 |* Ersterstellung MM 16.01.92
178 |* Letzte Aenderung MM 16.01.92
180 *************************************************************************/
181 RSCINST
RscFlag::CreateClient( RSCINST
* pInst
, const RSCINST
& rDfltI
,
182 sal_Bool bOwnClass
, Atom nConstId
)
184 RSCINST aInst
= CreateBasic( pInst
);
185 sal_uInt32 i
= 0, nFlag
= 0;
187 if( !bOwnClass
&& rDfltI
.IsInst() )
188 bOwnClass
= rDfltI
.pClass
->InHierarchy( this );
190 if( nEntries
!= (i
= GetConstPos( nConstId
)) ){
191 nFlag
= 1 << (i
% (sizeof( sal_uInt32
) * 8) );
192 i
= i
/ (sizeof( sal_uInt32
) * 8);
194 ((RscFlagInst
*)aInst
.pData
)[ i
].nFlags
&=
195 ~nFlag
| ((RscFlagInst
*)rDfltI
.pData
)[ i
].nFlags
;
196 ((RscFlagInst
*)aInst
.pData
)[ i
].nDfltFlags
&=
197 ~nFlag
| ((RscFlagInst
*)rDfltI
.pData
)[ i
].nDfltFlags
;
200 ((RscFlagInst
*)aInst
.pData
)[ i
].nFlags
&= ~nFlag
;
201 ((RscFlagInst
*)aInst
.pData
)[ i
].nDfltFlags
|= nFlag
;
208 /*************************************************************************
210 |* RscFlag::SetToDefault()
213 |* Ersterstellung MM 03.04.91
214 |* Letzte Aenderung MM 03.04.91
216 *************************************************************************/
217 void RscFlag::SetToDefault( const RSCINST
& rInst
)
221 for( i
= 0; i
< Size() / sizeof( RscFlagInst
); i
++ )
222 ((RscFlagInst
*)rInst
.pData
)[ i
].nDfltFlags
= 0xFFFFFFFF;
225 /*************************************************************************
230 |* Ersterstellung MM 03.04.91
231 |* Letzte Aenderung MM 03.04.91
233 *************************************************************************/
234 sal_Bool
RscFlag::IsDefault( const RSCINST
& rInst
)
238 for( i
= 0; i
< Size() / sizeof( RscFlagInst
); i
++ )
239 if( ((RscFlagInst
*)rInst
.pData
)[ i
].nDfltFlags
!= 0xFFFFFFFF )
244 sal_Bool
RscFlag::IsDefault( const RSCINST
& rInst
, Atom nConstId
)
246 sal_uInt32 i
= 0, nFlag
= 0;
248 if( nEntries
!= (i
= GetConstPos( nConstId
)) ){
249 nFlag
= 1 << (i
% (sizeof( sal_uInt32
) * 8) );
250 i
= i
/ (sizeof( sal_uInt32
) * 8);
251 if( ((RscFlagInst
*)rInst
.pData
)[ i
].nDfltFlags
& nFlag
)
259 /*************************************************************************
261 |* RscFlag::IsValueDefault()
264 |* Ersterstellung MM 25.04.91
265 |* Letzte Aenderung MM 25.04.91
267 *************************************************************************/
268 sal_Bool
RscFlag::IsValueDefault( const RSCINST
& rInst
, CLASS_DATA pDef
,
271 sal_uInt32 i
= 0, nFlag
= 0;
273 if( nEntries
!= (i
= GetConstPos( nConstId
)) ){
274 nFlag
= 1 << (i
% (sizeof( sal_uInt32
) * 8) );
275 i
= i
/ (sizeof( sal_uInt32
) * 8);
278 if( (((RscFlagInst
*)rInst
.pData
)[ i
].nFlags
& nFlag
)
279 == (((RscFlagInst
*)pDef
)[ i
].nFlags
& nFlag
) )
289 sal_Bool
RscFlag::IsValueDefault( const RSCINST
& rInst
, CLASS_DATA pDef
)
294 sal_uInt32 Flag
= 0, nIndex
= 0;
297 for( i
= 0; i
< nEntries
; i
++ ){
298 nIndex
= i
/ (sizeof( sal_uInt32
) * 8);
299 if( (((RscFlagInst
*)rInst
.pData
)[ nIndex
].nFlags
& Flag
)
300 != (((RscFlagInst
*)pDef
)[ nIndex
].nFlags
& Flag
) )
315 /*************************************************************************
320 |* Ersterstellung MM 10.04.91
321 |* Letzte Aenderung MM 10.04.91
323 *************************************************************************/
324 sal_Bool
RscFlag::IsSet( const RSCINST
& rInst
, Atom nConstId
)
326 sal_uInt32 i
= 0, nFlag
= 0;
328 if( nEntries
!= (i
= GetConstPos( nConstId
)) ){
329 nFlag
= 1 << (i
% (sizeof( sal_uInt32
) * 8) );
330 i
= i
/ (sizeof( sal_uInt32
) * 8);
331 if( ((RscFlagInst
*)rInst
.pData
)[ i
].nFlags
& nFlag
)
339 /*************************************************************************
341 |* RscFlag::WriteSrc()
344 |* Ersterstellung MM 08.04.91
345 |* Letzte Aenderung MM 08.04.91
347 *************************************************************************/
348 void RscFlag::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
349 RscTypCont
*, sal_uInt32
, const char * )
351 sal_uInt32 i
= 0, Flag
= 0, nIndex
= 0;
352 sal_Bool bComma
= sal_False
;
355 for( i
= 0; i
< nEntries
; i
++ ){
356 nIndex
= i
/ (sizeof( sal_uInt32
) * 8);
357 if( !( ((RscFlagInst
*)rInst
.pData
)[ nIndex
].nDfltFlags
& Flag
) ){
359 fprintf( fOutput
, ", " );
360 if( ((RscFlagInst
*)rInst
.pData
)[ nIndex
].nFlags
& Flag
)
361 fprintf( fOutput
, "%s", pHS
->getString( pVarArray
[ i
].nId
).getStr() );
363 fprintf( fOutput
, "not " );
364 fprintf( fOutput
, "%s", pHS
->getString( pVarArray
[ i
].nId
).getStr() );
374 /*************************************************************************
376 |* RscFlag::WriteRc()
379 |* Ersterstellung MM 15.04.91
380 |* Letzte Aenderung MM 15.04.91
382 *************************************************************************/
383 ERRTYPE
RscFlag::WriteRc( const RSCINST
& rInst
, RscWriteRc
& aMem
,
384 RscTypCont
*, sal_uInt32
, sal_Bool
)
387 sal_uInt32 i
= 0, Flag
= 0, nIndex
= 0;
390 for( i
= 0; i
< nEntries
; i
++ ){
391 nIndex
= i
/ (sizeof( sal_uInt32
) * 8);
392 if( ((RscFlagInst
*)rInst
.pData
)[ nIndex
].nFlags
& Flag
)
393 lVal
|= pVarArray
[ i
].lValue
;
400 aMem
.Put( (sal_Int32
)lVal
);
404 /*************************************************************************
406 |* RscClient::RscClient()
409 |* Ersterstellung MM 08.04.91
410 |* Letzte Aenderung MM 08.04.91
412 *************************************************************************/
413 RscClient::RscClient( Atom nId
, sal_uInt32 nTypeId
, RscFlag
* pClass
,
415 : RscTop ( nId
, nTypeId
)
418 nConstId
= nConstantId
;
421 /*************************************************************************
423 |* RscClient::GetClassType()
426 |* Ersterstellung MM 08.04.91
427 |* Letzte Aenderung MM 08.04.91
429 *************************************************************************/
430 RSCCLASS_TYPE
RscClient::GetClassType() const
432 return RSCCLASS_BOOL
;
435 /*************************************************************************
437 |* RscClient::WriteSrc()
440 |* Ersterstellung MM 08.04.91
441 |* Letzte Aenderung MM 08.04.91
443 *************************************************************************/
444 void RscClient::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
445 RscTypCont
*, sal_uInt32
, const char * )
447 if( pRefClass
->IsSet( rInst
, nConstId
) )
448 fprintf( fOutput
, "TRUE" );
450 fprintf( fOutput
, "FALSE" );
453 /*************************************************************************
455 |* RscClient::Create()
458 |* Ersterstellung MM 08.04.91
459 |* Letzte Aenderung MM 08.04.91
461 *************************************************************************/
462 RSCINST
RscClient::Create( RSCINST
* pInst
, const RSCINST
& rDflt
,
465 RSCINST aTmpI
, aDfltI
;
468 aTmpI
.pClass
= pRefClass
;
469 aTmpI
.pData
= pInst
->pData
;
472 if( !bOwnClass
&& rDflt
.IsInst() ){
473 bOwnClass
= rDflt
.pClass
->InHierarchy( this );
475 aDfltI
.pClass
= pRefClass
;
476 aDfltI
.pData
= rDflt
.pData
;
481 aTmpI
= pRefClass
->CreateClient( &aTmpI
, aDfltI
,
482 bOwnClass
, nConstId
);
484 aTmpI
= pRefClass
->CreateClient( NULL
, aDfltI
,
485 bOwnClass
, nConstId
);