diff --git a/MsBinaryFile/DocFile/BorderCode.cpp b/MsBinaryFile/DocFile/BorderCode.cpp index 891189702a..b47e30440c 100644 --- a/MsBinaryFile/DocFile/BorderCode.cpp +++ b/MsBinaryFile/DocFile/BorderCode.cpp @@ -34,23 +34,31 @@ namespace DocFileFormat { - BorderCode::BorderCode(): cv(0), dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) + BorderCode::BorderCode(): 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::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) + dptLineWidth(0), brcType(0), ico( Global::ColorIdentifier[0] ), dptSpace(0), fShadow(false), fFrame(false), fNil(false) { if ( FormatUtils::ArraySum( bytes, size ) == ( size * 255 ) ) { fNil = true; } else if ( size == 8 ) - { - //it's a border code of Word 2000/2003 + { //it's a border code of Word 2000/2003 cv = FormatUtils::BytesToInt32( bytes, 0, size ); - cv = cv & 0x00ffffff; + BYTE auto_ = GETBITS(*cv, 24, 31); + + if (auto_ == 0) + { + BYTE B = GETBITS(*cv, 0, 7); + BYTE G = GETBITS(*cv, 8, 15); + BYTE R = GETBITS(*cv, 16, 23); + cv = (B << 16) + (G << 8) + (R); + } + else cv = boost::none; ico = std::wstring( Global::ColorIdentifier[0] ); @@ -104,9 +112,9 @@ namespace DocFileFormat } std::wstring BorderCode::getColor() { - if (cv != 0) + if (cv) { - return FormatUtils::IntToFormattedWideString(cv, L"#%06x"); + return FormatUtils::IntToFormattedWideString(*cv, L"#%06x"); } else if (false == ico.empty()) { diff --git a/MsBinaryFile/DocFile/BorderCode.h b/MsBinaryFile/DocFile/BorderCode.h index 813d43e5a3..3b7997ae1a 100644 --- a/MsBinaryFile/DocFile/BorderCode.h +++ b/MsBinaryFile/DocFile/BorderCode.h @@ -73,7 +73,7 @@ namespace DocFileFormat friend class VMLPictureMapping; private: - _UINT32 cv; + boost::optional<_UINT32> cv; unsigned char dptLineWidth; unsigned char brcType; std::wstring ico;