コード例 #1
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;
                }
            }
        }
コード例 #2
0
ファイル: PubApp.cs プロジェクト: sillsdev/WorldPad
		void ThisStoryConvert_Click(Microsoft.Office.Core.CommandBarButton Ctrl, ref bool CancelDefault)
		{
			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;
			}
		}