mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-20 05:10:07 +08:00
git-svn-id: svn://fileserver/activex/AVS/Sources/TeamlabOffice/trunk/ServerComponents@52227 954022d7-b5bf-4e40-9824-e11837661b57
This commit is contained in:
committed by
Alexander Trofimov
parent
755fd2137c
commit
895589010b
62
ASCOfficePDFReader/Array.cpp
Normal file
62
ASCOfficePDFReader/Array.cpp
Normal file
@ -0,0 +1,62 @@
|
||||
#include "stdafx.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
#include "MemoryUtils.h"
|
||||
#include "Object.h"
|
||||
#include "Array.h"
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Array
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
Array::Array(XRef *pXRef)
|
||||
{
|
||||
m_pXRef = pXRef;
|
||||
m_arrItems = NULL;
|
||||
m_nItemSize = m_nCount = 0;
|
||||
m_nRef = 1;
|
||||
}
|
||||
|
||||
Array::~Array()
|
||||
{
|
||||
for ( int nIndex = 0; nIndex < m_nCount; ++nIndex)
|
||||
m_arrItems[nIndex].Free();
|
||||
MemUtilsFree(m_arrItems);
|
||||
}
|
||||
|
||||
void Array::Add(Object *pItem)
|
||||
{
|
||||
if ( m_nCount == m_nItemSize )
|
||||
{
|
||||
if ( m_nCount == 0 )
|
||||
{
|
||||
m_nItemSize = 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_nItemSize *= 2;
|
||||
}
|
||||
m_arrItems = (Object *)MemUtilsReallocArray( m_arrItems, m_nItemSize, sizeof(Object));
|
||||
}
|
||||
m_arrItems[m_nCount] = *pItem;
|
||||
++m_nCount;
|
||||
}
|
||||
|
||||
Object *Array::Get(int nIndex, Object *pObject)
|
||||
{
|
||||
if ( nIndex < 0 || nIndex >= m_nCount )
|
||||
{
|
||||
return pObject->InitNull();
|
||||
}
|
||||
return m_arrItems[nIndex].Fetch( m_pXRef, pObject);
|
||||
}
|
||||
|
||||
Object *Array::GetCopy(int nIndex, Object *pObject)
|
||||
{
|
||||
if ( nIndex < 0 || nIndex >= m_nCount )
|
||||
{
|
||||
return pObject->InitNull();
|
||||
}
|
||||
return m_arrItems[nIndex].Copy(pObject);
|
||||
}
|
||||
Reference in New Issue
Block a user