Commit dce58b62 authored by ElenaSubbotina's avatar ElenaSubbotina

fix bug #36322

parent bae85402
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
#include "IMapping.h" #include "IMapping.h"
#define GETBITS(from, numL, numH) ((from & (((1 << (numH - numL + 1)) - 1) << numL)) >> numL)
namespace DocFileFormat namespace DocFileFormat
{ {
class IVisitable class IVisitable
......
...@@ -462,57 +462,60 @@ namespace DocFileFormat ...@@ -462,57 +462,60 @@ namespace DocFileFormat
void PropertiesMapping::appendShading( XMLTools::XMLElement* parent, const ShadingDescriptor& desc ) void PropertiesMapping::appendShading( XMLTools::XMLElement* parent, const ShadingDescriptor& desc )
{ {
std::wstring pattern = getShadingPattern( desc );
if ( ( parent != NULL ) && ( desc.shadingSpecialValue == shadingSpecialValueNormal )) if ( ( parent != NULL ) && ( desc.shadingSpecialValue == shadingSpecialValueNormal ))
{ {
XMLTools::XMLElement shd( L"w:shd" ); XMLTools::XMLElement shd( L"w:shd" );
//fill color //pattern
XMLTools::XMLAttribute fill( L"w:fill" ); XMLTools::XMLAttribute val( L"w:val" );
val.SetValue( pattern);
shd.AppendAttribute( val );
if ( desc.shadingType == shadingTypeShd ) if (pattern != L"nil")
{ {
if ( desc.cvBackAuto ) //fill color
XMLTools::XMLAttribute fill( L"w:fill" );
if ( desc.shadingType == shadingTypeShd )
{ {
fill.SetValue( L"auto" ); if ( desc.cvBackAuto )
{
fill.SetValue( L"auto" );
}
else
{
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode);
}
} }
else else
{ {
fill.SetValue( RGBColor( (int)desc.cvBack, RedLast ).SixDigitHexCode); fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
} }
}
else
{
fill.SetValue( FormatUtils::MapValueToWideString( desc.icoBack, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( fill ); shd.AppendAttribute( fill );
//foreground color //foreground color
XMLTools::XMLAttribute color( L"w:color" ); XMLTools::XMLAttribute color( L"w:color" );
if ( desc.shadingType == shadingTypeShd ) if ( desc.shadingType == shadingTypeShd )
{
if ( desc.cvForeAuto )
{ {
color.SetValue( L"auto" ); if ( desc.cvForeAuto )
{
color.SetValue( L"auto" );
}
else
{
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode);
}
} }
else else
{ {
color.SetValue( RGBColor( (int)desc.cvFore, RedLast ).SixDigitHexCode); color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
} }
}
else
{
color.SetValue( FormatUtils::MapValueToWideString( desc.icoFore, &Global::ColorIdentifier[0][0], 17, 12 ));
}
shd.AppendAttribute( color );
//pattern
XMLTools::XMLAttribute val( L"w:val" );
val.SetValue( getShadingPattern( desc ));
shd.AppendAttribute( val );
shd.AppendAttribute( color );
}
parent->RemoveChildByName( L"w:shd" ); parent->RemoveChildByName( L"w:shd" );
parent->AppendChild( shd ); parent->AppendChild( shd );
} }
......
...@@ -174,9 +174,9 @@ namespace DocFileFormat ...@@ -174,9 +174,9 @@ namespace DocFileFormat
//it's a Word 97 SPRM //it's a Word 97 SPRM
short val = FormatUtils::BytesToInt16(bytes, 0, size); short val = FormatUtils::BytesToInt16(bytes, 0, size);
icoFore = (val & 0x1F); icoFore = GETBITS(val, 0, 4);
icoBack = ((val >> 5) & 0x1F); icoBack = GETBITS(val, 5, 9);
ipat = (ShadingPattern) ((val >> 10) & 0x3F); ipat = (ShadingPattern) GETBITS(val, 10, 15);
shadingType = shadingTypeShd80; shadingType = shadingTypeShd80;
...@@ -209,7 +209,7 @@ namespace DocFileFormat ...@@ -209,7 +209,7 @@ namespace DocFileFormat
else if (0x0F == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x80); } else if (0x0F == icoFore) { cvFore = RGB2 (0x80, 0x80, 0x80); }
else if (0x10 == icoFore) { cvFore = RGB2 (0xC0, 0xC0, 0xC0); } else if (0x10 == icoFore) { cvFore = RGB2 (0xC0, 0xC0, 0xC0); }
if (0x00 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); cvBackAuto = true; } if (0x00 == icoBack) { cvBack = RGB2 (0xFF, 0xFF, 0xFF); cvBackAuto = true; }
else if (0x01 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); } else if (0x01 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0x00); }
else if (0x02 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0xFF); } else if (0x02 == icoBack) { cvBack = RGB2 (0x00, 0x00, 0xFF); }
else if (0x03 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0xFF); } else if (0x03 == icoBack) { cvBack = RGB2 (0x00, 0xFF, 0xFF); }
......
...@@ -349,7 +349,7 @@ namespace DocFileFormat ...@@ -349,7 +349,7 @@ namespace DocFileFormat
void TableCellPropertiesMapping::apppendCellShading (unsigned char* sprmArg, int size, int cellIndex) void TableCellPropertiesMapping::apppendCellShading (unsigned char* sprmArg, int size, int cellIndex)
{ {
if (sprmArg) if (sprmArg && cellIndex >= 0)
{ {
//shading descriptor can have 10 bytes (Word 2000) or 2 bytes (Word 97) //shading descriptor can have 10 bytes (Word 2000) or 2 bytes (Word 97)
int shdLength = 2; int shdLength = 2;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment