Skip to content

Bugfix: correctly support color being set to "auto" #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Xceed.Words.NET/Src/Formatting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -784,7 +784,7 @@ public static Formatting Parse( XElement rPr, Formatting formatting = null )
var color = option.GetAttribute( XName.Get( "color", DocX.w.NamespaceName ) );
if( !string.IsNullOrEmpty( color ) )
{
formatting.UnderlineColor = System.Drawing.ColorTranslator.FromHtml( string.Format( "#{0}", color ) );
formatting.UnderlineColor = ( color == "auto") ? Color.Black : System.Drawing.ColorTranslator.FromHtml( string.Format( "#{0}", color ) );
}
}
catch( Exception )
Expand All @@ -806,7 +806,7 @@ public static Formatting Parse( XElement rPr, Formatting formatting = null )
var fill = option.GetAttribute( XName.Get( "fill", DocX.w.NamespaceName ) );
if( !string.IsNullOrEmpty( fill ) )
{
formatting.Shading = System.Drawing.ColorTranslator.FromHtml( string.Format( "#{0}", fill ) );
formatting.Shading = ( fill == "auto") ? Color.White : System.Drawing.ColorTranslator.FromHtml( string.Format( "#{0}", fill ) );
}
break;
case "rStyle":
Expand Down
8 changes: 4 additions & 4 deletions Xceed.Words.NET/Src/Table.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2194,7 +2194,7 @@ public Border GetBorder( TableBorderType borderType )

// The color attribute is used for the border color
var color = tblBorderType.Attribute( XName.Get( "color", DocX.w.NamespaceName ) );
if( color == null )
if( color == null || color.Value == "auto" )
{
// uses default border style
}
Expand Down Expand Up @@ -2931,7 +2931,7 @@ public Color Shading
XAttribute fill = shd?.Attribute( XName.Get( "fill", DocX.w.NamespaceName ) );

// If fill is null, this cell contains no Color information.
if( fill == null )
if( fill == null || fill.Value == "auto" )
return Color.White;

return ColorTranslator.FromHtml( string.Format( "#{0}", fill.Value ) );
Expand Down Expand Up @@ -3512,7 +3512,7 @@ public Color FillColor
XElement tcPr = Xml.Element( XName.Get( "tcPr", DocX.w.NamespaceName ) );
XElement shd = tcPr?.Element( XName.Get( "shd", DocX.w.NamespaceName ) );
XAttribute fill = shd?.Attribute( XName.Get( "fill", DocX.w.NamespaceName ) );
if( fill == null )
if( fill == null || fill.Value == "auto" )
return Color.Empty;

int argb = Int32.Parse( fill.Value.Replace( "#", "" ), NumberStyles.HexNumber );
Expand Down Expand Up @@ -3916,7 +3916,7 @@ public Border GetBorder( TableCellBorderType borderType )

// The color attribute is used for the border color
XAttribute color = tcBorderType.Attribute( XName.Get( "color", DocX.w.NamespaceName ) );
if( color == null )
if( color == null || color.Value == "auto" )
{
// uses default border style
}
Expand Down