/// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mini constructor (used for testing)
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string wsId)
     : this(beginMarker, endMarker, isExcluded, mappingTarget,
            domain, styleName, wsId, null)
 {
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style name
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string wsId, ICmAnnotationDefn noteType) :
     this(beginMarker, endMarker, isExcluded, mappingTarget, domain, styleName,
          wsId, noteType, false, ImportDomain.Main /*This will be ignored*/)
 {
 }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style name
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string wsId, ICmAnnotationDefn noteType) :
			this(beginMarker, endMarker, isExcluded, mappingTarget, domain, styleName,
			wsId, noteType, false, ImportDomain.Main /*This will be ignored*/)
		{
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, IStStyle style,
			string wsId, ICmAnnotationDefn noteType) :
			this(beginMarker, endMarker, isExcluded, mappingTarget, domain,
			style == null ? null : style.Name, wsId, noteType)
		{
			m_style = style;
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, IStStyle style,
                          string wsId, ICmAnnotationDefn noteType) :
     this(beginMarker, endMarker, isExcluded, mappingTarget, domain,
          style == null ? null : style.Name, wsId, noteType)
 {
     m_style = style;
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="copy"></param>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(ImportMappingInfo copy)
 {
     m_beginMarker   = copy.m_beginMarker;
     m_endMarker     = copy.m_endMarker;
     m_isExcluded    = copy.m_isExcluded;
     m_mappingTarget = copy.m_mappingTarget;
     m_domain        = copy.m_domain;
     m_styleName     = copy.m_styleName;
     m_style         = copy.m_style;
     m_wsId          = copy.m_wsId;
     m_noteType      = copy.m_noteType;
 }
		/// ----------------------------------------------------------------------------------------
		/// <summary>Constructor</summary>
		/// ----------------------------------------------------------------------------------------
		public MappingInfo(string beginMarker, string endMarker, bool isInline,
			string dataEncoding, MarkerDomain domain,string styleName, string ws,
			bool isExcluded, MappingTargetType mappingTarget)
		{
			this.beginMarker = beginMarker;
			this.endMarker = endMarker;
			this.isInline = isInline;
			this.dataEncoding = dataEncoding;
			this.domain = domain;
			this.styleName = styleName;
			this.ws = ws;
			this.isExcluded = isExcluded;
			this.mappingTarget = mappingTarget;
		}
        /// ------------------------------------------------------------------------------------
        /// <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();
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style name
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string wsId, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
		{
			m_beginMarker = beginMarker;
			m_endMarker = endMarker;
			m_isExcluded = isExcluded;
			m_mappingTarget = mappingTarget;
			m_domain = domain;
			m_styleName = styleName;
			m_style = null;
			m_wsId = wsId;
			m_noteType = noteType;
			if (isInUse)
			{
				m_inUse[ScriptureServices.CreateImportSourceKey(importDomain, wsId,
					noteType)] = isInUse;
			}
		}
Exemple #10
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style name
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string icuLocale, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
 {
     m_beginMarker   = beginMarker;
     m_endMarker     = endMarker;
     m_isExcluded    = isExcluded;
     m_mappingTarget = mappingTarget;
     m_domain        = domain;
     m_styleName     = styleName;
     m_style         = null;
     m_icuLocale     = icuLocale;
     m_noteType      = noteType;
     if (isInUse)
     {
         m_inUse[ScrImportSet.CreateImportSourceKey(importDomain, icuLocale,
                                                    noteType == null ? 0 : noteType.Hvo)] = isInUse;
     }
 }
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Mega constructor with style name
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
                          MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
                          string wsId, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
 {
     m_beginMarker   = beginMarker;
     m_endMarker     = endMarker;
     m_isExcluded    = isExcluded;
     m_mappingTarget = mappingTarget;
     m_domain        = domain;
     m_styleName     = styleName;
     m_style         = null;
     m_wsId          = wsId;
     m_noteType      = noteType;
     if (isInUse)
     {
         m_inUse[ScriptureServices.CreateImportSourceKey(importDomain, wsId,
                                                         noteType)] = isInUse;
     }
 }
Exemple #12
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Get the members of a ScrMarkerMapping into an ImportMappingInfo object
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ImportMappingInfo ToImportMappingInfo()
        {
            MarkerDomain domain = (MarkerDomain)Domain;

            if ((domain & MarkerDomain.DeprecatedScripture) != 0)
            {
                // If this mapping is for DeprecatedScripture, then clear
                // the DeprecatedScripture bit.
                domain ^= MarkerDomain.DeprecatedScripture;
            }

            if (Target == (int)MappingTargetType.DefaultParaChars)
            {
                return(new ImportMappingInfo(BeginMarker, EndMarker, Excluded,
                                             MappingTargetType.TEStyle, domain, StyleUtils.DefaultParaCharsStyleName,
                                             WritingSystem, NoteTypeRA));
            }

            return(new ImportMappingInfo(BeginMarker, EndMarker, Excluded,
                                         (MappingTargetType)Target, domain, StyleRA, WritingSystem, NoteTypeRA));
        }
Exemple #13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finalize the BT of the footnote, if any.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void EndBTFootnote()
		{
			Debug.Assert(m_fInFootnote);
			Debug.Assert(m_BTFootnoteStrBldr != null);
			ITsStrBldr strbldr = m_BTStrBldrs[m_wsCurrBtPara];
			TrimTrailingSpace(m_BTFootnoteStrBldr);
			// If the last character in the paragraph is a separator, then insert the footnote
			// marker before it. (see TE-2431)
			int ichMarker = strbldr.Length;
			if (ichMarker > 0)
			{
				string s = strbldr.GetChars(ichMarker - 1, ichMarker);
				if (UnicodeCharProps.get_IsSeparator(s[0]))
					ichMarker--;
			}
			if (m_CurrBTFootnote != null)
			{
				// Don't support importing multi-para footnotes
				IScrTxtPara para = (IScrTxtPara)m_CurrBTFootnote.ParagraphsOS[0];

				ICmTranslation transl = para.GetOrCreateBT();
				ITsString btTss = m_BTFootnoteStrBldr.Length == 0 ?
					m_TsStringFactory.MakeString(string.Empty, m_wsCurrBtPara) :
					m_BTFootnoteStrBldr.GetString();
				transl.Translation.set_String(m_wsCurrBtPara, btTss);
				m_CurrBTFootnote.InsertRefORCIntoTrans(strbldr, ichMarker, m_wsCurrBtPara);
				m_CurrBTFootnote = null;
			}
			else
			{
				m_BtFootnoteStrBldrs.Add(new BtFootnoteBldrInfo(m_wsCurrBtPara, m_BTFootnoteStrBldr,
					m_sBtFootnoteParaStyle, ichMarker, m_currentRef));
			}
			m_fInFootnote = false;
			m_BTFootnoteStrBldr = null;
			if ((m_styleProxy.Domain & MarkerDomain.Footnote) == 0)
				m_currDomain &= ~MarkerDomain.Footnote;
		}
Exemple #14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mega constructor with style name
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string icuLocale, ICmAnnotationDefn noteType, bool isInUse, ImportDomain importDomain)
		{
			m_beginMarker = beginMarker;
			m_endMarker = endMarker;
			m_isExcluded = isExcluded;
			m_mappingTarget = mappingTarget;
			m_domain = domain;
			m_styleName = styleName;
			m_style = null;
			m_icuLocale = icuLocale;
			m_noteType = noteType;
			if (isInUse)
			{
				m_inUse[ScrImportSet.CreateImportSourceKey(importDomain, icuLocale,
					noteType == null ? 0 : noteType.Hvo)] = isInUse;
			}
		}
Exemple #15
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor (used for testing) for mapping a non-inline marker to a style.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, MarkerDomain domain, string styleName,
			string icuLocale, ICmAnnotationDefn noteType) : this(beginMarker, null, false,
			MappingTargetType.TEStyle, domain, styleName, icuLocale, noteType)
		{
		}
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructor (used for testing) for mapping an inline marker to a style.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, string endMarker, MarkerDomain domain,
                          string styleName, string wsId, ICmAnnotationDefn noteType)
     : this(beginMarker,
            endMarker, false, MappingTargetType.TEStyle, domain, styleName, wsId, noteType)
 {
 }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Determine the default mapping for the given marker
        /// </summary>
        /// <param name="marker">The begin marker</param>
        /// <param name="styleName">The stylename, or null (output)</param>
        /// <param name="excluded">Flag indicating whether data marked up with this marker
        /// should be excluded (output)</param>
        /// <param name="target">Target type (output)</param>
        /// <param name="markerDomain"></param>
        /// <returns><c>true</c> if a default mapping was found for the given marker;
        /// <c>false</c> otherwise.</returns>
        /// ------------------------------------------------------------------------------------
        private bool GetDefaultMapping(string marker, out string styleName, out bool excluded,
                                       out MappingTargetType target, ref MarkerDomain markerDomain)
        {
            styleName = null;
            excluded  = false;
            target    = MappingTargetType.TEStyle;

            if (s_defaultMappings.ContainsKey(marker))
            {
                styleName    = s_defaultMappings[marker];
                markerDomain = ScriptureServices.GetDefaultDomainForStyle(m_stylesheet, styleName);
                return(true);
            }
            if (s_defaultExclusions.ContainsKey(marker))
            {
                excluded = true;
                return(true);
            }
            if (s_defaultProperties.ContainsKey(marker))
            {
                switch (s_defaultProperties[marker])
                {
                case "Figure":
                    target = MappingTargetType.Figure;
                    return(true);

                case "FigureCaption":
                    target = MappingTargetType.FigureCaption;
                    return(true);

                case "FigureCopyright":
                    target = MappingTargetType.FigureCopyright;
                    return(true);

                case "FigureDescription":
                    target = MappingTargetType.FigureDescription;
                    return(true);

                case "FigureFilename":
                    target = MappingTargetType.FigureFilename;
                    return(true);

                case "FigureLayoutPosition":
                    target = MappingTargetType.FigureLayoutPosition;
                    return(true);

                case "FigureRefRange":
                    target = MappingTargetType.FigureRefRange;
                    return(true);

                case "FigureScale":
                    target = MappingTargetType.FigureScale;
                    return(true);

                case "ChapterLabel":
                    target = MappingTargetType.ChapterLabel;
                    return(true);

                case "TitleShort":
                    target = MappingTargetType.TitleShort;
                    return(true);

                case "DefaultParagraphCharacters":
                    target    = MappingTargetType.TEStyle;
                    styleName = ResourceHelper.DefaultParaCharsStyleName;
                    return(true);

                case "DefaultFootnoteCharacters":
                    target       = MappingTargetType.TEStyle;
                    styleName    = ResourceHelper.DefaultParaCharsStyleName;
                    markerDomain = MarkerDomain.Footnote;
                    return(true);
                }
            }
            return(false);
        }
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Add a default mapping for the given Standard Format marker if it does not exist yet.
        /// </summary>
        /// <param name="marker">The SF marker</param>
        /// <param name="endMarker">The end marker (or null)</param>
        /// <param name="importDomain">The import domain from which this marker originates</param>
        /// <param name="fAutoMapBtMarkers">Indicates whether markers beginning with "bt" should
        /// be treated as back-translation markers if possible.</param>
        /// <param name="isInUse">Indicates whether this marker is actually in use in one or more
        /// of the import files (for P6, this is currently always false since we're getting the
        /// markers from the STY file -- we come back in a second pass and set it to true if we
        /// find it in a file).</param>
        /// <returns>The newly added mapping info, or the existing one if already in the list
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public ImportMappingInfo AddDefaultMappingIfNeeded(string marker, string endMarker,
                                                           ImportDomain importDomain, bool fAutoMapBtMarkers, bool isInUse)
        {
            // Look for the marker - if it is found, then we are done
            if (this[marker] != null)
            {
                return(this[marker]);
            }

            // Read the TEStyles XML file to generate a table of mappings
            if (s_defaultMappings.Count == 0)
            {
                ReadDefaultMappings();
            }

            string            styleName;
            bool              excluded;
            MappingTargetType target;
            MarkerDomain      markerDomain = (importDomain != ImportDomain.BackTrans) ?
                                             MarkerDomain.Default : MarkerDomain.BackTrans;

            if (importDomain == ImportDomain.Annotations)
            {
                // TODO (TE-5004): Map \rem (and possibly other markers?) automatically in annotations
                // domain. Probably need to have a separate import mapping set in TeStyles.xml that has
                // default mappings for the Annotations domain.
                styleName = null;
                excluded  = s_defaultExclusions.ContainsKey(marker);                //Make sure to check exclusions (TE-5703)
                target    = MappingTargetType.TEStyle;
            }
            else if (!GetDefaultMapping(marker, out styleName, out excluded, out target, ref markerDomain))
            {
                if (fAutoMapBtMarkers && importDomain == ImportDomain.Main &&
                    marker.StartsWith(@"\bt") && marker != @"\btc")
                {
                    // pick out the corresponding vernacular marker. "\btblah" -> "\blah"
                    string correspondingVernMarker = marker.Remove(1, 2);

                    // if domain is DeprecatedScripture and the corresponding vernacular marker is defined...
                    ImportMappingInfo correspondingVernMarkerInfo = this[correspondingVernMarker];
                    if (correspondingVernMarkerInfo != null &&
                        (correspondingVernMarkerInfo.Domain & MarkerDomain.DeprecatedScripture) != 0)
                    {
                        // clear the DeprecatedScripture bit.
                        correspondingVernMarkerInfo.Domain ^= MarkerDomain.DeprecatedScripture;
                    }
                    if (correspondingVernMarkerInfo != null)
                    {
                        // If the corresponding vernacular marker is already defined...
                        if (correspondingVernMarkerInfo.Domain != MarkerDomain.Note &&
                            (correspondingVernMarkerInfo.Domain & MarkerDomain.BackTrans) == 0 &&
                            (correspondingVernMarkerInfo.MappingTarget != MappingTargetType.TEStyle ||
                             correspondingVernMarkerInfo.StyleName != null))
                        {
                            styleName    = correspondingVernMarkerInfo.StyleName;
                            target       = correspondingVernMarkerInfo.MappingTarget;
                            markerDomain = correspondingVernMarkerInfo.Domain;

                            // We only want to map to the BackTrans domain when mapping to a paragraph
                            // style because character styles automatically assume the domain of their
                            // containing paragraphs.
                            if (m_stylesheet == null || styleName == null ||
                                m_stylesheet.GetType(styleName) == (int)StyleType.kstParagraph)
                            {
                                markerDomain |= MarkerDomain.BackTrans;
                            }
                        }
                    }
                    else if (GetDefaultMapping(correspondingVernMarker, out styleName, out excluded, out target,
                                               ref markerDomain))
                    {
                        // The corresponding vernacular marker has default mapping info so make this marker
                        // a back translation of it - unless it is an annotation or BT.
                        if (markerDomain == MarkerDomain.Note || markerDomain == MarkerDomain.BackTrans)
                        {
                            styleName    = null;
                            excluded     = false;
                            target       = MappingTargetType.TEStyle;
                            markerDomain = MarkerDomain.Default;
                        }
                        else
                        {
                            markerDomain |= MarkerDomain.BackTrans;
                        }
                    }
                }
            }
            // Create a mapping for the marker using the default mapping
            ImportMappingInfo newMapping = new ImportMappingInfo(marker, endMarker, excluded, target,
                                                                 markerDomain, styleName, null, null, isInUse, importDomain);

            Add(newMapping);
            return(newMapping);
        }
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Verify the next mapping in the collection that was created in the database
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void VerifyNextMapping(IEnumerator<IScrMarkerMapping> mappings, string beginMarker, string endMarker,
			MarkerDomain domain, string styleName, string ws, bool excluded, MappingTargetType target)
		{
			Assert.IsTrue(mappings.MoveNext());
			IScrMarkerMapping mapping = mappings.Current;

			Assert.AreEqual(beginMarker, mapping.BeginMarker, "Begin marker did not match for marker " + beginMarker);
			Assert.AreEqual(endMarker, mapping.EndMarker, "End marker did not match for marker " + beginMarker);
			Assert.AreEqual(domain, (MarkerDomain)mapping.Domain, "Domain did not match for marker " + beginMarker);
			if (styleName != null)
				Assert.AreEqual(styleName, mapping.StyleRA.Name, "Style name did not match for marker " + beginMarker);
			else
				Assert.IsNull(mapping.StyleRA, "Style should not have been set for marker " + beginMarker);
			Assert.AreEqual(ws, mapping.WritingSystem, "Writing system did not match for marker " + beginMarker);
			Assert.AreEqual(excluded, mapping.Excluded, "Excluded state was wrong for marker " + beginMarker);
			Assert.AreEqual(target, (MappingTargetType)mapping.Target, "Mapping target type did not match for marker " + beginMarker);
		}
Exemple #20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Finalize the BT of the footnote, if any.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected void EndBTFootnote()
		{
			Debug.Assert(m_fInFootnote);
			Debug.Assert(m_BTFootnoteStrBldr != null);
			ITsStrBldr strbldr = m_BTStrBldrs[m_wsCurrBtPara];
			// No need to assert, since the dictionary will
			// throw an exception if the key is not present.
			//Debug.Assert(strbldr != null);
			TrimTrailingSpace(m_BTFootnoteStrBldr);
			// If the last character in the paragraph is a separator, then insert the footnote
			// marker before it. (see TE-2431)
			int ichMarker = strbldr.Length;
			if (ichMarker > 0)
			{
				string s = strbldr.GetChars(ichMarker - 1, ichMarker);
				if (UnicodeCharProps.get_IsSeparator(s[0]))
					ichMarker--;
			}
			if (m_CurrBTFootnote != null)
			{
				// Don't support importing multi-para footnotes
				StTxtPara para = (StTxtPara)m_CurrBTFootnote.ParagraphsOS[0];

				ICmTranslation transl = para.GetOrCreateBT();
				transl.Translation.GetAlternative(m_wsCurrBtPara).UnderlyingTsString =
					(m_BTFootnoteStrBldr.Length == 0) ?
					m_TsStringFactory.MakeString(string.Empty, m_wsCurrBtPara) :
					m_BTFootnoteStrBldr.GetString();
				m_CurrBTFootnote.InsertRefORCIntoTrans(strbldr, ichMarker, m_wsCurrBtPara);
				m_CurrBTFootnote = null;
			}
			else
			{
				m_BtFootnoteStrBldrs.Add(new BtFootnoteBldrInfo(m_wsCurrBtPara, m_BTFootnoteStrBldr,
					m_sBtFootnoteParaStyle, ichMarker, m_currentRef));
			}
			m_fInFootnote = false;
			m_BTFootnoteStrBldr = null;
			//m_BtFootnoteStrBldrs.Clear();
			//m_currDomain = MarkerDomain.Default; // TODO: Do like EndFootnote
			if ((m_styleProxy.Domain & MarkerDomain.Footnote) == 0)
				m_currDomain &= ~MarkerDomain.Footnote;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Copy constructor
		/// </summary>
		/// <param name="copy"></param>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(ImportMappingInfo copy)
		{
			m_beginMarker = copy.m_beginMarker;
			m_endMarker = copy.m_endMarker;
			m_isExcluded = copy.m_isExcluded;
			m_mappingTarget = copy.m_mappingTarget;
			m_domain = copy.m_domain;
			m_styleName = copy.m_styleName;
			m_style = copy.m_style;
			m_wsId = copy.m_wsId;
			m_noteType = copy.m_noteType;
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructor (used for testing) for mapping an inline marker to a style.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, MarkerDomain domain,
			string styleName, string wsId, ICmAnnotationDefn noteType)
			: this(beginMarker,
				endMarker, false, MappingTargetType.TEStyle, domain, styleName, wsId, noteType)
		{
		}
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Mini constructor (used for testing)
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public ImportMappingInfo(string beginMarker, string endMarker, bool isExcluded,
			MappingTargetType mappingTarget, MarkerDomain domain, string styleName,
			string wsId)
			: this(beginMarker, endMarker, isExcluded, mappingTarget,
				domain, styleName, wsId, null)
		{
		}
Exemple #24
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}
Exemple #25
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determine the default mapping for the given marker
		/// </summary>
		/// <param name="marker">The begin marker</param>
		/// <param name="styleName">The stylename, or null (output)</param>
		/// <param name="excluded">Flag indicating whether data marked up with this marker
		/// should be excluded (output)</param>
		/// <param name="target">Target type (output)</param>
		/// <param name="markerDomain"></param>
		/// <returns><c>true</c> if a default mapping was found for the given marker;
		/// <c>false</c> otherwise.</returns>
		/// ------------------------------------------------------------------------------------
		private bool GetDefaultMapping(string marker, out string styleName, out bool excluded,
			out MappingTargetType target, ref MarkerDomain markerDomain)
		{
			styleName = null;
			excluded = false;
			target = MappingTargetType.TEStyle;

			if (s_defaultMappings.ContainsKey(marker))
			{
				styleName = s_defaultMappings[marker];
				markerDomain = ScrMarkerMapping.GetDefaultDomainForStyle(m_stylesheet, styleName);
				return true;
			}
			if (s_defaultExclusions.ContainsKey(marker))
			{
				excluded = true;
				return true;
			}
			if (s_defaultProperties.ContainsKey(marker))
			{
				switch(s_defaultProperties[marker])
				{
					case "Figure":
						target = MappingTargetType.Figure;
						return true;

					case "FigureCaption":
						target = MappingTargetType.FigureCaption;
						return true;

					case "FigureCopyright":
						target = MappingTargetType.FigureCopyright;
						return true;

					case "FigureDescription":
						target = MappingTargetType.FigureDescription;
						return true;

					case "FigureFilename":
						target = MappingTargetType.FigureFilename;
						return true;

					case "FigureLayoutPosition":
						target = MappingTargetType.FigureLayoutPosition;
						return true;

					case "FigureRefRange":
						target = MappingTargetType.FigureRefRange;
						return true;

					case "FigureScale":
						target = MappingTargetType.FigureScale;
						return true;

					case "ChapterLabel":
						target = MappingTargetType.ChapterLabel;
						return true;

					case "TitleShort":
						target = MappingTargetType.TitleShort;
						return true;

					case "DefaultParagraphCharacters":
						target = MappingTargetType.TEStyle;
						styleName = FdoResources.DefaultParaCharsStyleName;
						return true;

					case "DefaultFootnoteCharacters":
						target = MappingTargetType.TEStyle;
						styleName = FdoResources.DefaultParaCharsStyleName;
						markerDomain = MarkerDomain.Footnote;
						return true;
				}
			}
			return false;
		}
Exemple #26
0
		// TODO BryanW: Someday handle additional paragraphs in a footnote
		// protected void AddParaToFootnote(string sText, byte[] rgbParaProps)

		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// When finished adding all segments of the current footnote, call this to reset
		/// builder and other state variables to resume normal segment processing and increment
		/// the footnote counter.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void EndFootnote()
		{
			if (m_BTFootnoteStrBldr != null)
			{
				EndBTFootnote();
				return;
			}
			Debug.Assert(m_fInFootnote);
			m_ParaBldr.TrimTrailingSpaceInPara();
			// Create the paragraph even if the contents are empty; otherwise user will have no
			// way to enter contents later.
			m_lastPara = m_ParaBldr.CreateParagraph(m_CurrFootnote.Hvo);
			m_fInFootnote = false;
			m_sFootnoteBeginMarker = null;
			m_iCurrFootnote++; // increment for next footnote
			m_ParaBldr = m_SavedParaBldr;
			m_CurrFootnote = null;
			if ((m_styleProxy.Domain & MarkerDomain.Footnote) == 0)
				m_currDomain &= ~MarkerDomain.Footnote;
			// ENHANCE: For now, we just let the settings of the very first footnote dictate
			// what they will all look like. Later, we should do some statistical analysis.
			m_fInterpretFootnoteSettings = false;
		}
Exemple #27
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructor (used for testing) for mapping a non-inline marker to a style.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public ImportMappingInfo(string beginMarker, MarkerDomain domain, string styleName,
                          string icuLocale, ICmAnnotationDefn noteType) : this(beginMarker, null, false,
                                                                               MappingTargetType.TEStyle, domain, styleName, icuLocale, noteType)
 {
 }
		/// ------------------------------------------------------------------------------------
		/// <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();
		}
Exemple #29
0
        public void Test_AreProjectsAccessible()
        {
            CheckDisposed();

            ///	This test shows how to use the three new methods on the ParatextProjectProxy object.
            ///	To effectivly run a test in this environment, a resource file is needed that has PT
            ///	projects that can be added to the ParatextProjectProxy object.  With valid projects
            ///	the put assignments will not raise an exception.
            ///

            IParatextProjectProxy ptProject = new ParatextProjectProxyClass();

            MarkerDomain md = MarkerDomain.MD_Unknown;

            if (md == MarkerDomain.MD_Back)                     // needed to remove the CS0219 warning...
            {
                md = MarkerDomain.MD_Note;
            }

            string projectName = "";

            try
            {
                md                      = MarkerDomain.MD_Vern;
                projectName             = "PTVern";
                ptProject.VernTransProj = projectName;

                md                      = MarkerDomain.MD_Back;
                projectName             = "PTBack";
                ptProject.VernTransProj = projectName;

                md                      = MarkerDomain.MD_Note;
                projectName             = "PTNote";
                ptProject.VernTransProj = projectName;
            }
            catch
            {
                string msg;
                msg = "Unable to Add project: " + projectName;
                System.Diagnostics.Debug.WriteLine(msg);
            }

            int markerDomainsNotAccessible = ptProject.AreProjectsAccessible;

            if (markerDomainsNotAccessible != 0)
            {
                string projectFileName, msg;

                if (((byte)(markerDomainsNotAccessible) & (byte)(MarkerDomain.MD_Vern)) != 0)
                {
                    ptProject.GetProjectFilename(MarkerDomain.MD_Vern, out projectFileName);
                    msg = "Project file not Accessible: " + projectFileName;
                    System.Diagnostics.Debug.WriteLine(msg);
                }

                if (((byte)(markerDomainsNotAccessible) & (byte)(MarkerDomain.MD_Back)) != 0)
                {
                    ptProject.GetProjectFilename(MarkerDomain.MD_Back, out projectFileName);
                    msg = "Project file not Accessible: " + projectFileName;
                    System.Diagnostics.Debug.WriteLine(msg);
                }

                if (((byte)(markerDomainsNotAccessible) & (byte)(MarkerDomain.MD_Note)) != 0)
                {
                    ptProject.GetProjectFilename(MarkerDomain.MD_Note, out projectFileName);
                    msg = "Project file not Accessible: " + projectFileName;
                    System.Diagnostics.Debug.WriteLine(msg);
                }
            }
        }