protected void InitializeMapsFromStyleInfo(string strFont, string strId, string strName, List <string> lstStyleId, string strFilename) { if (!lstStyleId.Contains(strId)) { lstStyleId.Add(strId); } Debug.Assert(!MyMapIteratorList.MapStyleId2Name.ContainsKey(strId)); MyMapIteratorList.MapStyleId2Name.Add(strId, strName); // Apparently, it isn't impossible to have multiple styles with the same name... // see c:\temp\Buku\Buku Latihan Fnlg_06.doc // System.Diagnostics.Debug.Assert(!mapStyleName2FontName.ContainsKey(strName)); if (MapStyleName2FontName.ContainsKey(strName)) { MessageBox.Show( String.Format( "The Word document '{0}' contains two styles with the same name '{1}'. After the conversion, you should check the converted file carefully to see if the data in that style name was converted correctly. You may need to combine the segments into a single style for this to work properly.", strFilename, strName), FontsStylesForm.cstrCaption); } else { MapStyleName2FontName.Add(strName, strFont); } }
public override bool ConvertDocumentByStylesOnly(Dictionary <string, Font> mapName2Font, Func <string, DataIterator, string, Font, bool, bool> convertDoc) { // MapStyleId2Iterator, has one iterator for each unique style (across all docs). If there's // only one doc, then we're done. But if there's more than one doc, then we have to treat each // one as if by itself (which unfortunately means empty the collection and requery) if (!Program.IsOnlyOneDoc) { MapIteratorList = new MapIteratorListXPath(); GetTextIteratorListStyle(); // this initializes MapStyleId2Iterator } var bModified = false; foreach (string strStyleId in MyMapIteratorList.MapStyleId2Iterator.Keys) { if (MyMapIteratorList.MapStyleId2Name.ContainsKey(strStyleId)) { string strStyleName = MyMapIteratorList.MapStyleId2Name[strStyleId]; Debug.Assert(mapName2Font.ContainsKey(strStyleName)); Debug.Assert(MapStyleName2FontName.ContainsKey(strStyleName)); Font fontTarget = mapName2Font[strStyleName]; string strOrigFont = MapStyleName2FontName[strStyleName]; bModified |= convertDoc(strStyleName, MyMapIteratorList.MapStyleId2Iterator[strStyleId], strOrigFont, fontTarget, false); // update the font name as well if (strOrigFont != fontTarget.Name) { ReplaceTextFontNameGetStyleText(strStyleName, fontTarget.Name); } } } return(bModified); }