Example #1
0
        public override bool ConvertDocumentByFontNameOnly(Dictionary <string, Font> mapName2Font, Func <string, DataIterator, string, Font, bool, bool> convertDoc)
        {
            // MapFontNames2Iterator, has one iterator for each unique font (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();

                // this initializes MapFontNames2Iterator and MapSymbolFontNames2Iterator
                GetTextIteratorListFontCustom();
            }

            var bModified = false;

            foreach (string strFontName in MyMapIteratorList.MapFontNames2Iterator.Keys)
            {
                Debug.Assert(mapName2Font.ContainsKey(strFontName));
                Font fontTarget = mapName2Font[strFontName];

                bModified |= convertDoc(strFontName, MyMapIteratorList.MapFontNames2Iterator[strFontName],
                                        strFontName, fontTarget, false);

                // update the font name as well
                if (strFontName != fontTarget.Name)
                {
                    ReplaceTextFontNameGetFontText(strFontName, fontTarget.Name);
                }
            }

            foreach (string strFontName in MyMapIteratorList.MapSymbolFontNames2Iterator.Keys)
            {
                Debug.Assert(mapName2Font.ContainsKey(strFontName));
                Font fontTarget = mapName2Font[strFontName];

                bModified |= convertDoc(strFontName, MyMapIteratorList.MapSymbolFontNames2Iterator[strFontName],
                                        strFontName, fontTarget, false);

                // update the font name as well
                if (strFontName != fontTarget.Name)
                {
                    ReplaceSymbolTextFontNameGetFontText(strFontName, fontTarget.Name);
                }
            }
            return(bModified);
        }
Example #2
0
        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);
        }