Browse Source

V1.3.0 Released

master
BoucherS 7 years ago
parent
commit
675a7d62c3
68 changed files with 11201 additions and 185 deletions
  1. 1
    0
      Examples/Program.cs
  2. BIN
      Examples/Samples/Bookmark/Output/InsertBookmarks.docx
  3. BIN
      Examples/Samples/Bookmark/Output/ReplaceBookmarkText.docx
  4. BIN
      Examples/Samples/Chart/Output/3DChart.docx
  5. BIN
      Examples/Samples/Chart/Output/BarChart.docx
  6. BIN
      Examples/Samples/Chart/Output/LineChart.docx
  7. BIN
      Examples/Samples/Chart/Output/PieChart.docx
  8. BIN
      Examples/Samples/Document/Output/AddCustomProperties.docx
  9. BIN
      Examples/Samples/Document/Output/AppendDocument.docx
  10. BIN
      Examples/Samples/Document/Output/ApplyTemplate.docx
  11. BIN
      Examples/Samples/Equation/Output/EquationSample.docx
  12. BIN
      Examples/Samples/HeaderFooter/Output/HeadersFooters.docx
  13. BIN
      Examples/Samples/Hyperlink/Output/Hyperlinks.docx
  14. BIN
      Examples/Samples/Image/Output/AddPicture.docx
  15. BIN
      Examples/Samples/Image/Output/CopyPicture.docx
  16. BIN
      Examples/Samples/Image/Output/ModifyImage.docx
  17. BIN
      Examples/Samples/Line/Output/InsertHorizontalLine.docx
  18. BIN
      Examples/Samples/List/Output/AddList.docx
  19. BIN
      Examples/Samples/Margin/Output/Indentation.docx
  20. BIN
      Examples/Samples/Margin/Output/Margins.docx
  21. BIN
      Examples/Samples/Margin/Output/SetDirection.docx
  22. BIN
      Examples/Samples/Miscellaneous/Output/CompanyReport.docx
  23. BIN
      Examples/Samples/Miscellaneous/Output/CreateInvoice.docx
  24. BIN
      Examples/Samples/Miscellaneous/Output/CreateRecipe.docx
  25. BIN
      Examples/Samples/Paragraph/Output/ForceMultiParagraphsOnSinglePage.docx
  26. BIN
      Examples/Samples/Paragraph/Output/ForceParagraphOnSinglePage.docx
  27. BIN
      Examples/Samples/Paragraph/Output/Heading.docx
  28. BIN
      Examples/Samples/Paragraph/Output/SimpleFormattedParagraphs.docx
  29. BIN
      Examples/Samples/Paragraph/Output/TextActions.docx
  30. 2
    1
      Examples/Samples/Paragraph/ParagraphSample.cs
  31. BIN
      Examples/Samples/Parallel/Output/OutputDoc1.docx
  32. BIN
      Examples/Samples/Parallel/Output/OutputDoc2.docx
  33. BIN
      Examples/Samples/Parallel/Output/OutputDoc3.docx
  34. 47
    0
      Examples/Samples/Pdf/PdfSample.cs
  35. BIN
      Examples/Samples/Pdf/Resources/DocumentToConvert.docx
  36. BIN
      Examples/Samples/Protection/Output/AddPasswordProtection.docx
  37. BIN
      Examples/Samples/Protection/Output/AddProtection.docx
  38. BIN
      Examples/Samples/Section/Output/InsertSections.docx
  39. BIN
      Examples/Samples/Table/Output/ColumnsWidth.docx
  40. BIN
      Examples/Samples/Table/Output/CreateTableFromTemplate.docx
  41. BIN
      Examples/Samples/Table/Output/InsertRowAndImageTable.docx
  42. BIN
      Examples/Samples/Table/Output/MergeCells.docx
  43. BIN
      Examples/Samples/Table/Output/TextDirectionTable.docx
  44. BIN
      Examples/Samples/TableOfContent/Output/InsertTableOfContent.docx
  45. BIN
      Examples/Samples/TableOfContent/Output/InsertTableOfContentWithReference.docx
  46. 2
    0
      Examples/Xceed.Words.NET.Examples.csproj
  47. 0
    3
      Examples/bin/Debug/Examples.vshost.exe.config
  48. 0
    11
      Examples/bin/Debug/Examples.vshost.exe.manifest
  49. 5235
    0
      Examples/bin/Debug/Xceed.Words.NET.xml
  50. 0
    3
      Examples/bin/Release/Examples.exe.config
  51. 0
    3
      Examples/bin/Release/Examples.vshost.exe.config
  52. 0
    11
      Examples/bin/Release/Examples.vshost.exe.manifest
  53. 0
    0
      Examples/obj/x86/Debug/Xceed.Words.NET.Examples.csproj.CopyComplete
  54. 11
    1
      Examples/obj/x86/Debug/Xceed.Words.NET.Examples.csproj.FileListAbsolute.txt
  55. 0
    5
      Examples/obj/x86/Release/Xceed.Words.NET.Examples.csproj.FileListAbsolute.txt
  56. 1
    1
      Xceed.Words.NET/AssemblyVersionInfo.cs
  57. 5
    0
      Xceed.Words.NET/Src/Container.cs
  58. 21
    3
      Xceed.Words.NET/Src/DocX.cs
  59. 87
    7
      Xceed.Words.NET/Src/Formatting.cs
  60. 255
    105
      Xceed.Words.NET/Src/HelperFunctions.cs
  61. 7
    5
      Xceed.Words.NET/Src/List.cs
  62. 223
    14
      Xceed.Words.NET/Src/Paragraph.cs
  63. 45
    6
      Xceed.Words.NET/Src/Picture.cs
  64. 16
    2
      Xceed.Words.NET/Src/Table.cs
  65. 1
    1
      Xceed.Words.NET/Xceed.Words.NET.csproj
  66. 5235
    0
      Xceed.Words.NET/bin/Debug/Xceed.Words.NET.XML
  67. 7
    0
      Xceed.Words.NET/obj/Debug/Xceed.Words.NET.csproj.FileListAbsolute.txt
  68. 0
    3
      Xceed.Words.NET/obj/Release/Xceed.Words.NET.csproj.FileListAbsolute.txt

+ 1
- 0
Examples/Program.cs View File

MiscellaneousSample.CompanyReport(); MiscellaneousSample.CompanyReport();
MiscellaneousSample.CreateInvoice(); MiscellaneousSample.CreateInvoice();
Console.WriteLine( "\nPress any key to exit." ); Console.WriteLine( "\nPress any key to exit." );
Console.ReadKey(); Console.ReadKey();
} }

BIN
Examples/Samples/Bookmark/Output/InsertBookmarks.docx View File


BIN
Examples/Samples/Bookmark/Output/ReplaceBookmarkText.docx View File


BIN
Examples/Samples/Chart/Output/3DChart.docx View File


BIN
Examples/Samples/Chart/Output/BarChart.docx View File


BIN
Examples/Samples/Chart/Output/LineChart.docx View File


BIN
Examples/Samples/Chart/Output/PieChart.docx View File


BIN
Examples/Samples/Document/Output/AddCustomProperties.docx View File


BIN
Examples/Samples/Document/Output/AppendDocument.docx View File


BIN
Examples/Samples/Document/Output/ApplyTemplate.docx View File


BIN
Examples/Samples/Equation/Output/EquationSample.docx View File


BIN
Examples/Samples/HeaderFooter/Output/HeadersFooters.docx View File


BIN
Examples/Samples/Hyperlink/Output/Hyperlinks.docx View File


BIN
Examples/Samples/Image/Output/AddPicture.docx View File


BIN
Examples/Samples/Image/Output/CopyPicture.docx View File


BIN
Examples/Samples/Image/Output/ModifyImage.docx View File


BIN
Examples/Samples/Line/Output/InsertHorizontalLine.docx View File


BIN
Examples/Samples/List/Output/AddList.docx View File


BIN
Examples/Samples/Margin/Output/Indentation.docx View File


BIN
Examples/Samples/Margin/Output/Margins.docx View File


BIN
Examples/Samples/Margin/Output/SetDirection.docx View File


BIN
Examples/Samples/Miscellaneous/Output/CompanyReport.docx View File


BIN
Examples/Samples/Miscellaneous/Output/CreateInvoice.docx View File


BIN
Examples/Samples/Miscellaneous/Output/CreateRecipe.docx View File


BIN
Examples/Samples/Paragraph/Output/ForceMultiParagraphsOnSinglePage.docx View File


BIN
Examples/Samples/Paragraph/Output/ForceParagraphOnSinglePage.docx View File


BIN
Examples/Samples/Paragraph/Output/Heading.docx View File


BIN
Examples/Samples/Paragraph/Output/SimpleFormattedParagraphs.docx View File


BIN
Examples/Samples/Paragraph/Output/TextActions.docx View File


+ 2
- 1
Examples/Samples/Paragraph/ParagraphSample.cs View File

var p2 = document.InsertParagraph(); var p2 = document.InsertParagraph();


// Append some text and add formatting. // Append some text and add formatting.
p2.Append( "This is a formatted paragraph using spacing," )
p2.Append( "This is a formatted paragraph using spacing, line spacing, " )
.Font( new Font( "Courier New" ) ) .Font( new Font( "Courier New" ) )
.FontSize( 10 ) .FontSize( 10 )
.Italic() .Italic()
.Spacing( 5 ) .Spacing( 5 )
.SpacingLine( 22 )
.Append( "highlight" ).Highlight( Highlight.yellow ).UnderlineColor( Color.Blue ).CapsStyle( CapsStyle.caps ) .Append( "highlight" ).Highlight( Highlight.yellow ).UnderlineColor( Color.Blue ).CapsStyle( CapsStyle.caps )
.Append( " and strike through." ).StrikeThrough( StrikeThrough.strike ) .Append( " and strike through." ).StrikeThrough( StrikeThrough.strike )
.SpacingAfter( 40 ); .SpacingAfter( 40 );

BIN
Examples/Samples/Parallel/Output/OutputDoc1.docx View File


BIN
Examples/Samples/Parallel/Output/OutputDoc2.docx View File


BIN
Examples/Samples/Parallel/Output/OutputDoc3.docx View File


+ 47
- 0
Examples/Samples/Pdf/PdfSample.cs View File

/***************************************************************************************

DocX – DocX is the community edition of Xceed Words for .NET

Copyright (C) 2009-2017 Xceed Software Inc.

This program is provided to you under the terms of the Microsoft Public
License (Ms-PL) as published at http://wpftoolkit.codeplex.com/license

For more features and fast professional support,
pick up Xceed Words for .NET at https://xceed.com/xceed-words-for-net/

*************************************************************************************/
using System;
using System.IO;

namespace Xceed.Words.NET.Examples
{
public class PdfSample
{
#region Private Members


#endregion

#region Constructors

static PdfSample()
{
}

#endregion

#region Public Methods

/// <summary>
/// Load a document and convert it to PDF.
/// </summary>
public static void ConvertToPDF()
{

// This option is available when you buy Xceed Words for .NET from https://xceed.com/xceed-words-for-net/.
}

#endregion
}
}

BIN
Examples/Samples/Pdf/Resources/DocumentToConvert.docx View File


BIN
Examples/Samples/Protection/Output/AddPasswordProtection.docx View File


BIN
Examples/Samples/Protection/Output/AddProtection.docx View File


BIN
Examples/Samples/Section/Output/InsertSections.docx View File


BIN
Examples/Samples/Table/Output/ColumnsWidth.docx View File


BIN
Examples/Samples/Table/Output/CreateTableFromTemplate.docx View File


BIN
Examples/Samples/Table/Output/InsertRowAndImageTable.docx View File


BIN
Examples/Samples/Table/Output/MergeCells.docx View File


BIN
Examples/Samples/Table/Output/TextDirectionTable.docx View File


BIN
Examples/Samples/TableOfContent/Output/InsertTableOfContent.docx View File


BIN
Examples/Samples/TableOfContent/Output/InsertTableOfContentWithReference.docx View File


+ 2
- 0
Examples/Xceed.Words.NET.Examples.csproj View File

<Compile Include="Samples\Miscellaneous\MiscellaneousSample.cs" /> <Compile Include="Samples\Miscellaneous\MiscellaneousSample.cs" />
<Compile Include="Samples\Paragraph\ParagraphSample.cs" /> <Compile Include="Samples\Paragraph\ParagraphSample.cs" />
<Compile Include="Samples\Parallel\ParallelSample.cs" /> <Compile Include="Samples\Parallel\ParallelSample.cs" />
<Compile Include="Samples\Pdf\PdfSample.cs" />
<Compile Include="Samples\Protection\ProtectionSample.cs" /> <Compile Include="Samples\Protection\ProtectionSample.cs" />
<Compile Include="Samples\Section\SectionSample.cs" /> <Compile Include="Samples\Section\SectionSample.cs" />
<Compile Include="Samples\TableOfContent\TableOfContentSample.cs" /> <Compile Include="Samples\TableOfContent\TableOfContentSample.cs" />
<None Include="Samples\Parallel\Resources\Doc1.docx" /> <None Include="Samples\Parallel\Resources\Doc1.docx" />
<None Include="Samples\Parallel\Resources\Doc2.docx" /> <None Include="Samples\Parallel\Resources\Doc2.docx" />
<None Include="Samples\Parallel\Resources\Doc3.docx" /> <None Include="Samples\Parallel\Resources\Doc3.docx" />
<None Include="Samples\Pdf\Resources\DocumentToConvert.docx" />
<None Include="Samples\Table\Resources\DocumentWithTemplateTable.docx" /> <None Include="Samples\Table\Resources\DocumentWithTemplateTable.docx" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

+ 0
- 3
Examples/bin/Debug/Examples.vshost.exe.config View File

<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

+ 0
- 11
Examples/bin/Debug/Examples.vshost.exe.manifest View File

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

+ 5235
- 0
Examples/bin/Debug/Xceed.Words.NET.xml
File diff suppressed because it is too large
View File


+ 0
- 3
Examples/bin/Release/Examples.exe.config View File

<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

+ 0
- 3
Examples/bin/Release/Examples.vshost.exe.config View File

<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

+ 0
- 11
Examples/bin/Release/Examples.vshost.exe.manifest View File

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

+ 0
- 0
Examples/obj/x86/Debug/Xceed.Words.NET.Examples.csproj.CopyComplete View File


+ 11
- 1
Examples/obj/x86/Debug/Xceed.Words.NET.Examples.csproj.FileListAbsolute.txt View File

D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Examples\bin\Debug\Examples.exe.config
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\bin\Debug\Examples.exe.config
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\bin\Debug\Examples.exe
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\bin\Debug\Examples.pdb
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\bin\Debug\Xceed.Words.NET.dll
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\bin\Debug\Xceed.Words.NET.pdb
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\bin\Debug\Xceed.Words.NET.xml
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\obj\x86\Debug\Xceed.Words.NET.Examples.csprojAssemblyReference.cache
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\obj\x86\Debug\Xceed.Words.NET.Examples.csproj.CoreCompileInputs.cache
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\obj\x86\Debug\Xceed.Words.NET.Examples.csproj.CopyComplete
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\obj\x86\Debug\Examples.exe
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Examples\obj\x86\Debug\Examples.pdb

+ 0
- 5
Examples/obj/x86/Release/Xceed.Words.NET.Examples.csproj.FileListAbsolute.txt View File

D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Examples\bin\Release\Examples.exe.config
D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Examples\bin\Release\Examples.exe
D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Examples\bin\Release\Xceed.Words.NET.dll
D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Examples\obj\x86\Release\Xceed.Words.NET.Examples.csprojResolveAssemblyReference.cache
D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Examples\obj\x86\Release\Examples.exe

+ 1
- 1
Xceed.Words.NET/AssemblyVersionInfo.cs View File

internal static class _XceedVersionInfo internal static class _XceedVersionInfo
{ {
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )] [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public const string BaseVersion = "1.2";
public const string BaseVersion = "1.3";
[System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )] [System.Diagnostics.CodeAnalysis.SuppressMessage( "Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields" )]
public const string Version = BaseVersion + public const string Version = BaseVersion +
".0.0"; ".0.0";

+ 5
- 0
Xceed.Words.NET/Src/Container.cs View File

{ {
foreach( XElement xElement in p ) foreach( XElement xElement in p )
{ {
// Do not include inner paragraphs contained in a Fallback.
if( xElement.Ancestors().FirstOrDefault( x => x.Name.Equals( XName.Get( "Fallback", DocX.mc.NamespaceName ) ) ) != null )
{
continue;
}
var paragraph = new Paragraph( this.Document, xElement, index ); var paragraph = new Paragraph( this.Document, xElement, index );
paragraphs.Add( paragraph ); paragraphs.Add( paragraph );
index += HelperFunctions.GetText( xElement ).Length; index += HelperFunctions.GetText( xElement ).Length;

+ 21
- 3
Xceed.Words.NET/Src/DocX.cs View File

static internal XNamespace c = "http://schemas.openxmlformats.org/drawingml/2006/chart"; static internal XNamespace c = "http://schemas.openxmlformats.org/drawingml/2006/chart";
internal static XNamespace n = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering"; internal static XNamespace n = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering";
static internal XNamespace v = "urn:schemas-microsoft-com:vml"; static internal XNamespace v = "urn:schemas-microsoft-com:vml";
static internal XNamespace mc = "http://schemas.openxmlformats.org/markup-compatibility/2006";
#endregion #endregion


#region Private Members #region Private Members
/// Add an Image into this document from a fully qualified or relative filename. /// Add an Image into this document from a fully qualified or relative filename.
/// </summary> /// </summary>
/// <param name="filename">The fully qualified or relative filename.</param> /// <param name="filename">The fully qualified or relative filename.</param>
/// <param name="contentType">MIME type of image, guessed if not given.</param>
/// <returns>An Image file.</returns> /// <returns>An Image file.</returns>
/// <example> /// <example>
/// Add an Image into this document from a fully qualified filename. /// Add an Image into this document from a fully qualified filename.


// If this document does not contain a coreFilePropertyPart create one.) // If this document does not contain a coreFilePropertyPart create one.)
if( !_package.PartExists( new Uri( "/docProps/core.xml", UriKind.Relative ) ) ) if( !_package.PartExists( new Uri( "/docProps/core.xml", UriKind.Relative ) ) )
throw new Exception( "Core properties part doesn't exist." );
HelperFunctions.CreateCorePropertiesPart( this );


XDocument corePropDoc; XDocument corePropDoc;
var corePropPart = _package.GetPart( new Uri( "/docProps/core.xml", UriKind.Relative ) ); var corePropPart = _package.GetPart( new Uri( "/docProps/core.xml", UriKind.Relative ) );
_settings.Root.AddFirst( documentProtection ); _settings.Root.AddFirst( documentProtection );
} }




#endregion #endregion


#region Internal Methods #region Internal Methods
} }
} }


internal XElement GetDocDefaults()
{
return this._styles.Element( XName.Get( "styles", DocX.w.NamespaceName ) ).Element( XName.Get( "docDefaults", DocX.w.NamespaceName ) );
}

/// <summary> /// <summary>
/// Finds the next free Id for bookmarkStart/docPr. /// Finds the next free Id for bookmarkStart/docPr.
/// </summary> /// </summary>
case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles": case "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles":
document._stylesPart = package.GetPart( new Uri( uriString, UriKind.Relative ) ); document._stylesPart = package.GetPart( new Uri( uriString, UriKind.Relative ) );
using( TextReader tr = new StreamReader( document._stylesPart.GetStream() ) ) using( TextReader tr = new StreamReader( document._stylesPart.GetStream() ) )
{
document._styles = XDocument.Load( tr ); document._styles = XDocument.Load( tr );
var pPrDefault = document._styles.Root.Element( XName.Get( "docDefaults", DocX.w.NamespaceName ) ).Element( XName.Get( "pPrDefault", DocX.w.NamespaceName ) );
if( pPrDefault != null )
{
var pPr = pPrDefault.Element( XName.Get( "pPr", DocX.w.NamespaceName ) );
if( pPr != null )
{
Paragraph.SetDefaultValues( pPr );
}
}
}
break; break;


case "http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects": case "http://schemas.microsoft.com/office/2007/relationships/stylesWithEffects":
internal DocX( DocX document, XElement xml ) internal DocX( DocX document, XElement xml )
: base( document, xml ) : base( document, xml )
{ {
Paragraph.ResetDefaultValues();
} }


#endregion #endregion

+ 87
- 7
Xceed.Words.NET/Src/Formatting.cs View File

private Script? _script; private Script? _script;
private Highlight? _highlight; private Highlight? _highlight;
private Color? _shading; private Color? _shading;
private Border _border;
private double? _size; private double? _size;
private Color? _fontColor; private Color? _fontColor;
private Color? _underlineColor; private Color? _underlineColor;
} }
} }


public Border Border
{
get
{
return _border;
}
set
{
_border = value;
}
}

public string StyleName public string StyleName
{ {
get get
_rPr.Add( new XElement( XName.Get( "shd", DocX.w.NamespaceName ), new XAttribute( XName.Get( "fill", DocX.w.NamespaceName ), _shading.Value.ToHex() ) ) ); _rPr.Add( new XElement( XName.Get( "shd", DocX.w.NamespaceName ), new XAttribute( XName.Get( "fill", DocX.w.NamespaceName ), _shading.Value.ToHex() ) ) );
} }


if( _border != null )
{
_rPr.Add( new XElement( XName.Get( "bdr", DocX.w.NamespaceName ),
new object[] { new XAttribute( XName.Get( "color", DocX.w.NamespaceName ), _border.Color ),
new XAttribute( XName.Get( "space", DocX.w.NamespaceName ), _border.Space ),
new XAttribute( XName.Get( "sz", DocX.w.NamespaceName ), _border.Size ),
new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), _border.Tcbs )
} ) );
}

if( _capsStyle.HasValue ) if( _capsStyle.HasValue )
{ {
switch( _capsStyle ) switch( _capsStyle )
clone.Hidden = _hidden; clone.Hidden = _hidden;
clone.Highlight = _highlight; clone.Highlight = _highlight;
clone.Shading = _shading; clone.Shading = _shading;
clone.Border = _border;
clone.Italic = _italic; clone.Italic = _italic;
if( _kerning.HasValue ) if( _kerning.HasValue )
{ {
formatting.PercentageScale = Int32.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))); formatting.PercentageScale = Int32.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName)));
break; break;
case "sz": case "sz":
formatting.Size = Int32.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
formatting.Size = Double.Parse(option.GetAttribute(XName.Get("val", DocX.w.NamespaceName))) / 2;
break; break;
case "rFonts": case "rFonts":
var fontName = option.GetAttribute( XName.Get( "cs", DocX.w.NamespaceName ), null )
?? option.GetAttribute( XName.Get( "ascii", DocX.w.NamespaceName ), null )
?? option.GetAttribute( XName.Get( "hAnsi", DocX.w.NamespaceName ), null )
?? option.GetAttribute( XName.Get( "hint", DocX.w.NamespaceName ), null )
?? option.GetAttribute( XName.Get( "eastAsia", DocX.w.NamespaceName ), null );
formatting.FontFamily = new Font( fontName ?? "Calibri" );
var fontName = option.GetAttribute( XName.Get( "ascii", DocX.w.NamespaceName ), null )
?? option.GetAttribute( XName.Get( "hAnsi", DocX.w.NamespaceName ), null )
?? option.GetAttribute( XName.Get( "cs", DocX.w.NamespaceName ), null )
?? option.GetAttribute( XName.Get( "hint", DocX.w.NamespaceName ), null )
?? option.GetAttribute( XName.Get( "eastAsia", DocX.w.NamespaceName ), null );

formatting.FontFamily = ( fontName != null )
? new Font( fontName )
: ( formatting.FontFamily == null ) ?
new Font( "Calibri" ) : formatting.FontFamily;
break; break;
case "color": case "color":
try try
formatting.Shading = System.Drawing.ColorTranslator.FromHtml( string.Format( "#{0}", fill ) ); formatting.Shading = System.Drawing.ColorTranslator.FromHtml( string.Format( "#{0}", fill ) );
} }
break; break;
case "bdr":
var borderSize = BorderSize.one;
var borderColor = Color.Black;
var borderSpace = 0;
var borderStyle = BorderStyle.Tcbs_single;

var bdrColor = option.Attribute( XName.Get( "color", DocX.w.NamespaceName ) );
if( ( bdrColor != null ) && ( bdrColor.Value != "auto" ) )
{
borderColor = System.Drawing.ColorTranslator.FromHtml( string.Format( "#{0}", bdrColor.Value ) );
}
var size = option.Attribute( XName.Get( "sz", DocX.w.NamespaceName ) );
if( size != null )
{
var sizeValue = System.Convert.ToSingle( size.Value );
if( sizeValue == 2 )
borderSize = BorderSize.one;
else if( sizeValue == 4 )
borderSize = BorderSize.two;
else if( sizeValue == 6 )
borderSize = BorderSize.three;
else if( sizeValue == 8 )
borderSize = BorderSize.four;
else if( sizeValue == 12 )
borderSize = BorderSize.five;
else if( sizeValue == 18 )
borderSize = BorderSize.six;
else if( sizeValue == 24 )
borderSize = BorderSize.seven;
else if( sizeValue == 36 )
borderSize = BorderSize.eight;
else if( sizeValue == 48 )
borderSize = BorderSize.nine;
else
borderSize = BorderSize.one;
}
var space = option.Attribute( XName.Get( "space", DocX.w.NamespaceName ) );
if( space != null )
{
borderSpace = System.Convert.ToInt32( space.Value );
}
var bdrStyle = option.Attribute( XName.Get( "val", DocX.w.NamespaceName ) );
if( bdrStyle != null )
{
borderStyle = (BorderStyle)Enum.Parse( typeof( BorderStyle ), "Tcbs_" + bdrStyle.Value );
}

formatting.Border = new Border( borderStyle, borderSize, borderSpace, borderColor );
break;
case "rStyle": case "rStyle":
var style = option.GetAttribute( XName.Get( "val", DocX.w.NamespaceName ), null ); var style = option.GetAttribute( XName.Get( "val", DocX.w.NamespaceName ), null );
formatting.StyleName = style; formatting.StyleName = style;
if( other._shading != _shading ) if( other._shading != _shading )
return -1; return -1;


if( other._border != _border )
return -1;

if( other._size != _size ) if( other._size != _size )
return -1; return -1;



+ 255
- 105
Xceed.Words.NET/Src/HelperFunctions.cs View File

using System.Security.Principal; using System.Security.Principal;
using System.Globalization; using System.Globalization;
using System.Xml; using System.Xml;
using System.Diagnostics;


namespace Xceed.Words.NET namespace Xceed.Words.NET
{ {
{ {
sb.Append( ToText( Xml ) ); sb.Append( ToText( Xml ) );


if( Xml.HasElements )
// Do not read text from Fallback or drawing(a new paragraph will take care of drawing).
var fallbackValue = Xml.Name.Equals( XName.Get( "Fallback", DocX.mc.NamespaceName ) );
var drawingValue = Xml.Name.Equals( XName.Get( "drawing", DocX.w.NamespaceName ) );

if( Xml.HasElements && !fallbackValue && !drawingValue )
foreach( XElement e in Xml.Elements() ) foreach( XElement e in Xml.Elements() )
GetTextRecursive( e, ref sb ); GetTextRecursive( e, ref sb );
} }
if( text == String.Empty ) if( text == String.Empty )
return null; return null;


// Do not read text from Fallback.
var fallbackValue = e.AncestorsAndSelf().FirstOrDefault( x => x.Name.Equals( XName.Get( "Fallback", DocX.mc.NamespaceName ) ) );
if( fallbackValue != null )
return null;

// e is a w:t element, it must exist inside a w:r element or a w:tabs, lets climb until we find it. // e is a w:t element, it must exist inside a w:r element or a w:tabs, lets climb until we find it.
while( (e != null) && !e.Name.Equals( XName.Get( "r", DocX.w.NamespaceName ) ) && !e.Name.Equals( XName.Get( "tabs", DocX.w.NamespaceName ) ) )
while( ( e != null ) && !e.Name.Equals( XName.Get( "r", DocX.w.NamespaceName ) ) && !e.Name.Equals( XName.Get( "tabs", DocX.w.NamespaceName ) ) )
e = e.Parent; e = e.Parent;


FormattedText ft = new FormattedText(); FormattedText ft = new FormattedText();
{ {
case "tab": case "tab":
// Do not add "\t" for TabStopPositions defined in "tabs". // Do not add "\t" for TabStopPositions defined in "tabs".
return ((e.Parent != null) && e.Parent.Name.Equals( XName.Get( "tabs", DocX.w.NamespaceName ) )) ? "" : "\t";
case "br":
return "\n";
return ( ( e.Parent != null ) && e.Parent.Name.Equals( XName.Get( "tabs", DocX.w.NamespaceName ) ) ) ? "" : "\t";
//case "br":
// return "\n";
case "t": case "t":
goto case "delText"; goto case "delText";
case "delText": case "delText":
return e.Value; return e.Value;
} }
case "tr": case "tr":
goto case "br";
//goto case "br";
return "\n";
case "tc": case "tc":
goto case "tab"; goto case "tab";
case "ptab":
goto case "tab";
default: default:
return ""; return "";
} }
return settingsPart; return settingsPart;
} }


internal static void CreateCorePropertiesPart(DocX document)
{
PackagePart corePropertiesPart = document._package.CreatePart( new Uri( "/docProps/core.xml", UriKind.Relative ), "application/vnd.openxmlformats-package.core-properties+xml", CompressionOption.Maximum );

XDocument corePropDoc = XDocument.Parse( @"<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<cp:coreProperties xmlns:cp='http://schemas.openxmlformats.org/package/2006/metadata/core-properties' xmlns:dc='http://purl.org/dc/elements/1.1/' xmlns:dcterms='http://purl.org/dc/terms/' xmlns:dcmitype='http://purl.org/dc/dcmitype/' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
<dc:title></dc:title>
<dc:subject></dc:subject>
<dc:creator></dc:creator>
<cp:keywords></cp:keywords>
<dc:description></dc:description>
<cp:lastModifiedBy></cp:lastModifiedBy>
<cp:revision>1</cp:revision>
<dcterms:created xsi:type='dcterms:W3CDTF'>" + DateTime.UtcNow.ToString( "s" ) + "Z" + @"</dcterms:created>
<dcterms:modified xsi:type='dcterms:W3CDTF'>" + DateTime.UtcNow.ToString( "s" ) + "Z" + @"</dcterms:modified>
</cp:coreProperties>" );

using( TextWriter tw = new StreamWriter( new PackagePartStream( corePropertiesPart.GetStream( FileMode.Create, FileAccess.Write ) ) ) )
corePropDoc.Save( tw, SaveOptions.None );

document._package.CreateRelationship( corePropertiesPart.Uri, TargetMode.Internal, "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" );
}

internal static void CreateCustomPropertiesPart( DocX document ) internal static void CreateCustomPropertiesPart( DocX document )
{ {
var customPropertiesPart = document._package.CreatePart( new Uri( "/docProps/custom.xml", UriKind.Relative ), "application/vnd.openxmlformats-officedocument.custom-properties+xml", CompressionOption.Maximum ); var customPropertiesPart = document._package.CreatePart( new Uri( "/docProps/custom.xml", UriKind.Relative ), "application/vnd.openxmlformats-officedocument.custom-properties+xml", CompressionOption.Maximum );
throw new ArgumentOutOfRangeException( "Row and Column count must be greater than 0." ); throw new ArgumentOutOfRangeException( "Row and Column count must be greater than 0." );
} }


int[] columnWidths = new int[columnCount];
for (int i = 0; i < columnCount; i++)
int[] columnWidths = new int[ columnCount ];
for( int i = 0; i < columnCount; i++ )
{ {
columnWidths[i] = 2310;
columnWidths[ i ] = 2310;
} }
return CreateTable(rowCount, columnWidths);
return CreateTable( rowCount, columnWidths );
} }


internal static XElement CreateTable( int rowCount, int[] columnWidths ) internal static XElement CreateTable( int rowCount, int[] columnWidths )
/// <summary> /// <summary>
/// Add the default numbering.xml if it is missing from this document /// Add the default numbering.xml if it is missing from this document
/// </summary> /// </summary>
internal static XDocument AddDefaultNumberingXml(Package package)
internal static XDocument AddDefaultNumberingXml( Package package )
{ {
XDocument numberingDoc; XDocument numberingDoc;


var numberingPart = package.CreatePart(new Uri("/word/numbering.xml", UriKind.Relative), "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", CompressionOption.Maximum);
numberingDoc = DecompressXMLResource("Xceed.Words.NET.Resources.numbering.xml.gz");
var numberingPart = package.CreatePart( new Uri( "/word/numbering.xml", UriKind.Relative ), "application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml", CompressionOption.Maximum );
numberingDoc = DecompressXMLResource( "Xceed.Words.NET.Resources.numbering.xml.gz" );


using( TextWriter tw = new StreamWriter( new PackagePartStream( numberingPart.GetStream( FileMode.Create, FileAccess.Write ) ) ) ) using( TextWriter tw = new StreamWriter( new PackagePartStream( numberingPart.GetStream( FileMode.Create, FileAccess.Write ) ) ) )
{ {


var mainDocPart = GetMainDocumentPart( package ); var mainDocPart = GetMainDocumentPart( package );


mainDocPart.CreateRelationship(numberingPart.Uri, TargetMode.Internal, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering");
mainDocPart.CreateRelationship( numberingPart.Uri, TargetMode.Internal, "http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" );
return numberingDoc; return numberingDoc;
} }


internal static List CreateItemInList(List list, string listText, int level = 0, ListItemType listType = ListItemType.Numbered, int? startNumber = null, bool trackChanges = false, bool continueNumbering = false)
internal static List CreateItemInList( List list, string listText, int level = 0, ListItemType listType = ListItemType.Numbered, int? startNumber = null, bool trackChanges = false, bool continueNumbering = false )
{ {
if (list.NumId == 0)
{
list.CreateNewNumberingNumId(level, listType, startNumber, continueNumbering);
}
if( list.NumId == 0 )
{
list.CreateNewNumberingNumId( level, listType, startNumber, continueNumbering );
}


if (listText != null)
{
var newSection = new XElement
(
XName.Get("p", DocX.w.NamespaceName),
new XElement(XName.Get("pPr", DocX.w.NamespaceName),
new XElement(XName.Get("numPr", DocX.w.NamespaceName),
new XElement(XName.Get("ilvl", DocX.w.NamespaceName), new XAttribute(DocX.w + "val", level)),
new XElement(XName.Get("numId", DocX.w.NamespaceName), new XAttribute(DocX.w + "val", list.NumId)))),
new XElement(XName.Get("r", DocX.w.NamespaceName), new XElement(XName.Get("t", DocX.w.NamespaceName), listText))
);
if (trackChanges)
newSection = CreateEdit(EditType.ins, DateTime.Now, newSection);
if (startNumber == null)
list.AddItem(new Paragraph(list.Document, newSection, 0, ContainerType.Paragraph));
else
list.AddItemWithStartValue(new Paragraph(list.Document, newSection, 0, ContainerType.Paragraph), (int)startNumber);
}
return list;
if( listText != null )
{
var newSection = new XElement
(
XName.Get( "p", DocX.w.NamespaceName ),
new XElement( XName.Get( "pPr", DocX.w.NamespaceName ),
new XElement( XName.Get( "numPr", DocX.w.NamespaceName ),
new XElement( XName.Get( "ilvl", DocX.w.NamespaceName ), new XAttribute( DocX.w + "val", level ) ),
new XElement( XName.Get( "numId", DocX.w.NamespaceName ), new XAttribute( DocX.w + "val", list.NumId ) ) ) ),
new XElement( XName.Get( "r", DocX.w.NamespaceName ), new XElement( XName.Get( "t", DocX.w.NamespaceName ), listText ) )
);
if( trackChanges )
newSection = CreateEdit( EditType.ins, DateTime.Now, newSection );
if( startNumber == null )
list.AddItem( new Paragraph( list.Document, newSection, 0, ContainerType.Paragraph ) );
else
list.AddItemWithStartValue( new Paragraph( list.Document, newSection, 0, ContainerType.Paragraph ), ( int )startNumber );
}
return list;
} }


internal static UnderlineStyle GetUnderlineStyle(string styleName)
internal static UnderlineStyle GetUnderlineStyle( string styleName )
{ {
switch (styleName)
{
case "single":
return UnderlineStyle.singleLine;
case "double":
return UnderlineStyle.doubleLine;
case "thick":
return UnderlineStyle.thick;
case "dotted":
return UnderlineStyle.dotted;
case "dottedHeavy":
return UnderlineStyle.dottedHeavy;
case "dash":
return UnderlineStyle.dash;
case "dashedHeavy":
return UnderlineStyle.dashedHeavy;
case "dashLong":
return UnderlineStyle.dashLong;
case "dashLongHeavy":
return UnderlineStyle.dashLongHeavy;
case "dotDash":
return UnderlineStyle.dotDash;
case "dashDotHeavy":
return UnderlineStyle.dashDotHeavy;
case "dotDotDash":
return UnderlineStyle.dotDotDash;
case "dashDotDotHeavy":
return UnderlineStyle.dashDotDotHeavy;
case "wave":
return UnderlineStyle.wave;
case "wavyHeavy":
return UnderlineStyle.wavyHeavy;
case "wavyDouble":
return UnderlineStyle.wavyDouble;
case "words":
return UnderlineStyle.words;
default:
return UnderlineStyle.none;
}
switch( styleName )
{
case "single":
return UnderlineStyle.singleLine;
case "double":
return UnderlineStyle.doubleLine;
case "thick":
return UnderlineStyle.thick;
case "dotted":
return UnderlineStyle.dotted;
case "dottedHeavy":
return UnderlineStyle.dottedHeavy;
case "dash":
return UnderlineStyle.dash;
case "dashedHeavy":
return UnderlineStyle.dashedHeavy;
case "dashLong":
return UnderlineStyle.dashLong;
case "dashLongHeavy":
return UnderlineStyle.dashLongHeavy;
case "dotDash":
return UnderlineStyle.dotDash;
case "dashDotHeavy":
return UnderlineStyle.dashDotHeavy;
case "dotDotDash":
return UnderlineStyle.dotDotDash;
case "dashDotDotHeavy":
return UnderlineStyle.dashDotDotHeavy;
case "wave":
return UnderlineStyle.wave;
case "wavyHeavy":
return UnderlineStyle.wavyHeavy;
case "wavyDouble":
return UnderlineStyle.wavyDouble;
case "words":
return UnderlineStyle.words;
default:
return UnderlineStyle.none;
}
} }


internal static bool ContainsEveryChildOf(XElement elementWanted, XElement elementToValidate, MatchFormattingOptions formattingOptions)
internal static bool ContainsEveryChildOf( XElement elementWanted, XElement elementToValidate, MatchFormattingOptions formattingOptions )
{ {
foreach (XElement subElement in elementWanted.Elements())
{
if (!elementToValidate.Elements(subElement.Name).Where(bElement => bElement.GetAttribute(XName.Get("val", DocX.w.NamespaceName)) == subElement.GetAttribute(XName.Get("val", DocX.w.NamespaceName))).Any())
return false;
}
foreach( XElement subElement in elementWanted.Elements() )
{
if( !elementToValidate.Elements( subElement.Name ).Where( bElement => bElement.GetAttribute( XName.Get( "val", DocX.w.NamespaceName ) ) == subElement.GetAttribute( XName.Get( "val", DocX.w.NamespaceName ) ) ).Any() )
return false;
}


if (formattingOptions == MatchFormattingOptions.ExactMatch)
return elementWanted.Elements().Count() == elementToValidate.Elements().Count();
if( formattingOptions == MatchFormattingOptions.ExactMatch )
return elementWanted.Elements().Count() == elementToValidate.Elements().Count();


return true;
return true;
} }


internal static string GetListItemType( Paragraph p, DocX document ) internal static string GetListItemType( Paragraph p, DocX document )
{ {
var paragraphNumberPropertiesDescendants = p.ParagraphNumberProperties.Descendants(); var paragraphNumberPropertiesDescendants = p.ParagraphNumberProperties.Descendants();
var ilvlNode = paragraphNumberPropertiesDescendants.FirstOrDefault( el => el.Name.LocalName == "ilvl" ); var ilvlNode = paragraphNumberPropertiesDescendants.FirstOrDefault( el => el.Name.LocalName == "ilvl" );
var ilvlValue = ( ilvlNode != null) ? ilvlNode.Attribute( DocX.w + "val" ).Value : null;
var ilvlValue = ( ilvlNode != null ) ? ilvlNode.Attribute( DocX.w + "val" ).Value : null;


var numIdNode = paragraphNumberPropertiesDescendants.FirstOrDefault( el => el.Name.LocalName == "numId" ); var numIdNode = paragraphNumberPropertiesDescendants.FirstOrDefault( el => el.Name.LocalName == "numId" );
var numIdValue = ( numIdNode != null ) ? numIdNode.Attribute( DocX.w + "val" ).Value : null; var numIdValue = ( numIdNode != null ) ? numIdNode.Attribute( DocX.w + "val" ).Value : null;


//find num node in numbering
var documentNumberingDescendants = document._numbering.Descendants();
var numNodes = documentNumberingDescendants.Where( n => n.Name.LocalName == "num" );
XElement numNode = numNodes.FirstOrDefault( node => node.Attribute( DocX.w + "numId" ).Value.Equals( numIdValue ) );

if( numNode != null )
var abstractNumNode = HelperFunctions.GetAbstractNum( document, numIdValue );
if( abstractNumNode != null )
{ {
//Get abstractNumId node and its value from numNode
var abstractNumIdNode = numNode.Descendants().First( n => n.Name.LocalName == "abstractNumId" );
var abstractNumNodeValue = abstractNumIdNode.Attribute( DocX.w + "val" ).Value;

var abstractNumNodes = documentNumberingDescendants.Where( n => n.Name.LocalName == "abstractNum" );
XElement abstractNumNode = abstractNumNodes.FirstOrDefault( node => node.Attribute( DocX.w + "abstractNumId" ).Value.Equals( abstractNumNodeValue ) );

//Find lvl node
// Find lvl node.
var lvlNodes = abstractNumNode.Descendants().Where( n => n.Name.LocalName == "lvl" ); var lvlNodes = abstractNumNode.Descendants().Where( n => n.Name.LocalName == "lvl" );
// No lvl, check if a numStyleLink is used.
if( lvlNodes.Count() == 0 )
{
var linkedStyleNumId = HelperFunctions.GetLinkedStyleNumId( document, numIdValue );
if( linkedStyleNumId != -1 )
{
abstractNumNode = HelperFunctions.GetAbstractNum( document, linkedStyleNumId.ToString() );
if( abstractNumNode != null )
{
lvlNodes = abstractNumNode.Descendants().Where( n => n.Name.LocalName == "lvl" );
}
}
}
XElement lvlNode = null; XElement lvlNode = null;
foreach( XElement node in lvlNodes ) foreach( XElement node in lvlNodes )
{ {
else if( ilvlValue == null ) else if( ilvlValue == null )
{ {
var numStyleNode = node.Descendants().FirstOrDefault( n => n.Name.LocalName == "pStyle" ); var numStyleNode = node.Descendants().FirstOrDefault( n => n.Name.LocalName == "pStyle" );
if( ( numStyleNode != null) && numStyleNode.GetAttribute( DocX.w + "val" ).Equals( p.StyleName ) )
if( ( numStyleNode != null ) && numStyleNode.GetAttribute( DocX.w + "val" ).Equals( p.StyleName ) )
{ {
lvlNode = node; lvlNode = node;
break; break;
return null; return null;
} }


internal static XElement GetAbstractNum( DocX document, string numId )
{
if( document == null )
return null;
if( numId == null )
return null;

// Find num node in numbering.
var documentNumberingDescendants = document._numbering.Descendants();
var numNodes = documentNumberingDescendants.Where( n => n.Name.LocalName == "num" );
var numNode = numNodes.FirstOrDefault( node => node.Attribute( DocX.w + "numId" ).Value.Equals( numId ) );
if( numNode == null )
return null;

// Get abstractNumId node and its value from numNode.
var abstractNumIdNode = numNode.Descendants().FirstOrDefault( n => n.Name.LocalName == "abstractNumId" );
if( abstractNumIdNode == null )
return null;
var abstractNumNodeValue = abstractNumIdNode.Attribute( DocX.w + "val" ).Value;
if( string.IsNullOrEmpty( abstractNumNodeValue ) )
return null;

var abstractNumNodes = documentNumberingDescendants.Where( n => n.Name.LocalName == "abstractNum" );
var abstractNumNode = abstractNumNodes.FirstOrDefault( node => node.Attribute( DocX.w + "abstractNumId" ).Value.Equals( abstractNumNodeValue ) );

return abstractNumNode;
}

internal static string GetListItemStartValue( List list, int level ) internal static string GetListItemStartValue( List list, int level )
{ {
var abstractNumElement = list.GetAbstractNum( list.NumId ); var abstractNumElement = list.GetAbstractNum( list.NumId );
//Find lvl node //Find lvl node
var lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" ); var lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" );
var lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) ); var lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) );
// No ilvl, check if a numStyleLink is used.
if( lvlNode == null )
{
var linkedStyleNumId = HelperFunctions.GetLinkedStyleNumId( list.Document, list.NumId.ToString() );
if( linkedStyleNumId != -1 )
{
abstractNumElement = list.GetAbstractNum( linkedStyleNumId );
lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" );
lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) );
}
if( lvlNode == null )
return "1";
}


var startNode = lvlNode.Descendants().First( n => n.Name.LocalName == "start" ); var startNode = lvlNode.Descendants().First( n => n.Name.LocalName == "start" );
return startNode.GetAttribute( DocX.w + "val" ); return startNode.GetAttribute( DocX.w + "val" );
//Find lvl node //Find lvl node
var lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" ); var lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" );
var lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) ); var lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) );
// No ilvl, check if a numStyleLink is used.
if( lvlNode == null )
{
var linkedStyleNumId = HelperFunctions.GetLinkedStyleNumId( list.Document, list.NumId.ToString() );
if( linkedStyleNumId != -1 )
{
abstractNumElement = list.GetAbstractNum( linkedStyleNumId );
lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" );
lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) );
}
if( lvlNode == null )
return "%1.";
}


var textFormatNode = lvlNode.Descendants().First( n => n.Name.LocalName == "lvlText" ); var textFormatNode = lvlNode.Descendants().First( n => n.Name.LocalName == "lvlText" );
return textFormatNode.GetAttribute( DocX.w + "val" ); return textFormatNode.GetAttribute( DocX.w + "val" );
//Find lvl node //Find lvl node
var lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" ); var lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" );
var lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) ); var lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) );
// No ilvl, check if a numStyleLink is used.
if( lvlNode == null )
{
var linkedStyleNumId = HelperFunctions.GetLinkedStyleNumId( list.Document, list.NumId.ToString() );
if( linkedStyleNumId != -1 )
{
abstractNumElement = list.GetAbstractNum( linkedStyleNumId );
lvlNodes = abstractNumElement.Descendants().Where( n => n.Name.LocalName == "lvl" );
lvlNode = lvlNodes.FirstOrDefault( n => n.GetAttribute( DocX.w + "ilvl" ).Equals( level.ToString() ) );
}
if( lvlNode == null )
return null;
}


var pPr = lvlNode.Descendants().FirstOrDefault( n => n.Name.LocalName == "pPr" ); var pPr = lvlNode.Descendants().FirstOrDefault( n => n.Name.LocalName == "pPr" );
if( pPr != null ) if( pPr != null )
} }
return null; return null;
} }

private static XElement GetStyle( DocX fileToConvert, string styleName )
{
if( fileToConvert == null )
throw new ArgumentNullException( "fileToConvert" );
if( string.IsNullOrEmpty( styleName ) )
throw new ArgumentNullException( "styleName" );

var styles = fileToConvert._styles.Element( XName.Get( "styles", DocX.w.NamespaceName ) );
return ( from e in styles.Descendants()
let styleId = e.Attribute( XName.Get( "styleId", DocX.w.NamespaceName ) )
where ( styleId != null && styleId.Value == styleName )
select e ).FirstOrDefault();
}

private static int GetLinkedStyleNumId( DocX document, string numId )
{
Debug.Assert( document != null, "document should not be null" );

var abstractNumElement = HelperFunctions.GetAbstractNum( document, numId );
if( abstractNumElement != null )
{
var numStyleLink = abstractNumElement.Element( XName.Get( "numStyleLink", DocX.w.NamespaceName ) );
if( numStyleLink != null )
{
var val = numStyleLink.Attribute( XName.Get( "val", DocX.w.NamespaceName ) );
if( !string.IsNullOrEmpty( val.Value ) )
{
var linkedStyle = HelperFunctions.GetStyle( document, val.Value );
if( linkedStyle != null )
{
var linkedNumId = linkedStyle.Descendants( XName.Get( "numId", DocX.w.NamespaceName ) ).FirstOrDefault();
if( linkedNumId != null )
{
var linkedNumIdVal = linkedNumId.Attribute( XName.Get( "val", DocX.w.NamespaceName ) );
if( !string.IsNullOrEmpty( linkedNumIdVal.Value ) )
return Int32.Parse( linkedNumIdVal.Value );
}
}
}
}
}

return -1;
}
} }
} }

+ 7
- 5
Xceed.Words.NET/Src/List.cs View File

{ {
if( paragraph.IsListItem ) if( paragraph.IsListItem )
{ {
var numIdNode = paragraph.Xml.Descendants().First( s => s.Name.LocalName == "numId" );
var numIdNode = paragraph.Xml.Descendants().FirstOrDefault( s => s.Name.LocalName == "numId" );
if( numIdNode == null )
return;
var numId = Int32.Parse( numIdNode.Attribute( DocX.w + "val" ).Value ); var numId = Int32.Parse( numIdNode.Attribute( DocX.w + "val" ).Value );


if( CanAddListItem( paragraph ) ) if( CanAddListItem( paragraph ) )
if( paragraph.IsListItem ) if( paragraph.IsListItem )
{ {
//var lvlNode = paragraph.Xml.Descendants().First(s => s.Name.LocalName == "ilvl"); //var lvlNode = paragraph.Xml.Descendants().First(s => s.Name.LocalName == "ilvl");
var numIdNode = paragraph.Xml.Descendants().First( s => s.Name.LocalName == "numId" );
var numIdNode = paragraph.Xml.Descendants().FirstOrDefault( s => s.Name.LocalName == "numId" );
if( numIdNode == null )
return false;
var numId = Int32.Parse( numIdNode.Attribute( DocX.w + "val" ).Value ); var numId = Int32.Parse( numIdNode.Attribute( DocX.w + "val" ).Value );


//Level = Int32.Parse(lvlNode.Attribute(DocX.w + "val").Value); //Level = Int32.Parse(lvlNode.Attribute(DocX.w + "val").Value);
/// <returns>XElement representing the requested abstractNum</returns> /// <returns>XElement representing the requested abstractNum</returns>
internal XElement GetAbstractNum( int numId ) internal XElement GetAbstractNum( int numId )
{ {
var num = Document._numbering.Descendants().First( d => d.Name.LocalName == "num" && d.GetAttribute( DocX.w + "numId" ).Equals( numId.ToString() ) );
var abstractNumId = num.Descendants().First( d => d.Name.LocalName == "abstractNumId" ).GetAttribute( DocX.w + "val" );
return Document._numbering.Descendants().First( d => d.Name.LocalName == "abstractNum" && d.GetAttribute( DocX.w + "abstractNumId" ).Equals( abstractNumId ) );
return HelperFunctions.GetAbstractNum( this.Document, numId.ToString() );
} }


#endregion #endregion

+ 223
- 14
Xceed.Words.NET/Src/Paragraph.cs View File

internal int _startIndex, _endIndex; internal int _startIndex, _endIndex;
internal List<XElement> _styles = new List<XElement>(); internal List<XElement> _styles = new List<XElement>();


internal const float DefaultLineSpacing = 1.1f * 20.0f;
internal const float DefaultSingleLineSpacing = 12f;
private static float DefaultLineSpacing = Paragraph.DefaultSingleLineSpacing;
private static float DefaultLineSpacingAfter = 0f;
private static float DefaultLineSpacingBefore = 0f;

private static float DefaultIndentationFirstLine = 0f;
private static float DefaultIndentationHanging = 0f;
private static float DefaultIndentationBefore = 0f;
private static float DefaultIndentationAfter = 0f;


#endregion #endregion


if( firstLine != null ) if( firstLine != null )
return float.Parse( firstLine.Value ) / 570f; return float.Parse( firstLine.Value ) / 570f;


return 0.0f;
return Paragraph.DefaultIndentationFirstLine;
} }


set set
if( hanging != null ) if( hanging != null )
return float.Parse( hanging.Value ) / 570f; return float.Parse( hanging.Value ) / 570f;


return 0.0f;
return Paragraph.DefaultIndentationHanging;
} }


set set
if( left != null ) if( left != null )
return float.Parse( left.Value ) / 570f; return float.Parse( left.Value ) / 570f;


return 0.0f;
return Paragraph.DefaultIndentationBefore;
} }


set set
if( right != null ) if( right != null )
return float.Parse( right.Value ) / 570f; return float.Parse( right.Value ) / 570f;


return 0.0f;
return Paragraph.DefaultIndentationAfter;
} }


set set


set set
{ {
Spacing( value );
SpacingLine( value );
} }
} }


get get
{ {
XElement pPr = GetOrCreate_pPr(); XElement pPr = GetOrCreate_pPr();

XElement spacing = pPr.Element( XName.Get( "spacing", DocX.w.NamespaceName ) ); XElement spacing = pPr.Element( XName.Get( "spacing", DocX.w.NamespaceName ) );


if( spacing != null ) if( spacing != null )
{ {
XAttribute line = spacing.Attribute( XName.Get( "before", DocX.w.NamespaceName ) );
if( this.IsBeforeAutoSpacing() )
return 0f;

var line = spacing.Attribute( XName.Get( "before", DocX.w.NamespaceName ) );
if( line != null ) if( line != null )
{ {
float f; float f;
} }
} }


return 0.0f;
return Paragraph.DefaultLineSpacingBefore;
} }


set set


if( spacing != null ) if( spacing != null )
{ {
XAttribute line = spacing.Attribute( XName.Get( "after", DocX.w.NamespaceName ) );
if( this.IsAfterAutoSpacing() )
return 0f;

var line = spacing.Attribute( XName.Get( "after", DocX.w.NamespaceName ) );
if( line != null ) if( line != null )
{ {
float f; float f;
} }
} }


return 0.0f;
return Paragraph.DefaultLineSpacingAfter;
} }



set set
{ {
SpacingAfter( value ); SpacingAfter( value );
} }
} }


internal bool IsAfterAutoSpacing()
{
XElement pPr = GetOrCreate_pPr();
XElement spacing = pPr.Element( XName.Get( "spacing", DocX.w.NamespaceName ) );

if( spacing != null )
{
var afterAutoSpacing = spacing.Attribute( XName.Get( "afterAutospacing", DocX.w.NamespaceName ) );
if( ( afterAutoSpacing != null ) && ( afterAutoSpacing.Value == "1" ) )
return true;
}
return false;
}

internal bool IsBeforeAutoSpacing()
{
XElement pPr = GetOrCreate_pPr();
XElement spacing = pPr.Element( XName.Get( "spacing", DocX.w.NamespaceName ) );

if( spacing != null )
{
var beforeAutospacing = spacing.Attribute( XName.Get( "beforeAutospacing", DocX.w.NamespaceName ) );
if( ( beforeAutospacing != null ) && ( beforeAutospacing.Value == "1" ) )
return true;
}
return false;
}

public XElement ParagraphNumberProperties public XElement ParagraphNumberProperties
{ {
get get
} }
} }


_runs = Xml.Elements( XName.Get( "r", DocX.w.NamespaceName ) ).ToList();

HelperFunctions.RenumberIDs( Document ); HelperFunctions.RenumberIDs( Document );
} }


if( format.Shading.HasValue ) if( format.Shading.HasValue )
Shading( format.Shading.Value ); Shading( format.Shading.Value );


// Border
if( format.Border != null )
Border( format.Border );

// Italic // Italic
if( format.Italic.HasValue && format.Italic.Value ) if( format.Italic.HasValue && format.Italic.Value )
Italic(); Italic();
return this; return this;
} }


public Paragraph Border( Border border )
{
var size = "2";
switch( border.Size )
{
case BorderSize.two:
size = "4";
break;
case BorderSize.three:
size = "6";
break;
case BorderSize.four:
size = "8";
break;
case BorderSize.five:
size = "12";
break;
case BorderSize.six:
size = "18";
break;
case BorderSize.seven:
size = "24";
break;
case BorderSize.eight:
size = "36";
break;
case BorderSize.nine:
size = "48";
break;
case BorderSize.one:
default:
size = "2";
break;
}

var style = border.Tcbs.ToString().Remove(0, 5);

this.ApplyTextFormattingProperty( XName.Get( "bdr", DocX.w.NamespaceName ),
string.Empty,
new List<XAttribute>() { new XAttribute( XName.Get( "color", DocX.w.NamespaceName ), border.Color.ToHex() ),
new XAttribute( XName.Get( "space", DocX.w.NamespaceName ), border.Space ),
new XAttribute( XName.Get( "sz", DocX.w.NamespaceName ), size ),
new XAttribute( XName.Get( "val", DocX.w.NamespaceName ), style ) } );

return this;
}

/// <summary> /// <summary>
/// For use with Append() and AppendLine() /// For use with Append() and AppendLine()
/// </summary> /// </summary>
return this; return this;
} }


public Paragraph SpacingLine( double lineSpacing )
{
lineSpacing *= 20;

var pPr = GetOrCreate_pPr();
var spacing = pPr.Element( XName.Get( "spacing", DocX.w.NamespaceName ) );

if( lineSpacing > 0 )
{
if( spacing == null )
{
spacing = new XElement( XName.Get( "spacing", DocX.w.NamespaceName ) );
pPr.Add( spacing );
}

var lineAttribute = spacing.Attribute( XName.Get( "line", DocX.w.NamespaceName ) );

if( lineAttribute == null )
spacing.SetAttributeValue( XName.Get( "line", DocX.w.NamespaceName ), lineSpacing );
else
lineAttribute.SetValue( lineSpacing );
}

if( Math.Abs( lineSpacing ) < 0.1f && spacing != null )
{
var lineAttribute = spacing.Attribute( XName.Get( "line", DocX.w.NamespaceName ) );
lineAttribute.Remove();

if( !spacing.HasAttributes )
spacing.Remove();
}
return this;
}

public Paragraph Kerning( int kerning ) public Paragraph Kerning( int kerning )
{ {
if( !new int?[] { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }.Contains( kerning ) ) if( !new int?[] { 8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72 }.Contains( kerning ) )
} }
while( processed < count ); while( processed < count );


_runs = Xml.Elements( XName.Get( "r", DocX.w.NamespaceName ) ).ToList();

HelperFunctions.RenumberIDs( Document ); HelperFunctions.RenumberIDs( Document );
} }


{ {
var bookmarkStart = this.Xml.Descendants( XName.Get( "bookmarkStart", DocX.w.NamespaceName ) ) var bookmarkStart = this.Xml.Descendants( XName.Get( "bookmarkStart", DocX.w.NamespaceName ) )
.Where( x => x.Attribute( XName.Get( "name", DocX.w.NamespaceName ) ).Value == bookmarkName ) .Where( x => x.Attribute( XName.Get( "name", DocX.w.NamespaceName ) ).Value == bookmarkName )
.SingleOrDefault();
.FirstOrDefault();
if( bookmarkStart == null ) if( bookmarkStart == null )
return; return;




#region Internal Methods #region Internal Methods


internal static void ResetDefaultValues()
{
Paragraph.DefaultLineSpacing = Paragraph.DefaultSingleLineSpacing;
Paragraph.DefaultLineSpacingAfter = 0f;
Paragraph.DefaultLineSpacingBefore = 0f;

Paragraph.DefaultIndentationFirstLine = 0f;
Paragraph.DefaultIndentationHanging = 0f;
Paragraph.DefaultIndentationBefore = 0f;
Paragraph.DefaultIndentationAfter = 0f;
}

internal static void SetDefaultValues( XElement pPr )
{
if( pPr == null )
return;

// Default line spacings.
var spacing = pPr.Element( XName.Get( "spacing", DocX.w.NamespaceName ) );
if( spacing != null )
{
var line = spacing.Attribute( XName.Get( "line", DocX.w.NamespaceName ) );
if( line != null )
{
float f;

if( float.TryParse( line.Value, out f ) )
{
Paragraph.DefaultLineSpacing = f / 20.0f;
}
}
var after = spacing.Attribute( XName.Get( "after", DocX.w.NamespaceName ) );
if( after != null )
{
float f;
if( float.TryParse( after.Value, out f ) )
{
Paragraph.DefaultLineSpacingAfter = f / 20.0f;
}
}
var before = spacing.Attribute( XName.Get( "before", DocX.w.NamespaceName ) );
if( before != null )
{
float f;
if( float.TryParse( before.Value, out f ) )
{
Paragraph.DefaultLineSpacingBefore = f / 20.0f;
}
}
}

// Default indentations.
var ind = pPr.Element( XName.Get( "ind", DocX.w.NamespaceName ) );
if( ind != null )
{
var firstLine = ind.Attribute( XName.Get( "firstLine", DocX.w.NamespaceName ) );
if( firstLine != null )
{
Paragraph.DefaultIndentationFirstLine = float.Parse( firstLine.Value ) / 570f;
}
var hanging = ind.Attribute( XName.Get( "hanging", DocX.w.NamespaceName ) );
if( hanging != null )
{
Paragraph.DefaultIndentationHanging = float.Parse( hanging.Value ) / 570f;
}
var before = ind.Attribute( XName.Get( "left", DocX.w.NamespaceName ) );
if( before != null )
{
Paragraph.DefaultIndentationBefore = float.Parse( before.Value ) / 570f;
}
var after = ind.Attribute( XName.Get( "right", DocX.w.NamespaceName ) );
if( after != null )
{
Paragraph.DefaultIndentationAfter = float.Parse( after.Value ) / 570f;
}
}
}

/// <summary> /// <summary>
/// If the pPr element doesent exist it is created, either way it is returned by this function. /// If the pPr element doesent exist it is created, either way it is returned by this function.
/// </summary> /// </summary>
{ {
using( System.Drawing.Image img = System.Drawing.Image.FromStream( packagePartStream, useEmbeddedColorManagement: false, validateImageData: false ) ) using( System.Drawing.Image img = System.Drawing.Image.FromStream( packagePartStream, useEmbeddedColorManagement: false, validateImageData: false ) )
{ {
cx = img.Width * 9526;
cy = img.Height * 9526;
cx = img.Width * 914400 / Convert.ToInt32( img.HorizontalResolution );
cy = img.Height * 914400 / Convert.ToInt32( img.VerticalResolution );
} }
} }



+ 45
- 6
Xceed.Words.NET/Src/Picture.cs View File

{ {
#region Private Members #region Private Members


private const int EmusInPixel = 9525;

private string _id; private string _id;
private string _name; private string _name;
private string _descr; private string _descr;
private XElement _xfrm; private XElement _xfrm;
private XElement _prstGeom; private XElement _prstGeom;


// Calculating Height & Width in Inches
// https://startbigthinksmall.wordpress.com/2010/01/04/points-inches-and-emus-measuring-units-in-office-open-xml/
// http://lcorneliussen.de/raw/dashboards/ooxml/
private const int InchToEmuFactor = 914400;
private const double EmuToInchFactor = 1d / InchToEmuFactor;

#endregion #endregion


#region Internal Members #region Internal Members


internal const int EmusInPixel = 9525; // Result of : 914400 EMUs per inch / 96 pixel per inch.

internal Dictionary<PackagePart, PackageRelationship> _picture_rels; internal Dictionary<PackagePart, PackageRelationship> _picture_rels;


internal Image _img; internal Image _img;
} }


/// <summary> /// <summary>
/// Get or sets the Width of this Image.
/// Gets or sets the Width of this Image.
/// </summary> /// </summary>
public int Width public int Width
{ {
} }


/// <summary> /// <summary>
/// Get or sets the height of this Image.
/// Gets or sets the Width of this Image (in Inches)
/// </summary>
public double WidthInches
{
get
{
return Width * EmusInPixel * EmuToInchFactor;
}

set
{
Width = ( int )( value * InchToEmuFactor / EmusInPixel );
}
}

/// <summary>
/// Gets or sets the height of this Image.
/// </summary> /// </summary>
public int Height public int Height
{ {
} }
} }


/// <summary>
/// Gets or sets the Height of this Image (in Inches)
/// </summary>
public double HeightInches
{
get
{
return Height * EmusInPixel * EmuToInchFactor;
}

set
{
Height = ( int )( value * InchToEmuFactor / EmusInPixel );
}
}


#endregion #endregion


#region Constructors #region Constructors
{ {
var widthString = style.Value.Substring( style.Value.IndexOf( "width:" ) + 6 ); var widthString = style.Value.Substring( style.Value.IndexOf( "width:" ) + 6 );
var widthValueString = widthString.Substring( 0, widthString.IndexOf( "pt" ) ).Replace( ".", "," ); var widthValueString = widthString.Substring( 0, widthString.IndexOf( "pt" ) ).Replace( ".", "," );
var widthDouble = ( double.Parse( widthValueString ) / 72d ) * 914400;
var widthDouble = double.Parse( widthValueString ) * EmusInPixel;
_cx = System.Convert.ToInt32( widthDouble ); _cx = System.Convert.ToInt32( widthDouble );
} }
} }
{ {
var heightString = style.Value.Substring( style.Value.IndexOf( "height:" ) + 7 ); var heightString = style.Value.Substring( style.Value.IndexOf( "height:" ) + 7 );
var heightValueString = heightString.Substring( 0, heightString.IndexOf( "pt" ) ).Replace( ".", "," ); var heightValueString = heightString.Substring( 0, heightString.IndexOf( "pt" ) ).Replace( ".", "," );
var heightDouble = ( double.Parse( heightValueString ) / 72d ) * 914400;
var heightDouble = double.Parse( heightValueString ) * EmusInPixel;
_cy = System.Convert.ToInt32( heightDouble ); _cy = System.Convert.ToInt32( heightDouble );
} }
} }

+ 16
- 2
Xceed.Words.NET/Src/Table.cs View File



// If val is null, this cell contains no vAlign information. // If val is null, this cell contains no vAlign information.
if( val == null ) if( val == null )
return VerticalAlignment.Center;
return VerticalAlignment.Top;


// If val is not a VerticalAlign enum, something is wrong with this attributes value, so remove it and return VerticalAlignment.Center; // If val is not a VerticalAlign enum, something is wrong with this attributes value, so remove it and return VerticalAlignment.Center;
try try
catch catch
{ {
val.Remove(); val.Remove();
return VerticalAlignment.Center;
return VerticalAlignment.Top;
} }
} }


// If tcW is null, this cell contains no width information. // If tcW is null, this cell contains no width information.
// Get the w attribute of the tcW element. // Get the w attribute of the tcW element.
XAttribute w = tcW?.Attribute( XName.Get( "w", DocX.w.NamespaceName ) ); XAttribute w = tcW?.Attribute( XName.Get( "w", DocX.w.NamespaceName ) );
XAttribute type = tcW?.Attribute( XName.Get( "type", DocX.w.NamespaceName ) );


// If w is null, this cell contains no width information. // If w is null, this cell contains no width information.
if( w == null ) if( w == null )
return double.NaN; return double.NaN;
} }


if( type != null )
{
if( type.Value == "pct" )
{
return ( ( widthInWordUnits / 5000d ) * this._row._table.ColumnWidths.Sum() ) / 20;
}
else if( type.Value == "auto" )
{
var cellIndex = this._row.Cells.FindIndex( x => x.Xml == this.Xml );
if( cellIndex >= 0 )
return this._row._table.ColumnWidths[ cellIndex ] / 20;
}
}
// Using 20 to match DocX._pageSizeMultiplier. // Using 20 to match DocX._pageSizeMultiplier.
return ( widthInWordUnits / 20 ); return ( widthInWordUnits / 20 );
} }

+ 1
- 1
Xceed.Words.NET/Xceed.Words.NET.csproj View File

<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>
<Reference Include="System.Drawing" /> <Reference Include="System.Drawing" />
<Reference Include="System.XML" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq"> <Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework> <RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference> </Reference>

+ 5235
- 0
Xceed.Words.NET/bin/Debug/Xceed.Words.NET.XML
File diff suppressed because it is too large
View File


+ 7
- 0
Xceed.Words.NET/obj/Debug/Xceed.Words.NET.csproj.FileListAbsolute.txt View File

D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Xceed.Words.NET\bin\Debug\Xceed.Words.NET.XML
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Xceed.Words.NET\bin\Debug\Xceed.Words.NET.dll
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Xceed.Words.NET\bin\Debug\Xceed.Words.NET.pdb
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Xceed.Words.NET\obj\Debug\Xceed.Words.NET.csprojAssemblyReference.cache
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Xceed.Words.NET\obj\Debug\Xceed.Words.NET.csproj.CoreCompileInputs.cache
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Xceed.Words.NET\obj\Debug\Xceed.Words.NET.dll
D:\Dev\DocumentLibraries\Release\1.3.0\OpenSource\Generated\Xceed.Words.NET\obj\Debug\Xceed.Words.NET.pdb

+ 0
- 3
Xceed.Words.NET/obj/Release/Xceed.Words.NET.csproj.FileListAbsolute.txt View File

D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Xceed.Words.NET\bin\Release\Xceed.Words.NET.dll
D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Xceed.Words.NET\obj\Release\Xceed.Words.NET.csprojResolveAssemblyReference.cache
D:\Dev\DocumentLibraries\Release\1.2.0\OpenSource\Generated\Xceed.Words.NET\obj\Release\Xceed.Words.NET.dll

Loading…
Cancel
Save