Пример #1
0
        void SelectionConvert_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            if (!HookDocumentClose(Application.ActiveDocument))
            {
                return;
            }

            try
            {
                WordSelectionDocument doc = new WordSelectionDocument(Application.ActiveDocument, OfficeTextDocument.ProcessingType.eWordByWord);
#if !QueryAllFonts
                // first get the fonts the user wants to process
                OfficeDocumentProcessor aSelectionProcessor = null;
                FontConvertersPicker    aFCsPicker          = new FontConvertersPicker(doc);
                if ((aFCsPicker.ShowDialog() == DialogResult.OK) && (aFCsPicker.SelectedFontConverters.Count > 0))
                {
                    FontConverters aFCs = aFCsPicker.SelectedFontConverters;
                    aSelectionProcessor = new OfficeDocumentProcessor(aFCs, new SILConverterProcessorForm());
                }
#else
                OfficeDocumentProcessor aSelectionProcessor = new OfficeDocumentProcessor((FontConverters)null, new SILConverterProcessorForm());
#endif
                if (aSelectionProcessor != null)
                {
                    doc.ProcessWordByWord(aSelectionProcessor);
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
            }
        }
Пример #2
0
        void ThisStoryConvert()
        {
            if (!HookDocumentClose(Application.ActiveDocument))
            {
                return;
            }

            try
            {
#if DEBUG
                string strPubPIOVer = Application.Version;
                MessageBox.Show(String.Format("MSPub PIA version: {0}", strPubPIOVer));
#endif
                PubStoryDocument doc = new PubStoryDocument(Application.ActiveDocument, OfficeTextDocument.ProcessingType.eWordByWord);

                // we want to process the file word by word and show differences between
                //  the Input and (once) Converted string
                if ((m_aThisStoryWordByWordFontProcessor == null) || (m_strLastStoryName != doc.StoryName))
                {
                    m_aThisStoryWordByWordFontProcessor = null; // just in case we came thru the latter OR case

                    // first get the fonts the user wants to process
                    FontConvertersPicker aFCsPicker = new FontConvertersPicker(doc);
                    if ((aFCsPicker.ShowDialog() == DialogResult.OK) && (aFCsPicker.SelectedFontConverters.Count > 0))
                    {
                        FontConverters aFCs = aFCsPicker.SelectedFontConverters;
                        m_aThisStoryWordByWordFontProcessor = GetDocumentProcessor(aFCs, new SILConverterProcessorForm());
                    }
                }

                if (m_aThisStoryWordByWordFontProcessor != null)
                {
                    if (doc.ProcessWordByWord(m_aThisStoryWordByWordFontProcessor))
                    {
                        m_aThisStoryWordByWordFontProcessor = null;
                        m_strLastStoryName = null;
                    }
                    else
                    {
                        m_strLastStoryName = doc.StoryName;
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
                if ((m_aThisStoryWordByWordFontProcessor != null) && !m_aThisStoryWordByWordFontProcessor.AreLeftOvers)
                {
                    m_aThisStoryWordByWordFontProcessor = null;
                }
            }
        }
Пример #3
0
        protected void WholeDocumentConvert()
        {
            if (!HookDocumentClose(Application.ActiveDocument))
            {
                return;
            }

            try
            {
                PubDocument doc = new PubDocument(Application.ActiveDocument, OfficeTextDocument.ProcessingType.eWordByWord);

                // we want to process the file word by word and show differences between
                //  the Input and (once) Converted string
                if (m_aWordByWordFontProcessor == null)
                {
                    // first get the fonts the user wants to process
                    FontConvertersPicker aFCsPicker = new FontConvertersPicker(doc);
                    if ((aFCsPicker.ShowDialog() == DialogResult.OK) && (aFCsPicker.SelectedFontConverters.Count > 0))
                    {
                        FontConverters aFCs = aFCsPicker.SelectedFontConverters;
                        m_aWordByWordFontProcessor = GetDocumentProcessor(aFCs, new SILConverterProcessorForm());
                    }
                }

                if (m_aWordByWordFontProcessor != null)
                {
                    if (doc.ProcessWordByWord(m_aWordByWordFontProcessor))
                    {
                        m_aWordByWordFontProcessor = null;
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
                if ((m_aWordByWordFontProcessor != null) && !m_aWordByWordFontProcessor.AreLeftOvers)
                {
                    m_aWordByWordFontProcessor = null;
                }
            }
        }
Пример #4
0
        void WordByWordFont_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            if (!HookDocumentClose(Application.ActiveDocument))
            {
                return;
            }

            Application.System.Cursor = Word.WdCursorType.wdCursorWait;
            try
            {
                WordDocument doc = new WordDocument(Application.ActiveDocument, OfficeTextDocument.ProcessingType.eWordByWord);

                // we want to process the file word by word and show differences between
                //  the Input and (once) Converted string
                if (m_aWordByWordFontProcessor == null)
                {
                    // first get the fonts the user wants to process
                    FontConvertersPicker aFCsPicker = new FontConvertersPicker(doc);
                    if ((aFCsPicker.ShowDialog() == DialogResult.OK) && (aFCsPicker.SelectedFontConverters.Count > 0))
                    {
                        FontConverters aFCs = aFCsPicker.SelectedFontConverters;
                        m_aWordByWordFontProcessor = new OfficeDocumentProcessor(aFCs, new SILConverterProcessorForm());
                    }
                }

                if (m_aWordByWordFontProcessor != null)
                {
                    if (doc.ProcessWordByWord(m_aWordByWordFontProcessor))
                    {
                        m_aWordByWordFontProcessor = null;
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
            }

            Application.System.Cursor = Word.WdCursorType.wdCursorNormal;
        }
Пример #5
0
        protected FontConverter QueryUserForFontScan(string strFontName)
        {
            if ((strFontName == null) || (strFontName.Length == 0))
            {
                return(null);
            }

            // make sure our collection exists
            if (m_mapFontsEncountered == null)
            {
                m_mapFontsEncountered = new FontConverters();
            }

            if (!m_mapFontsEncountered.ContainsKey(strFontName))
            {
                DialogResult res = MessageBox.Show(String.Format("Do you want to convert words in the {0} font?", strFontName), OfficeApp.cstrCaption, MessageBoxButtons.YesNoCancel);

                FontConverter aFC = null;
                if (res == DialogResult.Cancel)
                {
                    throw new ApplicationException(OfficeApp.cstrAbortMessage);
                }
                if (res == DialogResult.Yes)
                {
                    aFC = QueryForFontConvert(strFontName);

                    /*
                     * FontConvertersPicker aFontConverterPicker = new FontConvertersPicker(strFontName);
                     * if( aFontConverterPicker.ShowDialog() == DialogResult.OK )
                     *  aFC = aFontConverterPicker.SelectedFontConverters[strFontName];
                     */
                    // aFC = new FontConverter(strFontName);
                }

                m_mapFontsEncountered.Add(strFontName, aFC);
            }

            return(m_mapFontsEncountered[strFontName]);
        }
Пример #6
0
        void RoundTripCheckFont_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
        {
            if (!HookDocumentClose(Application.ActiveDocument))
            {
                return;
            }

            Application.System.Cursor = Word.WdCursorType.wdCursorWait;
            try
            {
                WordDocument doc = new WordDocument(Application.ActiveDocument, OfficeTextDocument.ProcessingType.eWordByWord);

                if (m_aRoundTripCheckFontWordProcessor == null)
                {
                    // first get the fonts the user wants to process
                    FontConvertersPicker aFCsPicker = new FontConvertersPicker(doc);
                    if (aFCsPicker.ShowDialog() == DialogResult.OK)
                    {
                        FontConverters aFCs = aFCsPicker.SelectedFontConverters;
                        m_aRoundTripCheckFontWordProcessor = new RoundTripCheckWordProcessor(aFCs);
                    }
                }

                if (m_aRoundTripCheckFontWordProcessor != null)
                {
                    if (doc.ProcessWordByWord(m_aRoundTripCheckFontWordProcessor))
                    {
                        m_aRoundTripCheckFontWordProcessor = null;
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
            }

            Application.System.Cursor = Word.WdCursorType.wdCursorNormal;
        }
Пример #7
0
 /// <summary>
 /// This constructor is for when you have a collection of Font to Converter mappings AND a form
 /// to use to display the differences.
 /// </summary>
 /// <param name="aFCs"></param>
 /// <param name="form"></param>
 public OfficeDocumentProcessor(FontConverters aFCs, BaseConverterForm form)
 {
     m_aFCs  = aFCs;
     Form    = form;
     Process = CompareInputOutputProcess;    // good default
 }
Пример #8
0
 public RoundTripCheckWordProcessor(FontConverters aFCs)
     : base(aFCs, new RoundTripProcessorForm())
 {
 }
Пример #9
0
 public PubDocumentProcessor(FontConverters aFCs, BaseConverterForm form)
     : base(aFCs, form)
 {
 }
Пример #10
0
 protected OfficeDocumentProcessor GetDocumentProcessor(FontConverters aFCs, BaseConverterForm form)
 {
     return((IsPublisher2003) ?
            new OfficeDocumentProcessor(aFCs, form) :    // Publisher 2003
            new PubDocumentProcessor(aFCs, form));       // Publisher 2007/2010
 }
Пример #11
0
 protected OfficeDocumentProcessor GetDocumentProcessor(FontConverters aFCs, BaseConverterForm form)
 {
     return((Application.Version == "11.0") ?
            new OfficeDocumentProcessor(aFCs, form) :
            new PubDocumentProcessor(aFCs, form));
 }