コード例 #1
0
ファイル: InsertItemView.cs プロジェクト: 562127386/Ginseng8
        public OpenWorkItemsResult GetDefaultWorkItem()
        {
            OpenWorkItemsResult result = new OpenWorkItemsResult();

            _dummyNumber--;
            result.Number          = _dummyNumber;
            result.UseApplications = UseApplications;

            var type       = result.GetType();
            var properties = type.GetProperties();

            foreach (var kp in ContextValues.Where(kp => kp.Value != 0))
            {
                if (FindProperty(properties, kp.Key, out PropertyInfo property))
                {
                    property.SetValue(result, kp.Value);
                }
            }

            if (AppendIfMissing?.Any() ?? false)
            {
                foreach (var kp in AppendIfMissing.Where(kp => kp.Value != 0))
                {
                    if (FindProperty(properties, kp.Key, out PropertyInfo property) && !ContextValues.ContainsKey(kp.Key))
                    {
                        property.SetValue(result, kp.Value);
                    }
                }
            }

            return(result);
        }
コード例 #2
0
ファイル: InsertItemView.cs プロジェクト: 562127386/Ginseng8
        public IHtmlContent WriteContextFields(IHtmlHelper html)
        {
            // filter out zeroes from fields because they are FK violations
            // also filter out fields that are rendered in dropdowns

            // if we're using Dropdowns, then it  means we need to exclude the visible fields from the hidden fields
            var visibleFields = (Dropdowns != null) ?
                                new [] { "teamId", "applicationId", "projectId", "milestoneId", "sizeId" }.Select(s => s.ToLower()) :
            Enumerable.Empty <string>();

            foreach (var kp in ContextValues.Where(kp => kp.Value != 0 && !visibleFields.Contains(kp.Key.ToLower())))
            {
                TagBuilder input = new TagBuilder("input");
                input.MergeAttribute("type", "hidden");
                input.MergeAttribute("name", kp.Key);
                input.MergeAttribute("value", kp.Value.ToString());
                html.ViewContext.Writer.Write(input);
            }

            var returnUrl = new TagBuilder("input");

            returnUrl.MergeAttribute("type", "hidden");
            returnUrl.MergeAttribute("name", "returnUrl");
            returnUrl.MergeAttribute("value", UriHelper.GetDisplayUrl(html.ViewContext.HttpContext.Request));
            html.ViewContext.Writer.Write(returnUrl);

            return(null);
        }
コード例 #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the character style list of the combo box
        /// </summary>
        /// <param name="styleContext">the current Paragraph style context, usually based on
        /// the selection</param>
        /// <param name="view">The currently active view</param>
        /// ------------------------------------------------------------------------------------
        private void RefreshCharStyleComboBoxList(ContextValues styleContext, IRootSite view)
        {
            CharStyleListHelper.IncludeStylesWithContext.Clear();

            FwEditingHelper editingHelper = view.EditingHelper as FwEditingHelper;

            if (editingHelper != null && editingHelper.ApplicableStyleContexts != null)
            {
                CharStyleListHelper.IncludeStylesWithContext.AddRange(editingHelper.ApplicableStyleContexts);
            }
            else
            {
                CharStyleListHelper.IncludeStylesWithContext.Add(styleContext);
                if (!CharStyleListHelper.IncludeStylesWithContext.Contains(ContextValues.General))
                {
                    CharStyleListHelper.IncludeStylesWithContext.Add(ContextValues.General);
                }
                if (editingHelper != null &&
                    !CharStyleListHelper.IncludeStylesWithContext.Contains(editingHelper.InternalContext))
                {
                    CharStyleListHelper.IncludeStylesWithContext.Add(editingHelper.InternalContext);
                }
            }
            CharStyleListHelper.Refresh();
            CharStyleListHelper.ActiveView = view as Control;
        }
コード例 #4
0
 /// -------------------------------------------------------------------------------------
 /// <summary>
 /// Update the style context and do any special processing needed to deal with existing
 /// data that may be marked with the given style. (Since it was previously not an
 /// internal style, it is possible the user has used it in ways that would be
 /// incompatible with its intended use.) Any time a factory style is changed to an
 /// internal context, specific code must be written here to deal with it. Some possible
 /// options for dealing with this scenario are:
 /// * Delete any data previously marked with the style (and possibly set some other
 ///   object properties)
 /// * Add to the m_styleReplacements dictionary so existing data will be marked with a
 ///   different style (note that this will only work if no existing data should be
 ///   preserved with the style).
 /// </summary>
 /// <param name="style">The style being updated</param>
 /// <param name="context">The context (either internal or internal mappable) that the
 /// style is to be given</param>
 /// -------------------------------------------------------------------------------------
 protected override void ChangeFactoryStyleToInternal(IStStyle style, ContextValues context)
 {
     if (!CompatibleContext(style.Context, context))
     {
         if (style.Name == ScrStyleNames.FootnoteTargetRef)
         {
             foreach (var book in m_scr.ScriptureBooksOS)
             {
                 RemoveDirectUsesOfFootnoteTargetRef(book);
             }
             foreach (var draft in m_scr.ArchivedDraftsOC)
             {
                 foreach (var book in draft.BooksOS)
                 {
                     RemoveDirectUsesOfFootnoteTargetRef(book);
                 }
             }
         }
         else if (style.InUse)
         {
             // This is where we should handle any future upgrade issues
         }
     }
     style.Context = context;
 }
コード例 #5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Throw an exception if the specified context is not valid for the specified paragraph
 /// style. TE overrides to forbid 'general' paragraph styles.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="styleName"></param>
 /// ------------------------------------------------------------------------------------
 protected override void ValidateParagraphContext(ContextValues context, string styleName)
 {
     if (context == ContextValues.General)
     {
         ReportInvalidInstallation(String.Format(TeResourceHelper.GetResourceString("ksInvalidParagraphStyleContext"),
                                                 styleName, context.ToString()));
     }
 }
コード例 #6
0
 /// -------------------------------------------------------------------------------------
 /// <summary>
 /// If the proposed context for a style is internal or internalMappable, make sure the
 /// program actually expects and supports this context for this style.
 /// </summary>
 /// <param name="style">The style being updated</param>
 /// <param name="proposedContext">The proposed context for the style</param>
 /// <returns><c>true</c>if the proposed context is internal or internal mappable and
 /// the program recognizes it as a valid</returns>
 /// -------------------------------------------------------------------------------------
 public override bool IsValidInternalStyleContext(IStStyle style,
                                                  ContextValues proposedContext)
 {
     return((proposedContext == ContextValues.Internal &&
             ScrStyleNames.InternalStyles.Contains(style.Name)) ||
            (proposedContext == ContextValues.InternalMappable &&
             ScrStyleNames.InternalMappableStyles.Contains(style.Name)));
 }
コード例 #7
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Complain if the context is not valid for the tool that is loading the styles.
 /// TE currently allows all but Flex's private context
 /// </summary>
 /// <returns></returns>
 /// ------------------------------------------------------------------------------------
 protected override void ValidateContext(ContextValues context, string styleName)
 {
     if (context == ContextValues.InternalConfigureView)
     {
         ReportInvalidInstallation(String.Format(TeResourceHelper.GetResourceString("ksInvalidStyleContext"),
                                                 styleName, context.ToString(), ResourceFileName));
     }
 }
コード例 #8
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Complain if the context is not valid for the tool that is loading the styles.
 /// TE currently allows all but Flex's private context
 /// </summary>
 /// <returns></returns>
 /// ------------------------------------------------------------------------------------
 protected override void ValidateContext(ContextValues context, string styleName)
 {
     if (context == ContextValues.InternalConfigureView)
     {
         ReportInvalidInstallation(String.Format(
                                       "Style {0} is illegally defined with context '{1}' in {2}.",
                                       styleName, context, ResourceFileName));
     }
 }
コード例 #9
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Throw an exception if the specified context is not valid for the specified paragraph
 /// style. TE overrides to forbid 'general' paragraph styles.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="styleName"></param>
 /// ------------------------------------------------------------------------------------
 protected override void ValidateParagraphContext(ContextValues context, string styleName)
 {
     if (context == ContextValues.General)
     {
         ReportInvalidInstallation(String.Format(
                                       "Paragraph style {0} is illegally defined with context '{1}' in TeStyles.xml.",
                                       styleName, context));
     }
 }
コード例 #10
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Returns whether or not the context of the specified style is excluded (i.e., should
 /// not result in the creation of a TE Style).
 /// </summary>
 /// <param name="context">The context to test</param>
 /// <returns>True if the context is excluded, false otherwise</returns>
 /// ------------------------------------------------------------------------------------
 protected override bool IsExcludedContext(ContextValues context)
 {
     return(base.IsExcludedContext(context) ||
            context == ContextValues.BackMatter ||
            context == ContextValues.Book ||
            context == ContextValues.Publication ||
            context == ContextValues.IntroTitle ||
            context == ContextValues.PsuedoStyle ||
            context == ContextValues.InternalConfigureView /* Only used in FLEx */);
 }
コード例 #11
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Updates the styles combo boxes on the formatting toolbar, with the correct style name.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public void UpdateStyleComboBoxValue(IRootSite rootsite)
        {
            // If we don't have a paraStyleListHelper, we can't update the paragraph or
            // character style combo.
            if (ParaStyleListHelper == null || rootsite == null || rootsite.EditingHelper == null)
            {
                return;
            }

            FwEditingHelper fwEditingHelper = rootsite.EditingHelper as FwEditingHelper;

            if (fwEditingHelper != null && fwEditingHelper.IsPictureReallySelected)
            {
                return;
            }

            string paraStyleName = rootsite.EditingHelper.GetParaStyleNameFromSelection();
            var    style         = (paraStyleName == string.Empty) ? null :
                                   ParaStyleListHelper.StyleFromName(paraStyleName);

            RefreshParaStyleComboBoxList(style, rootsite);
            if (ParaStyleListHelper.SelectedStyleName != paraStyleName)
            {
                ParaStyleListHelper.SelectedStyleName = paraStyleName;
            }

            ContextValues currentContext = (style != null) ? style.Context :
                                           (fwEditingHelper != null) ? fwEditingHelper.InternalContext : ContextValues.General;

            if (CharStyleListHelper != null)
            {
                string charStyleName = rootsite.EditingHelper.GetCharStyleNameFromSelection();
                if (CharStyleListHelper.ActiveView != rootsite as Control ||
                    m_prevParaStyleContext != currentContext ||
                    (charStyleName != null && !CharStyleListHelper.Contains(charStyleName)) ||
                    (charStyleName == null && m_prevParaStyleContext == ContextValues.Note) ||
                    (fwEditingHelper != null && fwEditingHelper.ForceCharStyleComboRefresh))
                {
                    RefreshCharStyleComboBoxList(currentContext, rootsite);
                }
                if (charStyleName == string.Empty)
                {
                    charStyleName = StyleUtils.DefaultParaCharsStyleName;
                }
                if (charStyleName == null)
                {
                    charStyleName = string.Empty;
                }
                if (CharStyleListHelper.SelectedStyleName != charStyleName)
                {
                    CharStyleListHelper.SelectedStyleName = charStyleName;
                }
            }
            m_prevParaStyleContext = currentContext;
        }
コード例 #12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Save mapping details
        /// </summary>
        /// <remarks>Caller is responsible for saving the mapping somewhere useful. This
        /// just updates the mapping info.</remarks>
        /// ------------------------------------------------------------------------------------
        public void Save()
        {
            CheckDisposed();

            m_mapping.IsExcluded = chkExclude.Checked;
            if (!chkExclude.Checked)
            {
                m_mapping.Domain = MarkerDomain.Default;

                UpdateMapping(m_mapping, m_styleListHelper.SelectedStyleName);

                StyleListItem styleItem = (StyleListItem)lbStyles.SelectedItem;
                if (styleItem.Type != StyleType.kstCharacter ||
                    m_mapping.StyleName == ResourceHelper.DefaultParaCharsStyleName)
                {
                    if (rbtnFootnotes.Checked)
                    {
                        m_mapping.Domain = MarkerDomain.Footnote;
                    }
                    else if (rbtnNotes.Checked)
                    {
                        m_mapping.Domain = MarkerDomain.Note;
                    }
                    else
                    {
                        m_mapping.Domain = MarkerDomain.Default;
                    }

                    if (chkBackTranslation.Checked)
                    {
                        m_mapping.Domain |= MarkerDomain.BackTrans;
                    }
                }
                else
                {
                    ContextValues context =
                        (ContextValues)m_StyleSheet.GetContext(m_mapping.StyleName);
                    FunctionValues function = m_StyleSheet.GetFunction(m_mapping.StyleName);
                    if (context == ContextValues.BackTranslation ||
                        (context == ContextValues.Title && chkBackTranslation.Checked))
                    {
                        m_mapping.Domain = MarkerDomain.BackTrans;
                    }
                    else if (context == ContextValues.Note || function == FunctionValues.Footnote)
                    {
                        m_mapping.Domain = MarkerDomain.Footnote;
                    }
                }

                m_mapping.WsId = WritingSystem;
            }
        }
コード例 #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Find (or create and store) the ImportStyleProxy for the given style and context.
		/// </summary>
		/// <param name="sStyle">name of a paragraph style</param>
		/// <param name="context">ignored in XML import</param>
		/// <param name="defaultWs">The default writing system to use when creating a new style
		/// proxy.</param>
		/// <returns>The style proxy</returns>
		/// ------------------------------------------------------------------------------------
		public static ImportStyleProxy GetXmlParaStyleProxy(string sStyle, ContextValues context,
			int defaultWs)
		{
			ImportStyleProxy proxy;
			if (string.IsNullOrEmpty(sStyle))
				sStyle = ScrStyleNames.NormalParagraph;
			if (!s_styleProxies.TryGetValue(sStyle, out proxy))
			{
				proxy = new ImportStyleProxy(sStyle, StyleType.kstParagraph, defaultWs,
					context, s_styleSheet);
				s_styleProxies.Add(sStyle, proxy);
			}
			return proxy;
		}
コード例 #14
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Complain if the context is not valid for the tool that is loading the styles.
 /// Flex currently allows general styles and its own special one.
 /// </summary>
 /// <param name="context"></param>
 /// <param name="styleName"></param>
 /// <returns></returns>
 /// ------------------------------------------------------------------------------------
 protected override void ValidateContext(ContextValues context, string styleName)
 {
     if (context != ContextValues.InternalConfigureView &&
         context != ContextValues.Internal &&
         context != ContextValues.General &&
         context != ContextValues.Book &&
         context != ContextValues.Text &&
         context != ContextValues.PsuedoStyle &&
         context != ContextValues.InternalMappable &&
         context != ContextValues.Note &&
         context != ContextValues.Title)
     {
         ReportInvalidInstallation(String.Format(
                                       "Style {0} is illegally defined with context '{1}' in {2}.",
                                       styleName, context, ResourceFileName));
     }
 }
コード例 #15
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Find (or create and store) the ImportStyleProxy for the given style and context.
        /// </summary>
        /// <param name="sStyle">name of a paragraph style</param>
        /// <param name="context">ignored in XML import</param>
        /// <param name="defaultWs">The default writing system to use when creating a new style
        /// proxy.</param>
        /// <returns>The style proxy</returns>
        /// ------------------------------------------------------------------------------------
        public static ImportStyleProxy GetXmlParaStyleProxy(string sStyle, ContextValues context,
                                                            int defaultWs)
        {
            ImportStyleProxy proxy;

            if (string.IsNullOrEmpty(sStyle))
            {
                sStyle = ScrStyleNames.NormalParagraph;
            }
            if (!s_styleProxies.TryGetValue(sStyle, out proxy))
            {
                proxy = new ImportStyleProxy(sStyle, StyleType.kstParagraph, defaultWs,
                                             context, s_styleSheet);
                s_styleProxies.Add(sStyle, proxy);
            }
            return(proxy);
        }
コード例 #16
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Constructor with ContextValues and MarkerDomain as a parameters.
        /// </summary>
        /// <param name="sStyleName">Name of the style.</param>
        /// <param name="styleType">kstCharacter or kstParagraph</param>
        /// <param name="ws">character or paragraph writing system</param>
        /// <param name="context">Context that will be used if this is a new style (otherwise existing
        /// context in DB will be used), see ContextValues for possible types</param>
        /// <param name="domain">The marker domain to use</param>
        /// <param name="styleSheet">The style sheet</param>
        /// ------------------------------------------------------------------------------------
        public ImportStyleProxy(string sStyleName, StyleType styleType, int ws,
                                ContextValues context, MarkerDomain domain, FwStyleSheet styleSheet)
        {
            m_FwStyleSheet = styleSheet;
            m_domain       = domain;
            Debug.Assert(m_FwStyleSheet != null);

            m_ttpFormattingProps = null;
            m_fIsScriptureStyle  = true;     //default
            m_sEndMarker         = null;     //default

            if (context == ContextValues.EndMarker)
            {                       // this proxy represents an end marker - not a style; set bogus info
                sStyleName = "End"; //name does not matter
                styleType  = StyleType.kstCharacter;
            }
            else if (sStyleName != null)
            {
                // Determine whether style exists in the StyleSheet
                Debug.Assert(ws != 0);
                m_style = m_FwStyleSheet.FindStyle(sStyleName);
                if (m_style != null)
                {
                    // If this is an existing style, the actual type, context, structure, and
                    // function always override the requested values.
                    styleType   = m_style.Type;
                    context     = (ContextValues)m_style.Context;
                    m_structure = (StructureValues)m_style.Structure;
                    m_function  = (FunctionValues)m_style.Function;
                }
            }

            m_sStyleName = sStyleName;
            m_StyleType  = styleType;
            m_ws         = ws;
            m_Context    = context;

//			//force StartOfFootnote marker to be processed as a para style proxy having para props
//			if (context == StyleRole.StartOfFootnote)
//				m_StyleType = StyleType.kstParagraph;

            //set the text property vars for this proxy
            SetTextProps();
        }
コード例 #17
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a new style and add it to the Language Project stylesheet.
        /// </summary>
        /// <param name="name">style name</param>
        /// <param name="context">style context</param>
        /// <param name="structure">style structure</param>
        /// <param name="function">style function</param>
        /// <param name="isCharStyle">true if character style, otherwise false</param>
        /// <param name="userLevel">The user level.</param>
        /// <param name="styleCollection">The style collection.</param>
        /// <returns>The style</returns>
        /// ------------------------------------------------------------------------------------
        public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
                                     FunctionValues function, bool isCharStyle, int userLevel,
                                     FdoOwningCollection <IStStyle> styleCollection)
        {
            CheckDisposed();
            ITsPropsBldr bldr  = TsPropsBldrClass.Create();
            StStyle      style = new StStyle();

            styleCollection.Add(style);
            style.Name      = name;
            style.Context   = context;
            style.Structure = structure;
            style.Function  = function;
            style.Rules     = bldr.GetTextProps();
            style.Type      = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
            style.UserLevel = userLevel;

            return(style);
        }
コード例 #18
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a new style on the specified style list.
        /// </summary>
        /// <param name="styleList">The style list to add the style to</param>
        /// <param name="name">style name</param>
        /// <param name="context">style context</param>
        /// <param name="structure">style structure</param>
        /// <param name="function">style function</param>
        /// <param name="isCharStyle">true if character style, otherwise false</param>
        /// <param name="userLevel">User level</param>
        /// <param name="isBuiltIn">true if style is a bult-in style</param>
        /// ------------------------------------------------------------------------------------
        public IStStyle AddStyle(IFdoOwningCollection <IStStyle> styleList, string name,
                                 ContextValues context, StructureValues structure, FunctionValues function,
                                 bool isCharStyle, int userLevel, bool isBuiltIn)
        {
            IStStyle style = Cache.ServiceLocator.GetInstance <IStStyleFactory>().Create();

            styleList.Add(style);
            style.Name      = name;
            style.Context   = context;
            style.Structure = structure;
            style.Function  = function;
            style.Type      = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
            style.UserLevel = userLevel;
            ITsPropsBldr bldr = TsPropsBldrClass.Create();

            style.Rules     = bldr.GetTextProps();
            style.IsBuiltIn = isBuiltIn;
            return(style);
        }
コード例 #19
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Gets the style name that is the default style to use for the given context (this is
        /// the static version)
        /// </summary>
        /// <param name="context">the context</param>
        /// <param name="fCharStyle">set to <c>true</c> for character styles; otherwise
        /// <c>false</c>.</param>
        /// <returns>
        /// Name of the style that is the default for the context
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public static string GetDefaultStyleForContext(ContextValues context, bool fCharStyle)
        {
            if (fCharStyle)
            {
                // The current style is a character style, which means it should have a
                // context of "General". It should be impossible to create a TE
                // paragraph style with no specific Scripture context (i.e. a context of
                // General).
                if (context != ContextValues.General)
                {
                    throw new ArgumentException("Unexpected context for character style.");
                }

                // The default style for character styles is "Default Paragraph Characters",
                // which is represented by string.Empty (TE-5875)
                return(string.Empty);
            }

            switch (context)
            {
            case ContextValues.Annotation:
                return(ScrStyleNames.Remark);

            case ContextValues.Intro:
                return(ScrStyleNames.IntroParagraph);

            case ContextValues.Note:
                return(ScrStyleNames.NormalFootnoteParagraph);

            case ContextValues.Text:
                return(ScrStyleNames.NormalParagraph);

            case ContextValues.Title:
                return(ScrStyleNames.MainBookTitle);

            default:
                throw new ArgumentException("Unexpected context for paragraph style.");
            }
        }
コード例 #20
0
ファイル: TeImport.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get the context and paragraph text properties for this segment.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void GetSegmentInfo()
		{
			m_context = m_styleProxy.Context;

			// Determine the WS/Domain of the paragraph
			if (m_styleProxy.StyleType == StyleType.kstParagraph)
			{
				m_wsPara = m_styleProxy.WritingSystem;
				if (m_wsPara < 0)
					m_wsPara = 0;

				if (m_styleProxy.Domain == MarkerDomain.Default)
				{
					switch (m_importDomain)
					{
						case ImportDomain.Main:
							m_currDomain = MarkerDomain.Default;
							break;
						case ImportDomain.BackTrans:
							m_currDomain = MarkerDomain.BackTrans;
							break;
						case ImportDomain.Annotations:
							m_currDomain = MarkerDomain.Note;
							break;
					}
				}
				else
				{
					m_currDomain = m_styleProxy.Domain;
				}
			}
			else if ((m_importDomain == ImportDomain.Main ||
				(m_importDomain == ImportDomain.BackTrans && m_currDomain == MarkerDomain.Note)) &&
				(m_styleProxy.Function == FunctionValues.Chapter ||
				 m_styleProxy.Function == FunctionValues.Verse))
			{
				// Any chapter or verse number encountered while processing the main (i.e., Scripture)
				// import domain pops us out of any BT or Note paragraph back into the vernacular.
				m_wsPara = m_wsVern;
				m_currDomain = MarkerDomain.Default;
			}

			if (m_styleProxy.Domain != MarkerDomain.Default &&
				(m_styleProxy.Domain != MarkerDomain.Footnote ||
				(m_currDomain & MarkerDomain.Footnote) == 0))
			{
				m_currDomain = m_styleProxy.Domain;
			}
			else if (m_styleProxy.Domain == MarkerDomain.Default &&
				m_styleProxy.Context == ContextValues.EndMarker &&
				(!m_fInCharStyle || m_sCharStyleEndMarker == null))
			{
				m_currDomain = m_styleProxy.Domain;
			}

			// General character styles should be processed as Verse Text if they occur within
			// a verse text paragraph.
			if (m_context == ContextValues.General && m_fInVerseTextParagraph)
				m_context = ContextValues.Text;
		}
コード例 #21
0
ファイル: TeEditingHelper.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="ttpSrcArray">Array of props of each para to be inserted</param>
		/// <param name="tssParas">Array of TsStrings for each para to be inserted</param>
		/// <param name="srcContext">Context of paragraphs to be inserted</param>
		/// <returns>False if we can't allow the insertion</returns>
		/// ------------------------------------------------------------------------------------
		private bool InsertParagraphsBeforeSection(ITsTextProps[] ttpSrcArray,
			ITsString[] tssParas, ContextValues srcContext)
		{
			// save indices, not sure if insertion point will be valid after paragraphs have
			// been added.
			int bookIndex = BookIndex;
			int sectionIndex = SectionIndex;
			ScrBook book = BookFilter.GetBook(bookIndex);
			IScrSection section = book.SectionsOS[sectionIndex - 1];

			if (section.Context != srcContext)
				return false;

			int cAddedSections;
			if (!InsertParagraphsAtSectionEnd(book, section, ttpSrcArray, tssParas,
				sectionIndex, out cAddedSections))
				return false;

			SetInsertionPoint((int)ScrSection.ScrSectionTags.kflidHeading, bookIndex,
				sectionIndex + cAddedSections);
			return true;
		}
コード例 #22
0
ファイル: TeEditingHelper.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the style name that is the default style to use for the given context (this is
		/// the static version)
		/// </summary>
		/// <param name="context">the context</param>
		/// <param name="fCharStyle">set to <c>true</c> for character styles; otherwise
		/// <c>false</c>.</param>
		/// <returns>
		/// Name of the style that is the default for the context
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static string GetDefaultStyleForContext(ContextValues context, bool fCharStyle)
		{
			switch (context)
			{
				case ContextValues.Annotation:
					return ScrStyleNames.Remark;
				case ContextValues.Intro:
					return ScrStyleNames.IntroParagraph;
				case ContextValues.Note:
					return ScrStyleNames.NormalFootnoteParagraph;
				case ContextValues.Text:
					return ScrStyleNames.NormalParagraph;
				case ContextValues.Title:
					return ScrStyleNames.MainBookTitle;
				case ContextValues.General:
					if (fCharStyle)
					{
						// The current style is a character style. It is appropriate for a
						// character style to be the General context. The default style for
						// character styles is "Default Paragraph Characters" which is
						// represented by string.Empty (TE-5875)
						return string.Empty;
					}
					// we shouldn't get here, ever, but if the user has figured out a way to
					// create a style with no context (i.e. a context of general) we need to
					// return something to keep from crashing.
					Debug.Fail("Shouldn't try to get the default style for the General Context.");
					return ScrStyleNames.NormalParagraph;
				default:
					throw new ArgumentException("Unexpected context");
			}
		}
コード例 #23
0
ファイル: FdoTestBase.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style on the specified style list.
		/// </summary>
		/// <param name="styleList">The style list to add the style to</param>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <param name="userLevel">User level</param>
		/// <param name="isBuiltIn">true if style is a bult-in style</param>
		/// ------------------------------------------------------------------------------------
		public IStStyle AddStyle(IFdoOwningCollection<IStStyle> styleList, string name,
			ContextValues context, StructureValues structure, FunctionValues function,
			bool isCharStyle, int userLevel, bool isBuiltIn)
		{
			IStStyle style = Cache.ServiceLocator.GetInstance<IStStyleFactory>().Create();
			styleList.Add(style);
			style.Name = name;
			style.Context = context;
			style.Structure = structure;
			style.Function = function;
			style.Type = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
			style.UserLevel = userLevel;
			ITsPropsBldr bldr = TsPropsBldrClass.Create();
			style.Rules = bldr.GetTextProps();
			style.IsBuiltIn = isBuiltIn;
			return style;
		}
コード例 #24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Complain if the context is not valid for the tool that is loading the styles.
		/// Flex currently allows general styles and its own special one.
		/// </summary>
		/// <param name="context"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected override void ValidateContext(ContextValues context, string styleName)
		{
			if (context != ContextValues.InternalConfigureView &&
				context != ContextValues.Internal &&
				context != ContextValues.General)
				ReportInvalidInstallation(String.Format(FwApp.GetResourceString("ksInvalidStyleContext"),
					styleName, context.ToString(), ResourceFileName));
		}
コード例 #25
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style and add it to the Language Project stylesheet.
		/// </summary>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <param name="userLevel">The user level.</param>
		/// <param name="styleCollection">The style collection.</param>
		/// <returns>The style</returns>
		/// ------------------------------------------------------------------------------------
		public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
			FunctionValues function, bool isCharStyle, int userLevel,
			FdoOwningCollection<IStStyle> styleCollection)
		{
			CheckDisposed();
			ITsPropsBldr bldr = TsPropsBldrClass.Create();
			StStyle style = new StStyle();
			styleCollection.Add(style);
			style.Name = name;
			style.Context = context;
			style.Structure = structure;
			style.Function = function;
			style.Rules = bldr.GetTextProps();
			style.Type = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
			style.UserLevel = userLevel;

			return style;
		}
コード例 #26
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Casts the given contexts values to int.
 /// </summary>
 /// <remarks>Delete this method when we get rid of the old Styles dialog</remarks>
 /// <param name="context">The context.</param>
 /// ------------------------------------------------------------------------------------
 public static int ContextValuesToInt(ContextValues context)
 {
     return((int)context);
 }
コード例 #27
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Create a new style and add it to the Language Project stylesheet.
 /// </summary>
 /// <param name="name">style name</param>
 /// <param name="context">style context</param>
 /// <param name="structure">style structure</param>
 /// <param name="function">style function</param>
 /// <param name="isCharStyle">true if character style, otherwise false</param>
 /// <param name="styleCollection">The style collection.</param>
 /// <returns>The style</returns>
 /// ------------------------------------------------------------------------------------
 public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
                              FunctionValues function, bool isCharStyle, FdoOwningCollection <IStStyle> styleCollection)
 {
     return(AddTestStyle(name, context, structure, function, isCharStyle, 0, styleCollection));
 }
コード例 #28
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Complain if the context is not valid for the tool that is loading the styles.
		/// Flex currently allows general styles and its own special one.
		/// </summary>
		/// <param name="context"></param>
		/// <param name="styleName"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected override void ValidateContext(ContextValues context, string styleName)
		{
			if (context != ContextValues.InternalConfigureView &&
				context != ContextValues.Internal &&
				context != ContextValues.General)
				ReportInvalidInstallation(String.Format(
					"Style {0} is illegally defined with context '{1}' in {2}.",
					styleName, context, ResourceFileName));
		}
コード例 #29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style on the specified style list.
		/// </summary>
		/// <param name="styleList">The style list to add the style to</param>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <param name="userLevel">User level</param>
		/// <param name="isBuiltin">True for a builtin style, otherwise, false.</param>
		/// <returns>The new created (and properly owned style.</returns>
		/// ------------------------------------------------------------------------------------
		public IStStyle Create(IFdoOwningCollection<IStStyle> styleList, string name,
			ContextValues context, StructureValues structure, FunctionValues function,
			bool isCharStyle, int userLevel, bool isBuiltin)
		{
			var retval = new StStyle();
			styleList.Add(retval);
			retval.Name = name;
			retval.Context = context;
			retval.Structure = structure;
			retval.Function = function;
			retval.Type = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
			retval.UserLevel = userLevel;
			retval.IsBuiltIn = isBuiltin;

			return retval;
		}
コード例 #30
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the style name that is the default style to use for the given context
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override string DefaultStyleForContext(ContextValues context, bool fCharStyle)
		{
			return GetDefaultStyleForContext(context, fCharStyle);
		}
コード例 #31
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Gets the style name that is the default style to use for the given context (this is
		/// the static version)
		/// </summary>
		/// <param name="context">the context</param>
		/// <param name="fCharStyle">set to <c>true</c> for character styles; otherwise
		/// <c>false</c>.</param>
		/// <returns>
		/// Name of the style that is the default for the context
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public static string GetDefaultStyleForContext(ContextValues context, bool fCharStyle)
		{
			if (fCharStyle)
			{
				// The current style is a character style, which means it should have a
				// context of "General". It should be impossible to create a TE
				// paragraph style with no specific Scripture context (i.e. a context of
				// General).
				if (context != ContextValues.General)
					throw new ArgumentException("Unexpected context for character style.");

				// The default style for character styles is "Default Paragraph Characters",
				// which is represented by string.Empty (TE-5875)
				return string.Empty;
			}

			switch (context)
			{
				case ContextValues.Annotation:
					return ScrStyleNames.Remark;
				case ContextValues.Intro:
					return ScrStyleNames.IntroParagraph;
				case ContextValues.Note:
					return ScrStyleNames.NormalFootnoteParagraph;
				case ContextValues.Text:
					return ScrStyleNames.NormalParagraph;
				case ContextValues.Title:
					return ScrStyleNames.MainBookTitle;
				default:
					throw new ArgumentException("Unexpected context for paragraph style.");
			}
		}
コード例 #32
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Throw an exception if the specified context is not valid for the specified paragraph
		/// style. TE overrides to forbid 'general' paragraph styles.
		/// </summary>
		/// <param name="context"></param>
		/// <param name="styleName"></param>
		/// ------------------------------------------------------------------------------------
		protected override void ValidateParagraphContext(ContextValues context, string styleName)
		{
			if (context == ContextValues.General)
				ReportInvalidInstallation(String.Format(
					"Paragraph style {0} is illegally defined with context '{1}' in TeStyles.xml.",
					styleName, context));
		}
コード例 #33
0
ファイル: StyleServices.cs プロジェクト: vkarthim/liblcm
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Determines whether the specified context is considered internal (i.e. the user can't
 /// apply it).
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public static bool IsContextInternal(ContextValues context)
 {
     return(context == ContextValues.Internal ||
            context == ContextValues.InternalMappable ||
            context == ContextValues.Note);
 }
コード例 #34
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor with ContextValues as a parameter.
		/// </summary>
		/// <param name="sStyleName">Name of the style.</param>
		/// <param name="styleType">kstCharacter or kstParagraph</param>
		/// <param name="ws">character or paragraph writing system</param>
		/// <param name="context">Context that will be used if this is a new style (otherwise existing
		/// context in DB will be used), see ContextValues for possible types</param>
		/// <param name="styleSheet">The style sheet</param>
		/// ------------------------------------------------------------------------------------
		public ImportStyleProxy(string sStyleName, StyleType styleType, int ws,
			ContextValues context, FwStyleSheet styleSheet)
			: this(sStyleName, styleType, ws, context, MarkerDomain.Default, styleSheet)
		{
		}
コード例 #35
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Detemine whether the newly proposed context for a style is compatible with its
		/// current context.
		/// </summary>
		/// <param name="currContext">The existing context of the style</param>
		/// <param name="proposedContext">The context we want</param>
		/// <returns><c>true </c>if the passed in context can be upgraded as requested;
		/// <c>false</c> otherwise.</returns>
		/// -------------------------------------------------------------------------------------
		public static bool CompatibleContext(ContextValues currContext, ContextValues proposedContext)
		{
			if (currContext == proposedContext)
				return true;
			// Internal and InternalMappable are mutually compatible
			if ((currContext == ContextValues.InternalMappable && proposedContext == ContextValues.Internal) ||
				(proposedContext == ContextValues.InternalMappable && currContext == ContextValues.Internal))
				return true;
			// A (character) style having a specific Context can be made General
			return (proposedContext == ContextValues.General);
		}
コード例 #36
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style and add it to the Language Project stylesheet.
		/// </summary>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <param name="styleCollection">The style collection.</param>
		/// <returns>The style</returns>
		/// ------------------------------------------------------------------------------------
		public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
			FunctionValues function, bool isCharStyle, FdoOwningCollection<IStStyle> styleCollection)
		{
			return AddTestStyle(name, context, structure, function, isCharStyle, 0, styleCollection);
		}
コード例 #37
0
		private DomainObjectDTO CreateCharStyle(string sName, string sProp, ContextValues context)
		{
			DomainObjectDTO dtoStyle;
			Guid guid = Guid.NewGuid();
			string sGuid = guid.ToString().ToLowerInvariant();
			StringBuilder sb = new StringBuilder();
			sb.AppendLine(String.Format("<rt class=\"StStyle\" guid=\"{0}\" ownerguid=\"{1}\">",
				sGuid, m_dtoLangProj.Guid));
			sb.AppendLine("<IsBuiltIn val=\"true\" />");
			sb.AppendLine("<Name>");
			sb.AppendLine(String.Format("<Uni>{0}</Uni>", sName));
			sb.AppendLine("</Name>");
			sb.AppendLine("<Rules>");
			sb.AppendLine(sProp);
			sb.AppendLine("</Rules>");
			sb.AppendLine("<Type val=\"1\" />");
			if (context != ContextValues.General)
				sb.AppendLine(String.Format("<Context val=\"{0}\" />", (int)context));
			sb.AppendLine("</rt>");
			dtoStyle = new DomainObjectDTO(sGuid, "StStyle", sb.ToString());
			m_repoDTO.Add(dtoStyle);
			int idxEnd = m_sLangProjStyles.IndexOf("</Styles>");
			m_sLangProjStyles = m_sLangProjStyles.Insert(idxEnd, String.Format("<objsur guid=\"{0}\" t=\"o\"/>{1}", sGuid, Environment.NewLine));
			return dtoStyle;
		}
コード例 #38
0
ファイル: TeEditingHelper.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine the context and structure of the paragraphs to be inserted
		/// </summary>
		/// <param name="ttpSrcArray">Array of props of each para to be inserted</param>
		/// <param name="srcContext">The context of the paragraphs to be inserted, if they
		/// are all the same; undefined if this method returns false.</param>
		/// <param name="srcStructure">The structure of the paragraphs to be inserted, if they
		/// are all the same; StructureValues.Undefined if there is a mix.</param>
		/// <returns>false if any of the paragraphs to be inserted have null properties OR if
		/// there is a mix of different contexts in the paragraphs</returns>
		/// ------------------------------------------------------------------------------------
		private bool GetSourceContextAndStructure(ITsTextProps[] ttpSrcArray,
			out ContextValues srcContext, out StructureValues srcStructure)
		{
			srcContext = ContextValues.General;
			srcStructure = StructureValues.Undefined;

			for (int i = 0; i < ttpSrcArray.Length; i++)
			{
				string srcStyleName = null;
				if (ttpSrcArray[i] != null)
					srcStyleName = ttpSrcArray[i].GetStrPropValue((int)FwTextStringProp.kstpNamedStyle);

				if (srcStyleName == null)
					continue;

				IStStyle srcStyle = m_scr.FindStyle(srcStyleName);

				if (srcStyle == null || srcStyle.Type != StyleType.kstParagraph || (i > 0 && srcContext != srcStyle.Context))
					return false;

				srcContext = srcStyle.Context;
				srcStructure = (i > 0 && srcStructure != srcStyle.Structure ?
					StructureValues.Undefined : srcStyle.Structure);
			}

			return true;
		}
コード例 #39
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style and add it to the Language Project stylesheet.
		/// </summary>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <returns>The style</returns>
		/// ------------------------------------------------------------------------------------
		public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
			FunctionValues function, bool isCharStyle)
		{
			return AddTestStyle(name, context, structure, function, isCharStyle, Cache.LangProject.StylesOC);
		}
コード例 #40
0
ファイル: FdoTestBase.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style and add it to the Language Project stylesheet.
		/// </summary>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <param name="userLevel">The user level.</param>
		/// <param name="styleCollection">The style collection.</param>
		/// <returns>The style</returns>
		/// ------------------------------------------------------------------------------------
		public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
			FunctionValues function, bool isCharStyle, int userLevel, IFdoOwningCollection<IStStyle> styleCollection)
		{
			return AddStyle(styleCollection, name, context, structure, function, isCharStyle, userLevel, true);
		}
コード例 #41
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Complain if the context is not valid for the tool that is loading the styles.
		/// TE currently allows all but Flex's private context
		/// </summary>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected override void ValidateContext(ContextValues context, string styleName)
		{
			if (context == ContextValues.InternalConfigureView)
			{
				ReportInvalidInstallation(String.Format(TeResourceHelper.GetResourceString("ksInvalidStyleContext"),
					styleName, context.ToString(), ResourceFileName));
			}
		}
コード例 #42
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Gets the style name that is the default style to use for the given context
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected override string DefaultStyleForContext(ContextValues context, bool fCharStyle)
 {
     return(GetDefaultStyleForContext(context, fCharStyle));
 }
コード例 #43
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Throw an exception if the specified context is not valid for the specified paragraph
		/// style. TE overrides to forbid 'general' paragraph styles.
		/// </summary>
		/// <param name="context"></param>
		/// <param name="styleName"></param>
		/// ------------------------------------------------------------------------------------
		protected override void ValidateParagraphContext(ContextValues context, string styleName)
		{
			if (context == ContextValues.General)
				ReportInvalidInstallation(String.Format(TeResourceHelper.GetResourceString("ksInvalidParagraphStyleContext"),
					styleName, context.ToString()));
		}
コード例 #44
0
ファイル: TeEditingHelper.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine the context and structure of the paragraphs to be inserted
		/// </summary>
		/// <param name="ttpSrcArray">Array of props of each para to be inserted</param>
		/// <param name="srcContext">The context of the paragraphs to be inserted, if they
		/// are all the same; undefined if this method returns false.</param>
		/// <param name="srcStructure">The structure of the paragraphs to be inserted, if they
		/// are all the same; StructureValues.Undefined if there is a mix.</param>
		/// <returns>false if any of the paragraphs to be inserted have null properties OR if
		/// there is a mix of different contexts in the paragraphs</returns>
		/// ------------------------------------------------------------------------------------
		private bool GetSourceContextAndStructure(ITsTextProps[] ttpSrcArray,
			out ContextValues srcContext, out StructureValues srcStructure)
		{
			srcContext = ContextValues.General;
			srcStructure = StructureValues.Undefined;

			for(int i = 0; i < ttpSrcArray.Length; i++)
			{
				string srcStyleName = null;
				if (ttpSrcArray[i] != null)
					srcStyleName = ttpSrcArray[i].GetStrPropValue((int)FwTextStringProp.kstpNamedStyle);

				if (srcStyleName == null)
					continue;

				IStStyle srcStyle = m_scr.FindStyle(srcStyleName);
				if (srcStyle == null)
				{
					return false;
					// TODO: Handle case where stuff being pasted from non-FW app begins with a new-line
					//					foundBogusStyle = true;
					//					if (i == 0)
					//					{
					//						ttpSrcArray[0] = ttpDest;
					//						srcStyle = destStyle;
					//					}
					//					else
					//					{
					//						ttpSrcArray[i] = ttpSrcArray[i - 1];
					//						srcStyleName =
					//							ttpSrcArray[i].GetStrPropValue((int)FwTextStringProp.kstpNamedStyle);
					//						srcStyle = m_scr.FindStyle(srcStyleName);
					//					}
				}
				if (i > 0 && srcContext != srcStyle.Context)
					return false;

				srcContext = srcStyle.Context;
				srcStructure = (i > 0 && srcStructure != srcStyle.Structure ?
					StructureValues.Undefined : srcStyle.Structure);
			}

			return true;
		}
コード例 #45
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Update the style context and do any special processing needed to deal with existing
		/// data that may be marked with the given style. (Since it was previously not an
		/// internal style, it is possible the user has used it in ways that would be
		/// incompatible with its intended use.) Any time a factory style is changed to an
		/// internal context, specific code must be written here to deal with it. Some possible
		/// options for dealing with this scenario are:
		/// * Delete any data previously marked with the style (and possibly set some other
		///   object properties)
		/// * Add to the m_deletedStyles or m_replacedStyles arrays so existing data will be
		///   marked with a different style (note that this will only work if no existing data
		///   should be preserved with the style).
		/// </summary>
		/// <param name="style">The style being updated</param>
		/// <param name="context">The context (either internal or internal mappable) that the
		/// style is to be given</param>
		/// -------------------------------------------------------------------------------------
		protected override void ChangeFactoryStyleToInternal(IStStyle style, ContextValues context)
		{
			if (!CompatibleContext((ContextValues)style.Context, context))
			{
				if (style.Name == ScrStyleNames.FootnoteTargetRef)
				{
					foreach (IScrBook book in m_scr.ScriptureBooksOS)
						RemoveDirectUsesOfFootnoteTargetRef(book);
					foreach (IScrDraft draft in m_scr.ArchivedDraftsOC)
					{
						foreach (IScrBook book in draft.BooksOS)
							RemoveDirectUsesOfFootnoteTargetRef(book);
					}
				}
				else if (style.InUse)
				{
					// This is where we should handle any future upgrade issues
				}
			}
			style.Context = context;
		}
コード例 #46
0
ファイル: TeEditingHelper.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Inserts paragraphs into the content of the previous visible book.
		/// </summary>
		/// <param name="ttpSrcArray">Array of props of each para to be inserted</param>
		/// <param name="tssParas">Array of TsStrings for each para to be inserted</param>
		/// <param name="srcContext">Context of paragraphs to be inserted</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		private bool InsertParagraphsBeforeBook(ITsTextProps[] ttpSrcArray,
			ITsString[] tssParas, ContextValues srcContext)
		{
			int prevBook = BookIndex - 1;
			if (prevBook < 0)
				return false;

			ScrBook book = BookFilter.GetBook(prevBook);
			IScrSection section = book.SectionsOS[book.SectionsOS.Count - 1];

			if (section.Context != srcContext)
				return false;

			int cAddedSections;
			return InsertParagraphsAtSectionEnd(book, section, ttpSrcArray, tssParas,
				book.SectionsOS.Count, out cAddedSections);
		}
コード例 #47
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Returns whether or not the context of the specified style is excluded (i.e., should
		/// not result in the creation of a TE Style).
		/// </summary>
		/// <param name="context">The context to test</param>
		/// <returns>True if the context is excluded, false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		protected override bool IsExcludedContext(ContextValues context)
		{
			return (base.IsExcludedContext(context) ||
				context == ContextValues.BackMatter ||
				context == ContextValues.Book ||
				context == ContextValues.Publication ||
				context == ContextValues.IntroTitle ||
				context == ContextValues.PsuedoStyle ||
				context == ContextValues.InternalConfigureView /* Only used in FLEx */);
		}
コード例 #48
0
ファイル: TeImport.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Prepares a new Scripture section section (if needed). Used when the imported data
		/// switches from book title or background information to scripture data.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void PrepareForFirstScriptureSection()
		{
			FinalizePrevParagraph();

			// If there isn't a current section or there is and the section has content, then
			// create an implicit section break before chapter one, verse one of the scripture.
			// Otherwise an implicit section won't be created since it's assumed the current
			// section is the beginning of scripture data (as opposed to intro. or background
			// material.
			if (m_settings.ImportTranslation && m_importDomain == ImportDomain.Main &&
				(m_currSection == null || !m_currSection.IsValidObject() ||
				m_currSection.ContentOA.ParagraphsOS.Count > 0))
			{
				MakeSection();
			}

			m_fInScriptureText = true;
			m_fCurrentSectionIsIntro = false;

			// The paragraph style is set to a default here, but may get reset later, in
			// ProcessSegment. We set the default here because it won't get reset later
			// if the current segment is marked with a character style.
			m_ParaBldr.ParaStylePropsProxy = m_vernParaStyleProxy = m_DefaultScrParaProxy;
			m_context = ContextValues.Text;
		}
コード例 #49
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// If the proposed context for a style is internal or internalMappable, make sure the
		/// program actually expects and supports this context for this style.
		/// </summary>
		/// <param name="style">The style being updated</param>
		/// <param name="proposedContext">The proposed context for the style</param>
		/// <returns><c>true</c>if the proposed context is internal or internal mappable and
		/// the program recognizes it as a valid</returns>
		/// -------------------------------------------------------------------------------------
		public override bool IsValidInternalStyleContext(IStStyle style,
			ContextValues proposedContext)
		{
			return ((proposedContext == ContextValues.Internal &&
				ScrStyleNames.InternalStyles.Contains(style.Name)) ||
				(proposedContext == ContextValues.InternalMappable &&
				ScrStyleNames.InternalMappableStyles.Contains(style.Name)));
		}
コード例 #50
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructor with ContextValues as a parameter.
 /// </summary>
 /// <param name="sStyleName">Name of the style.</param>
 /// <param name="styleType">kstCharacter or kstParagraph</param>
 /// <param name="ws">character or paragraph writing system</param>
 /// <param name="context">Context that will be used if this is a new style (otherwise existing
 /// context in DB will be used), see ContextValues for possible types</param>
 /// <param name="styleSheet">The style sheet</param>
 /// ------------------------------------------------------------------------------------
 public ImportStyleProxy(string sStyleName, StyleType styleType, int ws,
                         ContextValues context, FwStyleSheet styleSheet)
     : this(sStyleName, styleType, ws, context, MarkerDomain.Default, styleSheet)
 {
 }
コード例 #51
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Create a new style and add it to the Language Project stylesheet.
 /// </summary>
 /// <param name="name">style name</param>
 /// <param name="context">style context</param>
 /// <param name="structure">style structure</param>
 /// <param name="function">style function</param>
 /// <param name="isCharStyle">true if character style, otherwise false</param>
 /// <param name="userLevel">The user level.</param>
 /// <param name="styleCollection">The style collection.</param>
 /// <returns>The style</returns>
 /// ------------------------------------------------------------------------------------
 public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
                              FunctionValues function, bool isCharStyle, int userLevel, IFdoOwningCollection <IStStyle> styleCollection)
 {
     return(AddStyle(styleCollection, name, context, structure, function, isCharStyle, userLevel, true));
 }
コード例 #52
0
ファイル: StyleServices.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether the specified context is considered internal (i.e. the user can't
		/// apply it).
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static bool IsContextInternal(ContextValues context)
		{
			return (context == ContextValues.Internal ||
				context == ContextValues.InternalMappable ||
				context == ContextValues.Note);
		}
コード例 #53
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Create a new style and add it to the Language Project stylesheet.
 /// </summary>
 /// <param name="name">style name</param>
 /// <param name="context">style context</param>
 /// <param name="structure">style structure</param>
 /// <param name="function">style function</param>
 /// <param name="isCharStyle">true if character style, otherwise false</param>
 /// <returns>The style</returns>
 /// ------------------------------------------------------------------------------------
 public IStStyle AddTestStyle(string name, ContextValues context, StructureValues structure,
                              FunctionValues function, bool isCharStyle)
 {
     return(AddTestStyle(name, context, structure, function, isCharStyle, Cache.LangProject.StylesOC));
 }
コード例 #54
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor with ContextValues and MarkerDomain as a parameters.
		/// </summary>
		/// <param name="sStyleName">Name of the style.</param>
		/// <param name="styleType">kstCharacter or kstParagraph</param>
		/// <param name="ws">character or paragraph writing system</param>
		/// <param name="context">Context that will be used if this is a new style (otherwise existing
		/// context in DB will be used), see ContextValues for possible types</param>
		/// <param name="domain">The marker domain to use</param>
		/// <param name="styleSheet">The style sheet</param>
		/// ------------------------------------------------------------------------------------
		public ImportStyleProxy(string sStyleName, StyleType styleType, int ws,
			ContextValues context, MarkerDomain domain, FwStyleSheet styleSheet)
		{
			m_FwStyleSheet = styleSheet;
			m_domain = domain;
			Debug.Assert(m_FwStyleSheet != null);

			m_ttpFormattingProps = null;
			m_fIsScriptureStyle = true; //default
			m_sEndMarker = null; //default

			if (context == ContextValues.EndMarker)
			{	// this proxy represents an end marker - not a style; set bogus info
				sStyleName = "End"; //name does not matter
				styleType = StyleType.kstCharacter;
			}
			else if (sStyleName != null)
			{
				// Determine whether style exists in the StyleSheet
				Debug.Assert(ws != 0);
				m_style = m_FwStyleSheet.FindStyle(sStyleName);
				if (m_style != null)
				{
					// If this is an existing style, the actual type, context, structure, and
					// function always override the requested values.
					styleType = m_style.Type;
					context = (ContextValues)m_style.Context;
					m_structure = (StructureValues)m_style.Structure;
					m_function = (FunctionValues)m_style.Function;
				}
			}

			m_sStyleName = sStyleName;
			m_StyleType = styleType;
			m_ws = ws;
			m_Context = context;

//			//force StartOfFootnote marker to be processed as a para style proxy having para props
//			if (context == StyleRole.StartOfFootnote)
//				m_StyleType = StyleType.kstParagraph;

			//set the text property vars for this proxy
			SetTextProps();
		}
コード例 #55
0
		/// -------------------------------------------------------------------------------------
		/// <summary>
		/// Update the style context and do any special processing needed to deal with existing
		/// data that may be marked with the given style. (Since it was previously not an internal
		/// style, it is possible the user has used it in ways that would be incompatible with
		/// its intended use.) Any time a factory style is changed to an internal context,
		/// specific code must be written here to deal with it. Some possible options for dealing
		/// with this scenario are:
		/// * Delete any data previously marked with the style (and possibly set some other
		///   object properties)
		/// * Add to the m_styleReplacements dictionary so existing data will be marked with a
		///   different style (note that this will only work if no existing data should be
		///   preserved with the style).
		/// </summary>
		/// <param name="style">The style being updated</param>
		/// <param name="context">The context (either internal or internal mappable) that the
		/// style is to be given</param>
		/// -------------------------------------------------------------------------------------
		protected virtual void ChangeFactoryStyleToInternal(IStStyle style, ContextValues context)
		{
			// By default nothing to do.
		}