| @@ -0,0 +1,72 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <PropertyGroup> | |||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
| <Platform Condition=" '$(Platform)' == '' ">x86</Platform> | |||
| <ProductVersion>8.0.30703</ProductVersion> | |||
| <SchemaVersion>2.0</SchemaVersion> | |||
| <ProjectGuid>{5C3408FE-0F80-4093-9C2B-1C46B4358F72}</ProjectGuid> | |||
| <OutputType>Exe</OutputType> | |||
| <AppDesignerFolder>Properties</AppDesignerFolder> | |||
| <RootNamespace>ConsoleApplication1</RootNamespace> | |||
| <AssemblyName>ConsoleApplication1</AssemblyName> | |||
| <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |||
| <TargetFrameworkProfile>Client</TargetFrameworkProfile> | |||
| <FileAlignment>512</FileAlignment> | |||
| <SccProjectName>SAK</SccProjectName> | |||
| <SccLocalPath>SAK</SccLocalPath> | |||
| <SccAuxPath>SAK</SccAuxPath> | |||
| <SccProvider>SAK</SccProvider> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | |||
| <PlatformTarget>x86</PlatformTarget> | |||
| <DebugSymbols>true</DebugSymbols> | |||
| <DebugType>full</DebugType> | |||
| <Optimize>false</Optimize> | |||
| <OutputPath>bin\Debug\</OutputPath> | |||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | |||
| <PlatformTarget>x86</PlatformTarget> | |||
| <DebugType>pdbonly</DebugType> | |||
| <Optimize>true</Optimize> | |||
| <OutputPath>bin\Release\</OutputPath> | |||
| <DefineConstants>TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Reference Include="System" /> | |||
| <Reference Include="System.Core" /> | |||
| <Reference Include="System.Xml.Linq" /> | |||
| <Reference Include="System.Data.DataSetExtensions" /> | |||
| <Reference Include="Microsoft.CSharp" /> | |||
| <Reference Include="System.Data" /> | |||
| <Reference Include="System.Xml" /> | |||
| <Reference Include="WindowsBase" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Compile Include="Program.cs" /> | |||
| <Compile Include="Properties\AssemblyInfo.cs" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="..\DocX\DocX.csproj"> | |||
| <Project>{E863D072-AA8B-4108-B5F1-785241B37F67}</Project> | |||
| <Name>DocX</Name> | |||
| </ProjectReference> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <None Include="data\load-error.docx" /> | |||
| <None Include="data\Test-01.docx" /> | |||
| </ItemGroup> | |||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||
| <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
| Other similar extension points exist, see Microsoft.Common.targets. | |||
| <Target Name="BeforeBuild"> | |||
| </Target> | |||
| <Target Name="AfterBuild"> | |||
| </Target> | |||
| --> | |||
| </Project> | |||
| @@ -0,0 +1,10 @@ | |||
| "" | |||
| { | |||
| "FILE_VERSION" = "9237" | |||
| "ENLISTMENT_CHOICE" = "NEVER" | |||
| "PROJECT_FILE_RELATIVE_PATH" = "" | |||
| "NUMBER_OF_EXCLUDED_FILES" = "0" | |||
| "ORIGINAL_PROJECT_FILE_PATH" = "" | |||
| "NUMBER_OF_NESTED_PROJECTS" = "0" | |||
| "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" | |||
| } | |||
| @@ -0,0 +1,51 @@ | |||
| using System; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using System.Text; | |||
| using Novacode; | |||
| using System.IO.Packaging; | |||
| using System.Diagnostics; | |||
| namespace ConsoleApplication1 | |||
| { | |||
| class Program | |||
| { | |||
| static void Main(string[] args) | |||
| { | |||
| //// Testing constants | |||
| //const string package_part_document = "/word/document.xml"; | |||
| //const string package_part_header_first = "/word/header3.xml"; | |||
| //const string package_part_header_odd = "/word/header2.xml"; | |||
| //const string package_part_header_even = "/word/header1.xml"; | |||
| //const string package_part_footer_first = "/word/footer3.xml"; | |||
| //const string package_part_footer_odd = "/word/footer2.xml"; | |||
| //const string package_part_footer_even = "/word/footer1.xml"; | |||
| //// Load Test-01.docx | |||
| //using (DocX document = DocX.Load("../../data/Test-01.docx")) | |||
| //{ | |||
| // // Get the headers from the document. | |||
| // Headers headers = document.Headers; Debug.Assert(headers != null); | |||
| // Header header_first = headers.first; Debug.Assert(header_first != null); | |||
| // Header header_odd = headers.odd; Debug.Assert(header_odd != null); | |||
| // Header header_even = headers.even; Debug.Assert(header_even != null); | |||
| // // Get the footers from the document. | |||
| // Footers footers = document.Footers; Debug.Assert(footers != null); | |||
| // Footer footer_first = footers.first; Debug.Assert(footer_first != null); | |||
| // Footer footer_odd = footers.odd; Debug.Assert(footer_odd != null); | |||
| // Footer footer_even = footers.even; Debug.Assert(footer_even != null); | |||
| // // Its important that each Paragraph knows the PackagePart it belongs to. | |||
| // document.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_document)); | |||
| // header_first.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_header_first)); | |||
| // header_odd.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_header_odd)); | |||
| // header_even.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_header_even)); | |||
| // footer_first.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_footer_first)); | |||
| // footer_odd.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_footer_odd)); | |||
| // footer_even.Paragraphs.ForEach(p => Debug.Assert(p.PackagePart.Uri.ToString() == package_part_footer_even)); | |||
| //} | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| using System.Reflection; | |||
| using System.Runtime.CompilerServices; | |||
| using System.Runtime.InteropServices; | |||
| // General Information about an assembly is controlled through the following | |||
| // set of attributes. Change these attribute values to modify the information | |||
| // associated with an assembly. | |||
| [assembly: AssemblyTitle("ConsoleApplication1")] | |||
| [assembly: AssemblyDescription("")] | |||
| [assembly: AssemblyConfiguration("")] | |||
| [assembly: AssemblyCompany("")] | |||
| [assembly: AssemblyProduct("ConsoleApplication1")] | |||
| [assembly: AssemblyCopyright("Copyright © 2010")] | |||
| [assembly: AssemblyTrademark("")] | |||
| [assembly: AssemblyCulture("")] | |||
| // Setting ComVisible to false makes the types in this assembly not visible | |||
| // to COM components. If you need to access a type in this assembly from | |||
| // COM, set the ComVisible attribute to true on that type. | |||
| [assembly: ComVisible(false)] | |||
| // The following GUID is for the ID of the typelib if this project is exposed to COM | |||
| [assembly: Guid("4fbe30d8-8d81-4dc4-adc2-58297c152631")] | |||
| // Version information for an assembly consists of the following four values: | |||
| // | |||
| // Major Version | |||
| // Minor Version | |||
| // Build Number | |||
| // Revision | |||
| // | |||
| // You can specify all the values or you can default the Build and Revision Numbers | |||
| // by using the '*' as shown below: | |||
| // [assembly: AssemblyVersion("1.0.*")] | |||
| [assembly: AssemblyVersion("1.0.0.0")] | |||
| [assembly: AssemblyFileVersion("1.0.0.0")] | |||
| @@ -1,15 +1,24 @@ | |||
| | |||
| Microsoft Visual Studio Solution File, Format Version 10.00 | |||
| # Visual Studio 2008 | |||
| Microsoft Visual Studio Solution File, Format Version 11.00 | |||
| # Visual Studio 2010 | |||
| Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DF41F5CE-8BCB-40CC-835F-54A3DB7D802F}" | |||
| ProjectSection(SolutionItems) = preProject | |||
| DocX.vsmdi = DocX.vsmdi | |||
| Local.testsettings = Local.testsettings | |||
| TraceAndTestImpact.testsettings = TraceAndTestImpact.testsettings | |||
| EndProjectSection | |||
| EndProject | |||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocX", "DocX\DocX.csproj", "{E863D072-AA8B-4108-B5F1-785241B37F67}" | |||
| EndProject | |||
| Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{DF41F5CE-8BCB-40CC-835F-54A3DB7D802F}" | |||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{5C3408FE-0F80-4093-9C2B-1C46B4358F72}" | |||
| EndProject | |||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests.csproj", "{3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}" | |||
| EndProject | |||
| Global | |||
| GlobalSection(TeamFoundationVersionControl) = preSolution | |||
| SccNumberOfProjects = 3 | |||
| SccNumberOfProjects = 4 | |||
| SccEnterpriseProvider = {4CA58AB2-18FA-4F8D-95D4-32DDF27D184C} | |||
| SccTeamFoundationServer = https://tfs08.codeplex.com/ | |||
| SccTeamFoundationServer = https://tfs.codeplex.com/tfs/tfs08 | |||
| SccLocalPath0 = . | |||
| SccProjectUniqueName1 = DocX\\DocX.csproj | |||
| SccProjectName1 = DocX | |||
| @@ -17,16 +26,52 @@ Global | |||
| SccProjectUniqueName2 = ConsoleApplication1\\ConsoleApplication1.csproj | |||
| SccProjectName2 = ConsoleApplication1 | |||
| SccLocalPath2 = ConsoleApplication1 | |||
| SccProjectUniqueName3 = UnitTests\\UnitTests.csproj | |||
| SccProjectName3 = UnitTests | |||
| SccLocalPath3 = UnitTests | |||
| EndGlobalSection | |||
| GlobalSection(TestCaseManagementSettings) = postSolution | |||
| CategoryFile = DocX.vsmdi | |||
| EndGlobalSection | |||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
| Debug|Any CPU = Debug|Any CPU | |||
| Debug|Mixed Platforms = Debug|Mixed Platforms | |||
| Debug|x86 = Debug|x86 | |||
| Release|Any CPU = Release|Any CPU | |||
| Release|Mixed Platforms = Release|Mixed Platforms | |||
| Release|x86 = Release|x86 | |||
| EndGlobalSection | |||
| GlobalSection(ProjectConfigurationPlatforms) = postSolution | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Release|Mixed Platforms.Build.0 = Release|Any CPU | |||
| {E863D072-AA8B-4108-B5F1-785241B37F67}.Release|x86.ActiveCfg = Release|Any CPU | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Debug|Any CPU.ActiveCfg = Debug|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Debug|Mixed Platforms.Build.0 = Debug|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Debug|x86.ActiveCfg = Debug|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Debug|x86.Build.0 = Debug|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Release|Any CPU.ActiveCfg = Release|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Release|Mixed Platforms.ActiveCfg = Release|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Release|Mixed Platforms.Build.0 = Release|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Release|x86.ActiveCfg = Release|x86 | |||
| {5C3408FE-0F80-4093-9C2B-1C46B4358F72}.Release|x86.Build.0 = Release|x86 | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Release|Mixed Platforms.Build.0 = Release|Any CPU | |||
| {3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}.Release|x86.ActiveCfg = Release|Any CPU | |||
| EndGlobalSection | |||
| GlobalSection(SolutionProperties) = preSolution | |||
| HideSolutionNode = FALSE | |||
| @@ -0,0 +1,6 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <TestLists xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> | |||
| <TestList name="Lists of Tests" id="8c43106b-9dc1-4907-a29f-aa66a61bf5b6"> | |||
| <RunConfiguration id="95fe5b2d-3af6-4f81-a23a-86c45b1f95a1" name="Local" storage="local.testsettings" type="Microsoft.VisualStudio.TestTools.Common.TestRunConfiguration, Microsoft.VisualStudio.QualityTools.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> | |||
| </TestList> | |||
| </TestLists> | |||
| @@ -191,7 +191,7 @@ namespace Novacode | |||
| public virtual void ReplaceText(string oldValue, string newValue, bool trackChanges) | |||
| { | |||
| ReplaceText(oldValue, newValue, trackChanges, false, false, RegexOptions.None); | |||
| ReplaceText(oldValue, newValue, false, false, trackChanges, RegexOptions.None); | |||
| } | |||
| public virtual void ReplaceText(string oldValue, string newValue, bool includeHeaders, bool includeFooters, bool trackChanges) | |||
| @@ -230,7 +230,6 @@ namespace Novacode | |||
| ); | |||
| } | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return p; | |||
| } | |||
| @@ -324,7 +323,6 @@ namespace Novacode | |||
| else | |||
| Xml.Add(newParagraph); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return newParagraph; | |||
| } | |||
| @@ -350,7 +348,6 @@ namespace Novacode | |||
| Xml.Add(newParagraph); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return Paragraphs.Last(); | |||
| } | |||
| @@ -284,11 +284,6 @@ namespace Novacode | |||
| // Get the word\settings.xml part | |||
| internal PackagePart settingsPart; | |||
| #region Private instance variables defined foreach DocX object | |||
| // The collection of Paragraphs in this document. | |||
| internal List<Paragraph> paragraphs = new List<Paragraph>(); | |||
| #endregion | |||
| #region Internal variables defined foreach DocX object | |||
| // Object representation of the .docx | |||
| internal Package package; | |||
| @@ -455,7 +450,7 @@ namespace Novacode | |||
| get | |||
| { | |||
| string text = string.Empty; | |||
| foreach (Paragraph p in paragraphs) | |||
| foreach (Paragraph p in Paragraphs) | |||
| { | |||
| text += p.Text + "\n"; | |||
| } | |||
| @@ -709,8 +704,6 @@ namespace Novacode | |||
| foreach (var r in externalHeaderAndFooterReferences.ToList()) | |||
| r.Remove(); | |||
| #endregion | |||
| HelperFunctions.RebuildParagraphs(this); | |||
| } | |||
| @@ -755,8 +748,6 @@ namespace Novacode | |||
| XElement newTable = HelperFunctions.CreateTable(rowCount, coloumnCount); | |||
| mainDoc.Descendants(XName.Get("body", DocX.w.NamespaceName)).First().Add(newTable); | |||
| HelperFunctions.RebuildParagraphs(this); | |||
| return new Table(this, newTable); | |||
| } | |||
| @@ -814,8 +805,6 @@ namespace Novacode | |||
| Table newTable = new Table(this, newXElement); | |||
| newTable.Design = t.Design; | |||
| HelperFunctions.RebuildParagraphs(this); | |||
| return newTable; | |||
| } | |||
| @@ -919,7 +908,6 @@ namespace Novacode | |||
| ); | |||
| } | |||
| HelperFunctions.RebuildParagraphs(this); | |||
| return new Table(this, newTable); | |||
| } | |||
| @@ -1094,8 +1082,6 @@ namespace Novacode | |||
| using (TextReader tr = new StreamReader(document.mainPart.GetStream(FileMode.Open, FileAccess.Read))) | |||
| document.mainDoc = XDocument.Load(tr, LoadOptions.PreserveWhitespace); | |||
| HelperFunctions.RebuildParagraphs(document); | |||
| #endregion | |||
| Headers headers = new Headers(); | |||
| @@ -2222,6 +2208,15 @@ namespace Novacode | |||
| return p; | |||
| } | |||
| public override List<Paragraph> Paragraphs | |||
| { | |||
| get | |||
| { | |||
| List<Paragraph> l = base.Paragraphs; | |||
| l.ForEach(x => x.PackagePart = mainPart); | |||
| return l; | |||
| } | |||
| } | |||
| #region IDisposable Members | |||
| @@ -1,5 +1,5 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <PropertyGroup> | |||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
| @@ -20,6 +20,25 @@ | |||
| </StartupObject> | |||
| <SignAssembly>false</SignAssembly> | |||
| <AssemblyOriginatorKeyFile>StrongNameKey.pfx</AssemblyOriginatorKeyFile> | |||
| <FileUpgradeFlags> | |||
| </FileUpgradeFlags> | |||
| <OldToolsVersion>3.5</OldToolsVersion> | |||
| <UpgradeBackupLocation /> | |||
| <PublishUrl>publish\</PublishUrl> | |||
| <Install>true</Install> | |||
| <InstallFrom>Disk</InstallFrom> | |||
| <UpdateEnabled>false</UpdateEnabled> | |||
| <UpdateMode>Foreground</UpdateMode> | |||
| <UpdateInterval>7</UpdateInterval> | |||
| <UpdateIntervalUnits>Days</UpdateIntervalUnits> | |||
| <UpdatePeriodically>false</UpdatePeriodically> | |||
| <UpdateRequired>false</UpdateRequired> | |||
| <MapFileExtensions>true</MapFileExtensions> | |||
| <ApplicationRevision>0</ApplicationRevision> | |||
| <ApplicationVersion>1.0.0.%2a</ApplicationVersion> | |||
| <IsWebBootstrapper>false</IsWebBootstrapper> | |||
| <UseApplicationTrust>false</UseApplicationTrust> | |||
| <BootstrapperEnabled>true</BootstrapperEnabled> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
| <DebugSymbols>true</DebugSymbols> | |||
| @@ -30,6 +49,7 @@ | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| <DocumentationFile>bin\Debug\DocX.xml</DocumentationFile> | |||
| <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
| <DebugType>pdbonly</DebugType> | |||
| @@ -38,6 +58,7 @@ | |||
| <DefineConstants>TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Reference Include="System" /> | |||
| @@ -94,6 +115,23 @@ | |||
| <EmbeddedResource Include="Resources\default_styles.xml.gz" /> | |||
| <EmbeddedResource Include="Resources\styles.xml.gz" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <BootstrapperPackage Include="Microsoft.Net.Client.3.5"> | |||
| <Visible>False</Visible> | |||
| <ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName> | |||
| <Install>false</Install> | |||
| </BootstrapperPackage> | |||
| <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1"> | |||
| <Visible>False</Visible> | |||
| <ProductName>.NET Framework 3.5 SP1</ProductName> | |||
| <Install>true</Install> | |||
| </BootstrapperPackage> | |||
| <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1"> | |||
| <Visible>False</Visible> | |||
| <ProductName>Windows Installer 3.1</ProductName> | |||
| <Install>true</Install> | |||
| </BootstrapperPackage> | |||
| </ItemGroup> | |||
| <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | |||
| <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
| Other similar extension points exist, see Microsoft.Common.targets. | |||
| @@ -69,5 +69,15 @@ namespace Novacode | |||
| return p; | |||
| } | |||
| public override List<Paragraph> Paragraphs | |||
| { | |||
| get | |||
| { | |||
| List<Paragraph> l = base.Paragraphs; | |||
| l.ForEach(x => x.PackagePart = mainPart); | |||
| return l; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -69,5 +69,15 @@ namespace Novacode | |||
| return p; | |||
| } | |||
| public override List<Paragraph> Paragraphs | |||
| { | |||
| get | |||
| { | |||
| List<Paragraph> l = base.Paragraphs; | |||
| l.ForEach(x => x.PackagePart = mainPart); | |||
| return l; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -347,33 +347,6 @@ namespace Novacode | |||
| return new XElement[] { before, after }; | |||
| } | |||
| static internal void RebuildParagraphs(DocX document) | |||
| { | |||
| document.paragraphLookup.Clear(); | |||
| document.paragraphs.Clear(); | |||
| // Get the runs in this paragraph | |||
| IEnumerable<XElement> paras = document.mainDoc.Descendants(XName.Get("p", "http://schemas.openxmlformats.org/wordprocessingml/2006/main")); | |||
| int startIndex = 0; | |||
| // Loop through each run in this paragraph | |||
| foreach (XElement par in paras) | |||
| { | |||
| Paragraph xp = new Paragraph(document, par, startIndex); | |||
| // Add to paragraph list | |||
| document.paragraphs.Add(xp); | |||
| // Only add runs which contain text | |||
| if (Paragraph.GetElementTextLength(par) > 0) | |||
| { | |||
| document.paragraphLookup.Add(xp.endIndex, xp); | |||
| startIndex = xp.endIndex; | |||
| } | |||
| } | |||
| } | |||
| /// <!-- | |||
| /// Bug found and fixed by trnilse. To see the change, | |||
| /// please compare this release to the previous release using TFS compare. | |||
| @@ -30,9 +30,6 @@ namespace Novacode | |||
| internal int startIndex, endIndex; | |||
| // A collection of Images in this Paragraph | |||
| private List<Picture> pictures; | |||
| /// <summary> | |||
| /// Returns a list of all Pictures in a Paragraph. | |||
| /// </summary> | |||
| @@ -134,21 +131,6 @@ namespace Novacode | |||
| this.endIndex = startIndex + GetElementTextLength(xml); | |||
| BuildRunLookup(xml); | |||
| // Get all of the images in this document | |||
| pictures = | |||
| ( | |||
| from i in xml.Descendants(XName.Get("drawing", DocX.w.NamespaceName)) | |||
| let id = | |||
| ( | |||
| from e in Xml.Descendants() | |||
| where e.Name.LocalName.Equals("blip") | |||
| select e.Attribute(XName.Get("embed", "http://schemas.openxmlformats.org/officeDocument/2006/relationships")).Value | |||
| ).Single() | |||
| let img = new Image(Document, mainPart.GetRelationship(id)) | |||
| select new Picture(Document, i, img) | |||
| ).ToList(); | |||
| RebuildDocProperties(); | |||
| #region It's possible that a Paragraph may have pStyle references | |||
| @@ -184,17 +166,6 @@ namespace Novacode | |||
| } | |||
| } | |||
| #endregion | |||
| #region Pictures | |||
| // Check if this Paragraph contains any Pictures | |||
| List<string> pictureElementIDs = | |||
| ( | |||
| from d in xml.Descendants() | |||
| let embed = d.Attribute(XName.Get("embed", "http://schemas.openxmlformats.org/officeDocument/2006/relationships")) | |||
| where embed != null | |||
| select embed.Value | |||
| ).ToList(); | |||
| #endregion | |||
| } | |||
| /// <summary> | |||
| @@ -1099,8 +1070,6 @@ namespace Novacode | |||
| runLookup = null; | |||
| } | |||
| } | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| } | |||
| internal void BuildRunLookup(XElement p) | |||
| @@ -1216,7 +1185,6 @@ namespace Novacode | |||
| { | |||
| Picture p = CreatePicture(Document, imageID, name, description); | |||
| Xml.Add(p.Xml); | |||
| pictures.Add(p); | |||
| return p; | |||
| } | |||
| @@ -1679,7 +1647,6 @@ namespace Novacode | |||
| runLookup.Clear(); | |||
| BuildRunLookup(Xml); | |||
| HelperFunctions.RenumberIDs(Document); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| } | |||
| /// <summary> | |||
| @@ -95,7 +95,6 @@ namespace Novacode | |||
| XElement newlyInserted = Xml.ElementsBeforeSelf().First(); | |||
| p.Xml = newlyInserted; | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return p; | |||
| } | |||
| @@ -106,8 +105,6 @@ namespace Novacode | |||
| XElement newlyInserted = Xml.ElementsAfterSelf().First(); | |||
| p.Xml = newlyInserted; | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return p; | |||
| } | |||
| @@ -145,7 +142,6 @@ namespace Novacode | |||
| XElement newlyInserted = Xml.ElementsBeforeSelf().First(); | |||
| Paragraph p = new Paragraph(Document, newlyInserted, -1); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return p; | |||
| } | |||
| @@ -164,7 +160,6 @@ namespace Novacode | |||
| XElement newlyInserted = Xml.ElementsAfterSelf().First(); | |||
| Paragraph p = new Paragraph(Document, newlyInserted, -1); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return p; | |||
| } | |||
| @@ -175,8 +170,6 @@ namespace Novacode | |||
| Xml.AddAfterSelf(newTable); | |||
| XElement newlyInserted = Xml.ElementsAfterSelf().First(); | |||
| ////DocX.RebuildTables(Document); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return new Table(Document, newlyInserted); | |||
| } | |||
| @@ -186,8 +179,6 @@ namespace Novacode | |||
| XElement newlyInserted = Xml.ElementsAfterSelf().First(); | |||
| t.Xml = newlyInserted; | |||
| //DocX.RebuildTables(Document); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return t; | |||
| } | |||
| @@ -198,8 +189,6 @@ namespace Novacode | |||
| Xml.AddBeforeSelf(newTable); | |||
| XElement newlyInserted = Xml.ElementsBeforeSelf().First(); | |||
| //DocX.RebuildTables(Document); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return new Table(Document, newlyInserted); | |||
| } | |||
| @@ -209,8 +198,6 @@ namespace Novacode | |||
| XElement newlyInserted = Xml.ElementsBeforeSelf().First(); | |||
| t.Xml = newlyInserted; | |||
| //DocX.RebuildTables(Document); | |||
| HelperFunctions.RebuildParagraphs(Document); | |||
| return t; | |||
| } | |||
| @@ -0,0 +1,10 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <TestSettings name="Local" id="95fe5b2d-3af6-4f81-a23a-86c45b1f95a1" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> | |||
| <Description>These are default test settings for a local test run.</Description> | |||
| <Deployment enabled="false" /> | |||
| <Execution> | |||
| <TestTypeSpecific /> | |||
| <AgentRule name="Execution Agents"> | |||
| </AgentRule> | |||
| </Execution> | |||
| </TestSettings> | |||
| @@ -0,0 +1,9 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <TestSettings name="Trace and Test Impact" enableDefaultDataCollectors="true" id="ddea5473-b23c-4e19-9fc6-bd924ed99e12" xmlns="http://microsoft.com/schemas/VisualStudio/TeamTest/2010"> | |||
| <Description>These are test settings for Trace and Test Impact.</Description> | |||
| <Execution> | |||
| <TestTypeSpecific /> | |||
| <AgentRule name="Execution Agents"> | |||
| </AgentRule> | |||
| </Execution> | |||
| </TestSettings> | |||
| @@ -0,0 +1,35 @@ | |||
| using System.Reflection; | |||
| using System.Runtime.CompilerServices; | |||
| using System.Runtime.InteropServices; | |||
| // General Information about an assembly is controlled through the following | |||
| // set of attributes. Change these attribute values to modify the information | |||
| // associated with an assembly. | |||
| [assembly: AssemblyTitle("UnitTests")] | |||
| [assembly: AssemblyDescription("")] | |||
| [assembly: AssemblyConfiguration("")] | |||
| [assembly: AssemblyCompany("")] | |||
| [assembly: AssemblyProduct("UnitTests")] | |||
| [assembly: AssemblyCopyright("Copyright © 2010")] | |||
| [assembly: AssemblyTrademark("")] | |||
| [assembly: AssemblyCulture("")] | |||
| // Setting ComVisible to false makes the types in this assembly not visible | |||
| // to COM components. If you need to access a type in this assembly from | |||
| // COM, set the ComVisible attribute to true on that type. | |||
| [assembly: ComVisible(false)] | |||
| // The following GUID is for the ID of the typelib if this project is exposed to COM | |||
| [assembly: Guid("63e90d26-1aa6-42b1-904d-fd112b6e8d44")] | |||
| // Version information for an assembly consists of the following four values: | |||
| // | |||
| // Major Version | |||
| // Minor Version | |||
| // Build Number | |||
| // Revision | |||
| // | |||
| // You can specify all the values or you can default the Build and Revision Numbers | |||
| // by using the '*' as shown below: | |||
| [assembly: AssemblyVersion("1.0.0.0")] | |||
| [assembly: AssemblyFileVersion("1.0.0.0")] | |||
| @@ -0,0 +1,75 @@ | |||
| using System; | |||
| using System.Text; | |||
| using System.Collections.Generic; | |||
| using System.Linq; | |||
| using Microsoft.VisualStudio.TestTools.UnitTesting; | |||
| using Novacode; | |||
| using System.Diagnostics; | |||
| namespace UnitTests | |||
| { | |||
| /// <summary> | |||
| /// Summary description for UnitTest1 | |||
| /// </summary> | |||
| [TestClass] | |||
| public class UnitTest1 | |||
| { | |||
| public UnitTest1() | |||
| { | |||
| TestMethod1(); | |||
| } | |||
| private TestContext testContextInstance; | |||
| /// <summary> | |||
| ///Gets or sets the test context which provides | |||
| ///information about and functionality for the current test run. | |||
| ///</summary> | |||
| public TestContext TestContext | |||
| { | |||
| get | |||
| { | |||
| return testContextInstance; | |||
| } | |||
| set | |||
| { | |||
| testContextInstance = value; | |||
| } | |||
| } | |||
| #region Additional test attributes | |||
| // | |||
| // You can use the following additional attributes as you write your tests: | |||
| // | |||
| // Use ClassInitialize to run code before running the first test in the class | |||
| // [ClassInitialize()] | |||
| // public static void MyClassInitialize(TestContext testContext) { } | |||
| // | |||
| // Use ClassCleanup to run code after all tests in a class have run | |||
| // [ClassCleanup()] | |||
| // public static void MyClassCleanup() { } | |||
| // | |||
| // Use TestInitialize to run code before running each test | |||
| // [TestInitialize()] | |||
| // public void MyTestInitialize() { } | |||
| // | |||
| // Use TestCleanup to run code after each test has run | |||
| // [TestCleanup()] | |||
| // public void MyTestCleanup() { } | |||
| // | |||
| #endregion | |||
| [TestMethod] | |||
| public void TestMethod1() | |||
| { | |||
| using (DocX document = DocX.Load(@"C:\Users\cathal\Documents\Visual Studio 2010\Projects\DocX\UnitTests\documents\simple.docx")) | |||
| { | |||
| Debug.Assert(document.Paragraphs.Count() == 1); | |||
| Paragraph p = document.Paragraphs[0]; | |||
| Debug.Assert(p.Text == "Paragraph 1"); | |||
| Debug.Assert(p.Pictures.Count == 1); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -0,0 +1,69 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |||
| <PropertyGroup> | |||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
| <ProductVersion> | |||
| </ProductVersion> | |||
| <SchemaVersion>2.0</SchemaVersion> | |||
| <ProjectGuid>{3EA73F1C-9E0B-4ED5-B04B-6C043D14D1AA}</ProjectGuid> | |||
| <OutputType>Library</OutputType> | |||
| <AppDesignerFolder>Properties</AppDesignerFolder> | |||
| <RootNamespace>UnitTests</RootNamespace> | |||
| <AssemblyName>UnitTests</AssemblyName> | |||
| <TargetFrameworkVersion>v4.0</TargetFrameworkVersion> | |||
| <FileAlignment>512</FileAlignment> | |||
| <ProjectTypeGuids>{3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids> | |||
| <SccProjectName>SAK</SccProjectName> | |||
| <SccLocalPath>SAK</SccLocalPath> | |||
| <SccAuxPath>SAK</SccAuxPath> | |||
| <SccProvider>SAK</SccProvider> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
| <DebugSymbols>true</DebugSymbols> | |||
| <DebugType>full</DebugType> | |||
| <Optimize>false</Optimize> | |||
| <OutputPath>bin\Debug\</OutputPath> | |||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
| <DebugType>pdbonly</DebugType> | |||
| <Optimize>true</Optimize> | |||
| <OutputPath>bin\Release\</OutputPath> | |||
| <DefineConstants>TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Reference Include="Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" /> | |||
| <Reference Include="System" /> | |||
| <Reference Include="System.Core"> | |||
| <RequiredTargetFramework>3.5</RequiredTargetFramework> | |||
| </Reference> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <CodeAnalysisDependentAssemblyPaths Condition=" '$(VS100COMNTOOLS)' != '' " Include="$(VS100COMNTOOLS)..\IDE\PrivateAssemblies"> | |||
| <Visible>False</Visible> | |||
| </CodeAnalysisDependentAssemblyPaths> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <Compile Include="Properties\AssemblyInfo.cs" /> | |||
| <Compile Include="UnitTest1.cs" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="..\DocX\DocX.csproj"> | |||
| <Project>{E863D072-AA8B-4108-B5F1-785241B37F67}</Project> | |||
| <Name>DocX</Name> | |||
| </ProjectReference> | |||
| </ItemGroup> | |||
| <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" /> | |||
| <!-- To modify your build process, add your task inside one of the targets below and uncomment it. | |||
| Other similar extension points exist, see Microsoft.Common.targets. | |||
| <Target Name="BeforeBuild"> | |||
| </Target> | |||
| <Target Name="AfterBuild"> | |||
| </Target> | |||
| --> | |||
| </Project> | |||
| @@ -0,0 +1,10 @@ | |||
| "" | |||
| { | |||
| "FILE_VERSION" = "9237" | |||
| "ENLISTMENT_CHOICE" = "NEVER" | |||
| "PROJECT_FILE_RELATIVE_PATH" = "" | |||
| "NUMBER_OF_EXCLUDED_FILES" = "0" | |||
| "ORIGINAL_PROJECT_FILE_PATH" = "" | |||
| "NUMBER_OF_NESTED_PROJECTS" = "0" | |||
| "SOURCE_CONTROL_SETTINGS_PROVIDER" = "PROVIDER" | |||
| } | |||