summaryrefslogtreecommitdiff
path: root/rsc/source/res
diff options
context:
space:
mode:
Diffstat (limited to 'rsc/source/res')
-rw-r--r--rsc/source/res/rscall.cxx40
-rw-r--r--rsc/source/res/rscarray.cxx426
-rw-r--r--rsc/source/res/rscclass.cxx672
-rw-r--r--rsc/source/res/rscclobj.cxx138
-rw-r--r--rsc/source/res/rscconst.cxx186
-rw-r--r--rsc/source/res/rsccont.cxx755
-rw-r--r--rsc/source/res/rscmgr.cxx346
-rw-r--r--rsc/source/res/rscrange.cxx139
-rw-r--r--rsc/source/res/rscstr.cxx293
-rw-r--r--rsc/source/res/rsctop.cxx410
10 files changed, 0 insertions, 3405 deletions
diff --git a/rsc/source/res/rscall.cxx b/rsc/source/res/rscall.cxx
deleted file mode 100644
index 84829c7e0ced..000000000000
--- a/rsc/source/res/rscall.cxx
+++ /dev/null
@@ -1,40 +0,0 @@
-/* -*- 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 .
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include <rscall.h>
-#include <rsckey.hxx>
-
-Atom nRsc_DELTALANG = InvalidAtom;
-Atom nRsc_DELTASYSTEM = InvalidAtom;
-
-void InitRscCompiler()
-{
- pStdParType = new OString("( const ResId & rResId, sal_Bool");
- pStdPar1 = new OString('(');
- pStdPar2 = new OString('(');
-
- nRefDeep = 10;
- pHS = new AtomContainer();
-};
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rscarray.cxx b/rsc/source/res/rscarray.cxx
deleted file mode 100644
index ba5f8fe16cbc..000000000000
--- a/rsc/source/res/rscarray.cxx
+++ /dev/null
@@ -1,426 +0,0 @@
-/* -*- 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 .
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <rscconst.hxx>
-#include <rscarray.hxx>
-#include <rscdb.hxx>
-
-RscInstNode::RscInstNode(sal_uInt32 nId) : nTypeId(nId)
-{
-}
-
-RscInstNode::~RscInstNode()
-{
- if( aInst.IsInst() )
- {
- aInst.pClass->Destroy( aInst );
- rtl_freeMemory( aInst.pData );
- }
-}
-
-sal_uInt32 RscInstNode::GetId() const
-{
- return nTypeId;
-}
-
-RscArray::RscArray( Atom nId, RESOURCE_TYPE nTypeId, RscTop * pSuper, RscEnum * pTypeCl )
- : RscTop( nId, nTypeId, pSuper )
- , pTypeClass(pTypeCl)
- , nOffInstData(RscTop::Size())
- , nSize(nOffInstData + ALIGNED_SIZE(sizeof(RscArrayInst)))
-{
-}
-
-RscArray::~RscArray()
-{
-}
-
-RscTop * RscArray::GetTypeClass() const
-{
- return pTypeClass;
-}
-
-static RscInstNode * Create( RscInstNode * pNode )
-{
- RscInstNode * pRetNode = nullptr;
-
- if( pNode )
- {
- pRetNode = new RscInstNode( pNode->GetId() );
- pRetNode->aInst = pNode->aInst.pClass->Create( nullptr, pNode->aInst );
- RscInstNode * pTmpNode = Create(pNode->Left());
- if (pTmpNode)
- pRetNode->Insert( pTmpNode );
- if( (pTmpNode = Create( pNode->Right() )) != nullptr )
- pRetNode->Insert( pTmpNode );
- }
-
- return pRetNode;
-}
-
-RSCINST RscArray::Create( RSCINST * pInst, const RSCINST & rDflt,
- bool bOwnClass )
-{
- RSCINST aInst;
- RscArrayInst * pClassData;
-
- if( !pInst )
- {
- aInst.pClass = this;
- aInst.pData = static_cast<CLASS_DATA>(rtl_allocateMemory( Size() ));
- }
- else
- aInst = *pInst;
-
- if( !bOwnClass && rDflt.IsInst() )
- bOwnClass = rDflt.pClass->InHierarchy( this );
-
- RscTop::Create( &aInst, rDflt, bOwnClass );
-
- pClassData = reinterpret_cast<RscArrayInst *>(aInst.pData + nOffInstData);
- pClassData->pNode = nullptr;
- if( bOwnClass )
- {
- RscArrayInst * pDfltClassData;
-
- pDfltClassData = reinterpret_cast<RscArrayInst *>(rDflt.pData + nOffInstData);
-
- pClassData->pNode = ::Create( pDfltClassData->pNode );
- }
- return aInst;
-}
-
-static void Destroy( RscInstNode * pNode )
-{
- if( pNode )
- {
- Destroy( pNode->Left() );
- Destroy( pNode->Right() );
- delete pNode;
- }
-}
-
-void RscArray::Destroy( const RSCINST & rInst )
-{
- RscArrayInst * pClassData;
-
- RscTop::Destroy( rInst );
-
- pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
-
- // delete the tree recursively
- ::Destroy( pClassData->pNode );
-}
-
-ERRTYPE RscArray::GetValueEle( const RSCINST & rInst,
- sal_Int32 lValue,
- RscTop * pCreateClass,
- RSCINST * pGetInst)
-{
- RscArrayInst * pClassData;
- RscInstNode * pNode;
-
- pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
-
- ERRTYPE aError;
-
- Atom nId;
- if( !pTypeClass->GetValueConst( sal_uInt32(lValue), &nId ) )
- { // not found
- return ERR_ARRAY_INVALIDINDEX;
- }
-
- if( pClassData->pNode )
- pNode = pClassData->pNode->Search( sal_uInt32(lValue) );
- else
- pNode = nullptr;
-
- if( !pNode )
- {
- pNode = new RscInstNode( sal_uInt32(lValue) );
- if( pCreateClass && GetSuperClass()->InHierarchy( pCreateClass ) )
- pNode->aInst = pCreateClass->Create( nullptr, rInst );
- else
- pNode->aInst = GetSuperClass()->Create( nullptr, rInst );
-
- pNode->aInst.pClass->SetToDefault( pNode->aInst );
- if( pClassData->pNode )
- pClassData->pNode->Insert( pNode );
- else
- pClassData->pNode = pNode;
- }
-
- *pGetInst = pNode->aInst;
- return aError;
-}
-
-ERRTYPE RscArray::GetArrayEle( const RSCINST & rInst,
- Atom nId,
- RscTop * pCreateClass,
- RSCINST * pGetInst)
-{
- sal_Int32 lValue;
- if( !pTypeClass->GetConstValue( nId, &lValue ) )
- { // not found
- return ERR_ARRAY_INVALIDINDEX;
- }
-
- return GetValueEle( rInst, lValue, pCreateClass, pGetInst );
-}
-
-static bool IsConsistent( RscInstNode * pNode )
-{
- bool bRet = true;
-
- if( pNode )
- {
- bRet = pNode->aInst.pClass->IsConsistent( pNode->aInst );
- if( !IsConsistent( pNode->Left() ) )
- bRet = false;
- if( !IsConsistent( pNode->Right() ) )
- bRet = false;
- }
- return bRet;
-}
-
-bool RscArray::IsConsistent( const RSCINST & rInst )
-{
- RscArrayInst * pClassData;
- bool bRet;
-
- bRet = RscTop::IsConsistent( rInst );
-
- pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
- if( !::IsConsistent( pClassData->pNode ) )
- bRet = false;
-
- return bRet;
-}
-
-static void SetToDefault( RscInstNode * pNode )
-{
- if( pNode )
- {
- pNode->aInst.pClass->SetToDefault( pNode->aInst );
- SetToDefault( pNode->Left() );
- SetToDefault( pNode->Right() );
- }
-}
-
-void RscArray::SetToDefault( const RSCINST & rInst )
-{
- RscArrayInst * pClassData;
-
- pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
-
- ::SetToDefault( pClassData->pNode );
-
- RscTop::SetToDefault( rInst );
-}
-
-static bool IsDefault( RscInstNode * pNode )
-{
- bool bRet = true;
-
- if( pNode )
- {
- bRet = pNode->aInst.pClass->IsDefault( pNode->aInst );
- if( bRet )
- bRet = IsDefault( pNode->Left() );
- if( bRet )
- bRet = IsDefault( pNode->Right() );
- }
- return bRet;
-}
-
-bool RscArray::IsDefault( const RSCINST & rInst )
-{
- RscArrayInst * pClassData;
-
- pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
-
- bool bRet = ::IsDefault( pClassData->pNode );
-
- if( bRet )
- bRet = RscTop::IsDefault( rInst );
- return bRet;
-}
-
-static bool IsValueDefault( RscInstNode * pNode, CLASS_DATA pDef )
-{
- bool bRet = true;
-
- if( pNode )
- {
- bRet = pNode->aInst.pClass->IsValueDefault( pNode->aInst, pDef );
- if( bRet )
- bRet = IsValueDefault( pNode->Left(), pDef );
- if( bRet )
- bRet = IsValueDefault( pNode->Right(), pDef );
- }
- return bRet;
-}
-
-bool RscArray::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
-{
- bool bRet = RscTop::IsValueDefault( rInst, pDef );
-
- if( bRet )
- {
- RscArrayInst * pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
-
- bRet = ::IsValueDefault( pClassData->pNode, pDef );
- }
- return bRet;
-}
-
-void RscArray::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const RscId & aId, const char * pVarName )
-{
- RscArrayInst * pClassData;
-
- pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
-
- if( pTC->IsSrsDefault() )
- { // only write one value
- RscInstNode * pNode = nullptr;
- if( pClassData->pNode )
- {
- std::vector< sal_uInt32 >::const_iterator it;
- for( it = pTC->GetFallbacks().begin(); !pNode && it != pTC->GetFallbacks().end(); ++it )
- pNode = pClassData->pNode->Search( *it );
- }
-
- if( pNode )
- {
- if( pNode->aInst.pClass->IsDefault( pNode->aInst ) )
- fprintf( fOutput, "Default" );
- else
- pNode->aInst.pClass->WriteSrcHeader(
- pNode->aInst, fOutput,
- pTC, nTab, aId, pVarName );
- return;
- }
- }
-
- if( IsDefault( rInst ) )
- fprintf( fOutput, "Default" );
- else
- {
- RSCINST aSuper( GetSuperClass(), rInst.pData );
- aSuper.pClass->WriteSrcHeader( aSuper, fOutput, pTC,
- nTab, aId, pVarName );
- }
- if( !pTC->IsSrsDefault() )
- WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
-}
-
-static void WriteSrc( RscInstNode * pNode, FILE * fOutput, RscTypCont * pTC,
- sal_uInt32 nTab, const char * pVarName,
- CLASS_DATA pDfltData, RscEnum * pTypeClass )
-{
- if( pNode )
- {
- WriteSrc( pNode->Left(), fOutput, pTC, nTab, pVarName,
- pDfltData, pTypeClass );
- if( !pNode->aInst.pClass->IsValueDefault( pNode->aInst, pDfltData ) )
- {
- fprintf( fOutput, ";\n" );
- for( sal_uInt32 n = 0; n < nTab; n++ )
- fputc( '\t', fOutput );
-
- Atom nIdxId;
- pTypeClass->GetValueConst( pNode->GetId(), &nIdxId );
- fprintf( fOutput, "%s[ %s ] = ", pVarName, pHS->getString( nIdxId ).getStr() );
- pNode->aInst.pClass->WriteSrcHeader( pNode->aInst, fOutput, pTC,
- nTab, RscId(), pVarName );
- }
- WriteSrc( pNode->Right(), fOutput, pTC, nTab, pVarName,
- pDfltData, pTypeClass );
- }
-}
-
-void RscArray::WriteSrcArray( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const char * pVarName )
-{
- RscArrayInst * pClassData;
-
- pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
-
- ::WriteSrc( pClassData->pNode, fOutput, pTC, nTab, pVarName,
- rInst.pData, pTypeClass );
-};
-
-void RscArray::WriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const char * pVarName )
-{
- WriteSrcArray( rInst, fOutput, pTC, nTab, pVarName );
-}
-
-ERRTYPE RscArray::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
- RscTypCont * pTC, sal_uInt32 nDeep )
-{
- ERRTYPE aError;
- RscArrayInst * pClassData;
- RscInstNode * pNode = nullptr;
-
- pClassData = reinterpret_cast<RscArrayInst *>(rInst.pData + nOffInstData);
-
- if( pClassData->pNode )
- {
-#if OSL_DEBUG_LEVEL > 2
- fprintf( stderr, "RscArray::WriteRc: Fallback " );
-#endif
- std::vector< sal_uInt32 >::const_iterator it;
- for( it = pTC->GetFallbacks().begin(); !pNode && it != pTC->GetFallbacks().end(); ++it )
- {
- pNode = pClassData->pNode->Search( *it );
-#if OSL_DEBUG_LEVEL > 2
- fprintf( stderr, " 0x%hx", *it );
-#endif
- }
-#if OSL_DEBUG_LEVEL > 2
- fprintf( stderr, "\n" );
-#endif
- }
-
- if( pNode )
- aError = pNode->aInst.pClass->WriteRc( pNode->aInst, rMem, pTC,
- nDeep );
- else
- aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep );
-
- return aError;
-}
-
-RscLangArray::RscLangArray( Atom nId, RESOURCE_TYPE nTypeId, RscTop * pSuper,
- RscEnum * pTypeCl )
- : RscArray( nId, nTypeId, pSuper, pTypeCl )
-{
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rscclass.cxx b/rsc/source/res/rscclass.cxx
deleted file mode 100644
index 386b34a2229a..000000000000
--- a/rsc/source/res/rscclass.cxx
+++ /dev/null
@@ -1,672 +0,0 @@
-/* -*- 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 .
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <rscdb.hxx>
-#include <rscclass.hxx>
-
-#include <tools/rcid.h>
-
-RscClass::RscClass( Atom nId, RESOURCE_TYPE nTypeId, RscTop * pSuperCl )
- : RscTop( nId, nTypeId, pSuperCl )
- , nSuperSize(RscTop::Size())
- , nSize(nSuperSize + ALIGNED_SIZE(sizeof(RscClassInst )))
- , nEntries(0), pVarTypeList(nullptr)
-{
-}
-
-void RscClass::Pre_dtor()
-{
- sal_uInt32 i;
-
- RscTop::Pre_dtor();
-
- for( i = 0; i < nEntries; i++ )
- {
- if( pVarTypeList[ i ].pDefault )
- {
- pVarTypeList[ i ].pClass->Destroy(
- RSCINST( pVarTypeList[ i ].pClass,
- pVarTypeList[ i ].pDefault ) );
- rtl_freeMemory( pVarTypeList[ i ].pDefault );
- pVarTypeList[ i ].pDefault = nullptr;
- }
- }
-}
-
-RscClass::~RscClass()
-{
- if( pVarTypeList )
- rtl_freeMemory( static_cast<void *>(pVarTypeList) );
-}
-
-RSCINST RscClass::GetInstData
-(
- CLASS_DATA pData,
- sal_uInt32 nEle,
- bool bGetCopy
-)
-{
- RSCINST aInst;
-
- aInst.pClass = pVarTypeList[ nEle ].pClass;
- if( pData )
- {
- if( RSCVAR::NoDataInst & pVarTypeList[ nEle ].nVarType )
- {
- RSCINST aTmpI;
-
- aTmpI.pClass = this;
- aTmpI.pData = pData;
- if( bGetCopy )
- aInst.pData = GetCopyVar(
- aTmpI,
- pVarTypeList[ nEle ].nDataBaseName
- ).pData;
- else
- aInst.pData = GetVariable(
- aTmpI,
- pVarTypeList[ nEle ].nDataBaseName,
- RSCINST()
- ).pData;
- }
- else if( RSCVAR::Pointer & pVarTypeList[ nEle ].nVarType )
- {
- aInst.pData = *reinterpret_cast<CLASS_DATA *>(pData + pVarTypeList[ nEle ].nOffset);
- }
- else
- aInst.pData = pData + pVarTypeList[ nEle ].nOffset;
- }
- return aInst;
-}
-
-CLASS_DATA RscClass::GetDfltData( sal_uInt32 nEle )
-{
- if( pVarTypeList[ nEle ].pDefault )
- return pVarTypeList[ nEle ].pDefault;
-
- return pVarTypeList[ nEle ].pClass->GetDefault().pData;
-}
-
-void RscClass::SetVarDflt( CLASS_DATA pData, sal_uInt32 nEle, bool bSet )
-{
- RscClassInst * pClass;
-
- pClass = reinterpret_cast<RscClassInst *>(pData + nSuperSize );
- if( bSet )
- pClass->nVarDflt |= ((sal_uLong)1 << nEle);
- else
- pClass->nVarDflt &= ~((sal_uLong)1 << nEle);
-}
-
-bool RscClass::IsDflt( CLASS_DATA pData, sal_uInt32 nEle )
-{
- RscClassInst * pClass;
-
- pClass = reinterpret_cast<RscClassInst *>(pData + nSuperSize );
- return pClass->nVarDflt & ((sal_uLong)1 << nEle);
-}
-
-RSCINST RscClass::Create( RSCINST * pInst,
- const RSCINST & rDflt,
- bool bOwnClass)
-{
- sal_uInt32 i;
- RSCINST aInst;
- RSCINST aMemInst, aDfltI;
-
- if( !pInst )
- {
- aInst.pClass = this;
- aInst.pData = static_cast<CLASS_DATA>(rtl_allocateMemory( Size() ));
- }
- else
- aInst = *pInst;
-
- if( !bOwnClass && rDflt.IsInst() )
- bOwnClass = rDflt.pClass->InHierarchy( this );
-
- RscTop::Create( &aInst, rDflt, bOwnClass );
-
- if( bOwnClass )
- reinterpret_cast<RscClassInst *>(aInst.pData + nSuperSize)->nVarDflt =
- reinterpret_cast<RscClassInst *>(rDflt.pData + nSuperSize)->nVarDflt;
- else
- reinterpret_cast<RscClassInst *>(aInst.pData + nSuperSize)->nVarDflt = ~((sal_uLong)0);
-
- for( i = 0; i < nEntries; i++ )
- {
- aDfltI = GetInstData( bOwnClass ? rDflt.pData : nullptr, i, true );
-
- if( (RSCVAR::Pointer & pVarTypeList[ i ].nVarType) &&
- !(RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType) )
- {
- CLASS_DATA * ppData = reinterpret_cast<CLASS_DATA*>(aInst.pData + pVarTypeList[ i ].nOffset );
- *ppData = nullptr;
- if( aDfltI.IsInst() )
- {
- aMemInst = pVarTypeList[ i ].pClass->Create( nullptr, aDfltI );
- *ppData = aMemInst.pData;
- }
- }
- else
- {
- aMemInst = GetInstData( aInst.pData, i, true );
- aMemInst = aMemInst.pClass->Create( &aMemInst, aDfltI );
- }
- }
-
- return aInst;
-}
-
-void RscClass::Destroy( const RSCINST & rInst )
-{
- sal_uInt32 i;
-
- RscTop::Destroy( rInst );
-
- for( i = 0; i < nEntries; i++ )
- {
- if( !(pVarTypeList[ i ].nVarType & RSCVAR::NoDataInst) )
- {
- RSCINST aTmpI;
-
- aTmpI = GetInstData( rInst.pData, i, true );
- if( aTmpI.IsInst() )
- {
- // destroy object
- aTmpI.pClass->Destroy( aTmpI );
- if( pVarTypeList[ i ].nVarType & RSCVAR::Pointer )
- {
- // free memory
- rtl_freeMemory( aTmpI.pData );
- }
- }
- }
- }
-}
-
-ERRTYPE RscClass::SetVariable( Atom nVarName,
- RscTop * pClass,
- RSCINST * pDflt,
- RSCVAR nVarType,
- sal_uInt32 nMask,
- Atom nDataBaseName)
-{
- if( pVarTypeList )
- {
- pVarTypeList = static_cast<VARTYPE_STRUCT *>(rtl_reallocateMemory( static_cast<void *>(pVarTypeList),
- ((nEntries +1) * sizeof( VARTYPE_STRUCT )) ));
- }
- else
- {
- pVarTypeList = static_cast<VARTYPE_STRUCT *>(rtl_allocateMemory( (nEntries + 1)
- * sizeof( VARTYPE_STRUCT ) ));
- }
- pVarTypeList[ nEntries ].nVarName = nVarName;
- pVarTypeList[ nEntries ].nMask = nMask;
- pVarTypeList[ nEntries ].pClass = pClass;
- pVarTypeList[ nEntries ].nOffset = nSize;
- pVarTypeList[ nEntries ].nDataBaseName = nDataBaseName;
- if( pDflt )
- pVarTypeList[ nEntries ].pDefault = pDflt->pData;
- else
- pVarTypeList[ nEntries ].pDefault = nullptr;
-
- pVarTypeList[ nEntries ].nVarType = ~RSCVAR::Pointer & nVarType;
- if( pClass->Size() > 10 )
- pVarTypeList[ nEntries ].nVarType |= RSCVAR::Pointer;
-
- if( !(pVarTypeList[ nEntries ].nVarType & RSCVAR::NoDataInst) )
- {
- if( pVarTypeList[ nEntries ].nVarType & RSCVAR::Pointer )
- {
- nSize += sizeof( CLASS_DATA );
- }
- else
- nSize += pClass->Size();
- }
-
- nEntries++;
- if( nEntries > (sizeof( sal_uLong ) * 8) )
- {
- // range for default is too small
- RscExit( 16 );
- }
- return ERR_OK;
-}
-
-RSCINST RscClass::GetVariable( const RSCINST & rInst,
- Atom nVarName,
- const RSCINST & rInitInst,
- bool bInitDflt,
- RscTop * pCreateClass)
-{
- sal_uInt32 i = 0;
- RSCINST aTmpI;
-
- while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
- i++;
-
- if( i < nEntries )
- {
- if( RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType )
- {
- aTmpI = GetVariable( rInst,
- pVarTypeList[ i ].nDataBaseName,
- RSCINST() );
- aTmpI.pClass = pVarTypeList[ i ].pClass;
- }
- else
- {
- // generate default instance
- RSCINST aDefInst = rInitInst;
- if( !aDefInst.IsInst() && bInitDflt )
- {
- // set to default variables
- aDefInst.pData = pVarTypeList[ i ].pDefault;
- aDefInst.pClass = pVarTypeList[ i ].pClass;
- }
-
- aTmpI = GetInstData( rInst.pData, i );
- if( aTmpI.IsInst() )
- {
- if( aDefInst.IsInst() )
- {
- aTmpI.pClass->Destroy( aTmpI );
- aTmpI.pClass->Create( &aTmpI, aDefInst );
- }
- }
- else
- { // is provided via pointer
- CLASS_DATA * ppData
- = reinterpret_cast<CLASS_DATA *>(rInst.pData + pVarTypeList[ i ].nOffset);
- aTmpI = aTmpI.pClass->Create( nullptr, aDefInst );
- *ppData = aTmpI.pData;
- }
- }
- // set as non default
- SetVarDflt( rInst.pData, i, false );
- return aTmpI;
- }
-
- return RscTop::GetVariable( rInst, nVarName, rInitInst,
- bInitDflt, pCreateClass );
-}
-
-RSCINST RscClass::GetCopyVar( const RSCINST & rInst, Atom nVarName)
-{
- sal_uInt32 i = 0;
- RSCINST aVarI;
-
- while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
- i++;
-
- if( i < nEntries )
- {
- if( RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType )
- {
- aVarI = GetCopyVar( rInst, pVarTypeList[ i ].nDataBaseName );
- aVarI.pClass = pVarTypeList[ i ].pClass;
- }
- else
- {
- if( IsDflt( rInst.pData, i ) )
- {
- // initialize with default variables
- aVarI = GetVariable( rInst, nVarName, RSCINST(), true );
- SetVarDflt( rInst.pData, i, true );
- }
- else
- aVarI = GetInstData( rInst.pData, i, true );
-
- }
- return aVarI ;
- }
-
- return RscTop::GetCopyVar( rInst, nVarName );
-}
-
-bool RscClass::IsConsistent( const RSCINST & rInst )
-{
- sal_uInt32 i = 0;
- RSCINST aTmpI;
- bool bRet;
-
- bRet = RscTop::IsConsistent( rInst );
-
- for( i = 0; i < nEntries; i++ )
- {
- if( !(RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType) )
- {
- aTmpI = GetInstData( rInst.pData, i, true );
-
- if( aTmpI.IsInst() )
- if( ! aTmpI.pClass->IsConsistent( aTmpI ) )
- bRet = false;
- }
- }
-
- return bRet;
-}
-
-void RscClass::SetToDefault( const RSCINST & rInst )
-{
- sal_uInt32 i;
- RSCINST aTmpI;
- RscClassInst * pClass;
-
- pClass = reinterpret_cast<RscClassInst *>(rInst.pData + nSuperSize );
-
- for( i = 0; i < nEntries; i++ )
- {
- // variables without own memory are set from "data server" to default
- if( !(RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType) )
- {
- aTmpI = GetInstData( rInst.pData, i, true );
- if( aTmpI.IsInst() )
- aTmpI.pClass->SetToDefault( aTmpI );
- }
- }
- pClass->nVarDflt = ~((sal_uLong)0); // set everything to default
-
- RscTop::SetToDefault( rInst );
-}
-
-bool RscClass::IsDefault( const RSCINST & rInst )
-{
- sal_uInt32 i;
- RSCINST aTmpI;
-
- for( i = 0; i < nEntries; i++ )
- {
- // variables without own memory are looked for default in "data server"
- if( !(RSCVAR::NoDataInst & pVarTypeList[ i ].nVarType) )
- if( !IsDflt( rInst.pData, i ) )
- return false;
- }
-
- return RscTop::IsDefault( rInst );
-}
-
-RSCINST RscClass::GetDefault( Atom nVarId )
-{
- sal_uInt32 i;
-
- i = 0;
- while( i < nEntries && pVarTypeList[ i ].nVarName != nVarId )
- i++;
-
- if( i < nEntries )
- {
- RSCINST aTmpI;
-
- aTmpI.pClass = pVarTypeList[ i ].pClass;
- aTmpI.pData = GetDfltData( i );
- return aTmpI;
- }
-
- return RscTop::GetDefault( nVarId );
-}
-
-bool RscClass::IsValueDflt( CLASS_DATA pData, sal_uInt32 nEle )
-{
- RSCINST aTmpI;
-
- aTmpI = GetInstData( pData, nEle, true );
-
- if( aTmpI.IsInst() )
- {
- if( RSCVAR::SvDynamic & pVarTypeList[ nEle ].nVarType )
- return false;
-
- if( aTmpI.pClass == pVarTypeList[ nEle ].pClass )
- // they also have the same class
- return aTmpI.pClass->IsValueDefault( aTmpI, GetDfltData( nEle ) );
- else
- return false;
- }
- return true;
-}
-
-bool RscClass::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
-{
- RSCINST aTmpI;
- RSCINST aDfltI;
-
- if( !RscTop::IsValueDefault( rInst, pDef ) )
- return false;
-
- if( pDef )
- {
- for( sal_uInt32 i = 0; i < nEntries; i++ )
- {
- aTmpI = GetInstData( rInst.pData, i, true );
- if( aTmpI.IsInst() )
- {
- if( aTmpI.pClass != pVarTypeList[ i ].pClass )
- // they don't have the same class
- return false;
-
- aDfltI = GetInstData( pDef, i, true );
- if( !aDfltI.IsInst() )
- aDfltI.pData = GetDfltData( i );
-
- if( !aTmpI.pClass->IsValueDefault( aTmpI, aDfltI.pData ) )
- return false;
- }
- }
- }
- else
- return false;
-
- return true;
-}
-
-void RscClass::SetDefault( const RSCINST & rInst, Atom nVarName )
-{
- sal_uInt32 i = 0;
- RSCINST aTmpI;
-
- while( i < nEntries && pVarTypeList[ i ].nVarName != nVarName )
- i++;
-
- if( i < nEntries )
- {
- aTmpI = GetInstData( rInst.pData, i, true );
- if( aTmpI.IsInst() )
- {
- aTmpI.pClass->Destroy( aTmpI );
- aTmpI.pClass->Create( &aTmpI, RSCINST() );
- SetVarDflt( rInst.pData, i, true );
- }
- }
- else // look for variable in super class
- RscTop::SetDefault( rInst, nVarName );
-
-}
-
-
-void RscClass::WriteSrc( const RSCINST & rInst,
- FILE * fOutput,
- RscTypCont * pTC,
- sal_uInt32 nTab,
- const char * pVarName)
-{
- sal_uInt32 i = 0, n = 0;
- RSCINST aTmpI;
-
- RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
-
- for( i = 0; i < nEntries; i++ )
- {
- if( !(RSCVAR::Hidden & pVarTypeList[ i ].nVarType) )
- {
- if( !IsDflt( rInst.pData, i ) && !IsValueDflt( rInst.pData, i ) )
- {
- aTmpI = GetInstData( rInst.pData, i, true );
-
- if( aTmpI.IsInst() )
- {
- const char * pName = pHS->getString( pVarTypeList[ i ].nVarName ).getStr();
-
- for( n = 0; n < nTab; n++ )
- fputc( '\t', fOutput );
-
- fprintf( fOutput, "%s", pName );
- fprintf( fOutput, " = " );
- aTmpI.pClass->WriteSrcHeader(
- aTmpI, fOutput, pTC, nTab, RscId(), pName );
- fprintf( fOutput, ";\n" );
- }
- }
- }
- }
-
- return;
-}
-
-ERRTYPE RscClass::WriteInstRc( const RSCINST & rInst,
- RscWriteRc & rMem,
- RscTypCont * pTC,
- sal_uInt32 nDeep )
-{
- sal_uInt32 i = 0;
- ERRTYPE aError;
- RSCINST aTmpI;
- sal_uInt32 nMaskOff = 0;// offset to address mask field
-
- // when a variable is masked, then mask field
- for( i = 0; i < nEntries; i++ )
- {
- if( pVarTypeList[ i ].nMask )
- {
- nMaskOff = rMem.Size();
- rMem.Put( sal_uInt32(0) );
- break;
- }
- }
-
- for( i = 0; i < nEntries && aError.IsOk(); i++ )
- {
- if( !((RSCVAR::NoDataInst | RSCVAR::NoRc) & pVarTypeList[ i ].nVarType ))
- {
- if( pVarTypeList[ i ].nMask )
- {
- if( !IsDflt( rInst.pData, i ) )
- {
- aTmpI = GetInstData( rInst.pData, i, true );
- aError = aTmpI.pClass->
- WriteRcHeader(aTmpI, rMem, pTC,
- RscId(), nDeep);
- sal_uInt32 nMask = rMem.GetLong( nMaskOff );
- nMask |= pVarTypeList[ i ].nMask;
- rMem.PutAt( nMaskOff, nMask );
- }
- }
- else
- {
- if( IsDflt( rInst.pData, i ) )
- {
- aTmpI.pClass = pVarTypeList[ i ].pClass;
- aTmpI.pData = GetDfltData( i );
- }
- else
- aTmpI = GetInstData( rInst.pData, i, true );
-
- aError = aTmpI.pClass->
- WriteRcHeader( aTmpI, rMem, pTC,
- RscId(), nDeep );
- }
- }
- }
-
- return aError;
-}
-
-ERRTYPE RscClass::WriteRc( const RSCINST & rInst,
- RscWriteRc & rMem,
- RscTypCont * pTC,
- sal_uInt32 nDeep )
-{
- ERRTYPE aError;
-
- aError = RscTop::WriteRc(rInst, rMem, pTC, nDeep);
- if( aError.IsOk() )
- aError = WriteInstRc(rInst, rMem, pTC, nDeep);
-
- return aError;
-}
-
-RscTupel::RscTupel( Atom nId, RESOURCE_TYPE nTypeId )
- : RscClass( nId, nTypeId, nullptr )
-{
-}
-
-RSCINST RscTupel::GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos,
- const RSCINST & rInitInst )
-{
- if( nPos >= nEntries )
- {
- return RSCINST();
- }
- else
- return GetVariable( rInst, pVarTypeList[ nPos ].nVarName, rInitInst );
-}
-
-void RscTupel::WriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const char * pVarName )
-{
- sal_uInt32 i = 0;
- RSCINST aTmpI;
-
- RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
-
- fprintf( fOutput, "< " );
- for( i = 0; i < nEntries; i++ )
- {
- if( !(RSCVAR::Hidden & pVarTypeList[ i ].nVarType) )
- {
- if( !IsDflt( rInst.pData, i )
- && !IsValueDflt( rInst.pData, i ) )
- {
- aTmpI = GetInstData( rInst.pData, i, true );
-
- if( aTmpI.IsInst() )
- aTmpI.pClass->WriteSrcHeader(
- aTmpI, fOutput, pTC, nTab, RscId(), pVarName );
- else
- fprintf( fOutput, "Default" );
- }
- else
- fprintf( fOutput, "Default" );
- fprintf( fOutput, "; " );
- }
- }
- fprintf( fOutput, ">" );
-
- return;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rscclobj.cxx b/rsc/source/res/rscclobj.cxx
deleted file mode 100644
index 29184286cd8d..000000000000
--- a/rsc/source/res/rscclobj.cxx
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- 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 .
- */
-
-
-#include <rscclobj.hxx>
-#include <rsctop.hxx>
-
-
-RefNode::RefNode( Atom nTyp )
- : nTypNameId(nTyp), pObjBiTree(nullptr)
-{
-}
-
-sal_uInt32 RefNode::GetId() const
-{
- return nTypNameId;
-}
-
-// insert a node in the b-tree pObjBiTree
-// if the node with the same name is in pObjBiTree,
-// return sal_False and no insert,
-
-bool RefNode::PutObjNode( ObjNode * pPutObject )
-{
- if( pObjBiTree )
- return pObjBiTree->Insert( pPutObject );
-
- pObjBiTree = pPutObject;
- return true;
-}
-
-// insert a node in the b-tree pObjBiTree
-// if the node with the same name is in pObjBiTree,
-// return NULL and no insert,
-// if not return the pointer to the Object
-ObjNode * RefNode::GetObjNode( const RscId & rRscId )
-{
- if( pObjBiTree )
- return pObjBiTree->Search( rRscId );
- return nullptr;
-}
-
-ObjNode::ObjNode( const RscId & rId, CLASS_DATA pData, RscFileTab::Index lKey )
- : aRscId(rId)
- , pRscObj(pData)
- , lFileKey(lKey)
-{
-}
-
-ObjNode * ObjNode::DelObjNode( RscTop * pClass, RscFileTab::Index nFileKey )
-{
- ObjNode * pRetNode = this;
-
- if( Right() )
- pRight = static_cast<ObjNode *>(Right())->DelObjNode( pClass, nFileKey );
- if( Left() )
- pLeft = static_cast<ObjNode *>(Left())->DelObjNode( pClass, nFileKey );
-
- if( GetFileKey() == nFileKey )
- {
- if( GetRscObj() )
- {
- pClass->Destroy( RSCINST( pClass, GetRscObj() ) );
- rtl_freeMemory( GetRscObj() );
- }
- pRetNode = static_cast<ObjNode *>(Right());
- if( pRetNode )
- {
- if( Left() )
- pRetNode->Insert( static_cast<ObjNode *>(Left()) );
- }
- else
- pRetNode = static_cast<ObjNode *>(Left());
-
- delete this;
- }
- return pRetNode;
-}
-
-sal_uInt32 ObjNode::GetId() const
-{
- return aRscId.GetNumber();
-}
-
-bool ObjNode::IsConsistent()
-{
- bool bRet = true;
-
- if( aRscId.GetNumber() > 0x7FFF || aRscId.GetNumber() < 1 )
- {
- bRet = false;
- }
- else
- {
- if( Left() )
- {
- if( !static_cast<ObjNode *>(Left())->IsConsistent() )
- {
- bRet = false;
- }
- if( static_cast<ObjNode *>(Left())->aRscId >= aRscId )
- {
- bRet = false;
- }
- }
- if( Right() )
- {
- if( static_cast<ObjNode *>(Right())->aRscId <= aRscId )
- {
- bRet = false;
- }
- if( !static_cast<ObjNode *>(Right())->IsConsistent() )
- {
- bRet = false;
- }
- }
- }
-
- return bRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rscconst.cxx b/rsc/source/res/rscconst.cxx
deleted file mode 100644
index c0161106dbea..000000000000
--- a/rsc/source/res/rscconst.cxx
+++ /dev/null
@@ -1,186 +0,0 @@
-/* -*- 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 .
- */
-
-#include <cstdlib>
-#include <cstdio>
-#include <cstring>
-
-#include <rscconst.hxx>
-#include <rscall.h>
-#include <rschash.hxx>
-#include <tools/resid.hxx>
-
-RscEnum::RscEnum( Atom nId, RESOURCE_TYPE nTypeId )
- : RscTop( nId, nTypeId )
- , pVarArray(nullptr), nEntries(0)
-{
-}
-
-RscEnum::~RscEnum()
-{
- if( pVarArray )
- rtl_freeMemory( static_cast<void *>(pVarArray) );
-}
-
-void RscEnum::SetConstant( Atom nVarName, sal_Int32 lValue )
-{
- if( pVarArray )
- pVarArray = static_cast<VarEle *>(rtl_reallocateMemory( static_cast<void *>(pVarArray),
- ((nEntries +1) * sizeof( VarEle )) ));
- else
- pVarArray = static_cast<VarEle *>(rtl_allocateMemory( (nEntries +1) * sizeof( VarEle ) ));
- pVarArray[ nEntries ].nId = nVarName;
- pVarArray[ nEntries ].lValue = lValue;
- nEntries++;
-}
-
-bool RscEnum::GetConstValue( Atom nConst, sal_Int32 * pValue ) const
-{
- sal_uInt32 i = 0;
-
- for( i = 0; i < nEntries; i++ )
- {
- if( pVarArray[ i ].nId == nConst )
- {
- *pValue = pVarArray[ i ].lValue;
- return true;
- }
- }
- return false;
-}
-
-bool RscEnum::GetValueConst( sal_Int32 lValue, Atom * pConst ) const
-{
- sal_uInt32 i = 0;
-
- for( i = 0; i < nEntries; i++ )
- {
- if( pVarArray[ i ].lValue == lValue )
- {
- *pConst = pVarArray[ i ].nId;
- return true;
- }
- }
- return false;
-}
-
-sal_uInt32 RscEnum::GetConstPos( Atom nConst )
-{
- sal_uInt32 i = 0;
-
- for( i = 0; i < nEntries; i++ )
- {
- if( pVarArray[ i ].nId == nConst )
- return i;
- }
-
- return nEntries;
-}
-
-ERRTYPE RscEnum::SetConst( const RSCINST & rInst, Atom nConst, sal_Int32 /*nVal*/ )
-{
- sal_uInt32 i = 0;
-
- if( nEntries != (i = GetConstPos( nConst )) )
- {
- reinterpret_cast<RscEnumInst *>(rInst.pData)->nValue = i;
- reinterpret_cast<RscEnumInst *>(rInst.pData)->bDflt = false;
- return ERR_OK;
- }
-
- return ERR_RSCENUM;
-}
-
-ERRTYPE RscEnum::SetNumber( const RSCINST & rInst, sal_Int32 lValue )
-{
- sal_uInt32 i = 0;
-
- for( i = 0; i < nEntries; i++ )
- {
- if( pVarArray[ i ].lValue == lValue )
- return SetConst( rInst, pVarArray[ i ].nId, lValue );
- }
-
- return ERR_RSCENUM;
-}
-
-ERRTYPE RscEnum::GetConst( const RSCINST & rInst, Atom * pH )
-{
- *pH = pVarArray[ reinterpret_cast<RscEnumInst *>(rInst.pData)->nValue ].nId;
- return ERR_OK;
-}
-
-ERRTYPE RscEnum::GetNumber( const RSCINST & rInst, sal_Int32 * pNumber ){
- *pNumber = pVarArray[ reinterpret_cast<RscEnumInst *>(rInst.pData)->nValue ].lValue;
- return ERR_OK;
-}
-
-RSCINST RscEnum::Create( RSCINST * pInst, const RSCINST & rDflt, bool bOwnClass )
-{
- RSCINST aInst;
-
- if( !pInst )
- {
- aInst.pClass = this;
- aInst.pData = static_cast<CLASS_DATA>(
- rtl_allocateMemory( sizeof( RscEnumInst ) ));
- }
- else
- aInst = *pInst;
-
- if( !bOwnClass && rDflt.IsInst() )
- bOwnClass = rDflt.pClass->InHierarchy( this );
-
- if( bOwnClass )
- memmove( aInst.pData, rDflt.pData, Size() );
- else
- {
- reinterpret_cast<RscEnumInst *>(aInst.pData)->nValue = 0;
- reinterpret_cast<RscEnumInst *>(aInst.pData)->bDflt = true;
- }
-
- return aInst;
-}
-
-bool RscEnum::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
-{
- return pDef && (reinterpret_cast<RscEnumInst*>(rInst.pData)->nValue == reinterpret_cast<RscEnumInst*>(pDef)->nValue );
-}
-
-void RscEnum::WriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont *, sal_uInt32, const char * )
-{
- fprintf( fOutput, "%s",
- pHS->getString( pVarArray[ reinterpret_cast<RscEnumInst *>(rInst.pData)->nValue ].nId ).getStr() );
-}
-
-ERRTYPE RscEnum::WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
- RscTypCont *, sal_uInt32 )
-{
- aMem.Put( pVarArray[ reinterpret_cast<RscEnumInst *>(rInst.pData)->nValue ].lValue );
- return ERR_OK;
-}
-
-RscLangEnum::RscLangEnum()
- : RscEnum( pHS->getID( "LangEnum" ), RSC_NOTYPE ),
- mnLangId( 0x400 )
-{
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rsccont.cxx b/rsc/source/res/rsccont.cxx
deleted file mode 100644
index 60e7064efe49..000000000000
--- a/rsc/source/res/rsccont.cxx
+++ /dev/null
@@ -1,755 +0,0 @@
-/* -*- 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 .
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <rsccont.hxx>
-
-#include <tools/rcid.h>
-
-void ENTRY_STRUCT::Destroy()
-{
- aName.Destroy();
- if( aInst.IsInst() )
- {
- aInst.pClass->Destroy( aInst );
- rtl_freeMemory( aInst.pData );
- }
-}
-
-RscBaseCont::RscBaseCont( Atom nId, RESOURCE_TYPE nTypeId,
- bool bNoIdent )
- : RscTop(nId, nTypeId, nullptr)
- , pTypeClass(nullptr)
- , bNoId(bNoIdent), nOffInstData(RscTop::Size())
- , nSize(nOffInstData + ALIGNED_SIZE(sizeof(RscBaseContInst)))
-
-{
-}
-
-RscBaseCont::~RscBaseCont()
-{
-}
-
-void RscBaseCont::DestroyElements( RscBaseContInst * pClassData )
-{
- if( pClassData->nEntries )
- {
- for (sal_uInt32 i = 0; i < pClassData->nEntries; i++ )
- {
- pClassData->pEntries[ i ].Destroy();
- }
- rtl_freeMemory( pClassData->pEntries );
- pClassData->pEntries = nullptr;
- pClassData->nEntries = 0;
- }
-}
-
-RSCINST RscBaseCont::Create( RSCINST * pInst, const RSCINST & rDflt,
- bool bOwnClass )
-{
- RSCINST aInst;
- RscBaseContInst * pClassData;
-
- if( !pInst )
- {
- aInst.pClass = this;
- aInst.pData = static_cast<CLASS_DATA>(rtl_allocateMemory( Size() ));
- }
- else
- aInst = *pInst;
-
- if( !bOwnClass && rDflt.IsInst() )
- bOwnClass = rDflt.pClass->InHierarchy( this );
-
- RscTop::Create( &aInst, rDflt, bOwnClass );
-
- pClassData = reinterpret_cast<RscBaseContInst *>(aInst.pData + nOffInstData);
- pClassData->nEntries = 0;
- pClassData->pEntries = nullptr;
- pClassData->bDflt = true;
-
- if( bOwnClass )
- {
- RscBaseContInst * pDfltClassData;
- RSCINST aDfltI;
-
- pDfltClassData = reinterpret_cast<RscBaseContInst *>(rDflt.pData + nOffInstData);
-
- if( 0 != pDfltClassData->nEntries )
- {
- *pClassData = *pDfltClassData;
- pClassData->pEntries =
- static_cast<ENTRY_STRUCT *>(rtl_allocateMemory( sizeof( ENTRY_STRUCT )
- * pClassData->nEntries ));
- for (sal_uInt32 i = 0; i < pClassData->nEntries; i++ )
- {
- pClassData->pEntries[ i ].Create();
- pClassData->pEntries[ i ].aName =
- pDfltClassData->pEntries[ i ].aName;
- aDfltI = pDfltClassData->pEntries[ i ].aInst;
- pClassData->pEntries[ i ].aInst =
- aDfltI.pClass->Create( nullptr, aDfltI );
- }
- }
- }
-
- return aInst;
-}
-
-void RscBaseCont::Destroy( const RSCINST & rInst )
-{
- RscBaseContInst * pClassData;
-
- RscTop::Destroy( rInst);
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
- DestroyElements( pClassData );
-}
-
-RSCINST RscBaseCont::SearchElePos( const RSCINST & rInst, const RscId & rEleName,
- RscTop * pClass, sal_uInt32 nPos )
-{
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
- if( !pClass )
- pClass = pTypeClass;
-
- if( rEleName.IsId() )
- {
- for (sal_uInt32 i = nPos; i < pClassData->nEntries; i++ )
- {
- if( pClassData->pEntries[ i ].aName == rEleName &&
- pClassData->pEntries[ i ].aInst.pClass == pClass )
- {
- return pClassData->pEntries[ i ].aInst;
- }
- }
- }
- return RSCINST();
-}
-
-RSCINST RscBaseCont::SearchEle( const RSCINST & rInst, const RscId & rEleName,
- RscTop * pClass )
-{
- return SearchElePos( rInst, rEleName, pClass, 0 );
-}
-
-ERRTYPE RscBaseCont::GetElement( const RSCINST & rInst, const RscId & rEleName,
- RscTop * pCreateClass,
- const RSCINST & rCreateInst, RSCINST * pGetInst )
-{
- RscBaseContInst * pClassData;
- RSCINST aTmpI;
- ERRTYPE aError;
-
- if( !bNoId && !rEleName.IsId() )
- aError = WRN_CONT_NOID;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- if( pCreateClass )
- {
- if( !pCreateClass->InHierarchy( pTypeClass ) )
- {
- return ERR_CONT_INVALIDTYPE;
- }
- }
- else
- pCreateClass = pTypeClass;
-
- pClassData->bDflt = false;
-
- if( !bNoId )
- aTmpI = SearchEle( rInst, rEleName, pCreateClass );
- // entry found
- if( aTmpI.IsInst() )
- {
- aError = WRN_CONT_DOUBLEID;
- if( rCreateInst.IsInst() )
- {
- aTmpI.pClass->Destroy( aTmpI );
- aTmpI.pClass->Create( &aTmpI, rCreateInst );
- }
- }
- else
- {
- if( pClassData->pEntries )
- {
- pClassData->pEntries =
- static_cast<ENTRY_STRUCT *>(rtl_reallocateMemory( pClassData->pEntries,
- sizeof( ENTRY_STRUCT ) * (pClassData->nEntries +1) ));
- }
- else
- {
- pClassData->pEntries =
- static_cast<ENTRY_STRUCT *>(rtl_allocateMemory( sizeof( ENTRY_STRUCT )
- * (pClassData->nEntries +1) ));
- }
-
- pClassData->pEntries[ pClassData->nEntries ].Create();
- pClassData->pEntries[ pClassData->nEntries ].aName = rEleName;
-
- if( rCreateInst.IsInst() )
- {
- // initialize instance with CreateInst data
- pClassData->pEntries[ pClassData->nEntries ].aInst =
- pCreateClass->Create( nullptr, rCreateInst );
- }
- else
- {
- pClassData->pEntries[ pClassData->nEntries ].aInst =
- pCreateClass->Create( nullptr, RSCINST() );
- }
-
- pClassData->nEntries++;
- aTmpI = pClassData->pEntries[ pClassData->nEntries -1 ].aInst;
- }
-
- *pGetInst = aTmpI;
- return aError;
-}
-
-sal_uInt32 RscBaseCont::GetCount( const RSCINST & rInst )
-{
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
- return pClassData->nEntries;
-}
-
-RSCINST RscBaseCont::GetPosEle( const RSCINST & rInst, sal_uInt32 nPos )
-{
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- if( nPos < pClassData->nEntries )
- return pClassData->pEntries[ nPos ].aInst;
- return RSCINST();
-}
-
-ERRTYPE RscBaseCont::MovePosEle( const RSCINST & rInst, sal_uInt32 nDestPos,
- sal_uInt32 nSourcePos )
-{
- ERRTYPE aError;
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- if( (nDestPos < pClassData->nEntries) && (nSourcePos < pClassData->nEntries) )
- {
- ENTRY_STRUCT aEntry;
- int nInc = 1;
- sal_uInt32 i = 0;
-
- // mark source
- aEntry = pClassData->pEntries[ nSourcePos ];
- // guess direction of the for-loop
- if( nDestPos < nSourcePos )
- nInc = -1;
-
- for( i = nSourcePos; i != nDestPos; i += nInc )
- pClassData->pEntries[ i ] = pClassData->pEntries[ i + nInc ];
-
- // assign source to target
- pClassData->pEntries[ nDestPos ] = aEntry;
- }
- else
- aError = ERR_RSCCONT;
-
- return aError;
-}
-
-ERRTYPE RscBaseCont::SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos,
- const RscId & rId )
-{
- RscBaseContInst * pClassData;
- RSCINST aTmpI;
- ERRTYPE aError;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- if( nPos < pClassData->nEntries )
- {
- if( ! (rId == pClassData->pEntries[ nPos ].aName) )
- aTmpI = SearchEle( rInst, rId,
- pClassData->pEntries[ nPos ].aInst.pClass );
- if( !aTmpI.IsInst() )
- pClassData->pEntries[ nPos ].aName = rId;
- else
- aError = ERR_RSCCONT;
- }
- else
- aError = ERR_RSCCONT;
-
- return aError;
-}
-
-SUBINFO_STRUCT RscBaseCont::GetInfoEle( const RSCINST & rInst, sal_uInt32 nPos )
-{
- RscBaseContInst * pClassData;
- SUBINFO_STRUCT aInfo;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- if( nPos < pClassData->nEntries )
- {
- aInfo.aId = pClassData->pEntries[ nPos ].aName;
- }
- return aInfo;
-}
-
-ERRTYPE RscBaseCont::SetString( const RSCINST & rInst, const char * pStr )
-{
- RscBaseContInst * pClassData;
- RSCINST aTmpI;
- ERRTYPE aError;
- char *pTmpStr;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- // otherwise infinite recursion is possible
- if( RSC_NOTYPE == pTypeClass->GetTypId() )
- {
- aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr );
-
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetString( aTmpI, pStr );
- else
- {
- aError.Clear();
- DeletePos( rInst, pClassData->nEntries -1 );
- aError = GetElement( rInst, RscId(), nullptr, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetString( aTmpI, &pTmpStr );
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetString( aTmpI, pStr );
- }
-
- if( aError.IsError() )
- DeletePos( rInst, pClassData->nEntries -1 );
- }
- else
- aError = ERR_UNKNOWN_METHOD;
-
- return aError;
-}
-
-ERRTYPE RscBaseCont::SetNumber( const RSCINST & rInst, sal_Int32 lValue )
-{
- RscBaseContInst * pClassData;
- RSCINST aTmpI;
- ERRTYPE aError;
- sal_Int32 lNumber;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- // otherwise infinite recursion is possible
- if( RSC_NOTYPE == pTypeClass->GetTypId() )
- {
- aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber );
-
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetNumber( aTmpI, lValue );
- else
- {
- aError.Clear();
- DeletePos( rInst, pClassData->nEntries -1 );
- aError = GetElement( rInst, RscId(), nullptr, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetNumber( aTmpI, &lNumber );
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetNumber( aTmpI, lValue );
- }
- if( aError.IsError() )
- DeletePos( rInst, pClassData->nEntries -1 );
- }
- else
- aError = ERR_UNKNOWN_METHOD;
-
- return aError;
-}
-
-ERRTYPE RscBaseCont::SetBool( const RSCINST & rInst,
- bool bValue)
-{
- RscBaseContInst * pClassData;
- RSCINST aTmpI;
- ERRTYPE aError;
- bool bBool;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- // otherwise infinite recursion is possible
- if( RSC_NOTYPE == pTypeClass->GetTypId() )
- {
- aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetBool( aTmpI, &bBool );
-
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetBool( aTmpI, bValue );
- else
- {
- aError.Clear();
- DeletePos( rInst, pClassData->nEntries -1 );
- aError = GetElement( rInst, RscId(), nullptr, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetBool( aTmpI, &bBool );
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetBool( aTmpI, bValue );
- }
-
- if( aError.IsError() )
- DeletePos( rInst, pClassData->nEntries -1 );
- }
- else
- aError = ERR_UNKNOWN_METHOD;
-
- return aError;
-}
-
-ERRTYPE RscBaseCont::SetConst( const RSCINST & rInst,
- Atom nValueId,
- sal_Int32 lValue)
-{
- RscBaseContInst * pClassData;
- RSCINST aTmpI;
- ERRTYPE aError;
- Atom nConst;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- // otherwise infinite recursion is possible
- if( RSC_NOTYPE == pTypeClass->GetTypId() )
- {
- aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetConst( aTmpI, &nConst );
-
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue );
- else
- {
- aError.Clear();
- DeletePos( rInst, pClassData->nEntries -1 );
- aError = GetElement( rInst, RscId(), nullptr, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetConst( aTmpI, &nConst );
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetConst( aTmpI, nValueId, lValue );
- }
-
- if( aError.IsError() )
- DeletePos( rInst, pClassData->nEntries -1 );
- }
- else
- aError = ERR_UNKNOWN_METHOD;
-
- return aError;
-}
-
-ERRTYPE RscBaseCont::SetRef( const RSCINST & rInst, const RscId & rRefId )
-{
- RscBaseContInst * pClassData;
- RSCINST aTmpI;
- ERRTYPE aError;
- RscId aId;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- // otherwise infinite recursion is possible
- if( RSC_NOTYPE == pTypeClass->GetTypId() )
- {
- aError = GetElement( rInst, RscId(), pTypeClass, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetRef( aTmpI, &aId );
-
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetRef( aTmpI, rRefId );
- else
- {
- aError.Clear();
- DeletePos( rInst, pClassData->nEntries -1 );
- aError = GetElement( rInst, RscId(), nullptr, RSCINST(), &aTmpI );
- aError = aTmpI.pClass->GetRef( aTmpI, &aId );
- if( aError.IsOk() )
- aError = aTmpI.pClass->SetNumber( aTmpI, rRefId.GetNumber() );
- }
-
- if( aError.IsError() )
- DeletePos( rInst, pClassData->nEntries -1 );
- }
- else
- aError = ERR_UNKNOWN_METHOD;
-
- return aError;
-}
-
-bool RscBaseCont::IsConsistent( const RSCINST & rInst )
-{
- sal_uInt32 i = 0;
- RscBaseContInst * pClassData;
- bool bRet;
-
- bRet = RscTop::IsConsistent( rInst );
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- // check for duplicate Id and keep order
- // complexity = n^2 / 2
- for( i = 0; i < pClassData->nEntries; i++ )
- {
- if( !bNoId )
- {
- if( pClassData->pEntries[ i ].aName.GetNumber() > 0x7FFF ||
- pClassData->pEntries[ i ].aName.GetNumber() < 1 )
- {
- bRet = false;
- }
- else if( SearchElePos( rInst, pClassData->pEntries[ i ].aName,
- pClassData->pEntries[ i ].aInst.pClass, i +1 ).IsInst() )
- {
- bRet = false;
- }
- }
- if( ! pClassData->pEntries[ i ].aInst.pClass->
- IsConsistent( pClassData->pEntries[ i ].aInst ) )
- {
- bRet = false;
- }
- }
-
- return bRet;
-}
-
-void RscBaseCont::SetToDefault( const RSCINST & rInst )
-{
- sal_uInt32 i = 0;
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- for( i = 0; i < pClassData->nEntries; i++ )
- {
- pClassData->pEntries[ i ].aInst.pClass->
- SetToDefault( pClassData->pEntries[ i ].aInst );
- }
-
- RscTop::SetToDefault( rInst );
-}
-
-bool RscBaseCont::IsDefault( const RSCINST & rInst )
-{
- sal_uInt32 i = 0;
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- if( !pClassData->bDflt )
- return false;
-
- for( i = 0; i < pClassData->nEntries; i++ )
- {
- if( ! pClassData->pEntries[ i ].aInst.pClass->
- IsDefault( pClassData->pEntries[ i ].aInst ) )
- {
- return false;
- }
- }
-
- return RscTop::IsDefault( rInst );
-}
-
-bool RscBaseCont::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
-{
- RscBaseContInst * pClassData;
-
- if( !RscTop::IsValueDefault( rInst, pDef ) )
- return false;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- if( pClassData->nEntries )
- return false;
- else
- return true;
-}
-
-void RscBaseCont::Delete( const RSCINST & rInst, RscTop * pClass,
- const RscId & rId )
-{
- sal_uInt32 i = 0;
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
- if( !pClass )
- pClass = pTypeClass;
-
- for( i = 0; i < pClassData->nEntries; i++ )
- {
- if( pClassData->pEntries[ i ].aName == rId )
- {
- if( pClassData->pEntries[ i ].aInst.pClass == pClass || !pClass )
- {
- DeletePos( rInst, i );
- return;
- }
- }
- }
-
-}
-
-void RscBaseCont::DeletePos( const RSCINST & rInst, sal_uInt32 nPos )
-{
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- if( nPos < pClassData->nEntries )
- {
- if( 1 == pClassData->nEntries )
- DestroyElements( pClassData );
- else
- {
- pClassData->pEntries[ nPos ].Destroy();
- pClassData->nEntries--;
-
- for (sal_uInt32 i = nPos; i < pClassData->nEntries; i++ )
- pClassData->pEntries[ i ] = pClassData->pEntries[ i + 1 ];
-
- }
- }
-}
-
-void RscBaseCont::ContWriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const char * pVarName )
-{
- sal_uInt32 i = 0, t = 0;
- RscBaseContInst * pClassData;
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- for( i = 0; i < pClassData->nEntries; i++ )
- {
- for( t = 0; t < nTab; t++ )
- fputc( '\t', fOutput );
-
- pClassData->pEntries[ i ].aInst.pClass->
- WriteSrcHeader( pClassData->pEntries[ i ].aInst,
- fOutput, pTC, nTab,
- pClassData->pEntries[ i ].aName, pVarName );
- fprintf( fOutput, ";\n" );
- }
-}
-
-ERRTYPE RscBaseCont::ContWriteRc( const RSCINST & rInst, RscWriteRc & rMem,
- RscTypCont * pTC, sal_uInt32 nDeep )
-{
- RscBaseContInst * pClassData;
- ERRTYPE aError;
-
- if( bNoId )
- {
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- for (sal_uInt32 i = 0; i < pClassData->nEntries && aError.IsOk(); i++ )
- {
- aError = pClassData->pEntries[ i ].aInst.pClass->
- WriteRcHeader( pClassData->pEntries[ i ].aInst,
- rMem, pTC,
- pClassData->pEntries[ i ].aName,
- nDeep );
- }
- }
-
- return aError ;
-}
-
-void RscBaseCont::WriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const char * pVarName )
-{
- RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
- ContWriteSrc( rInst, fOutput, pTC, nTab, pVarName );
-}
-
-ERRTYPE RscBaseCont::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
- RscTypCont * pTC, sal_uInt32 nDeep )
-{
- ERRTYPE aError;
-
- aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep );
- if( aError.IsOk() )
- aError = ContWriteRc( rInst, rMem, pTC, nDeep );
-
- return aError;
-}
-
-RscContWriteSrc::RscContWriteSrc( Atom nId, RESOURCE_TYPE nTypeId )
- : RscBaseCont( nId, nTypeId, true )
-{
-}
-
-void RscContWriteSrc::WriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const char * pVarName )
-{
- sal_uInt32 i;
-
- RscTop::WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
-
- fprintf( fOutput, "\n" );
- for( i = 0; i < nTab; i++ )
- fputc( '\t', fOutput );
-
- fprintf( fOutput, "{\n" );
-
- ContWriteSrc( rInst, fOutput, pTC, nTab +1, pVarName );
-
- for( i = 0; i < nTab; i++ )
- fputc( '\t', fOutput );
-
- fprintf( fOutput, "}" );
-}
-
-RscCont::RscCont( Atom nId, RESOURCE_TYPE nTypeId )
- : RscContWriteSrc( nId, nTypeId )
-{
-}
-
-ERRTYPE RscCont::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
- RscTypCont * pTC, sal_uInt32 nDeep )
-{
- RscBaseContInst * pClassData;
- ERRTYPE aError;
-
- aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep );
-
- pClassData = reinterpret_cast<RscBaseContInst *>(rInst.pData + nOffInstData);
-
- rMem.Put( pClassData->nEntries );
-
- if( aError.IsOk() )
- aError = ContWriteRc( rInst, rMem, pTC, nDeep );
-
- return aError;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rscmgr.cxx b/rsc/source/res/rscmgr.cxx
deleted file mode 100644
index 6c0b1441d042..000000000000
--- a/rsc/source/res/rscmgr.cxx
+++ /dev/null
@@ -1,346 +0,0 @@
-/* -*- 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 .
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <rscmgr.hxx>
-#include <rscdb.hxx>
-
-RscMgr::RscMgr( Atom nId, RESOURCE_TYPE nTypeId, RscTop * pSuperCl )
- : RscClass( nId, nTypeId, pSuperCl )
-{
-}
-
-sal_uInt32 RscMgr::Size() const
-{
- return RscClass::Size() + ALIGNED_SIZE( sizeof( RscMgrInst ) );
-}
-
-RSCINST RscMgr::Create( RSCINST * pInst, const RSCINST & rDflt, bool bOwnClass )
-{
- RSCINST aInst;
- RscMgrInst * pClassData;
-
- if( !pInst )
- {
- aInst.pClass = this;
- aInst.pData = static_cast<CLASS_DATA>(rtl_allocateMemory( Size() ));
- }
- else
- aInst = *pInst;
-
- if( !bOwnClass && rDflt.IsInst() )
- bOwnClass = rDflt.pClass->InHierarchy( this );
-
- RscClass::Create( &aInst, rDflt, bOwnClass );
-
- pClassData = reinterpret_cast<RscMgrInst *>(aInst.pData + RscClass::Size() );
- pClassData->Create();
-
- if( bOwnClass )
- {
- RscMgrInst * pDfltData = reinterpret_cast<RscMgrInst *>(rDflt.pData + RscClass::Size());
- *pClassData = *pDfltData;
- }
-
- return aInst;
-}
-
-void RscMgr::Destroy( const RSCINST & rInst )
-{
- RscMgrInst * pClassData;
-
- RscClass::Destroy( rInst );
-
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
- pClassData->Destroy();
-}
-
-void RscMgr::SetToDefault( const RSCINST & rInst )
-{
- RscMgrInst * pClassData;
-
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
- pClassData->bDflt = true;
-
- RscClass::SetToDefault( rInst );
-}
-
-bool RscMgr::IsDefault( const RSCINST & rInst )
-{
- RscMgrInst * pClassData;
-
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
- if( !pClassData->bDflt )
- return false;
-
- return RscClass::IsDefault( rInst );
-}
-
-bool RscMgr::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
-{
- if( !RscClass::IsValueDefault( rInst, pDef ) )
- return false;
-
- if( pDef )
- {
- RscMgrInst * pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
- RscMgrInst * pDfltData = reinterpret_cast<RscMgrInst *>(pDef + RscClass::Size());
-
- if( !pClassData->aRefId.IsId() && !pDfltData->aRefId.IsId() )
- {
- return true;
- }
- }
-
- return false;
-}
-
-
-void RscMgr::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const RscId & rId, const char * pVarName )
-{
- RscMgrInst * pClassData;
- sal_uInt32 i;
-
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
-
- fprintf( fOutput, "%s %s",
- pHS->getString( rInst.pClass->GetId() ).getStr(),
- (rId.GetName()).getStr() );
-
- if( pClassData->aRefId.IsId() )
- fprintf( fOutput, ",%s", pClassData->aRefId.GetName().getStr() );
- else
- {
- fprintf( fOutput, "\n" );
- for( i = 0; i < nTab; i++ )
- fputc( '\t', fOutput );
-
- fprintf( fOutput, "{\n" );
-
- rInst.pClass->WriteSrc( rInst, fOutput, pTC, nTab +1, pVarName );
-
- RscClass::WriteSrc( rInst, fOutput, pTC, nTab +1, pVarName);
-
- for( i = 0; i < nTab; i++ )
- fputc( '\t', fOutput );
-
- fprintf( fOutput, "}" );
- }
-}
-
-void RscMgr::WriteSrc( const RSCINST &, FILE *, RscTypCont *, sal_uInt32,
- const char * )
-{
-}
-
-ERRTYPE RscMgr::WriteRcHeader( const RSCINST & rInst, RscWriteRc & rMem,
- RscTypCont * pTC, const RscId &rId,
- sal_uInt32 nDeep )
-{
- RscMgrInst * pClassData;
- ERRTYPE aError;
- ObjNode * pObjNode = nullptr;
-
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
-
- if( pClassData->aRefId.IsId() )
- {
- // increment and test to avoid endless recursion
- nDeep++;
- if( nDeep > nRefDeep )
- aError = ERR_REFTODEEP;
- else
- pObjNode = rInst.pClass->GetRefClass()->
- GetObjNode( pClassData->aRefId );
-
- if( !pObjNode && pTC )
- {
- OStringBuffer aMsg(pHS->getString(rInst.pClass->GetId()));
- aMsg.append(' ').append(pClassData->aRefId.GetName());
- aError = WRN_MGR_REFNOTFOUND;
- pTC->pEH->Error(aError, rInst.pClass, rId, aMsg.getStr());
- }
- }
-
- if( aError.IsOk() )
- {
- if( pObjNode )
- {
- RSCINST aRefI;
- RscTop * pTmpRefClass = rInst.pClass->GetRefClass();
-
- aRefI = RSCINST( rInst.pClass, pObjNode->GetRscObj() );
- if( pTmpRefClass == rInst.pClass )
- {
- aError = aRefI.pClass->WriteRcHeader( aRefI, rMem, pTC,
- rId, nDeep );
- }
- else
- {
- RSCINST aRefInst = rInst.pClass->Create( nullptr, aRefI );
- aError = aRefI.pClass->WriteRcHeader( aRefInst, rMem, pTC,
- rId, nDeep );
- pTmpRefClass->Destroy( aRefInst );
- }
- }
- else
- {
- sal_uInt32 nOldSize;
- sal_uInt32 nLocalSize;
-
- nOldSize = rMem.IncSize( 16 /*sizeof( RSHEADER_TYPE )*/ );
-
- aError = rInst.pClass->WriteRc( rInst, rMem, pTC, nDeep );
- if( aError.IsOk() )
- aError = WriteInstRc( rInst, rMem, pTC, nDeep );
- nLocalSize = rMem.Size();
-
- if( aError.IsOk() )
- {
- // RscClass is skipped
- aError = RscTop::WriteRc( rInst, rMem, pTC, nDeep );
- }
-
- /*
- // structure definition from which the resource is built
- struct RSHEADER_TYPE{
- RESOURCE_TYPE nRT; // resource type
- sal_uInt32 nRT; // resource type
- sal_uInt32 nGlobOff; // global offset
- sal_uInt32 nLocalOff; // local offset
- };
- */
- sal_uInt32 nID = rId.GetNumber();
- rMem.PutAt( nOldSize, nID );
- rMem.PutAt( nOldSize +4, (sal_uInt32)rInst.pClass->GetTypId() );
- rMem.PutAt( nOldSize +8, (sal_uInt32)(rMem.Size() - nOldSize) );
- rMem.PutAt( nOldSize +12, (sal_uInt32)(nLocalSize - nOldSize) );
- }
- }
-
- return aError;
-}
-
-ERRTYPE RscMgr::WriteRc( const RSCINST &, RscWriteRc &,
- RscTypCont *, sal_uInt32 )
-
-{
- return ERR_OK;
-}
-
-bool RscMgr::IsConsistent( const RSCINST & rInst )
-{
- bool bRet;
- RscMgrInst * pClassData;
-
- bRet = RscClass::IsConsistent( rInst );
-
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
- if( pClassData->aRefId.IsId() &&
- ((pClassData->aRefId.GetNumber() < 1) ||
- (pClassData->aRefId.GetNumber() > 0x7FFF) ||
- IsToDeep( rInst ).IsError()) )
- {
- bRet = false;
- }
-
- return bRet;
-}
-
-ERRTYPE RscMgr::GetRef( const RSCINST & rInst, RscId * pRscId )
-{
- RscMgrInst * pClassData;
-
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
- *pRscId = pClassData->aRefId;
- return ERR_OK;
-}
-
-ERRTYPE RscMgr::IsToDeep( const RSCINST & rInst )
-{
- RscMgrInst * pClassData;
- RscId aOldId, aId;
- ERRTYPE aError;
- RSCINST aTmpI = rInst;
- ObjNode * pObjNode;
- sal_uInt32 nDeep = 0;
-
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
-
- while( aTmpI.IsInst() && (nDeep < nRefDeep) && aError.IsOk() )
- {
- // retrieve reference
- aTmpI.pClass->GetRef( aTmpI, &aId );
- // retrieve referenced object
- pObjNode = aTmpI.pClass->GetObjNode( aId );
- // was the referenced object found?
- if( pObjNode )
- {
- aTmpI.pData = pObjNode->GetRscObj();
- nDeep++;
- }
- else //aTmpI.IsInst() becomes false, end loop
- aTmpI.pData = nullptr;
- }
-
- if( nDeep >= nRefDeep )
- {
- pClassData->aRefId = aOldId;
- aError = ERR_REFTODEEP;
- }
-
- return aError;
-}
-
-ERRTYPE RscMgr::SetRef( const RSCINST & rInst, const RscId & rRefId )
-{
- RscMgrInst * pClassData;
- RscId aOldId, aId;
- ERRTYPE aError;
-
- if( rRefId.IsId() &&
- ((rRefId.GetNumber() < 1) ||
- (rRefId.GetNumber() > 0x7FFF)) )
- {
- aError = ERR_IDRANGE;
- }
- else
- {
- pClassData = reinterpret_cast<RscMgrInst *>(rInst.pData + RscClass::Size());
- aOldId = pClassData->aRefId;// mark old value
- pClassData->aRefId = rRefId;// previous entry to avoid failure when recursing
-
-
- aError = IsToDeep( rInst );
- if( aError.IsOk() )
- pClassData->bDflt = false;
- else
- pClassData->aRefId = aOldId;
- }
-
- return aError;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rscrange.cxx b/rsc/source/res/rscrange.cxx
deleted file mode 100644
index db7957d07644..000000000000
--- a/rsc/source/res/rscrange.cxx
+++ /dev/null
@@ -1,139 +0,0 @@
-/* -*- 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 .
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <rscrange.hxx>
-
-RscLongRange::RscLongRange( Atom nId, RESOURCE_TYPE nTypeId )
- : RscTop( nId, nTypeId )
- , nMin(0), nMax(0)
-{
-}
-
-void RscLongRange::SetRange( sal_Int32 nMinimum, sal_Int32 nMaximum )
-{
- if( nMinimum > nMaximum )
- {
- nMin = nMaximum;
- nMax = nMinimum;
- }
- else
- {
- nMax = nMaximum;
- nMin = nMinimum;
- }
-}
-
-bool RscLongRange::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
-{
- if( pDef )
- return 0 == memcmp( &reinterpret_cast<RscLongRangeInst*>(rInst.pData)->nValue,
- &reinterpret_cast<RscLongRangeInst*>(pDef)->nValue,
- sizeof( sal_Int32 ) );
-
- return false;
-}
-
-ERRTYPE RscLongRange::SetNumber( const RSCINST & rInst, sal_Int32 nValue )
-{
- if( nMax < nValue || nMin > nValue )
- return ERR_RSCRANGE_OUTDEFSET;
-
- void * pData = &reinterpret_cast<RscLongRangeInst*>(rInst.pData)->nValue;
- memcpy( pData, &nValue, sizeof( sal_Int32 ) );
- reinterpret_cast<RscLongRangeInst *>(rInst.pData)->bDflt = false;
- return ERR_OK;
-}
-
-ERRTYPE RscLongRange::GetNumber( const RSCINST & rInst, sal_Int32 * pN )
-{
- memmove( pN, &reinterpret_cast<RscLongRangeInst*>(rInst.pData)->nValue,
- sizeof( sal_Int32 ) );
- return ERR_OK;
-}
-
-RSCINST RscLongRange::Create( RSCINST * pInst, const RSCINST & rDflt,
- bool bOwnClass )
-{
- RSCINST aInst;
-
- if( !pInst )
- {
- aInst.pClass = this;
- aInst.pData = static_cast<CLASS_DATA>(rtl_allocateMemory( sizeof( RscLongRangeInst ) ));
- }
- else
- aInst = *pInst;
-
- if( !bOwnClass && rDflt.IsInst() )
- bOwnClass = rDflt.pClass->InHierarchy( this );
-
- if( bOwnClass )
- memmove( aInst.pData, rDflt.pData, sizeof( RscLongRangeInst ) );
- else
- {
- sal_Int32 lDflt;
- if( 0 >= nMin && 0 <= nMax )
- lDflt = 0;
- else
- lDflt = nMin;
-
- void * pData = &reinterpret_cast<RscLongRangeInst*>(aInst.pData)->nValue;
- memcpy( pData, &lDflt, sizeof( sal_Int32 ) );
- reinterpret_cast<RscLongRangeInst *>(aInst.pData)->bDflt = true;
- }
-
- return aInst;
-}
-
-void RscLongRange::WriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont *, sal_uInt32, const char * )
-{
- sal_Int32 lVal;
- GetNumber( rInst, &lVal );
- fprintf( fOutput, "%d", static_cast<int>(lVal) );
-}
-
-ERRTYPE RscLongRange::WriteRc( const RSCINST & rInst, RscWriteRc & aMem,
- RscTypCont *, sal_uInt32 )
-{
- sal_Int32 lVal;
-
- GetNumber( rInst, &lVal );
- aMem.Put( lVal );
-
- return ERR_OK;
-}
-
-RscLongEnumRange::RscLongEnumRange( Atom nId, RESOURCE_TYPE nTypeId )
- : RscLongRange( nId, nTypeId )
-{
-}
-
-ERRTYPE RscLongEnumRange::SetConst( const RSCINST & rInst, Atom /*nConst*/,
- sal_Int32 nValue )
-{
- return SetNumber( rInst, nValue );
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rscstr.cxx b/rsc/source/res/rscstr.cxx
deleted file mode 100644
index 918fb5ab1afb..000000000000
--- a/rsc/source/res/rscstr.cxx
+++ /dev/null
@@ -1,293 +0,0 @@
-/* -*- 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 .
- */
-
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-#include <rscdb.hxx>
-#include <rscstr.hxx>
-
-#include <rtl/textcvt.h>
-#include <rtl/textenc.h>
-
-RscString::RscString( Atom nId, RESOURCE_TYPE nTypeId )
- : RscTop( nId, nTypeId )
- , pRefClass(nullptr)
-{
-}
-
-ERRTYPE RscString::SetString( const RSCINST & rInst, const char * pStr )
-{
- char * pTmp;
- ERRTYPE aError;
-
- if( aError.IsOk() )
- {
- reinterpret_cast<RscStringInst *>(rInst.pData)->bDflt = false;
-
- pTmp = reinterpret_cast<RscStringInst *>(rInst.pData)->pStr;
- if( pTmp )
- {
- rtl_freeMemory( pTmp );
- pTmp = nullptr;
- }
-
- if( pStr )
- {
- sal_uInt32 nLen = strlen( pStr ) +1;
- pTmp = static_cast<char *>(rtl_allocateMemory( nLen ));
- memcpy( pTmp, pStr, nLen );
- }
-
- reinterpret_cast<RscStringInst *>(rInst.pData)->pStr = pTmp;
- }
-
- return aError;
-}
-
-ERRTYPE RscString::GetString( const RSCINST & rInst, char ** ppStr )
-{
- *ppStr = reinterpret_cast<RscStringInst *>(rInst.pData)->pStr;
- return ERR_OK;
-}
-
-ERRTYPE RscString::GetRef( const RSCINST & rInst, RscId * pRscId )
-{
- *pRscId = reinterpret_cast<RscStringInst *>(rInst.pData)->aRefId;
- return ERR_OK;
-}
-
-ERRTYPE RscString::SetRef( const RSCINST & rInst, const RscId & rRefId )
-{
- if( pRefClass )
- {
- reinterpret_cast<RscStringInst *>(rInst.pData)->aRefId = rRefId;
- reinterpret_cast<RscStringInst *>(rInst.pData)->bDflt = false;
- }
- else
- return ERR_REFNOTALLOWED;
-
- return ERR_OK;
-}
-
-RSCINST RscString::Create( RSCINST * pInst, const RSCINST & rDflt,
- bool bOwnClass )
-{
- RSCINST aInst;
-
- if( !pInst )
- {
- aInst.pClass = this;
- aInst.pData = static_cast<CLASS_DATA>(
- rtl_allocateMemory( sizeof( RscStringInst ) ));
- }
- else
- aInst = *pInst;
-
- if( !bOwnClass && rDflt.IsInst() )
- bOwnClass = rDflt.pClass->InHierarchy( this );
-
- reinterpret_cast<RscStringInst *>(aInst.pData)->aRefId.Create();
- reinterpret_cast<RscStringInst *>(aInst.pData)->pStr = nullptr;
- reinterpret_cast<RscStringInst *>(aInst.pData)->bDflt = true;
-
- if( bOwnClass )
- {
- reinterpret_cast<RscStringInst *>(aInst.pData)->aRefId =
- reinterpret_cast<RscStringInst *>(rDflt.pData)->aRefId;
- SetString( aInst, reinterpret_cast<RscStringInst *>(rDflt.pData)->pStr );
- reinterpret_cast<RscStringInst *>(aInst.pData)->bDflt =
- reinterpret_cast<RscStringInst *>(rDflt.pData)->bDflt;
- }
-
- return aInst;
-}
-
-void RscString::Destroy( const RSCINST & rInst )
-{
- if( reinterpret_cast<RscStringInst *>(rInst.pData)->pStr )
- rtl_freeMemory( reinterpret_cast<RscStringInst *>(rInst.pData)->pStr );
- reinterpret_cast<RscStringInst *>(rInst.pData)->aRefId.Destroy();
-}
-
-bool RscString::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
-{
- RscStringInst * pData = reinterpret_cast<RscStringInst*>(rInst.pData);
- RscStringInst * pDefData = reinterpret_cast<RscStringInst*>(pDef);
-
- if( pDef )
- {
- if( pData->aRefId.IsId() || pDefData->aRefId.IsId() )
- {
- if( pData->aRefId.aExp.IsNumber() &&
- pDefData->aRefId.aExp.IsNumber() )
- {
- // check whether reference identifiers are equal
- if( pData->aRefId.GetNumber() == pDefData->aRefId.GetNumber() )
- {
- return true;
- }
- }
- }
- else
- {
- bool bStrEmpty = false;
- bool bDefStrEmpty = false;
-
- if( pData->pStr )
- {
- bStrEmpty = ('\0' == *pData->pStr);
- }
- else
- bStrEmpty = true;
-
- if( pDefData->pStr )
- {
- bDefStrEmpty = ('\0' == *pDefData->pStr);
- }
- else
- bDefStrEmpty = true;
-
- if( !bStrEmpty || !bDefStrEmpty )
- {
- return false;
- }
- return true;
- }
- }
-
- return false;
-}
-
-void RscString::WriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont *, sal_uInt32, const char * )
-{
- if ( reinterpret_cast<RscStringInst *>(rInst.pData)->aRefId.IsId() )
- {
- fprintf( fOutput, "%s",
- reinterpret_cast<RscStringInst *>(rInst.pData)->aRefId.GetName().getStr() );
- }
- else
- {
- RscStringInst * pStrI = reinterpret_cast<RscStringInst *>(rInst.pData);
- if( pStrI->pStr ){
- //char * pChangeTab = RscChar::GetChangeTab();
- sal_uInt32 n = 0;
- sal_uInt32 nPos, nSlashPos;
-
- do
- {
- fputc( '\"', fOutput );
- nSlashPos = nPos = 0;
-
- while( pStrI->pStr[ n ] && (nPos < 72 || nPos - nSlashPos <= 3) )
- { // after \ drop at least 3 characters \xa7
- fputc( pStrI->pStr[ n ], fOutput );
- if( pStrI->pStr[ n ] == '\\' )
- nSlashPos = nPos;
- n++;
- nPos++;
- }
-
- fputc( '\"', fOutput );
- if( pStrI->pStr[ n ] ) // end not reached yet
- {
- fputc( '\n', fOutput );
- }
- }
- while( pStrI->pStr[ n ] );
- }
- else
- fprintf( fOutput, "\"\"" );
- }
-}
-
-ERRTYPE RscString::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
- RscTypCont * pTC, sal_uInt32 nDeep )
-{
- ERRTYPE aError;
- ObjNode * pObjNode = nullptr;
-
-
- if( reinterpret_cast<RscStringInst *>(rInst.pData)->aRefId.IsId() )
- {
- RscId aId( reinterpret_cast<RscStringInst *>(rInst.pData)->aRefId );
- RSCINST aTmpI;
-
- aTmpI.pClass = pRefClass;
-
- while( aError.IsOk() && aId.IsId() )
- {
- // increment and test to avoid endless recursion
- nDeep++;
- if( nDeep > nRefDeep )
- aError = ERR_REFTODEEP;
- else
- {
- pObjNode = pRefClass->GetObjNode( aId );
- if( pObjNode )
- {
- aTmpI.pData = pObjNode->GetRscObj();
- aError = pRefClass->GetRef( aTmpI, &aId );
- }
- else
- {
- if( pTC )
- {
- OStringBuffer aMsg(pHS->getString(
- pRefClass->GetId()));
- aMsg.append(' ').append(aId.GetName());
- aError = WRN_STR_REFNOTFOUND;
- pTC->pEH->Error( aError, rInst.pClass,
- RscId(), aMsg.getStr() );
- }
- break;
- }
- }
- }
- }
-
- if( aError.IsOk() )
- {
- if( pObjNode )
- {
- RSCINST aRefI;
-
- aRefI = RSCINST( pRefClass, pObjNode->GetRscObj() );
- aError = aRefI.pClass->WriteRc( aRefI, rMem, pTC, nDeep );
- }
- else
- {
- if( reinterpret_cast<RscStringInst *>(rInst.pData)->pStr && pTC )
- {
- char * pStr = RscChar::MakeUTF8( reinterpret_cast<RscStringInst *>(rInst.pData)->pStr,
- pTC->GetSourceCharSet() );
- rMem.PutUTF8( pStr );
- rtl_freeMemory( pStr );
- }
- else
- rMem.PutUTF8( reinterpret_cast<RscStringInst *>(rInst.pData)->pStr );
- }
- }
- return aError;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/rsc/source/res/rsctop.cxx b/rsc/source/res/rsctop.cxx
deleted file mode 100644
index adc61de5a086..000000000000
--- a/rsc/source/res/rsctop.cxx
+++ /dev/null
@@ -1,410 +0,0 @@
-/* -*- 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 .
- */
-
-
-#include <stdio.h>
-#include <string.h>
-#include <rsctop.hxx>
-
-RscTop::RscTop( Atom nId, RESOURCE_TYPE nTypIdent, RscTop * pSuperCl )
- : RefNode( nId )
- , pSuperClass( pSuperCl )
- , nTypId( nTypIdent )
-{
- pRefClass = this;
- if( pSuperClass )
- SetCallPar( pSuperClass->aCallPar1, pSuperClass->aCallPar2,
- pSuperClass->aCallParType );
-}
-
-void RscTop::SetCallPar(const OString& rPar1, const OString& rPar2,
- const OString& rParType)
-{
- aCallPar1 = rPar1;
- aCallPar2 = rPar2;
- aCallParType = rParType;
-}
-
-RSCINST const & RscTop::GetDefault()
-{
- if( !aDfltInst.IsInst() )
- aDfltInst = this->Create( nullptr, RSCINST() );
- return aDfltInst;
-}
-
-void RscTop::Pre_dtor()
-{
- if( aDfltInst.IsInst() )
- {
- aDfltInst.pClass->Destroy( aDfltInst );
- rtl_freeMemory( aDfltInst.pData );
- aDfltInst = RSCINST();
- };
-}
-
-RscTop * RscTop::GetTypeClass() const
-{
- if( pSuperClass )
- return pSuperClass->GetTypeClass();
- else
- return nullptr;
-}
-
-sal_uInt32 RscTop::Size() const
-{
- if( pSuperClass )
- return pSuperClass->Size();
- else
- return 0;
-}
-
-ERRTYPE RscTop::GetRef( const RSCINST & rInst, RscId * pRscId )
-{
- if( pSuperClass )
- return pSuperClass->GetRef( rInst, pRscId );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-bool RscTop::InHierarchy( RscTop * pClass )
-{
- if( this == pClass )
- return true;
- if( pSuperClass )
- return pSuperClass->InHierarchy( pClass );
- return false;
-}
-
-ERRTYPE RscTop::SetVariable( Atom nVarName, RscTop * pClass,
- RSCINST * pDflt, RSCVAR nVarType, sal_uInt32 nMask,
- Atom nDataBaseName )
-{
- if( pSuperClass )
- return pSuperClass->SetVariable( nVarName, pClass, pDflt,
- nVarType, nMask, nDataBaseName );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-RSCINST RscTop::GetVariable( const RSCINST & rInst,
- Atom nVarName,
- const RSCINST & rInitInst,
- bool bInitDflt,
- RscTop * pCreateClass)
-{
- if( pSuperClass )
- return pSuperClass->GetVariable( rInst, nVarName, rInitInst, bInitDflt, pCreateClass );
- else
- return RSCINST();
-}
-
-RSCINST RscTop::GetCopyVar( const RSCINST & rInst, Atom nVarName )
-{
- if( pSuperClass )
- return pSuperClass->GetCopyVar( rInst, nVarName );
- else
- return RSCINST();
-}
-
-RSCINST RscTop::GetTupelVar( const RSCINST & rInst, sal_uInt32 nPos,
- const RSCINST & rInitInst )
-{
- if( pSuperClass )
- return pSuperClass->GetTupelVar( rInst, nPos, rInitInst );
- else
- return RSCINST();
-}
-
-ERRTYPE RscTop::GetElement( const RSCINST & rInst, const RscId & rEleName,
- RscTop *pCreateClass, const RSCINST & rCreateInst,
- RSCINST * pGetInst )
-{
- if( pSuperClass )
- return pSuperClass-> GetElement( rInst, rEleName,
- pCreateClass, rCreateInst,
- pGetInst );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::GetArrayEle( const RSCINST & rInst,
- Atom nId,
- RscTop * pCreateClass,
- RSCINST * pGetInst)
-{
- if( pSuperClass )
- return pSuperClass->GetArrayEle( rInst, nId, pCreateClass, pGetInst );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::GetValueEle( const RSCINST & rInst,
- sal_Int32 lValue,
- RscTop * pCreateClass,
- RSCINST * pGetInst)
-{
- if( pSuperClass )
- return pSuperClass->GetValueEle( rInst, lValue, pCreateClass, pGetInst );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-RSCINST RscTop::SearchEle( const RSCINST & rInst, const RscId & rEleName,
- RscTop * pClass )
-{
- if( pSuperClass )
- return pSuperClass->SearchEle( rInst, rEleName, pClass );
- else
- return RSCINST();
-}
-
-RSCINST RscTop::GetPosEle( const RSCINST & rInst, sal_uInt32 nPos )
-{
- if( pSuperClass )
- return pSuperClass->GetPosEle( rInst, nPos );
- else
- return RSCINST();
-}
-
-ERRTYPE RscTop::MovePosEle( const RSCINST & rInst, sal_uInt32 nDestPos,
- sal_uInt32 nSourcePos )
-{
- if( pSuperClass )
- return pSuperClass->MovePosEle( rInst, nDestPos, nSourcePos );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::SetPosRscId( const RSCINST & rInst, sal_uInt32 nPos,
- const RscId & rRscId )
-{
- if( pSuperClass )
- return pSuperClass->SetPosRscId( rInst, nPos, rRscId );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-SUBINFO_STRUCT RscTop::GetInfoEle( const RSCINST & rInst, sal_uInt32 nPos )
-{
- if( pSuperClass )
- return pSuperClass->GetInfoEle( rInst, nPos );
- else
- return SUBINFO_STRUCT();
-}
-
-sal_uInt32 RscTop::GetCount( const RSCINST & rInst )
-{
- if( pSuperClass )
- return pSuperClass->GetCount( rInst );
- else
- return 0;
-}
-
-ERRTYPE RscTop::SetNumber( const RSCINST & rInst, sal_Int32 lValue )
-{
- if( pSuperClass )
- return pSuperClass->SetNumber( rInst, lValue );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::SetBool( const RSCINST & rInst, bool bValue )
-{
- if( pSuperClass )
- return pSuperClass->SetBool( rInst, bValue );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::SetConst( const RSCINST & rInst, Atom nId, sal_Int32 nVal )
-{
- if( pSuperClass )
- return pSuperClass->SetConst( rInst, nId, nVal );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::SetNotConst( const RSCINST & rInst, Atom nId )
-{
- if( pSuperClass )
- return pSuperClass->SetNotConst( rInst, nId );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::SetString( const RSCINST & rInst, const char * pStr )
-{
- if( pSuperClass )
- return pSuperClass->SetString( rInst, pStr );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::GetNumber( const RSCINST & rInst, sal_Int32 * pN )
-{
- if( pSuperClass )
- return pSuperClass->GetNumber( rInst, pN );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::GetBool( const RSCINST & rInst, bool * pB )
-{
- if( pSuperClass )
- return pSuperClass->GetBool( rInst, pB );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::GetConst( const RSCINST & rInst, Atom * pH )
-{
- if( pSuperClass )
- return pSuperClass->GetConst( rInst, pH );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-ERRTYPE RscTop::GetString( const RSCINST & rInst, char ** ppStr )
-{
- if( pSuperClass )
- return pSuperClass->GetString( rInst, ppStr );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-RSCINST RscTop::Create( RSCINST * pInst, const RSCINST & rDefInst, bool bOwnRange )
-{
- if( pSuperClass )
- return pSuperClass->Create( pInst, rDefInst, bOwnRange );
- else
- {
- if( pInst )
- return *pInst;
- return RSCINST();
- }
-}
-
-void RscTop::Destroy( const RSCINST & rInst )
-{
- if( pSuperClass )
- pSuperClass->Destroy( rInst );
-}
-
-bool RscTop::IsConsistent( const RSCINST & rInst )
-{
- if( pSuperClass )
- return pSuperClass->IsConsistent( rInst );
- else
- return true;
-}
-
-void RscTop::SetToDefault( const RSCINST & rInst )
-{
- if( pSuperClass )
- pSuperClass->SetToDefault( rInst );
-}
-
-bool RscTop::IsDefault( const RSCINST & rInst )
-{
- if( pSuperClass )
- return pSuperClass->IsDefault( rInst );
- else
- return true;
-}
-
-bool RscTop::IsValueDefault( const RSCINST & rInst, CLASS_DATA pDef )
-{
- if( pSuperClass )
- return pSuperClass->IsValueDefault( rInst, pDef );
- else
- return true;
-}
-
-void RscTop::SetDefault( const RSCINST & rInst, Atom nVarId )
-{
- if( pSuperClass )
- pSuperClass->SetDefault( rInst, nVarId );
-}
-
-RSCINST RscTop::GetDefault( Atom nVarId )
-{
- if( pSuperClass )
- return pSuperClass->GetDefault( nVarId );
- else
- return RSCINST();
-}
-
-void RscTop::Delete( const RSCINST & rInst, RscTop * pClass,
- const RscId & rId )
-{
- if( pSuperClass )
- pSuperClass->Delete( rInst, pClass, rId );
-}
-
-void RscTop::DeletePos( const RSCINST & rInst, sal_uInt32 nPos )
-{
- if( pSuperClass )
- pSuperClass->DeletePos( rInst, nPos );
-}
-
-ERRTYPE RscTop::SetRef( const RSCINST & rInst, const RscId & rRefId )
-{
- if( pSuperClass )
- return pSuperClass->SetRef( rInst, rRefId );
- else
- return ERR_UNKNOWN_METHOD;
-}
-
-void RscTop::WriteSrcHeader( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab,
- const RscId & rId, const char * pVarName )
-{
- if( pSuperClass )
- pSuperClass->WriteSrcHeader( rInst, fOutput, pTC, nTab, rId, pVarName );
- else
- rInst.pClass->WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
-}
-
-void RscTop::WriteSrc( const RSCINST & rInst, FILE * fOutput,
- RscTypCont * pTC, sal_uInt32 nTab, const char * pVarName )
-{
- if( pSuperClass )
- pSuperClass->WriteSrc( rInst, fOutput, pTC, nTab, pVarName );
-}
-
-ERRTYPE RscTop::WriteRcHeader( const RSCINST & rInst, RscWriteRc & rMem,
- RscTypCont * pTC, const RscId & rId,
- sal_uInt32 nDeep )
-{
- if( pSuperClass )
- return pSuperClass->WriteRcHeader( rInst, rMem, pTC, rId, nDeep );
- else
- return rInst.pClass->WriteRc( rInst, rMem, pTC, nDeep );
-}
-
-ERRTYPE RscTop::WriteRc( const RSCINST & rInst, RscWriteRc & rMem,
- RscTypCont * pTC, sal_uInt32 nDeep )
-{
- if( pSuperClass )
- return pSuperClass->WriteRc( rInst, rMem, pTC, nDeep );
- else
- return ERR_OK;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */