I understood why I had this behavior. The TOC was created with the
regional options set to french, and the list separator is “;” so the TOC
is:
{ TOC \o “1-3” \h \z \t “ELA-Title;4;Intro_Title1;2;Intro_Title2;3;Intro_Title3;4” }
But in english, the list separator is “,”, and the TOC must be:<span style=“font-size:10.0pt;font-family:“Courier New”” lang=“EN-GB”>
{ TOC \o “1-3” \h \z \t “ELA-Title,4,Intro_Title1,2;Intro_Title2,3,Intro_Title3,4” } <span style=“font-size:12.0pt;font-family:“Times New Roman”,“serif”;mso-fareast-language:FR”>
As I update the TOC with regional options in english, I have to replace “;” by “,” in the TOC before updating:
<!–[if gte mso 9]>
<w:WordDocument>
<w:View>Normal</w:View>
<w:Zoom>0</w:Zoom>
<w:TrackMoves/>
<w:TrackFormatting/>
<w:HyphenationZone>21</w:HyphenationZone>
<w:PunctuationKerning/>
<w:ValidateAgainstSchemas/>
<w:SaveIfXMLInvalid>false</w:SaveIfXMLInvalid>
<w:IgnoreMixedContent>false</w:IgnoreMixedContent>
<w:AlwaysShowPlaceholderText>false</w:AlwaysShowPlaceholderText>
<w:DoNotPromoteQF/>
<w:LidThemeOther>FR</w:LidThemeOther>
<w:LidThemeAsian>X-NONE</w:LidThemeAsian>
<w:LidThemeComplexScript>X-NONE</w:LidThemeComplexScript>
<w:Compatibility>
<w:BreakWrappedTables/>
<w:SnapToGridInCell/>
<w:WrapTextWithPunct/>
<w:UseAsianBreakRules/>
<w:DontGrowAutofit/>
<w:SplitPgBreakAndParaMark/>
<w:EnableOpenTypeKerning/>
<w:DontFlipMirrorIndents/>
<w:OverrideTableStyleHps/>
</w:Compatibility>
<m:mathPr>
<m:mathFont m:val=“Cambria Math”/>
<m:brkBin m:val=“before”/>
<m:brkBinSub m:val="–"/>
<m:smallFrac m:val=“off”/>
<m:dispDef/>
<m:lMargin m:val=“0”/>
<m:rMargin m:val=“0”/>
<m:defJc m:val=“centerGroup”/>
<m:wrapIndent m:val=“1440”/>
<m:intLim m:val=“subSup”/>
<m:naryLim m:val=“undOvr”/>
</m:mathPr></w:WordDocument>
<![endif]–><!–[if gte mso 10]>
/* Style Definitions */
table.MsoNormalTable
{mso-style-name:"Tableau Normal";
mso-tstyle-rowband-size:0;
mso-tstyle-colband-size:0;
mso-style-noshow:yes;
mso-style-priority:99;
mso-style-parent:"";
mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
mso-para-margin-top:0cm;
mso-para-margin-right:0cm;
mso-para-margin-bottom:10.0pt;
mso-para-margin-left:0cm;
line-height:115%;
mso-pagination:widow-orphan;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-ascii-font-family:Calibri;
mso-ascii-theme-font:minor-latin;
mso-hansi-font-family:Calibri;
mso-hansi-theme-font:minor-latin;
mso-bidi-font-family:"Times New Roman";
mso-bidi-theme-font:minor-bidi;
mso-fareast-language:EN-US;}
<![endif]–>
Aspose.Words.NodeCollection fieldStarts = doc.GetChildNodes(Aspose.Words.NodeType.FieldStart, true);
foreach (Aspose.Words.Fields.FieldStart fieldStart in fieldStarts)
{
if (fieldStart.FieldType == Aspose.Words.Fields.FieldType.FieldTOC)
{
Aspose.Words.Node fieldSeparator =
fieldStart.NextSibling;
fieldSeparator.Range.Replace(";",
System.Threading.Thread.CurrentThread.CurrentUICulture.TextInfo.ListSeparator, false, false);
}
}