예제 #1
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Apply the selected style with only the specified style name.
 /// </summary>
 /// <param name="sStyleToApply">Style name (this could be a paragraph or character
 /// style).</param>
 /// ------------------------------------------------------------------------------------
 public override void ApplyStyle(string sStyleToApply)
 {
     if (m_decoratedEditingHelper != null)
     {
         m_decoratedEditingHelper.ApplyStyle(sStyleToApply);
     }
     else
     {
         base.ApplyStyle(sStyleToApply);
     }
 }
예제 #2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Shows the Format Apply Style dialog. Apply the results to the selection of the active
        /// view if the user clicks OK.
        /// </summary>
        /// <param name="paraStyleName">Name of the para style.</param>
        /// <param name="charStyleName">Name of the char style.</param>
        /// <param name="maxStyleLevel">The maximum style level that will be shown in this
        /// dialog. (apps that do not use style levels in their stylesheets can pass 0)</param>
        /// ------------------------------------------------------------------------------------
        public void ShowApplyStyleDialog(string paraStyleName, string charStyleName, int maxStyleLevel)
        {
            SimpleRootSite rootsite = (ActiveView as SimpleRootSite);

            try
            {
                if (rootsite != null)
                {
                    rootsite.ShowRangeSelAfterLostFocus = true;
                }

                int hvoRoot, frag;
                IVwViewConstructor vc;
                IVwStylesheet      ss;
                ActiveView.CastAsIVwRootSite().RootBox.GetRootObject(out hvoRoot, out vc, out frag, out ss);
                using (FwApplyStyleDlg applyStyleDlg = new FwApplyStyleDlg(ActiveView.CastAsIVwRootSite(),
                                                                           Cache, StyleSheet.RootObjectHvo, StyleSheetOwningFlid,
                                                                           StyleSheet.GetDefaultBasedOnStyleName(), maxStyleLevel,
                                                                           paraStyleName, charStyleName, hvoRoot, FwApp.App, FwApp.App))
                {
                    if (FwEditingHelper != null)
                    {
                        if (FwEditingHelper.ApplicableStyleContexts != null)
                        {
                            applyStyleDlg.ApplicableStyleContexts = FwEditingHelper.ApplicableStyleContexts;
                        }
                    }
                    else if (FwApp.App != null)
                    {
                        // Window doesn't have an editing helper, go with whole-app default
                        if (FwApp.App.DefaultStyleContexts != null)
                        {
                            applyStyleDlg.ApplicableStyleContexts = FwApp.App.DefaultStyleContexts;
                        }
                    }
                    applyStyleDlg.AllowSelectStyleTypes = m_callbacks.ShowSelectStylesComboInStylesDialog;
                    IVwSelection sel = EditingHelper.CurrentSelection.Selection;
                    applyStyleDlg.CanApplyCharacterStyle = sel.CanFormatChar;
                    applyStyleDlg.CanApplyParagraphStyle = sel.CanFormatPara;

                    if (applyStyleDlg.ShowDialog(m_callbacks) == DialogResult.OK)
                    {
                        EditingHelper.ApplyStyle(applyStyleDlg.StyleChosen);
                    }
                }
            }
            finally
            {
                if (rootsite != null)
                {
                    rootsite.ShowRangeSelAfterLostFocus = false;
                }
            }
        }
예제 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Provides access to EditingHelper.ApplyStyle
        /// </summary>
        /// <param name="sStyleToApply"></param>
        /// ------------------------------------------------------------------------------------
        public void ApplyStyle(string sStyleToApply)
        {
            CheckDisposed();

            EditingHelper.ApplyStyle(sStyleToApply);
        }
예제 #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Shows the Format Apply Style dialog. Apply the results to the selection of the active
        /// view if the user clicks OK.
        /// </summary>
        /// <param name="paraStyleName">Name of the para style.</param>
        /// <param name="charStyleName">Name of the char style.</param>
        /// <param name="maxStyleLevel">The maximum style level that will be shown in this
        /// dialog. (apps that do not use style levels in their stylesheets can pass 0)</param>
        /// ------------------------------------------------------------------------------------
        public void ShowApplyStyleDialog(string paraStyleName, string charStyleName, int maxStyleLevel)
        {
            SimpleRootSite rootsite = (ActiveView as SimpleRootSite);

            try
            {
                if (rootsite != null)
                {
                    rootsite.ShowRangeSelAfterLostFocus = true;
                }

                IVwSelection sel = EditingHelper.CurrentSelection.Selection;
                if (paraStyleName == null && charStyleName == null)
                {
                    // If the caller didn't know the default style, try to figure it out from
                    // the selection.
                    GetStyleNames(rootsite, sel, ref paraStyleName, ref charStyleName);
                }
                int hvoRoot, frag;
                IVwViewConstructor vc;
                IVwStylesheet      ss;
                ActiveView.CastAsIVwRootSite().RootBox.GetRootObject(out hvoRoot, out vc, out frag, out ss);
                using (FwApplyStyleDlg applyStyleDlg = new FwApplyStyleDlg(ActiveView.CastAsIVwRootSite(),
                                                                           Cache, ActiveStyleSheet.RootObjectHvo, StyleSheetOwningFlid,
                                                                           ActiveStyleSheet.GetDefaultBasedOnStyleName(), maxStyleLevel,
                                                                           paraStyleName, charStyleName, hvoRoot, m_app, m_app))
                {
                    if (FwEditingHelper != null)
                    {
                        if (FwEditingHelper.ApplicableStyleContexts != null)
                        {
                            applyStyleDlg.ApplicableStyleContexts = FwEditingHelper.ApplicableStyleContexts;
                        }
                    }
                    else if (m_app != null)
                    {
                        // Window doesn't have an editing helper, go with whole-app default
                        if (m_app.DefaultStyleContexts != null)
                        {
                            applyStyleDlg.ApplicableStyleContexts = m_app.DefaultStyleContexts;
                        }
                    }
                    applyStyleDlg.AllowSelectStyleTypes  = m_callbacks.ShowTEStylesComboInStylesDialog;
                    applyStyleDlg.CanApplyCharacterStyle = sel.CanFormatChar;
                    applyStyleDlg.CanApplyParagraphStyle = sel.CanFormatPara;

                    if (applyStyleDlg.ShowDialog(m_callbacks) == DialogResult.OK)
                    {
                        string sUndo, sRedo;
                        ResourceHelper.MakeUndoRedoLabels("kstidUndoApplyStyle", out sUndo, out sRedo);
                        using (UndoTaskHelper helper = new UndoTaskHelper(Cache.ActionHandlerAccessor,
                                                                          ActiveView.CastAsIVwRootSite(), sUndo, sRedo))
                        {
                            EditingHelper.ApplyStyle(applyStyleDlg.StyleChosen);
                            helper.RollBack = false;
                        }
                    }
                }
            }
            finally
            {
                if (rootsite != null)
                {
                    rootsite.ShowRangeSelAfterLostFocus = false;
                }
            }
        }
예제 #5
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Exposes the ApplyStyle method for testing
        /// </summary>
        /// <param name="styleName">Style name</param>
        /// ------------------------------------------------------------------------------------
        public void ApplyStyle(string styleName)
        {
            CheckDisposed();

            EditingHelper.ApplyStyle(styleName);
        }