コード例 #1
0
ファイル: BulletInfoTests.cs プロジェクト: bbriggs/FieldWorks
		public void Setup()
		{
			m_infoTable = new StyleInfoTable("Normal", null);
			BaseStyleInfo styleInfo = new BaseStyleInfo();
			m_infoTable.Add("TestStyle", styleInfo);
			m_infoTable.ConnectStyles();
		}
コード例 #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the specified new style.
		/// </summary>
		/// <param name="newStyle">The new style.</param>
		/// ------------------------------------------------------------------------------------
		public override void Add(BaseStyleInfo newStyle)
		{
			base.Add(newStyle);
			int index = ListBoxControl.FindStringExact(newStyle.Name);
			ListBoxControl.SelectedIndex = index;
		}
コード例 #3
0
ファイル: FwGeneralTab.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Fills the following styles combo for a specific style
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		private void FillFollowingStyles(BaseStyleInfo styleInfo)
		{
			m_cboFollowingStyle.Items.Clear();

			// Add all of the styles of the same type
			List<string> styleList = new List<string>();
			foreach (BaseStyleInfo style in m_styleTable.Values)
			{
				// If the style types are not the same, then do not allow them.
				if (style.IsCharacterStyle != styleInfo.IsCharacterStyle)
					continue;
				// TE-6346: Add this style to the list if it's already the following style for the
				// given styleInfo, even if it's an internal style because internal styles can have
				// themselves as their own following style.
				if (styleInfo.NextStyle == style || !style.IsInternalStyle)
					styleList.Add(style.Name);
			}
			styleList.Sort();
			m_cboFollowingStyle.Items.AddRange(styleList.ToArray());
		}
コード例 #4
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Removes the specified style from the list
		/// </summary>
		/// <param name="style">The style.</param>
		/// ------------------------------------------------------------------------------------
		public virtual void Remove(BaseStyleInfo style)
		{
			m_styleItemList.Remove(style.Name);
			Refresh();
		}
コード例 #5
0
		public void CreateCopy()
		{
			IStStyle testStyle = AddTestStyle("Title Main", ContextValues.Title,
				StructureValues.Body, FunctionValues.Prose, false, m_scr.StylesOC);

			BaseStyleInfo basedOnInfo = new BaseStyleInfo();
			DummyStyleInfo origInfo = new DummyStyleInfo();
			origInfo.Name = "original";
			origInfo.Usage = "This is the original style";
			origInfo.BasedOnStyle = basedOnInfo;
			origInfo.NextStyle = origInfo;
			origInfo.IsParagraphStyle = true;
			origInfo.Context = ContextValues.Publication;
			origInfo.Structure = StructureValues.Heading;
			origInfo.Function = FunctionValues.List;
			origInfo.ExplicitRightToLeftStyle = false;
			origInfo.UserLevel = 2;
			origInfo.RealStyle = testStyle;
			origInfo.IsBuiltIn = true;

			BaseStyleInfo newInfo = new BaseStyleInfo(origInfo, "new");
			Assert.AreEqual("new", newInfo.Name);
			Assert.AreEqual(origInfo.Usage, newInfo.Usage);
			Assert.AreEqual(origInfo.BasedOnStyle, newInfo.BasedOnStyle);
			Assert.AreEqual(origInfo.NextStyle, newInfo.NextStyle);
			Assert.AreEqual(origInfo.IsParagraphStyle, newInfo.IsParagraphStyle);
			Assert.AreEqual(origInfo.Context, newInfo.Context);
			Assert.AreEqual(origInfo.Structure, newInfo.Structure);
			Assert.AreEqual(origInfo.Function, newInfo.Function);
			Assert.AreEqual(TriStateBool.triFalse, newInfo.DirectionIsRightToLeft);
			Assert.AreEqual(origInfo.UserLevel, newInfo.UserLevel);

			Assert.AreEqual(null, newInfo.RealStyle, "a copy of a style should not have a DB style backing it");
			Assert.AreEqual(false, newInfo.IsBuiltIn, "Copies of styles should not be considered built in");
		}
コード例 #6
0
ファイル: StyleListItem.cs プロジェクト: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Constructs a StyleListItem (i.e. an StStyle object) based on a real style.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public StyleListItem(BaseStyleInfo styleInfo)
		{
			m_styleInfo = styleInfo;
		}
コード例 #7
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Initializes a new instance of the <see cref="StyleInfo"/> class. This constructor
 /// is used to make a copy of a style with a new name.
 /// </summary>
 /// <param name="copyFrom">The copy from.</param>
 /// <param name="newName">name for the new copied style</param>
 /// ------------------------------------------------------------------------------------
 public StyleInfo(BaseStyleInfo copyFrom, string newName) : base(copyFrom, newName)
 {
     m_dirty = true;
 }
コード例 #8
0
        private void WriteFontAndParagraphRulesXml(ExportStyleInfo style, XmlWriter writer, string basedOnStyle, BaseStyleInfo nextStyle)
        {
            if (style.FontInfoForWs(-1) == null)
            {
                writer.WriteStartElement("font");
                writer.WriteEndElement();
                return;
            }
            // Generate the font info (the font element is required by the DTD even if it has no attributes)
            writer.WriteStartElement("font");
            IEnumerable <Tuple <string, string> > fontProps = CollectFontProps(style.FontInfoForWs(-1));

            if (fontProps.Any())
            {
                foreach (var prop in fontProps)
                {
                    writer.WriteAttributeString(prop.Item1, prop.Item2);
                }
            }
            foreach (var writingSystem in Cache.LangProject.AllWritingSystems)
            {
                var wsOverrideProps = CollectFontProps(style.FontInfoForWs(writingSystem.Handle));
                if (wsOverrideProps.Any())
                {
                    writer.WriteStartElement("override");
                    writer.WriteAttributeString("wsId", writingSystem.RFC5646);
                    foreach (var prop in wsOverrideProps)
                    {
                        writer.WriteAttributeString(prop.Item1, prop.Item2);
                    }
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();             // font
            IEnumerable <Tuple <string, string> > paragraphProps = CollectParagraphProps(style, basedOnStyle, nextStyle);

            if (paragraphProps.Any())
            {
                writer.WriteStartElement("paragraph");
                foreach (var prop in paragraphProps)
                {
                    writer.WriteAttributeString(prop.Item1, prop.Item2);
                }
                writer.WriteEndElement();                 // paragraph
            }
        }
コード例 #9
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the specified new style.
 /// </summary>
 /// <param name="newStyle">The new style.</param>
 /// ------------------------------------------------------------------------------------
 public virtual void Add(BaseStyleInfo newStyle)
 {
     m_styleItemList.Add(newStyle.Name, new StyleListItem(newStyle));
     Refresh();
 }
コード例 #10
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Removes the specified style from the list
 /// </summary>
 /// <param name="style">The style.</param>
 /// ------------------------------------------------------------------------------------
 public virtual void Remove(BaseStyleInfo style)
 {
     m_styleItemList.Remove(style.Name);
     Refresh();
 }
コード例 #11
0
		public void MergeWritingSystemWithStyleDefnForToWs_DoesNotConvertStyleDefinition()
		{
			IWritingSystem fromWs;
			WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-NO", true, false, out fromWs);
			IWritingSystem toWs;
			WritingSystemServices.FindOrCreateWritingSystem(Cache, null, "en-SO", true, false, out toWs);
			EnsureAnalysisWs(new[] { fromWs, toWs });

			var style1 = Cache.ServiceLocator.GetInstance<IStStyleFactory>().Create();
			Cache.LangProject.StylesOC.Add(style1);
			var fontOverrides = new Dictionary<int, FontInfo>();
			var fontOverride = new FontInfo();
			fontOverride.m_italic.ExplicitValue = true;
			fontOverrides[fromWs.Handle] = fontOverride;
			fontOverride = new FontInfo();
			fontOverride.m_bold.ExplicitValue = true;
			fontOverrides[toWs.Handle] = fontOverride;
			var bldr = TsPropsBldrClass.Create();
			BaseStyleInfo.SaveFontOverridesToBuilder(fontOverrides, bldr);
			style1.Rules = bldr.GetTextProps();
			m_actionHandler.EndUndoTask();
			UndoableUnitOfWorkHelper.Do("doit", "undoit", m_actionHandler,
				() => WritingSystemServices.MergeWritingSystems(Cache, fromWs, toWs));
			var styleInfo = new BaseStyleInfo(style1);
			var overrideInfo = styleInfo.OverrideCharacterStyleInfo(toWs.Handle);
			Assert.IsNotNull(overrideInfo);
			Assert.That(overrideInfo.Bold.Value, Is.True);
			Assert.That(overrideInfo.Italic.ValueIsSet, Is.False);
		}
コード例 #12
0
ファイル: FwGeneralTab.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines if style1 derives from style2 or if the styles are the same
		/// </summary>
		/// <param name="style1">style 1</param>
		/// <param name="style2">style 2</param>
		/// <returns>true if style1 derives from style2</returns>
		/// ------------------------------------------------------------------------------------
		private bool DerivesFromOrSame(BaseStyleInfo style1, BaseStyleInfo style2)
		{
			while (style1 != null)
			{
				if (style2.Name == style1.Name)
					return true;
				style1 = style1.BasedOnStyle;
			}
			return false;
		}
コード例 #13
0
ファイル: FwGeneralTab.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Determines whether or not the specified base style can be used as a base for the
		/// specified style
		/// </summary>
		/// <param name="baseStyle">The base style</param>
		/// <param name="styleInfo">The style</param>
		/// <returns>True if the base style can be used as a base for the specified style,
		/// false otherwise</returns>
		/// ------------------------------------------------------------------------------------
		private bool StylesCanBeABaseFor(BaseStyleInfo baseStyle, BaseStyleInfo styleInfo)
		{
			// If the style is not in the DB yet, then we want to allow any style to be a base
			// so the user can select something
			if (styleInfo.RealStyle == null)
				return true;

			// Styles can always be based on general styles
			if (baseStyle.Context == ContextValues.General)
				return true;

			// If the base style is actually the base style of the style, then show it in the
			// list
			if (styleInfo.BasedOnStyle == baseStyle)
				return true;

			// Otherwise, the context, structure and function of the style must match for a
			// style to be based on it.
			return (baseStyle.Context == styleInfo.Context &&
				baseStyle.Structure == styleInfo.Structure &&
				baseStyle.Function == baseStyle.Function);
		}
コード例 #14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Removes the specified style from the list
		/// </summary>
		/// <param name="style">The style.</param>
		/// ------------------------------------------------------------------------------------
		public override void Remove(BaseStyleInfo style)
		{
			// Save the index of the selected item so it can be restored later.
			int oldSelectedIndex = ListBoxControl.SelectedIndex;

			base.Remove(style);

			if (oldSelectedIndex >= ListBoxControl.Items.Count)
				--oldSelectedIndex;
			ListBoxControl.SelectedIndex = oldSelectedIndex;
		}
コード例 #15
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Saves the style information to the DB.
        /// </summary>
        /// <param name="style">The StStyle to save to.</param>
        /// <param name="existingStyle"><c>true</c> if the style exists; otherwise <c>false</c></param>
        /// <param name="isModified">if set to <c>true</c> the user has made changes to the
        /// properties of the style so that they may differ from the factory defaults
        /// (caller is not required to guarantee absolutely that the properties do in fact
        /// differ, since the user could set the properties back to the original values).</param>
        /// ------------------------------------------------------------------------------------
        public void SaveToDB(IStStyle style, bool existingStyle, bool isModified)
        {
            Debug.Assert(IsValid);

            m_style    = style;
            style.Name = m_name;
            style.Usage.UserDefaultWritingSystem = TsStringUtils.MakeString(
                m_usage,
                Cache.ServiceLocator.WritingSystemManager.UserWs);
            style.Type = m_styleType;
            if (IsBuiltIn)
            {
                style.IsModified = isModified;
            }
            else
            {
                // We need to update the context, structure, and function to be what the base
                // style is. We only want to do this for user styles so we don't override what
                // is set in the stylesheet.
                // Go down the inheritance chain until we find a value to be based on.
                BaseStyleInfo basedOn = RealBasedOnStyleInfo;

                if (!existingStyle)                 // Never change the context, etc. for an existing style
                {
                    if (basedOn != null)
                    {
                        // If the based-on style cannot be inherited from, then this style must
                        // be a copy of another style, from which it will have inherited its
                        // context, structure, and function.
                        if (basedOn.CanInheritFrom && basedOn.UserLevel > 0)
                        {
                            m_context   = basedOn.Context;
                            m_structure = basedOn.Structure;
                            m_function  = basedOn.Function;
                        }
                    }
                    else if (IsParagraphStyle)
                    {
                        throw new ArgumentException("A user-defined paragraph style must have a real based-on style");
                    }
                }
            }
            style.Context   = m_context;
            style.Structure = m_structure;
            style.Function  = m_function;
            style.UserLevel = m_userLevel;

            // Build the text props
            ITsPropsBldr styleProps = TsStringUtils.MakePropsBldr();

            if (m_defaultFontInfo.m_fontName.IsExplicit)
            {
                styleProps.SetStrPropValue((int)FwTextPropType.ktptFontFamily,
                                           m_defaultFontInfo.m_fontName.Value);
            }

            if (m_bulletInfo.IsExplicit)
            {
                m_bulletInfo.Value.ConvertAsTextProps(styleProps);
            }

            if (m_defaultFontInfo.m_bold.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptBold,
                                            (int)FwTextPropVar.ktpvEnum,
                                            m_defaultFontInfo.m_bold.Value ?
                                            (int)FwTextToggleVal.kttvInvert :
                                            (int)FwTextToggleVal.kttvOff);
            }

            if (m_defaultFontInfo.m_italic.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptItalic,
                                            (int)FwTextPropVar.ktpvEnum,
                                            m_defaultFontInfo.m_italic.Value ?
                                            (int)FwTextToggleVal.kttvInvert :
                                            (int)FwTextToggleVal.kttvOff);
            }

            if (m_defaultFontInfo.m_superSub.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptSuperscript, 0,
                                            (int)m_defaultFontInfo.m_superSub.Value);
            }

            if (m_defaultFontInfo.m_fontSize.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptFontSize, 0,
                                            m_defaultFontInfo.m_fontSize.Value);
            }

            if (m_defaultFontInfo.m_fontColor.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptForeColor, 0,
                                            (int)ColorUtil.ConvertColorToBGR(m_defaultFontInfo.m_fontColor.Value));
            }

            if (m_defaultFontInfo.m_backColor.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptBackColor, 0,
                                            (int)ColorUtil.ConvertColorToBGR(m_defaultFontInfo.m_backColor.Value));
            }

            if (m_defaultFontInfo.m_offset.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptOffset,
                                            (int)FwTextPropVar.ktpvMilliPoint,
                                            m_defaultFontInfo.m_offset.Value);
            }

            if (m_defaultFontInfo.m_underline.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptUnderline, 0,
                                            (int)m_defaultFontInfo.m_underline.Value);
            }

            if (m_defaultFontInfo.m_underlineColor.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptUnderColor, 0,
                                            (int)ColorUtil.ConvertColorToBGR(m_defaultFontInfo.m_underlineColor.Value));
            }

            if (m_defaultFontInfo.m_features.IsExplicit)
            {
                styleProps.SetStrPropValue((int)FwTextPropType.ktptFontVariations,
                                           m_defaultFontInfo.m_features.Value);
            }

            if (m_rtl.IsExplicit && m_rtl.Value != TriStateBool.triNotSet)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptRightToLeft, 0,
                                            (m_rtl.Value == TriStateBool.triTrue) ? 1 : 0);
            }

            if (m_alignment.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptAlign,
                                            (int)FwTextPropVar.ktpvEnum, (int)m_alignment.Value);
            }

            if (m_spaceBefore.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptSpaceBefore, 0,
                                            m_spaceBefore.Value);
            }

            if (m_spaceAfter.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptSpaceAfter, 0,
                                            m_spaceAfter.Value);
            }

            if (m_firstLineIndent.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptFirstIndent, 0,
                                            m_firstLineIndent.Value);
            }

            if (m_leadingIndent.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptLeadingIndent, 0,
                                            m_leadingIndent.Value);
            }

            if (m_trailingIndent.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptTrailingIndent, 0,
                                            m_trailingIndent.Value);
            }

            if (m_lineSpacing.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptLineHeight,
                                            m_lineSpacing.Value.m_relative ?
                                            (int)FwTextPropVar.ktpvRelative : (int)FwTextPropVar.ktpvMilliPoint,
                                            m_lineSpacing.Value.m_lineHeight);
            }

            if (m_border.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderTop,
                                            0, m_border.Value.Top);
                styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderBottom,
                                            0, m_border.Value.Bottom);
                styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderLeading,
                                            0, m_border.Value.Leading);
                styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderTrailing,
                                            0, m_border.Value.Trailing);
            }

            if (m_borderColor.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptBorderColor, 0,
                                            (int)ColorUtil.ConvertColorToBGR(m_borderColor.Value));
            }

            if (m_keepWithNext.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptKeepWithNext, 0,
                                            (m_keepWithNext.Value) ? 1 : 0);
            }

            if (m_keepTogether.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptKeepTogether, 0,
                                            (m_keepTogether.Value) ? 1 : 0);
            }

            if (m_widowOrphanControl.IsExplicit)
            {
                styleProps.SetIntPropValues((int)FwTextPropType.ktptWidowOrphanControl, 0,
                                            (m_widowOrphanControl.Value) ? 1 : 0);
            }

            SaveFontOverridesToBuilder(m_fontInfoOverrides, styleProps);

            style.Rules = styleProps.GetTextProps();
        }
コード例 #16
0
 /// <summary>
 /// Copy constructor, builds an ExportStyleInfo from a BaseStyleInfo
 /// </summary>
 /// <param name="style"></param>
 public ExportStyleInfo(BaseStyleInfo style) : base(style, "export" + style.Name)
 {
 }
コード例 #17
0
 /// <summary>
 ///
 /// </summary>
 public StyleComboItem(BaseStyleInfo sty)
 {
     m_style = sty;
 }
コード例 #18
0
        /// <summary>
        /// Collects the paragraph info for the style in tuples of attribute name, attribute value
        /// </summary>
        private IEnumerable <Tuple <string, string> > CollectParagraphProps(ExportStyleInfo styleRules, string basedOnStyle, BaseStyleInfo nextStyle)
        {
            var paragraphProps = new List <Tuple <string, string> >();

            GetPointPropAttribute((int)FwTextPropType.ktptSpaceBefore, "spaceBefore", styleRules.RealStyle.Rules, paragraphProps);
            GetPointPropAttribute((int)FwTextPropType.ktptSpaceAfter, "spaceAfter", styleRules.RealStyle.Rules, paragraphProps);
            GetPointPropAttribute((int)FwTextPropType.ktptLeadingIndent, "indentLeft", styleRules.RealStyle.Rules, paragraphProps);
            GetPointPropAttribute((int)FwTextPropType.ktptTrailingIndent, "indentRight", styleRules.RealStyle.Rules, paragraphProps);
            GetColorValueAttribute((int)FwTextPropType.ktptBackColor, "background", styleRules.RealStyle.Rules, paragraphProps);
            if (basedOnStyle != null)
            {
                paragraphProps.Add(new Tuple <string, string>("basedOn", GetStyleId(basedOnStyle)));
            }
            if (nextStyle != null)
            {
                paragraphProps.Add(new Tuple <string, string>("next", GetStyleId(nextStyle)));
            }
            if (styleRules.HasFirstLineIndent)
            {
                // hanging and firstLine are stored in an overloaded property value, negative for hanging, positive for firstline
                if (styleRules.FirstLineIndent < 0)
                {
                    paragraphProps.Add(new Tuple <string, string>("hanging", -(styleRules.FirstLineIndent / 1000) + " pt"));
                }
                else
                {
                    paragraphProps.Add(new Tuple <string, string>("firstLine", styleRules.FirstLineIndent / 1000 + " pt"));
                }
            }
            if (styleRules.HasAlignment)
            {
                var    alignment  = styleRules.Alignment;
                string alignValue = "none";
                switch (alignment)
                {
                case FwTextAlign.ktalCenter:
                    alignValue = "center";
                    break;

                case FwTextAlign.ktalLeft:
                    alignValue = "left";
                    break;

                case FwTextAlign.ktalRight:
                    alignValue = "right";
                    break;

                case FwTextAlign.ktalJustify:
                    alignValue = "full";
                    break;
                }
                paragraphProps.Add(new Tuple <string, string>("alignment", alignValue));
            }
            if (styleRules.HasLineSpacing)
            {
                string lineSpaceType;
                // relative is used for single, 1.5, double space
                if (styleRules.LineSpacing.m_relative)
                {
                    lineSpaceType = "rel";
                }
                else if (styleRules.LineSpacing.m_lineHeight <= 0)
                {
                    // for historical reasons negative values mean exact, and positive mean at least
                    // (see: Framework\StylesXmlAccessor.cs SetParagraphProperties())
                    lineSpaceType = "exact";
                }
                else
                {
                    lineSpaceType = "atleast";
                }
                var lineSpace = Math.Abs(styleRules.LineSpacing.m_lineHeight) / 1000 + " pt";
                paragraphProps.Add(new Tuple <string, string>("lineSpacing", lineSpace));
                paragraphProps.Add(new Tuple <string, string>("lineSpacingType", lineSpaceType));
            }

            return(paragraphProps);
        }
コード例 #19
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Constructs a StyleListItem (i.e. an StStyle object) based on a real style.
 /// </summary>
 /// ------------------------------------------------------------------------------------
 public StyleListItem(BaseStyleInfo styleInfo)
 {
     m_styleInfo = styleInfo;
 }
コード例 #20
0
		public void ConstructBasedOnStyleAndEffects()
		{
			IStStyle mainTitleStyle = AddTestStyle("Title Main", ContextValues.Title,
				StructureValues.Body, FunctionValues.Prose, false, Cache.LangProject.StylesOC);
			var props = TsPropsFactoryClass.Create().MakeProps("rubbish", Cache.DefaultAnalWs, 0);
			var sut = new BaseStyleInfo(mainTitleStyle, props);
			Assert.That(sut.Cache, Is.EqualTo(Cache));
		}
コード例 #21
0
        private void WriteFontAndParagraphRulesXml(ExportStyleInfo style, XmlWriter writer, string basedOnStyle, BaseStyleInfo nextStyle)
        {
            if (style.FontInfoForWs(-1) == null)
            {
                writer.WriteStartElement("font");
                writer.WriteEndElement();
                return;
            }
            // Generate the font info (the font element is required by the DTD even if it has no attributes)
            writer.WriteStartElement("font");
            IEnumerable <Tuple <string, string> > fontProps = CollectFontProps(style.FontInfoForWs(-1));

            if (fontProps.Any())
            {
                foreach (var prop in fontProps)
                {
                    writer.WriteAttributeString(prop.Item1, prop.Item2);
                }
            }
            foreach (var writingSystem in Cache.LangProject.AllWritingSystems)
            {
                var wsOverrideProps = CollectFontProps(style.FontInfoForWs(writingSystem.Handle));
                if (wsOverrideProps.Any())
                {
                    writer.WriteStartElement("override");
                    writer.WriteAttributeString("wsId", writingSystem.LanguageTag);
                    foreach (var prop in wsOverrideProps)
                    {
                        writer.WriteAttributeString(prop.Item1, prop.Item2);
                    }
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();             // font
            IEnumerable <Tuple <string, string> > paragraphProps = CollectParagraphProps(style, basedOnStyle, nextStyle);

            if (paragraphProps.Any())
            {
                writer.WriteStartElement("paragraph");
                foreach (var prop in paragraphProps)
                {
                    writer.WriteAttributeString(prop.Item1, prop.Item2);
                }

                //Bullet/Number FontInfo
                try
                {
                    IEnumerable <Tuple <string, string> > bulNumParaProperty = CollectBulletProps(style.BulletInfo);
                    foreach (var prop in bulNumParaProperty)
                    {
                        string propName = prop.Item1;
                        if (BulletPropertyMap.ContainsKey(propName.ToLower()))
                        {
                            propName = BulletPropertyMap[propName.ToLower()];
                        }
                        writer.WriteAttributeString(propName, prop.Item2);
                    }
                    // Generate the font info (the font element is required by the DTD even if it has no attributes)
                    writer.WriteStartElement("BulNumFontInfo");
                    IEnumerable <Tuple <string, string> > bulletFontInfoProperties = CollectFontProps(style.BulletInfo.FontInfo);
                    if (bulletFontInfoProperties.Any())
                    {
                        foreach (var prop in bulletFontInfoProperties)
                        {
                            writer.WriteAttributeString(prop.Item1, prop.Item2);
                        }
                    }
                    writer.WriteEndElement();                     // bullet
                }
                catch {}
                writer.WriteEndElement();                 // paragraph
            }
        }
コード例 #22
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the specified new style.
		/// </summary>
		/// <param name="newStyle">The new style.</param>
		/// ------------------------------------------------------------------------------------
		public virtual void Add(BaseStyleInfo newStyle)
		{
			m_styleItemList.Add(newStyle.Name, new StyleListItem(newStyle));
			Refresh();
		}
コード例 #23
0
 /// <summary>
 /// Converts the style name into the 'id' attribute expected by the code that reads in stylesheet files
 /// </summary>
 private static string GetStyleId(BaseStyleInfo style)
 {
     return(GetStyleId(style.Name));
 }
コード例 #24
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the given style info entry to the table.
		/// </summary>
		/// <param name="key">The key of the element to add (typically a TE Stylename, but may
		/// be another unique token (if this entry represents a style which is not known to
		/// exist)</param>
		/// <param name="value">The value of the element to add (must not be null)</param>
		/// <exception cref="T:System.ArgumentException">An element with the same key already
		/// exists in the <see cref="T:System.Collections.Generic.Dictionary`2"></see>.</exception>
		/// <exception cref="T:System.ArgumentNullException">key or value is null.</exception>
		/// ------------------------------------------------------------------------------------
		public override void Add(string key, BaseStyleInfo value)
		{
			base.Add(key, value);
			// We need to set the P6 Marker based on the key, but only if it's null. If it's
			// not null, this is probably a case where an entry is being re-keyed based on the
			// TE style name, so we should leave the P6 marker as is.
			UsfmStyEntry entry = (UsfmStyEntry)value;
			if (entry.P6Marker == null)
				entry.P6Marker = key.Replace(' ', '_');
		}
コード例 #25
0
ファイル: StyleInfo.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="StyleInfo"/> class. This constructor
		/// is used to make a copy of a style with a new name.
		/// </summary>
		/// <param name="copyFrom">The copy from.</param>
		/// <param name="newName">name for the new copied style</param>
		/// ------------------------------------------------------------------------------------
		public StyleInfo(BaseStyleInfo copyFrom, string newName): base(copyFrom, newName)
		{
			m_dirty = true;
		}
コード例 #26
0
			public StyleComboItem(BaseStyleInfo sty)
			{
				m_style = sty;
			}
コード例 #27
0
ファイル: FwGeneralTab.cs プロジェクト: bbriggs/FieldWorks
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Fills the based on styles combo for a specific style
		/// </summary>
		/// <param name="styleInfo">The style info.</param>
		/// ------------------------------------------------------------------------------------
		private void FillBasedOnStyles(BaseStyleInfo styleInfo)
		{
			m_cboBasedOn.Items.Clear();

			// If this is a character style then put in "Default Paragraph Characters"
			if (styleInfo.IsCharacterStyle)
				m_cboBasedOn.Items.Add(StyleUtils.DefaultParaCharsStyleName);

			// Add all of the styles that are not myself or any style that derives from me and
			// have the same context as me
			List<string> styleList = new List<string>();
			foreach (BaseStyleInfo baseStyle in m_styleTable.Values)
			{
				// If the style types are not the same, then do not allow them.
				if (baseStyle.IsCharacterStyle != styleInfo.IsCharacterStyle)
					continue;
				// TE-6344: If styleInfo is already based on baseStyle, then we must include baseStyle
				// in the list, even if it is not normally a style that can be a based-on
				// style. This allows a style with a context of internal (such as "Normal" in
				// TE) to appear in the list when it is the basis for a built-in or copied style.
				if (styleInfo.BasedOnStyle == baseStyle)
				{
					Debug.Assert(!DerivesFromOrSame(baseStyle, styleInfo)); // Sanity check for circular reference
					styleList.Add(baseStyle.Name);
				}
				else if (!DerivesFromOrSame(baseStyle, styleInfo) && baseStyle.CanInheritFrom &&
					StylesCanBeABaseFor(baseStyle, styleInfo))
				{
					styleList.Add(baseStyle.Name);
				}
			}
			styleList.Sort();
			m_cboBasedOn.Items.AddRange(styleList.ToArray());
		}