コード例 #1
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            if (!commands[IDM.FONTNAME].Enabled)
            {
                return;
            }

            commands[IDM.FONTNAME].Execute(FontFamily);
        }
コード例 #2
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            const string   smallCapsAttribute = "style=\"font-variant: small-caps\"";
            ElementFactory factory            = () => markupServices.CreateElement(_ELEMENT_TAG_ID.TAGID_FONT, smallCapsAttribute);

            WrapInElement(factory, markupServices, markupRange);
        }
コード例 #3
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            if (!commands[IDM.STRIKETHROUGH].Enabled)
            {
                return;
            }

            commands[IDM.STRIKETHROUGH].Execute();
        }
コード例 #4
0
        /// <summary>
        /// Asks a document site to activate the document making the call as a
        /// document object rather than an in-place-active object and, optionally,
        /// specifies which view of the object document to activate. This is based
        /// on the CFramerDocument::ActivateMe method from the FramerEx sample
        /// (referenced above in the class comment). The only difference is that
        /// we don't call IOleDocumentView.SetRect after the call to UIActivate
        /// since we don't allow additional of toolbars, etc. to the container.
        /// </summary>
        /// <param name="pViewToActivate"> Pointer to the document view to be used
        /// in activating the document object. Can be NULL according to the
        /// specification, however MSHTML should always pass a valid view when
        /// requesting activation.</param>
        void IOleDocumentSite.ActivateMe(IOleDocumentView pViewToActivate)
        {
            // log access to method
            LOG("IOleDocumentSite", "ActivateMe");

            // MSHTML should always pass us a view
            if (pViewToActivate == null)
            {
                Debug.Fail("MSHMTL should always pass us a view!");
                ComHelper.Return(HRESULT.E_FAILED);
            }

            // Get a reference to the document's view
            oleDocumentView = pViewToActivate;

            // Associate our site with the document view
            pViewToActivate.SetInPlaceSite((IOleInPlaceSite)(this));

            // Get the command target for the view
            oleCommandTarget = (IOleCommandTargetWithExecParams)oleDocumentView;

            // hookup extra-feature accessor to the command target
            standardCommandSet = new MshtmlCoreCommandSet(oleCommandTarget);

            // UI Activate the document view
            oleDocumentView.UIActivate(true);

            // Show the view!
            oleDocumentView.Show(true);
        }
コード例 #5
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            ElementFactory factory = () => markupServices.CreateElement(_ELEMENT_TAG_ID.TAGID_SUP, String.Empty);

            WrapInElement(factory, markupServices, markupRange);
        }
コード例 #6
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            // Special case because MSHTML is not able remove underlines from <a> elements.
            if (!Underline)
            {
                // Find the parent <a> element (if one exists).
                IHTMLElement currentElement = markupRange.Start.CurrentScope;
                while (currentElement != null && !(currentElement is IHTMLAnchorElement))
                {
                    currentElement = currentElement.parentElement;
                }

                if (currentElement != null)
                {
                    // Explicitly remove the underline.
                    const string   noTextDecorationAttribute = "style=\"text-decoration: none\"";
                    ElementFactory factory = () => markupServices.CreateElement(_ELEMENT_TAG_ID.TAGID_FONT, noTextDecorationAttribute);
                    WrapInElement(factory, markupServices, markupRange);

                    return;
                }
            }

            if (!commands[IDM.UNDERLINE].Enabled)
            {
                return;
            }

            commands[IDM.UNDERLINE].Execute();

            Debug.Assert(commands[IDM.UNDERLINE].Latched == Underline, "UnderlineTextStyle did not yield the correct results.");
        }
コード例 #7
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            if (!commands[IDM.FORECOLOR].Enabled)
            {
                return;
            }

            commands[IDM.FORECOLOR].Execute(ColorHelper.ColorToString(FontColor));
        }
コード例 #8
0
        /// <summary>
        /// Executes each fix up segment.
        /// </summary>
        /// <param name="registeredFixupSegments">A list of fixup segments to be executed.</param>
        private void ExecuteRegisteredFixupSegments(ICollection<FixupSegment> registeredFixupSegments)
        {
            // Creating a text range is expensive, so we just create one and reuse it.
            IHTMLBodyElement body = (IHTMLBodyElement)destinationDocument.body;
            IHTMLTxtRange textRange = body.createTextRange();

            // We can QI the IHTMLTxtRange for IOleCommandTarget which then lets us pass each fixup segment a
            // command set that they can execute against.
            IOleCommandTargetWithExecParams target = (IOleCommandTargetWithExecParams)textRange;
            MshtmlCoreCommandSet commands = new MshtmlCoreCommandSet(target);

            foreach (FixupSegment fixupSegment in registeredFixupSegments)
            {
                destinationMarkupServices.MoveRangeToPointers(fixupSegment.RangeToFixup.Start, fixupSegment.RangeToFixup.End, textRange);
                fixupSegment.DoFixup(destinationMarkupServices, commands);
            }

            registeredFixupSegments.Clear();
        }
コード例 #9
0
 public abstract void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands);
コード例 #10
0
 public void DoFixup(MshtmlMarkupServices markupServices, MshtmlCoreCommandSet commands)
 {
     SourceTextStyle.Apply(markupServices, RangeToFixup, commands);
 }
コード例 #11
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            string         fontSizeAttribute = String.Format(CultureInfo.InvariantCulture, "style=\"font-size:{0:F1}pt\"", FontSizeInPoints);
            ElementFactory factory           = () => markupServices.CreateElement(_ELEMENT_TAG_ID.TAGID_FONT, fontSizeAttribute);

            WrapInElement(factory, markupServices, markupRange);
        }
コード例 #12
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            const string   overlineAttribute = "style=\"text-decoration: overline\"";
            ElementFactory factory           = () => markupServices.CreateElement(_ELEMENT_TAG_ID.TAGID_FONT, overlineAttribute);

            WrapInElement(factory, markupServices, markupRange);
        }
コード例 #13
0
 public void DoFixup(MshtmlMarkupServices markupServices, MshtmlCoreCommandSet commands)
 {
     SourceTextStyle.Apply(markupServices, RangeToFixup, commands);
 }
コード例 #14
0
        public override void Apply(MshtmlMarkupServices markupServices, MarkupRange markupRange, MshtmlCoreCommandSet commands)
        {
            if (!commands[IDM.BOLD].Enabled)
            {
                return;
            }

            BoldApplier boldApplier = new BoldApplier(markupServices, markupRange, commands[IDM.BOLD]);

            boldApplier.Execute();
        }