This commit is contained in:
Elena.Subbotina
2023-12-06 16:21:11 +03:00
parent 5b93fb7fe3
commit 87f0b9cb05
5 changed files with 33 additions and 59 deletions

View File

@ -34,13 +34,13 @@
namespace DocFileFormat
{
BorderCode::BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
BorderCode::BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
{
}
/// Parses the unsigned char for a BRC
BorderCode::BorderCode( unsigned char* bytes, int size ):
cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorNameIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false)
{
if ( FormatUtils::ArraySum( bytes, size ) == ( size * 255 ) )
{
@ -50,6 +50,7 @@ namespace DocFileFormat
{
//it's a border code of Word 2000/2003
cv = FormatUtils::BytesToInt32( bytes, 0, size );
ico = std::wstring( Global::ColorIdentifier[0] );
dptLineWidth = bytes[4];
@ -71,7 +72,7 @@ namespace DocFileFormat
val = FormatUtils::BytesToUInt16( bytes, 2, size );
ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorNameIdentifier[0][0], 17, 12 );
ico = FormatUtils::MapValueToWideString( ( val & 0x00FF ), &Global::ColorIdentifier[0][0], 17, 12 );
dptSpace = ( val & 0x1F00 ) >> 8;
}
else if (size == 2)
@ -81,7 +82,7 @@ namespace DocFileFormat
dptLineWidth = GETBITS(val, 0, 2);
brcType = GETBITS(val, 3, 4);
fShadow = GETBIT(val, 5);
ico = FormatUtils::MapValueToWideString(GETBITS(val, 6, 10), &Global::ColorNameIdentifier[0][0], 17, 12 );
ico = FormatUtils::MapValueToWideString(GETBITS(val, 6, 10), &Global::ColorIdentifier[0][0], 17, 12 );
dptSpace = GETBITS(val, 11, 15);
}
@ -100,11 +101,22 @@ namespace DocFileFormat
fNil = bc.fNil;
}
}
std::wstring BorderCode::getColor()
{
if (cv != 0)
{
return FormatUtils::IntToFormattedWideString(cv, L"#%06x");
}
else if (false == ico.empty())
{
return ico;
}
else return L"auto";
}
bool BorderCode::operator == ( const BorderCode& bc )
{
if ( ( cv == bc.cv ) && ( dptLineWidth == bc.dptLineWidth ) && ( brcType == bc.brcType ) &&
( ico == bc.ico ) && ( dptSpace == bc.dptSpace ) && ( fShadow == bc.fShadow ) &&
(ico == bc.ico ) && ( dptSpace == bc.dptSpace ) && ( fShadow == bc.fShadow ) &&
( fFrame == bc.fFrame ) && ( fNil == bc.fNil ) )
{
return true;