Пример #1
0
        public override void ReplaceText(OfficeRange aWordRange, Font fontTarget, ref int nCharIndex, string strNewText)
        {
            PubRange thisRange = (PubRange)aWordRange;

            thisRange.ReplaceText(strNewText);

            if (fontTarget != null)
            {
                SetRangeFont(aWordRange, fontTarget.Name);
            }

            nCharIndex = aWordRange.EndIndex;
        }
        public override bool ProcessWordByWord(OfficeDocumentProcessor aWordProcessor, ProcessingType eType)
        {
            Pub.Stories aStories = Document.Stories;
            int         nStoryId = 1;

            if (aWordProcessor.AreLeftOvers)
            {
                DialogResult res = MessageBox.Show("Click 'Yes' to restart where you left off, 'No' to start over at the top, and 'Cancel' to quit", OfficeApp.cstrCaption, MessageBoxButtons.YesNoCancel);
                if (res == DialogResult.No)
                {
                    aWordProcessor.LeftOvers = null;
                }
                else if (res == DialogResult.Cancel)
                {
                    return(true);
                }
                else
                {
                    System.Diagnostics.Debug.Assert(res == DialogResult.Yes);
                    PubRange rngPub = (PubRange)aWordProcessor.LeftOvers;
                    nStoryId = rngPub.StoryID;
                }
            }

            for (; nStoryId <= aStories.Count; nStoryId++)
            {
                Pub.Story aStory = aStories[nStoryId];

                bool bResult = ProcessStory(aWordProcessor, aStory);

                if (aWordProcessor.AreLeftOvers)
                {
                    PubRange rngPub = (PubRange)aWordProcessor.LeftOvers;
                    rngPub.StoryID = nStoryId;  // remember which story we were doing when the user cancelled
                }

                if (!bResult)
                {
                    return(false);
                }

                aWordProcessor.ReplaceAll = false;  // stop after each story
            }

            return(true);
        }
        public override bool ProcessWordByWord(OfficeDocumentProcessor aWordProcessor)
        {
            if (Document.Selection.Type == Pub.PbSelectionType.pbSelectionNone)
            {
                throw new ApplicationException("Nothing selected!");
            }

            PubRange      aSelectionRange = (PubRange)SelectionRange;
            PubParagraphs aParagraphs     = aSelectionRange.Paragraphs;

            if (aParagraphs.Count > 1)
            {
                return(ProcessParagraphs(aWordProcessor, aParagraphs));
            }
            else
            {
                int nCharIndex = 0;
                return(aWordProcessor.Process(aSelectionRange, ref nCharIndex));
            }
        }
Пример #4
0
 public PubRange(PubRange basedOnRange)
     : this(basedOnRange.RangeBasedOn)
 {
 }