Exemplo n.º 1
0
        void SpellFixerWordByWord_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_aWordByWordSpellFixerProcessor == null)
                {
                    SpellFixerProcessorForm form = new SpellFixerProcessorForm(GetSpellFixer);
                    FontConverter           aFC  = new FontConverter(GetSpellFixer);
                    m_aWordByWordSpellFixerProcessor = new OfficeDocumentProcessor(aFC, form);
                }

                if (doc.ProcessWordByWord(m_aWordByWordSpellFixerProcessor))
                {
                    m_aWordByWordSpellFixerProcessor = null;
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
            }
            Application.System.Cursor = Word.WdCursorType.wdCursorNormal;
        }
Exemplo n.º 2
0
        void SpellFixerWordByWordFont_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_aWordByWordFontSpellFixerProcessor == null)
                {
                    SpellFixerProcessorForm form = new SpellFixerProcessorForm(GetSpellFixer);

                    // next get the fonts the user wants to process
                    FontConvertersPicker aFCsPicker = new FontConvertersPicker(doc, GetSpellFixer.SpellFixerEncConverter);

                    if ((aFCsPicker.ShowDialog() == DialogResult.OK) && (aFCsPicker.SelectedFontConverters.Count > 0))
                    {
                        m_aWordByWordFontSpellFixerProcessor = new OfficeDocumentProcessor(aFCsPicker.SelectedFontConverters, form);
                    }
                    else
                    {
                        return;
                    }
                }

                if (m_aWordByWordFontSpellFixerProcessor != null)
                {
                    if (doc.ProcessWordByWord(m_aWordByWordFontSpellFixerProcessor))
                    {
                        m_aWordByWordFontSpellFixerProcessor = null;
                    }
                }
            }
            catch (Exception ex)
            {
                DisplayException(ex);
            }
            Application.System.Cursor = Word.WdCursorType.wdCursorNormal;
        }