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: rscrange.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"
33 /****************** I N C L U D E S **************************************/
35 // C and C++ Includes.
41 #include <tools/solar.h>
43 // Programmabh�ngige Includes.
44 #include <rscrange.hxx>
46 /****************** D E F I N E S ****************************************/
47 /****************** C O D E **********************************************/
48 /****************** R s c R a n g e **************************************/
49 /*************************************************************************
51 |* RscRange::RscRange()
54 |* Ersterstellung MM 03.04.91
55 |* Letzte Aenderung MM 03.04.91
57 *************************************************************************/
58 RscRange::RscRange( Atom nId
, sal_uInt32 nTypeId
)
59 : RscTop( nId
, nTypeId
)
62 nSize
= ALIGNED_SIZE( sizeof( RscRangeInst
) );
65 /*************************************************************************
67 |* RscRange::GetClassType()
70 |* Ersterstellung MM 03.04.91
71 |* Letzte Aenderung MM 03.04.91
73 *************************************************************************/
74 RSCCLASS_TYPE
RscRange::GetClassType() const
76 return RSCCLASS_NUMBER
;
79 /*************************************************************************
81 |* RscRange::SetRange()
84 |* Ersterstellung MM 03.04.91
85 |* Letzte Aenderung MM 03.04.91
87 *************************************************************************/
88 ERRTYPE
RscRange::SetRange( INT32 nMinimum
, INT32 nMaximum
)
90 if( nMinimum
> nMaximum
)
104 /*************************************************************************
106 |* RscRange::IsValueDefault()
109 |* Ersterstellung MM 15.02.92
110 |* Letzte Aenderung MM 15.02.92
112 *************************************************************************/
113 BOOL
RscRange::IsValueDefault( const RSCINST
& rInst
, CLASS_DATA pDef
)
117 if( ((RscRangeInst
*)rInst
.pData
)->nValue
==
118 ((RscRangeInst
*)pDef
)->nValue
)
127 /*************************************************************************
129 |* RscRange::SetNumber()
132 |* Ersterstellung MM 03.04.91
133 |* Letzte Aenderung MM 03.04.91
135 *************************************************************************/
136 ERRTYPE
RscRange::SetNumber( const RSCINST
& rInst
, INT32 nValue
)
138 if( nMax
< nValue
|| nMin
> nValue
)
139 return( ERR_RSCRANGE_OUTDEFSET
);
140 ((RscRangeInst
*)rInst
.pData
)->nValue
= (sal_uInt16
)( nValue
- nMin
);
141 ((RscRangeInst
*)rInst
.pData
)->bDflt
= FALSE
;
145 /*************************************************************************
147 |* RscRange::GetNumber()
150 |* Ersterstellung MM 22.04.91
151 |* Letzte Aenderung MM 22.04.91
153 *************************************************************************/
154 ERRTYPE
RscRange::GetNumber( const RSCINST
& rInst
, INT32
* pN
)
156 *pN
= ((RscRangeInst
*)rInst
.pData
)->nValue
+ nMin
;
160 /*************************************************************************
162 |* RscRange::Create()
165 |* Ersterstellung MM 03.04.91
166 |* Letzte Aenderung MM 03.04.91
168 *************************************************************************/
169 RSCINST
RscRange::Create( RSCINST
* pInst
, const RSCINST
& rDflt
,
177 aInst
.pData
= (CLASS_DATA
)
178 rtl_allocateMemory( sizeof( RscRangeInst
) );
182 if( !bOwnClass
&& rDflt
.IsInst() )
183 bOwnClass
= rDflt
.pClass
->InHierarchy( this );
186 memmove( aInst
.pData
, rDflt
.pData
, sizeof( RscRangeInst
) );
189 if( 0L >= nMin
&& 0L <= nMax
)
190 ((RscRangeInst
*)aInst
.pData
)->nValue
= (sal_uInt16
)(0L - nMin
);
192 ((RscRangeInst
*)aInst
.pData
)->nValue
= 0;
193 ((RscRangeInst
*)aInst
.pData
)->bDflt
= TRUE
;
199 /*************************************************************************
201 |* RscRange::WriteSrc()
204 |* Ersterstellung MM 08.04.91
205 |* Letzte Aenderung MM 08.04.91
207 *************************************************************************/
208 void RscRange::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
209 RscTypCont
*, sal_uInt32
, const char * )
211 fprintf( fOutput
, "%ld", long( ((RscRangeInst
*)rInst
.pData
)->nValue
+ nMin
) );
214 /*************************************************************************
216 |* RscRange::WriteRc()
219 |* Ersterstellung MM 15.04.91
220 |* Letzte Aenderung MM 15.04.91
222 *************************************************************************/
223 ERRTYPE
RscRange::WriteRc( const RSCINST
& rInst
, RscWriteRc
& aMem
,
224 RscTypCont
*, sal_uInt32
, BOOL
)
229 n
= (sal_uInt16
)(((RscRangeInst
*)rInst
.pData
)->nValue
+ nMin
);
235 n
= (sal_Int16
)(((RscRangeInst
*)rInst
.pData
)->nValue
+ nMin
);
242 //=======================================================================
243 void RscRange::WriteRcAccess
246 RscTypCont
* /*pTC*/,
250 fprintf( fOutput
, "\t\tSet%s( ", pName
);
252 fprintf( fOutput
, "*(sal_uInt32 *)(pResData+nOffset) );\n" );
254 fprintf( fOutput
, "*(sal_Int32 *)(pResData+nOffset) );\n" );
255 fprintf( fOutput
, "\t\tnOffset += sizeof( sal_uInt32 );\n" );
258 /****************** R s c L o n g R a n g e ******************************/
259 /*************************************************************************
261 |* RscLongRange::RscLongRange()
264 |* Ersterstellung MM 18.07.94
265 |* Letzte Aenderung MM 18.07.94
267 *************************************************************************/
268 RscLongRange::RscLongRange( Atom nId
, sal_uInt32 nTypeId
)
269 : RscTop( nId
, nTypeId
)
272 nSize
= ALIGNED_SIZE( sizeof( RscLongRangeInst
) );
275 /*************************************************************************
277 |* RscLongRange::GetClassType()
280 |* Ersterstellung MM 18.07.94
281 |* Letzte Aenderung MM 18.07.94
283 *************************************************************************/
284 RSCCLASS_TYPE
RscLongRange::GetClassType() const
286 return RSCCLASS_NUMBER
;
289 /*************************************************************************
291 |* RscLongRange::SetRange()
294 |* Ersterstellung MM 18.07.94
295 |* Letzte Aenderung MM 18.07.94
297 *************************************************************************/
298 ERRTYPE
RscLongRange::SetRange( INT32 nMinimum
, INT32 nMaximum
)
300 if( nMinimum
> nMaximum
)
314 /*************************************************************************
316 |* RscLongRange::IsValueDefault()
319 |* Ersterstellung MM 15.02.92
320 |* Letzte Aenderung MM 15.02.92
322 *************************************************************************/
323 BOOL
RscLongRange::IsValueDefault( const RSCINST
& rInst
, CLASS_DATA pDef
)
326 return 0 == memcmp( &((RscLongRangeInst
*)rInst
.pData
)->nValue
,
327 &((RscLongRangeInst
*)pDef
)->nValue
,
333 /*************************************************************************
335 |* RscLongRange::SetNumber()
338 |* Ersterstellung MM 18.07.94
339 |* Letzte Aenderung MM 18.07.94
341 *************************************************************************/
342 ERRTYPE
RscLongRange::SetNumber( const RSCINST
& rInst
, INT32 nValue
)
344 if( nMax
< nValue
|| nMin
> nValue
)
345 return( ERR_RSCRANGE_OUTDEFSET
);
346 void * pData
= &((RscLongRangeInst
*)rInst
.pData
)->nValue
;
347 memmove( pData
, &nValue
, sizeof( INT32
) );
348 ((RscLongRangeInst
*)rInst
.pData
)->bDflt
= FALSE
;
352 /*************************************************************************
354 |* RscLongRange::GetNumber()
357 |* Ersterstellung MM 22.04.91
358 |* Letzte Aenderung MM 22.04.91
360 *************************************************************************/
361 ERRTYPE
RscLongRange::GetNumber( const RSCINST
& rInst
, INT32
* pN
)
363 memmove( pN
, &((RscLongRangeInst
*)rInst
.pData
)->nValue
,
368 /*************************************************************************
370 |* RscLongRange::Create()
373 |* Ersterstellung MM 18.07.94
374 |* Letzte Aenderung MM 18.07.94
376 *************************************************************************/
377 RSCINST
RscLongRange::Create( RSCINST
* pInst
, const RSCINST
& rDflt
,
385 aInst
.pData
= (CLASS_DATA
)
386 rtl_allocateMemory( sizeof( RscLongRangeInst
) );
390 if( !bOwnClass
&& rDflt
.IsInst() )
391 bOwnClass
= rDflt
.pClass
->InHierarchy( this );
394 memmove( aInst
.pData
, rDflt
.pData
, sizeof( RscLongRangeInst
) );
398 if( 0L >= nMin
&& 0L <= nMax
)
402 void * pData
= &((RscLongRangeInst
*)aInst
.pData
)->nValue
;
403 memmove( pData
, &lDflt
, sizeof( INT32
) );
404 ((RscLongRangeInst
*)aInst
.pData
)->bDflt
= TRUE
;
410 /*************************************************************************
412 |* RscLongRange::WriteSrc()
415 |* Ersterstellung MM 18.07.94
416 |* Letzte Aenderung MM 18.07.94
418 *************************************************************************/
419 void RscLongRange::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
420 RscTypCont
*, sal_uInt32
, const char * )
423 GetNumber( rInst
, &lVal
);
424 fprintf( fOutput
, "%d", static_cast<int>(lVal
) );
427 /*************************************************************************
429 |* RscLongRange::WriteRc()
432 |* Ersterstellung MM 18.07.94
433 |* Letzte Aenderung MM 18.04.94
435 *************************************************************************/
436 ERRTYPE
RscLongRange::WriteRc( const RSCINST
& rInst
, RscWriteRc
& aMem
,
437 RscTypCont
*, sal_uInt32
, BOOL
)
441 GetNumber( rInst
, &lVal
);
442 aMem
.Put( (INT32
)lVal
);
447 //=======================================================================
448 void RscLongRange::WriteRcAccess
451 RscTypCont
* /*pTC*/,
455 fprintf( fOutput
, "\t\tSet%s( ", pName
);
456 fprintf( fOutput
, "GetLong( pResData+nOffset ) );\n" );
457 fprintf( fOutput
, "\t\tnOffset += sizeof( INT32 );\n" );
460 /****************** R s c L o n g E n u m R a n g e *********************/
461 /*************************************************************************
462 |* RscLongEnumRange::RscLongEnumRange()
465 *************************************************************************/
466 RscLongEnumRange::RscLongEnumRange( Atom nId
, sal_uInt32 nTypeId
)
467 : RscLongRange( nId
, nTypeId
)
471 /*************************************************************************
472 |* RscLongEnumRange::SetConst()
475 *************************************************************************/
476 ERRTYPE
RscLongEnumRange::SetConst( const RSCINST
& rInst
, Atom
/*nConst*/,
479 return SetNumber( rInst
, nValue
);
482 /****************** R s c I d R a n g e **********************************/
483 /*************************************************************************
485 |* RscIdRange::RscIdRange()
488 |* Ersterstellung MM 03.04.91
489 |* Letzte Aenderung MM 03.04.91
491 *************************************************************************/
492 RscIdRange::RscIdRange( Atom nId
, sal_uInt32 nTypeId
)
493 : RscTop( nId
, nTypeId
)
495 nSize
= ALIGNED_SIZE( sizeof( RscId
) );
499 /*************************************************************************
501 |* RscIdRange::RscIdRange()
504 |* Ersterstellung MM 03.04.91
505 |* Letzte Aenderung MM 03.04.91
507 *************************************************************************/
508 RSCCLASS_TYPE
RscIdRange::GetClassType() const
510 return RSCCLASS_NUMBER
;
513 /*************************************************************************
515 |* RscIdRange::Create()
518 |* Ersterstellung MM 03.04.91
519 |* Letzte Aenderung MM 03.04.91
521 *************************************************************************/
522 RSCINST
RscIdRange::Create( RSCINST
* pInst
, const RSCINST
& rDflt
, BOOL bOwnClass
){
528 aInst
.pData
= (CLASS_DATA
)rtl_allocateMemory( sizeof( RscId
) );
534 if( !bOwnClass
&& rDflt
.IsInst() )
535 bOwnClass
= rDflt
.pClass
->InHierarchy( this );
537 pClassData
= (RscId
*)aInst
.pData
;
539 pClassData
->Create();
541 *pClassData
= *(RscId
*)rDflt
.pData
;
543 *pClassData
= RscId();
544 if( 0 >= nMin
&& 0 <= nMax
)
545 *pClassData
= RscId( (INT32
)0 );
547 *pClassData
= RscId( nMin
);
548 //cUnused wird fuer Defaultkennung verwendet
549 ((RscId
*)aInst
.pData
)->aExp
.cUnused
= TRUE
;
555 /*************************************************************************
557 |* RscIdRange::Destroy()
560 |* Ersterstellung MM 22.11.91
561 |* Letzte Aenderung MM 22.11.91
563 *************************************************************************/
564 void RscIdRange :: Destroy( const RSCINST
& rInst
){
565 ((RscId
*)rInst
.pData
)->Destroy();
568 /*************************************************************************
570 |* RscIdRange::IsValueDefault()
573 |* Ersterstellung MM 15.01.92
574 |* Letzte Aenderung MM 15.01.92
576 *************************************************************************/
577 BOOL
RscIdRange::IsValueDefault( const RSCINST
& rInst
, CLASS_DATA pDef
){
579 if( ((RscId
*)rInst
.pData
)->aExp
.IsNumber()
580 && ((RscId
*)pDef
)->aExp
.IsNumber() )
582 if( ((RscId
*)rInst
.pData
)->GetNumber() ==
583 ((RscId
*)pDef
)->GetNumber() )
593 /*************************************************************************
595 |* RscIdRange::SetNumber()
598 |* Ersterstellung MM 25.11.91
599 |* Letzte Aenderung MM 25.11.91
601 *************************************************************************/
602 ERRTYPE
RscIdRange::SetNumber( const RSCINST
& rInst
, INT32 nValue
)
604 if( nMax
< nValue
|| nMin
> nValue
)
605 return( ERR_RSCRANGE_OUTDEFSET
);
607 *(RscId
*)rInst
.pData
= RscId( nValue
);
608 ((RscId
*)rInst
.pData
)->aExp
.cUnused
= FALSE
;
612 /*************************************************************************
614 |* RscIdRange::GetNumber()
617 |* Ersterstellung MM 25.11.91
618 |* Letzte Aenderung MM 25.11.91
620 *************************************************************************/
621 ERRTYPE
RscIdRange::GetNumber( const RSCINST
& rInst
, INT32
* plValue
){
622 *plValue
= ((RscId
*)rInst
.pData
)->GetNumber();
626 /*************************************************************************
628 |* RscIdRange::SetRef()
631 |* Ersterstellung MM 22.11.91
632 |* Letzte Aenderung MM 22.11.91
634 *************************************************************************/
635 ERRTYPE
RscIdRange::SetRef( const RSCINST
& rInst
, const RscId
& rRscId
){
638 aError
= SetNumber( rInst
, rRscId
);
640 *(RscId
*)rInst
.pData
= rRscId
;
641 ((RscId
*)rInst
.pData
)->aExp
.cUnused
= FALSE
;
645 aError
= ERR_RSCRANGE_OUTDEFSET
;
650 /*************************************************************************
652 |* RscIdRange::GetRef()
655 |* Ersterstellung MM 22.11.91
656 |* Letzte Aenderung MM 22.11.91
658 *************************************************************************/
659 ERRTYPE
RscIdRange::GetRef( const RSCINST
& rInst
, RscId
* pRscId
){
660 *pRscId
= *(RscId
*)rInst
.pData
;
665 /*************************************************************************
667 |* RscIdRange::WriteSrc()
670 |* Ersterstellung MM 22.11.91
671 |* Letzte Aenderung MM 25.11.91
673 *************************************************************************/
674 void RscIdRange::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
675 RscTypCont
*, sal_uInt32
, const char * )
677 fprintf( fOutput
, "%s", ((RscId
*)rInst
.pData
)->GetName().GetBuffer() );
680 /*************************************************************************
682 |* RscIdRange::WriteRc()
685 |* Ersterstellung MM 25.11.91
686 |* Letzte Aenderung MM 25.11.91
688 *************************************************************************/
689 ERRTYPE
RscIdRange::WriteRc( const RSCINST
& rInst
, RscWriteRc
& aMem
,
690 RscTypCont
*, sal_uInt32
, BOOL
)
692 INT32 lVal
= ((RscId
*)rInst
.pData
)->GetNumber();
694 aMem
.Put( (INT32
)lVal
);
699 //=======================================================================
700 void RscIdRange::WriteRcAccess
703 RscTypCont
* /*pTC*/,
707 fprintf( fOutput
, "\t\tSet%s( ", pName
);
708 fprintf( fOutput
, "GetLong( pResData+nOffset ) );\n" );
709 fprintf( fOutput
, "\t\tnOffset += sizeof( INT32 );\n" );
712 /*************************************************************************
714 |* RscIdRange::IsConsistent()
717 |* Ersterstellung MM 22.11.91
718 |* Letzte Aenderung MM 22.11.91
720 *************************************************************************/
721 BOOL
RscIdRange::IsConsistent( const RSCINST
& rInst
, RscInconsList
* pList
)
723 long nValue
= ((RscId
*)rInst
.pData
)->GetNumber();
724 if( (nMax
>= nValue
) && (nMin
<= nValue
) )
728 pList
->Insert( new RscInconsistent(
729 *(RscId
*)rInst
.pData
, *(RscId
*)rInst
.pData
) );
734 /****************** R s c B o o l ****************************************/
735 /*************************************************************************
737 |* RscBool::RscBool()
740 |* Ersterstellung MM 29.04.91
741 |* Letzte Aenderung MM 29.04.91
743 *************************************************************************/
744 RscBool::RscBool( Atom nId
, sal_uInt32 nTypeId
)
745 : RscRange( nId
, nTypeId
)
747 RscRange::SetRange( 0, 1 );
750 /*************************************************************************
752 |* RscBool::GetClassType()
755 |* Ersterstellung MM 29.04.91
756 |* Letzte Aenderung MM 29.04.91
758 *************************************************************************/
759 RSCCLASS_TYPE
RscBool::GetClassType() const
761 return RSCCLASS_BOOL
;
764 /*************************************************************************
766 |* RscBool::WriteSrc()
769 |* Ersterstellung MM 29.04.91
770 |* Letzte Aenderung MM 29.04.91
772 *************************************************************************/
773 void RscBool::WriteSrc( const RSCINST
& rInst
, FILE * fOutput
,
774 RscTypCont
*, sal_uInt32
, const char * )
778 GetNumber( rInst
, &l
);
780 fprintf( fOutput
, "TRUE" );
782 fprintf( fOutput
, "FALSE" );
785 //=======================================================================
786 void RscBool::WriteRcAccess
789 RscTypCont
* /*pTC*/,
793 fprintf( fOutput
, "\t\tSet%s( ", pName
);
794 fprintf( fOutput
, "(BOOL)*(short *)(pResData+nOffset) );\n" );
795 fprintf( fOutput
, "\t\tnOffset += sizeof( short );\n" );
798 /****************** R s c B r e a k R a n g e ****************************/
799 /*************************************************************************
801 |* RscBreakRange::SetNumber()
804 |* Ersterstellung MM 24.06.91
805 |* Letzte Aenderung MM 24.06.91
807 *************************************************************************/
808 RscBreakRange :: RscBreakRange( Atom nId
, sal_uInt32 nTypeId
)
809 : RscRange( nId
, nTypeId
)
811 nOutRange
= 0xFFFFFFFF;
814 /*************************************************************************
816 |* RscBreakRange::SetNumber()
819 |* Ersterstellung MM 24.06.91
820 |* Letzte Aenderung MM 24.06.91
822 *************************************************************************/
823 ERRTYPE
RscBreakRange::SetNumber( const RSCINST
& rInst
, INT32 nValue
){
824 if( nValue
== nOutRange
)
825 return( ERR_RSCRANGE_OUTDEFSET
);
827 return( RscRange::SetNumber( rInst
, nValue
) );
830 /*************************************************************************
832 |* RscBreakRange::Create()
835 |* Ersterstellung MM 24.06.91
836 |* Letzte Aenderung MM 24.06.91
838 *************************************************************************/
839 RSCINST
RscBreakRange::Create( RSCINST
* pInst
, const RSCINST
& rDflt
,
845 aInst
= RscRange::Create( pInst
, rDflt
, bOwnClass
);
847 GetNumber( aInst
, &l
);
849 ((RscRangeInst
*)aInst
.pData
)->nValue
++;