LCOV - code coverage report
Current view: top level - libreoffice/rsc/source/res - rscconst.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 108 0.0 %
Date: 2012-12-17 Functions: 0 21 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : /****************** I N C L U D E S **************************************/
      21             : 
      22             : // C and C++ Includes.
      23             : #include <cstdlib>
      24             : #include <cstdio>
      25             : #include <cstring>
      26             : 
      27             : // Solar Definitionen
      28             : #include <tools/solar.h>
      29             : 
      30             : // Programmabhaengige Includes.
      31             : #include <rscconst.hxx>
      32             : #include <rscall.h>
      33             : #include <rschash.hxx>
      34             : #include <tools/resid.hxx>
      35             : 
      36             : /****************** C O D E **********************************************/
      37             : /****************** R s c C o n s t **************************************/
      38             : /*************************************************************************
      39             : |*
      40             : |*    RscConst::RscConst()
      41             : |*
      42             : *************************************************************************/
      43           0 : RscConst::RscConst( Atom nId, sal_uInt32 nTypeId )
      44           0 :     : RscTop( nId, nTypeId )
      45             : {
      46           0 :     pVarArray = NULL;
      47           0 :     nEntries = 0;
      48           0 : }
      49             : 
      50             : /*************************************************************************
      51             : |*
      52             : |*    RscConst::~RscConst()
      53             : |*
      54             : *************************************************************************/
      55           0 : RscConst::~RscConst()
      56             : {
      57           0 :     if( pVarArray )
      58           0 :         rtl_freeMemory( (void *)pVarArray );
      59           0 : }
      60             : 
      61             : /*************************************************************************
      62             : |*
      63             : |*    RscConst::GetClassType()
      64             : |*
      65             : *************************************************************************/
      66           0 : RSCCLASS_TYPE RscConst::GetClassType() const
      67             : {
      68           0 :     return RSCCLASS_CONST;
      69             : }
      70             : 
      71             : /*************************************************************************
      72             : |*
      73             : |*    RscConst::SetConstance()
      74             : |*
      75             : *************************************************************************/
      76           0 : ERRTYPE RscConst::SetConstant( Atom nVarName, sal_Int32 lValue ){
      77           0 :     if( pVarArray )
      78             :         pVarArray = (VarEle *)
      79             :             rtl_reallocateMemory( (void *)pVarArray,
      80           0 :                 ((nEntries +1) * sizeof( VarEle )) );
      81             :     else
      82             :         pVarArray = (VarEle *)
      83           0 :             rtl_allocateMemory( ((nEntries +1) * sizeof( VarEle )) );
      84           0 :     pVarArray[ nEntries ].nId     = nVarName;
      85           0 :     pVarArray[ nEntries ].lValue  = lValue;
      86           0 :     nEntries++;
      87             : 
      88           0 :     return( ERR_OK );
      89             : }
      90             : 
      91             : /*************************************************************************
      92             : |*
      93             : |*    RscConst::GetConstance()
      94             : |*
      95             : *************************************************************************/
      96           0 : Atom RscConst::GetConstant( sal_uInt32 nPos ){
      97           0 :      if( nPos < nEntries )
      98           0 :         return pVarArray[ nPos ].nId;
      99           0 :     return( InvalidAtom );
     100             : }
     101             : 
     102             : /*************************************************************************
     103             : |*
     104             : |*    RscConst::GetConstValue()
     105             : |*
     106             : *************************************************************************/
     107           0 : sal_Bool RscConst::GetConstValue( Atom nConst, sal_Int32 * pValue ) const
     108             : {
     109           0 :     sal_uInt32 i = 0;
     110             : 
     111           0 :     for( i = 0; i < nEntries; i++ )
     112           0 :         if( pVarArray[ i ].nId == nConst )
     113             :         {
     114           0 :             *pValue = pVarArray[ i ].lValue;
     115           0 :             return sal_True;
     116             :         }
     117           0 :     return sal_False;
     118             : }
     119             : 
     120             : /*************************************************************************
     121             : |*
     122             : |*    RscConst::GetValueConst()
     123             : |*
     124             : *************************************************************************/
     125           0 : sal_Bool RscConst::GetValueConst( sal_Int32 lValue, Atom * pConst ) const
     126             : {
     127           0 :     sal_uInt32 i = 0;
     128             : 
     129           0 :     for( i = 0; i < nEntries; i++ )
     130           0 :         if( pVarArray[ i ].lValue == lValue )
     131             :         {
     132           0 :             *pConst = pVarArray[ i ].nId;
     133           0 :             return sal_True;
     134             :         }
     135           0 :     return sal_False;
     136             : }
     137             : 
     138             : /*************************************************************************
     139             : |*
     140             : |*    RscConst::GetConstPos()
     141             : |*
     142             : |*    Beschreibung      Sucht die Position der Konstanten
     143             : |*                      Return = nEntries, nicht gefunden
     144             : |*                      Return = Position im Feld
     145             : |*
     146             : *************************************************************************/
     147           0 : sal_uInt32 RscConst::GetConstPos( Atom nConst )
     148             : {
     149           0 :     sal_uInt32 i = 0;
     150             : 
     151           0 :     for( i = 0; i < nEntries; i++ )
     152             :     {
     153           0 :         if( pVarArray[ i ].nId == nConst )
     154           0 :             return( i );
     155             :     }
     156             : 
     157           0 :     return( nEntries );
     158             : }
     159             : 
     160             : /*************************************************************************
     161             : |*
     162             : |*    RscEnum::WriteSyntax()
     163             : |*
     164             : *************************************************************************/
     165           0 : void RscConst::WriteSyntax( FILE * fOutput, RscTypCont * pTC )
     166             : {
     167           0 :     RscTop::WriteSyntax( fOutput, pTC );
     168             : 
     169           0 :     sal_uInt32 i = 0;
     170             :     // Wenn eine Variable Maskierung hat, dann Maskenfeld
     171           0 :     fprintf( fOutput, "\t" );
     172           0 :     for( i = 0; i < nEntries; i++ )
     173             :     {
     174           0 :         fprintf( fOutput, "%s, ", pHS->getString( pVarArray[ i ].nId ).getStr() );
     175           0 :         if( 3 == (i % 4) && i < sal_uInt32(nEntries -1) )
     176           0 :             fprintf( fOutput, "\n\t" );
     177             :     };
     178           0 :     fprintf( fOutput, "\n" );
     179           0 : }
     180             : 
     181             : //==================================================================
     182           0 : void RscConst::WriteRcAccess
     183             : (
     184             :     FILE * fOutput,
     185             :     RscTypCont * /*pTC*/,
     186             :     const char * pName
     187             : )
     188             : {
     189           0 :     fprintf( fOutput, "\t\tSet%s( %s( ", pName, pHS->getString( GetId() ).getStr() );
     190           0 :     fprintf( fOutput, "*(short*)(pResData+nOffset) ) );\n" );
     191           0 :     fprintf( fOutput, "\t\tnOffset += sizeof( short );\n" );
     192           0 : }
     193             : 
     194             : /****************** R s c E n u m ****************************************/
     195             : /*************************************************************************
     196             : |*
     197             : |*    RscEnum::RscEnum()
     198             : |*
     199             : *************************************************************************/
     200           0 : RscEnum::RscEnum( Atom nId, sal_uInt32 nTypeId )
     201           0 :             : RscConst( nId, nTypeId )
     202             : {
     203           0 :     nSize = ALIGNED_SIZE( sizeof( RscEnumInst ) );
     204           0 : }
     205             : 
     206             : /*************************************************************************
     207             : |*
     208             : |*    RscEnum::SetConst()
     209             : |*
     210             : *************************************************************************/
     211           0 : ERRTYPE RscEnum::SetConst( const RSCINST & rInst, Atom nConst, sal_Int32 /*nVal*/ )
     212             : {
     213           0 :     sal_uInt32 i = 0;
     214             : 
     215           0 :     if( nEntries != (i = GetConstPos( nConst )) )
     216             :     {
     217           0 :         ((RscEnumInst *)rInst.pData)->nValue = i;
     218           0 :         ((RscEnumInst *)rInst.pData)->bDflt = sal_False;
     219           0 :         return( ERR_OK );
     220             :     };
     221             : 
     222           0 :     return( ERR_RSCENUM );
     223             : }
     224             : 
     225             : /*************************************************************************
     226             : |*
     227             : |*    RscEnum::SetNumber()
     228             : |*
     229             : *************************************************************************/
     230           0 : ERRTYPE RscEnum::SetNumber( const RSCINST & rInst, sal_Int32 lValue )
     231             : {
     232           0 :     sal_uInt32  i = 0;
     233             : 
     234           0 :     for( i = 0; i < nEntries; i++ ){
     235           0 :         if( (sal_Int32)pVarArray[ i ].lValue == lValue )
     236           0 :             return( SetConst( rInst, pVarArray[ i ].nId, lValue ) );
     237             :     };
     238             : 
     239           0 :     return( ERR_RSCENUM );
     240             : }
     241             : 
     242             : /*************************************************************************
     243             : |*
     244             : |*    RscEnum::GetConst()
     245             : |*
     246             : *************************************************************************/
     247           0 : ERRTYPE RscEnum::GetConst( const RSCINST & rInst, Atom * pH ){
     248           0 :     *pH = pVarArray[ ((RscEnumInst *)rInst.pData)->nValue ].nId;
     249           0 :     return( ERR_OK );
     250             : }
     251             : 
     252             : /*************************************************************************
     253             : |*
     254             : |*    RscEnum::GetNumber()
     255             : |*
     256             : *************************************************************************/
     257           0 : ERRTYPE RscEnum::GetNumber( const RSCINST & rInst, sal_Int32 * pNumber ){
     258           0 :     *pNumber = pVarArray[ ((RscEnumInst *)rInst.pData)->nValue ].lValue;
     259           0 :     return( ERR_OK );
     260             : }
     261             : 
     262             : /*************************************************************************
     263             : |*
     264             : |*    RscEnum::Create()
     265             : |*
     266             : *************************************************************************/
     267           0 : RSCINST RscEnum::Create( RSCINST * pInst, const RSCINST & rDflt, sal_Bool bOwnClass ){
     268           0 :     RSCINST aInst;
     269             : 
     270           0 :     if( !pInst ){
     271           0 :         aInst.pClass = this;
     272             :         aInst.pData = (CLASS_DATA)
     273           0 :                       rtl_allocateMemory( sizeof( RscEnumInst ) );
     274             :     }
     275             :     else
     276           0 :         aInst = *pInst;
     277           0 :     if( !bOwnClass && rDflt.IsInst() )
     278           0 :         bOwnClass = rDflt.pClass->InHierarchy( this );
     279             : 
     280           0 :     if( bOwnClass )
     281           0 :         memmove( aInst.pData, rDflt.pData, Size() );
     282             :     else{
     283           0 :         ((RscEnumInst *)aInst.pData)->nValue = 0;
     284           0 :         ((RscEnumInst *)aInst.pData)->bDflt = sal_True;
     285             :     }
     286             : 
     287           0 :     return( aInst );
     288             : }
     289             : 
     290             : /*************************************************************************
     291             : |*
     292             : |*    RscEnum::IsValueDefault()
     293             : |*
     294             : *************************************************************************/
     295           0 : sal_Bool RscEnum::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef ){
     296           0 :     if( pDef ){
     297           0 :         if( ((RscEnumInst*)rInst.pData)->nValue ==
     298             :           ((RscEnumInst*)pDef)->nValue )
     299             :         {
     300           0 :             return sal_True;
     301             :         }
     302             :     }
     303             : 
     304           0 :     return sal_False;
     305             : }
     306             : 
     307             : /*************************************************************************
     308             : |*
     309             : |*    RscEnum::WriteSrc()
     310             : |*
     311             : *************************************************************************/
     312           0 : void RscEnum::WriteSrc( const RSCINST & rInst, FILE * fOutput,
     313             :                          RscTypCont *, sal_uInt32, const char * )
     314             : {
     315             :     fprintf( fOutput, "%s", pHS->getString(
     316           0 :              pVarArray[ ((RscEnumInst *)rInst.pData)->nValue ].nId ).getStr() );
     317           0 : }
     318             : 
     319             : /*************************************************************************
     320             : |*
     321             : |*    RscEnum::WriteRc()
     322             : |*
     323             : *************************************************************************/
     324           0 : ERRTYPE RscEnum::WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
     325             :                           RscTypCont *, sal_uInt32, sal_Bool )
     326             : {
     327           0 :     aMem.Put( (sal_Int32)pVarArray[ ((RscEnumInst *)rInst.pData)->nValue ].lValue );
     328           0 :     return( ERR_OK );
     329             : }
     330             : 
     331           0 : RscLangEnum::RscLangEnum()
     332             :         : RscEnum( pHS->getID( "LangEnum" ), RSC_NOTYPE ),
     333           0 :           mnLangId( 0x400 )
     334             : {
     335           0 : }
     336             : 
     337             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10