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;

View File

@ -73,54 +73,19 @@ namespace DocFileFormat
friend class VMLPictureMapping;
private:
/// 24-bit border color
int cv;
/// Width of a single line in 1/8pt, max of 32pt
unsigned char dptLineWidth;
/// Border type code:
/// 0 none
/// 1 single
/// 2 thick
/// 3 double
/// 5 hairline
/// 6 dot
/// 7 dash large gap
/// 8 dot dash
/// 9 dot dot dash
/// 10 triple
/// 11 thin-thick small gap
/// 12 tick-thin small gap
/// 13 thin-thick-thin small gap
/// 14 thin-thick medium gap
/// 15 thick-thin medium gap
/// 16 thin-thick-thin medium gap
/// 17 thin-thick large gap
/// 18 thick-thin large gap
/// 19 thin-thick-thin large gap
/// 20 wave
/// 21 double wave
/// 22 dash small gap
/// 23 dash dot stroked
/// 24 emboss 3D
/// 25 engrave 3D
unsigned char brcType;
/// The color of the Border.
/// Unused if cv is set.
std::wstring ico;
/// Width of space to maintain between border and text within border
int dptSpace;
/// When true, border is drawn with shadow. Must be false when BRC is substructure of the TC
bool fShadow;
/// When true, don't reverse the border
bool fFrame;
/// It's a nil BRC, bytes are FFFF.
bool fNil;
public:
/// Creates a new BorderCode with default values
std::wstring getColor();
BorderCode();
/// Parses the unsigned char for a BRC
BorderCode( unsigned char* bytes, int size );
BorderCode( const BorderCode& bc );

View File

@ -46,14 +46,14 @@ namespace Global
L"FF0000",//L"red",
L"FFFF00",//L"yellow",
L"FFFFFF",//L"white",
L"darkBlue",
L"darkCyan",
L"darkGreen",
L"darkMagenta",
L"darkRed",
L"darkYellow",
L"darkGray",
L"lightGray"
L"000080", //darkBlue
L"008080", //darkCyan
L"008000", //darkGreen
L"800080", //darkMagenta
L"800000", //darkRed
L"808000", //darkYellow
L"808080", //darkGray
L"C0C0C0" //lightGray
};
static const wchar_t ColorNameIdentifier[17][12] =
{

View File

@ -447,7 +447,8 @@ namespace DocFileFormat
border->AppendAttribute( space );
XMLTools::XMLAttribute color( L"w:color" );
color.SetValue( RGBColor( brc->cv, RedFirst ).SixDigitHexCode);
color.SetValue(brc->getColor());
border->AppendAttribute( color );
if ( brc->fShadow )

View File

@ -498,17 +498,13 @@ namespace DocFileFormat
{//borders color
if (pict->brcTop)
m_pXmlWriter->WriteAttribute( L"o:bordertopcolor",
pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcTop->cv, L"#%06x") : pict->brcTop->ico);
m_pXmlWriter->WriteAttribute( L"o:bordertopcolor", pict->brcTop->getColor());
if (pict->brcLeft)
m_pXmlWriter->WriteAttribute( L"o:borderleftcolor",
pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcLeft->cv, L"#%06x") : pict->brcLeft->ico);
m_pXmlWriter->WriteAttribute( L"o:borderleftcolor", pict->brcLeft->getColor());
if (pict->brcBottom)
m_pXmlWriter->WriteAttribute( L"o:borderbottomcolor",
pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcBottom->cv, L"#%06x") : pict->brcBottom->ico);
m_pXmlWriter->WriteAttribute( L"o:borderbottomcolor", pict->brcBottom->getColor());
if (pict->brcRight)
m_pXmlWriter->WriteAttribute( L"o:borderrightcolor",
pict->brcTop->ico.empty() ? FormatUtils::IntToFormattedWideString(pict->brcRight->cv, L"#%06x") : pict->brcRight->ico);
m_pXmlWriter->WriteAttribute( L"o:borderrightcolor", pict->brcRight->getColor());
}
m_pXmlWriter->WriteNodeEnd( L"", TRUE, FALSE );