mirror of
https://github.com/ONLYOFFICE/core.git
synced 2026-07-11 14:00:32 +08:00
170 lines
5.9 KiB
C++
170 lines
5.9 KiB
C++
#pragma once
|
|
|
|
#include "Brc80MayBeNil.h"
|
|
#include "Prl.h"
|
|
|
|
namespace ASCDocFileFormat
|
|
{
|
|
class TableBordersOperand80: public IOperand
|
|
{
|
|
public:
|
|
TableBordersOperand80() : bytes(NULL), cb(0)
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
explicit TableBordersOperand80( Brc80MayBeNil _brcTop, Brc80MayBeNil _brcLeft, Brc80MayBeNil _brcBottom, Brc80MayBeNil _brcRight, Brc80MayBeNil _brcHorizontalInside, Brc80MayBeNil _brcVerticalInside ) : brcTop(_brcTop), brcLeft(_brcLeft), brcBottom(_brcBottom), brcRight(_brcRight), brcHorizontalInside(_brcHorizontalInside), brcVerticalInside(_brcVerticalInside), bytes(NULL), cb(0)
|
|
{
|
|
Initialize();
|
|
}
|
|
|
|
TableBordersOperand80( const TableBordersOperand80& _tableBordersOperand80 ): brcTop(_tableBordersOperand80.brcTop), brcLeft(_tableBordersOperand80.brcLeft), brcBottom(_tableBordersOperand80.brcBottom), brcRight(_tableBordersOperand80.brcRight), brcHorizontalInside(_tableBordersOperand80.brcHorizontalInside), brcVerticalInside(_tableBordersOperand80.brcVerticalInside), bytes(NULL), cb(0)
|
|
{
|
|
this->bytes = new unsigned char[this->cb + 1];
|
|
memcpy_s( this->bytes, ( this->cb + 1 ), _tableBordersOperand80.bytes, ( _tableBordersOperand80.cb + 1 ) );
|
|
}
|
|
|
|
explicit TableBordersOperand80( const Prl& _prl ):
|
|
bytes(NULL), cb(0)
|
|
{
|
|
unsigned long prlSize = 0;
|
|
|
|
unsigned char* bytes = _prl.GetBytes( &prlSize );
|
|
|
|
if ( bytes != NULL )
|
|
{
|
|
brcTop = Brc80MayBeNil( FormatUtils::BytesToUInt32( bytes, ( 0 + sizeof(unsigned short) + sizeof(unsigned char) ), prlSize ) );
|
|
brcLeft = Brc80MayBeNil( FormatUtils::BytesToUInt32( bytes, ( 4 + sizeof(unsigned short) + sizeof(unsigned char) ), prlSize ) );
|
|
brcBottom = Brc80MayBeNil( FormatUtils::BytesToUInt32( bytes, ( 8 + sizeof(unsigned short) + sizeof(unsigned char) ), prlSize ) );
|
|
brcRight = Brc80MayBeNil( FormatUtils::BytesToUInt32( bytes, ( 12 + sizeof(unsigned short) + sizeof(unsigned char) ), prlSize ) );
|
|
brcHorizontalInside = Brc80MayBeNil( FormatUtils::BytesToUInt32( bytes, ( 16 + sizeof(unsigned short) + sizeof(unsigned char) ), prlSize ) );
|
|
brcVerticalInside = Brc80MayBeNil( FormatUtils::BytesToUInt32( bytes, ( 20 + sizeof(unsigned short) + sizeof(unsigned char) ), prlSize ) );
|
|
|
|
RELEASEARRAYOBJECTS (bytes);
|
|
}
|
|
|
|
this->Initialize();
|
|
}
|
|
|
|
TableBordersOperand80& operator = ( const TableBordersOperand80& _tableBordersOperand80 )
|
|
{
|
|
if ( this != &_tableBordersOperand80 )
|
|
{
|
|
this->brcTop = _tableBordersOperand80.brcTop;
|
|
this->brcLeft = _tableBordersOperand80.brcLeft;
|
|
this->brcBottom = _tableBordersOperand80.brcBottom;
|
|
this->brcRight = _tableBordersOperand80.brcRight;
|
|
this->brcHorizontalInside = _tableBordersOperand80.brcHorizontalInside;
|
|
this->brcVerticalInside = _tableBordersOperand80.brcVerticalInside;
|
|
|
|
this->Initialize();
|
|
}
|
|
|
|
return *this;
|
|
}
|
|
|
|
void SetTopBorder( const Brc80MayBeNil& _brc80MayBeNilTop )
|
|
{
|
|
this->brcTop = _brc80MayBeNilTop;
|
|
|
|
this->Initialize();
|
|
}
|
|
|
|
void SetLeftBorder( const Brc80MayBeNil& _brc80MayBeNilLeft )
|
|
{
|
|
this->brcLeft = _brc80MayBeNilLeft;
|
|
|
|
this->Initialize();
|
|
}
|
|
|
|
void SetBottomBorder( const Brc80MayBeNil& _brc80MayBeNilBottom )
|
|
{
|
|
this->brcBottom = _brc80MayBeNilBottom;
|
|
|
|
this->Initialize();
|
|
}
|
|
|
|
void SetRightBorder( const Brc80MayBeNil& _brc80MayBeNilRight )
|
|
{
|
|
this->brcRight = _brc80MayBeNilRight;
|
|
|
|
this->Initialize();
|
|
}
|
|
|
|
void SetHorizontalInsideBorder( const Brc80MayBeNil& _brc80MayBeNilHorizontalInside )
|
|
{
|
|
this->brcHorizontalInside = _brc80MayBeNilHorizontalInside;
|
|
|
|
this->Initialize();
|
|
}
|
|
|
|
void SetVerticalInsideBorder( const Brc80MayBeNil& _brc80MayBeNilVerticalInside )
|
|
{
|
|
this->brcVerticalInside = _brc80MayBeNilVerticalInside;
|
|
|
|
this->Initialize();
|
|
}
|
|
|
|
virtual ~TableBordersOperand80()
|
|
{
|
|
RELEASEARRAYOBJECTS (bytes);
|
|
}
|
|
|
|
virtual unsigned int Size() const
|
|
{
|
|
return ( this->cb + 1 );
|
|
}
|
|
|
|
virtual operator unsigned char*() const
|
|
{
|
|
return this->bytes;
|
|
}
|
|
|
|
virtual operator const unsigned char*() const
|
|
{
|
|
return (const unsigned char*)this->bytes;
|
|
}
|
|
|
|
private:
|
|
void Initialize()
|
|
{
|
|
RELEASEARRAYOBJECTS (bytes);
|
|
|
|
this->cb = ( 6 * sizeof(Brc80MayBeNil) );
|
|
|
|
this->bytes = new unsigned char[this->cb + 1];
|
|
|
|
if ( this->bytes != NULL )
|
|
{
|
|
memset( this->bytes, 0, ( this->cb + 1 ) );
|
|
|
|
unsigned int brcTopValue = this->brcTop;
|
|
unsigned int brcLeftValue = this->brcLeft;
|
|
unsigned int brcBottomValue = this->brcBottom;
|
|
unsigned int brcRightValue = this->brcRight;
|
|
unsigned int brcHorizontalInsideValue = this->brcHorizontalInside;
|
|
unsigned int brcVerticalInsideValue = this->brcVerticalInside;
|
|
|
|
this->bytes[0] = this->cb;
|
|
memcpy( ( this->bytes + sizeof(this->cb) ), &brcTopValue, sizeof(brcTopValue) );
|
|
memcpy( ( this->bytes + sizeof(this->cb) + sizeof(brcTopValue) ), &brcLeftValue, sizeof(brcLeftValue) );
|
|
memcpy( ( this->bytes + sizeof(this->cb) + sizeof(brcTopValue) + sizeof(brcLeftValue) ), &brcBottomValue, sizeof(brcBottomValue) );
|
|
memcpy( ( this->bytes + sizeof(this->cb) + sizeof(brcTopValue) + sizeof(brcLeftValue) + sizeof(brcBottomValue) ), &brcRightValue, sizeof(brcRightValue) );
|
|
memcpy( ( this->bytes + sizeof(this->cb) + sizeof(brcTopValue) + sizeof(brcLeftValue) + sizeof(brcBottomValue) + sizeof(brcRightValue) ), &brcHorizontalInsideValue, sizeof(brcHorizontalInsideValue) );
|
|
memcpy( ( this->bytes + sizeof(this->cb) + sizeof(brcTopValue) + sizeof(brcLeftValue) + sizeof(brcBottomValue) + sizeof(brcRightValue) + sizeof(brcHorizontalInsideValue) ), &brcVerticalInsideValue, sizeof(brcVerticalInsideValue) );
|
|
}
|
|
}
|
|
|
|
private:
|
|
|
|
unsigned char cb;
|
|
Brc80MayBeNil brcTop;
|
|
Brc80MayBeNil brcLeft;
|
|
Brc80MayBeNil brcBottom;
|
|
Brc80MayBeNil brcRight;
|
|
Brc80MayBeNil brcHorizontalInside;
|
|
Brc80MayBeNil brcVerticalInside;
|
|
|
|
unsigned char* bytes;
|
|
};
|
|
} |