| @@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\Unit | |||
| EndProject | |||
| Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Examples", "Examples\Examples.csproj", "{F3022BB7-0E40-4C80-A495-37FEAF3671AB}" | |||
| EndProject | |||
| Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "Documentation", "Documentation\Documentation.shfbproj", "{1EB1EE8F-9978-425B-A742-533DCCEB4811}" | |||
| EndProject | |||
| Global | |||
| GlobalSection(TeamFoundationVersionControl) = preSolution | |||
| SccNumberOfProjects = 5 | |||
| @@ -29,9 +31,9 @@ Global | |||
| SccProjectUniqueName3 = Examples\\Examples.csproj | |||
| SccProjectName3 = Examples | |||
| SccLocalPath3 = Examples | |||
| SccProjectUniqueName4 = ConsoleApplication4\\ConsoleApplication4.csproj | |||
| SccProjectName4 = ConsoleApplication4 | |||
| SccLocalPath4 = ConsoleApplication4 | |||
| SccProjectUniqueName4 = Documentation\\Documentation.shfbproj | |||
| SccProjectName4 = Documentation | |||
| SccLocalPath4 = Documentation | |||
| EndGlobalSection | |||
| GlobalSection(TestCaseManagementSettings) = postSolution | |||
| CategoryFile = DocX.vsmdi | |||
| @@ -75,6 +77,16 @@ Global | |||
| {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Release|Mixed Platforms.Build.0 = Release|x86 | |||
| {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Release|x86.ActiveCfg = Release|x86 | |||
| {F3022BB7-0E40-4C80-A495-37FEAF3671AB}.Release|x86.Build.0 = Release|x86 | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Debug|x86.ActiveCfg = Debug|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Any CPU.Build.0 = Release|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|Mixed Platforms.Build.0 = Release|Any CPU | |||
| {1EB1EE8F-9978-425B-A742-533DCCEB4811}.Release|x86.ActiveCfg = Release|Any CPU | |||
| EndGlobalSection | |||
| GlobalSection(SolutionProperties) = preSolution | |||
| HideSolutionNode = FALSE | |||
| @@ -2785,79 +2785,101 @@ namespace Novacode | |||
| UpdateCustomPropertyValue(this, cp.Name, cp.Value.ToString()); | |||
| } | |||
| internal static void UpdateCustomPropertyValue(DocX document, string customPropertyName, string customPropertyValue) | |||
| { | |||
| foreach (XElement e in document.mainDoc.Descendants(XName.Get("fldSimple", w.NamespaceName))) | |||
| { | |||
| string attr_value = e.Attribute(XName.Get("instr", w.NamespaceName)).Value.Replace(" ", string.Empty).Trim(); | |||
| string match_value = string.Format(@"DOCPROPERTY {0} \* MERGEFORMAT", customPropertyName).Replace(" ", string.Empty); | |||
| // A list of documents, which will contain, The Main Document and if they exist: header1, header2, header3, footer1, footer2, footer3. | |||
| List<XElement> documents = new List<XElement>{ document.mainDoc.Root }; | |||
| if (attr_value.Equals(match_value, StringComparison.CurrentCultureIgnoreCase)) | |||
| { | |||
| XElement firstRun = e.Element(w + "r"); | |||
| XElement firstText = firstRun.Element(w + "t"); | |||
| XElement rPr = firstText.Element(w + "rPr"); | |||
| // Check if each header exists and add if if so. | |||
| #region Headers | |||
| Headers headers = document.Headers; | |||
| if (headers.first != null) | |||
| documents.Add(headers.first.Xml); | |||
| if (headers.odd != null) | |||
| documents.Add(headers.odd.Xml); | |||
| if (headers.even != null) | |||
| documents.Add(headers.even.Xml); | |||
| #endregion | |||
| // Delete everything and insert updated text value | |||
| e.RemoveNodes(); | |||
| // Check if each footer exists and add if if so. | |||
| #region Footers | |||
| Footers footers = document.Footers; | |||
| if (footers.first != null) | |||
| documents.Add(footers.first.Xml); | |||
| if (footers.odd != null) | |||
| documents.Add(footers.odd.Xml); | |||
| if (footers.even != null) | |||
| documents.Add(footers.even.Xml); | |||
| #endregion | |||
| XElement t = new XElement(w + "t", rPr, customPropertyValue); | |||
| Novacode.Text.PreserveSpace(t); | |||
| e.Add(new XElement(firstRun.Name, firstRun.Attributes(), firstRun.Element(XName.Get("rPr", w.NamespaceName)), t)); | |||
| } | |||
| } | |||
| // Process each document in the list. | |||
| foreach (XElement doc in documents) | |||
| { | |||
| foreach (XElement e in doc.Descendants(XName.Get("instrText", w.NamespaceName))) | |||
| { | |||
| string attr_value = e.Value.Replace(" ", string.Empty).Trim(); | |||
| string match_value = string.Format(@"DOCPROPERTY {0} \* MERGEFORMAT", customPropertyName).Replace(" ", string.Empty); | |||
| //#region Headers | |||
| //foreach(PackagePart pp in document.headers) | |||
| //{ | |||
| // XDocument header = XDocument.Load(new StreamReader(pp.GetStream())); | |||
| // foreach (XElement e in header.Descendants(XName.Get("fldSimple", w.NamespaceName))) | |||
| // { | |||
| // if (e.Attribute(XName.Get("instr", w.NamespaceName)).Value.Trim().Equals(string.Format(@"DOCPROPERTY {0} \* MERGEFORMAT", customPropertyName), StringComparison.CurrentCultureIgnoreCase)) | |||
| // { | |||
| // XElement firstRun = e.Element(w + "r"); | |||
| // // Delete everything and insert updated text value | |||
| // e.RemoveNodes(); | |||
| // XElement t = new XElement(w + "t", customPropertyValue); | |||
| // Novacode.Text.PreserveSpace(t); | |||
| // e.Add(new XElement(firstRun.Name, firstRun.Attributes(), firstRun.Element(XName.Get("rPr", w.NamespaceName)), t)); | |||
| // } | |||
| // } | |||
| // using (TextWriter tw = new StreamWriter(pp.GetStream())) | |||
| // header.Save(tw); | |||
| //} | |||
| //#endregion | |||
| //#region Footers | |||
| //foreach (PackagePart pp in document.footers) | |||
| //{ | |||
| // XDocument footer = XDocument.Load(new StreamReader(pp.GetStream())); | |||
| if (attr_value.Equals(match_value, StringComparison.CurrentCultureIgnoreCase)) | |||
| { | |||
| XNode node = e.Parent.NextNode; | |||
| bool found = false; | |||
| while (true) | |||
| { | |||
| if (node.NodeType == XmlNodeType.Element) | |||
| { | |||
| var ele = node as XElement; | |||
| var match = ele.Descendants(XName.Get("t", w.NamespaceName)); | |||
| if (match.Count() > 0) | |||
| { | |||
| if (!found) | |||
| { | |||
| match.First().Value = customPropertyValue; | |||
| found = true; | |||
| } | |||
| else | |||
| { | |||
| ele.RemoveNodes(); | |||
| } | |||
| } | |||
| else | |||
| { | |||
| match = ele.Descendants(XName.Get("fldChar", w.NamespaceName)); | |||
| if (match.Count() > 0) | |||
| { | |||
| var endMatch = match.First().Attribute(XName.Get("fldCharType", w.NamespaceName)); | |||
| if (endMatch != null && endMatch.Value == "end") | |||
| { | |||
| break; | |||
| } | |||
| } | |||
| } | |||
| } | |||
| node = node.NextNode; | |||
| } | |||
| } | |||
| } | |||
| // foreach (XElement e in footer.Descendants(XName.Get("fldSimple", w.NamespaceName))) | |||
| // { | |||
| // if (e.Attribute(XName.Get("instr", w.NamespaceName)).Value.Trim().Equals(string.Format(@"DOCPROPERTY {0} \* MERGEFORMAT", customPropertyName), StringComparison.CurrentCultureIgnoreCase)) | |||
| // { | |||
| // XElement firstRun = e.Element(w + "r"); | |||
| foreach (XElement e in doc.Descendants(XName.Get("fldSimple", w.NamespaceName))) | |||
| { | |||
| string attr_value = e.Attribute(XName.Get("instr", w.NamespaceName)).Value.Replace(" ", string.Empty).Trim(); | |||
| string match_value = string.Format(@"DOCPROPERTY {0} \* MERGEFORMAT", customPropertyName).Replace(" ", string.Empty); | |||
| // // Delete everything and insert updated text value | |||
| // e.RemoveNodes(); | |||
| if (attr_value.Equals(match_value, StringComparison.CurrentCultureIgnoreCase)) | |||
| { | |||
| XElement firstRun = e.Element(w + "r"); | |||
| XElement firstText = firstRun.Element(w + "t"); | |||
| XElement rPr = firstText.Element(w + "rPr"); | |||
| // XElement t = new XElement(w + "t", customPropertyValue); | |||
| // Novacode.Text.PreserveSpace(t); | |||
| // e.Add(new XElement(firstRun.Name, firstRun.Attributes(), firstRun.Element(XName.Get("rPr", w.NamespaceName)), t)); | |||
| // } | |||
| // } | |||
| // Delete everything and insert updated text value | |||
| e.RemoveNodes(); | |||
| // using (TextWriter tw = new StreamWriter(pp.GetStream())) | |||
| // footer.Save(tw); | |||
| //} | |||
| //#endregion | |||
| XElement t = new XElement(w + "t", rPr, customPropertyValue); | |||
| Novacode.Text.PreserveSpace(t); | |||
| e.Add(new XElement(firstRun.Name, firstRun.Attributes(), firstRun.Element(XName.Get("rPr", w.NamespaceName)), t)); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| public override Paragraph InsertParagraph() | |||
| @@ -48,8 +48,7 @@ | |||
| <DefineConstants>DEBUG;TRACE</DefineConstants> | |||
| <ErrorReport>prompt</ErrorReport> | |||
| <WarningLevel>4</WarningLevel> | |||
| <DocumentationFile> | |||
| </DocumentationFile> | |||
| <DocumentationFile>bin\Debug\DocX.XML</DocumentationFile> | |||
| <CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
| @@ -118,9 +117,6 @@ | |||
| </Compile> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <None Include="Help\Changes in this version 1.0.0.10.docx" /> | |||
| <None Include="Help\DocX v1.0.0.10 - Documentation.chm" /> | |||
| <None Include="Help\Read Me.docx" /> | |||
| <None Include="StrongNameFile.pfx" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| @@ -0,0 +1,74 @@ | |||
| <?xml version="1.0" encoding="utf-8"?> | |||
| <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> | |||
| <PropertyGroup> | |||
| <!-- The configuration and platform will be used to determine which | |||
| assemblies to include from solution and project documentation | |||
| sources --> | |||
| <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | |||
| <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | |||
| <SchemaVersion>2.0</SchemaVersion> | |||
| <ProjectGuid>{1eb1ee8f-9978-425b-a742-533dcceb4811}</ProjectGuid> | |||
| <SHFBSchemaVersion>1.9.3.0</SHFBSchemaVersion> | |||
| <!-- AssemblyName, Name, and RootNamespace are not used by SHFB but Visual | |||
| Studio adds them anyway --> | |||
| <AssemblyName>Documentation</AssemblyName> | |||
| <RootNamespace>Documentation</RootNamespace> | |||
| <Name>Documentation</Name> | |||
| <!-- SHFB properties --> | |||
| <OutputPath>Help\</OutputPath> | |||
| <HtmlHelpName>Documentation</HtmlHelpName> | |||
| <Language>en-US</Language> | |||
| <HelpFileFormat>HtmlHelp1</HelpFileFormat> | |||
| <IndentHtml>False</IndentHtml> | |||
| <FrameworkVersion>.NET 4.0.30319</FrameworkVersion> | |||
| <KeepLogFile>True</KeepLogFile> | |||
| <DisableCodeBlockComponent>False</DisableCodeBlockComponent> | |||
| <CppCommentsFixup>False</CppCommentsFixup> | |||
| <CleanIntermediates>True</CleanIntermediates> | |||
| <SyntaxFilters>Standard</SyntaxFilters> | |||
| <SdkLinkTarget>Blank</SdkLinkTarget> | |||
| <RootNamespaceContainer>False</RootNamespaceContainer> | |||
| <PresentationStyle>vs2005</PresentationStyle> | |||
| <Preliminary>False</Preliminary> | |||
| <NamingMethod>Guid</NamingMethod> | |||
| <HelpTitle>DocX - A Sandcastle Documented Class Library</HelpTitle> | |||
| <FeedbackEMailLinkText>coffey.cathal%40gmail.com</FeedbackEMailLinkText> | |||
| <FeedbackEMailAddress>coffey.cathal%40gmail.com</FeedbackEMailAddress> | |||
| <ContentPlacement>AboveNamespaces</ContentPlacement> | |||
| <DocumentationSources> | |||
| <DocumentationSource sourceFile="..\DocX\DocX.csproj" /> | |||
| </DocumentationSources> | |||
| <SccProjectName>SAK</SccProjectName> | |||
| <SccProvider>SAK</SccProvider> | |||
| <SccAuxPath>SAK</SccAuxPath> | |||
| <SccLocalPath>SAK</SccLocalPath> | |||
| <WorkingPath>%temp%\</WorkingPath> | |||
| </PropertyGroup> | |||
| <!-- There are no properties for these groups. AnyCPU needs to appear in | |||
| order for Visual Studio to perform the build. The others are optional | |||
| common platform types that may appear. --> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' "> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' "> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' "> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' "> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|Win32' "> | |||
| </PropertyGroup> | |||
| <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' "> | |||
| </PropertyGroup> | |||
| <ItemGroup> | |||
| <Folder Include="Help\" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <None Include="Help\Documentation.chm" /> | |||
| </ItemGroup> | |||
| <!-- Import the SHFB build targets --> | |||
| <Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" /> | |||
| </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" | |||
| } | |||