Exemple #1
0
    public static void Create()
    {
        var data  = new BooleanData();
        var style = new TestStyle(data);

        Assert.That(style.Data, Is.SameAs(data));
    }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Store style details in the array.
        /// </summary>
        ///
        /// <param name="sName">The style name</param>
        /// <param name="saUsage">The usage information for the style</param>
        /// <param name="hvoStyle">The style to be stored</param>
        /// <param name="hvoBasedOn">What the style is based on</param>
        /// <param name="hvoNext">The next Style</param>
        /// <param name="nType">The Style type</param>
        /// <param name="fBuiltIn">True if predefined style</param>
        /// <param name="fModified">True if user has modified predefined style</param>
        /// <param name="ttp">TextProps, contains the formatting of the style</param>
        /// -----------------------------------------------------------------------------------
        public void PutStyle(string sName, string saUsage, int hvoStyle, int hvoBasedOn,
                             int hvoNext, int nType, bool fBuiltIn, bool fModified, ITsTextProps ttp)
        {
            TestStyle style = null;             // our local reference

            // Get the matching TestStyle from the List of styles, if it's there
            foreach (TestStyle stStyle in m_rgStyles)
            {
                if (stStyle.Hvo == hvoStyle)
                {
                    style = stStyle;
                    break;
                }
            }
            // If the hvoStyle is not in the List, this is a new style;
            // create a new TestStyle and insert it into the List of styles
            if (style == null)
            {
                style     = new TestStyle();
                style.Hvo = hvoStyle;
                m_rgStyles.Add(style);
            }

            // Save the style properties in the fdocache's style object
            style.Name         = sName;
            style.BasedOnStyle = hvoBasedOn;
            style.NextStyle    = hvoNext;
            style.Type         = nType;
            style.IsBuiltIn    = fBuiltIn;
            style.IsModified   = fModified;
            style.Rules        = ttp;

            m_htStyleRules[sName] = ttp;
        }
        public override void FixtureSetup()
        {
            base.FixtureSetup();

            FwRegistrySettings.Init();
            m_application = new MockFwXApp(new MockFwManager {
                Cache = Cache
            }, null, null);
            var configFilePath = Path.Combine(FwDirectoryFinder.CodeDirectory, m_application.DefaultConfigurationPathname);

            m_window = new MockFwXWindow(m_application, configFilePath);
            ((MockFwXWindow)m_window).Init(Cache);             // initializes Mediator values
            m_mediator = m_window.Mediator;
            m_mediator.AddColleague(new StubContentControlProvider());
            m_window.LoadUI(configFilePath);
            // set up clerk to allow DictionaryPublicationDecorator to be created during the UploadToWebonaryController driven export
            const string reversalIndexClerk = @"<?xml version='1.0' encoding='UTF-8'?>
			<root>
				<clerks>
					<clerk id='entries'>
						<recordList owner='LexDb' property='Entries'/>
					</clerk>
				</clerks>
				<tools>
					<tool label='Dictionary' value='lexiconDictionary' icon='DocumentView'>
						<control>
							<dynamicloaderinfo assemblyPath='xWorks.dll' class='SIL.FieldWorks.XWorks.XhtmlDocView'/>
							<parameters area='lexicon' clerk='entries' layout='Bartholomew' layoutProperty='DictionaryPublicationLayout' editable='false' configureObjectName='Dictionary'/>
						</control>
					</tool>
				</tools>
			</root>"            ;
            var          doc = new XmlDocument();

            doc.LoadXml(reversalIndexClerk);
            XmlNode clerkNode = doc.SelectSingleNode("//tools/tool[@label='Dictionary']//parameters[@area='lexicon']");

            m_Clerk = RecordClerkFactory.CreateClerk(m_mediator, clerkNode, false);
            m_mediator.PropertyTable.SetProperty("ActiveClerk", m_Clerk);
            m_mediator.PropertyTable.SetProperty("ToolForAreaNamed_lexicon", "lexiconDictionary");
            Cache.ProjectId.Path = Path.Combine(FwDirectoryFinder.SourceDirectory, "xWorks/xWorksTests/TestData/");
            // setup style sheet and style to allow the css to generate during the UploadToWebonaryController driven export
            m_styleSheet  = FontHeightAdjuster.StyleSheetFromMediator(m_mediator);
            m_owningTable = new StyleInfoTable("AbbySomebody", (IWritingSystemManager)Cache.WritingSystemFactory);
            var fontInfo     = new FontInfo();
            var letHeadStyle = new TestStyle(fontInfo, Cache)
            {
                Name = CssGenerator.LetterHeadingStyleName, IsParagraphStyle = false
            };
            var dictNormStyle = new TestStyle(fontInfo, Cache)
            {
                Name = CssGenerator.DictionaryNormal, IsParagraphStyle = true
            };

            m_styleSheet.Styles.Add(letHeadStyle);
            m_styleSheet.Styles.Add(dictNormStyle);
            m_owningTable.Add(CssGenerator.LetterHeadingStyleName, letHeadStyle);
            m_owningTable.Add(CssGenerator.DictionaryNormal, dictNormStyle);
        }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Was the (predefined) style named sName changed by the user?
        /// </summary>
        ///
        /// <param name="sName"></param>
        /// <returns></returns>
        /// -----------------------------------------------------------------------------------
        public bool IsModified(string sName)
        {
            TestStyle style = FindStyle(sName);

            if (style != null)
            {
                return(style.IsModified);
            }
            return(false);
        }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Is the style named sName a predefined style?
        /// </summary>
        ///
        /// <param name="sName"></param>
        /// <returns></returns>
        /// -----------------------------------------------------------------------------------
        public bool IsBuiltIn(string sName)
        {
            TestStyle style = FindStyle(sName);

            if (style != null)
            {
                return(style.IsBuiltIn);
            }
            return(false);
        }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Get the type for the style
        /// </summary>
        ///
        /// <param name="sName">Style name</param>
        /// <returns>Returns type of the style (0 by default)</returns>
        /// -----------------------------------------------------------------------------------
        public int GetType(string sName)
        {
            TestStyle style = FindStyle(sName);

            if (style != null)
            {
                return(style.Type);
            }

            return(0);
        }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Get the basedOn style name for the style.
        /// </summary>
        ///
        /// <param name="sName">Name of the style</param>
        /// <returns>Name of the BasedOn style if available, otherwise empty string</returns>
        /// -----------------------------------------------------------------------------------
        public string GetBasedOn(string sName)
        {
            TestStyle style = FindStyle(sName);

            if (style != null && style.BasedOnStyle != 0)
            {
                string sNameBasedOn = GetStyleName(style.BasedOnStyle);
                return((sNameBasedOn != null) ? sNameBasedOn : string.Empty);
            }
            return(string.Empty);
        }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Get the next style that will be used if the user types a CR at the end of this
        /// paragraph. If the input is null, return "Normal".
        /// </summary>
        ///
        /// <param name="sName">Name of the style for this paragraph.</param>
        /// <returns>Name of the style for the next paragraph.</returns>
        /// -----------------------------------------------------------------------------------
        public string GetNextStyle(string sName)
        {
            TestStyle style = FindStyle(sName);

            if (style != null && style.NextStyle != 0)
            {
                string sNameNext = GetStyleName(style.NextStyle);
                return((sNameNext != null) ? sNameNext : "Normal");
            }
            return("Normal");
        }
 /// -----------------------------------------------------------------------------------
 /// <summary>
 /// Delete a style from a stylesheet.
 /// </summary>
 /// <param name="hvoStyle">ID of style to delete.</param>
 /// -----------------------------------------------------------------------------------
 public void Delete(int hvoStyle)
 {
     for (int i = 0; i < m_rgStyles.Count; i++)
     {
         TestStyle style = m_rgStyles[i];
         if (style.Hvo == hvoStyle)
         {
             {
                 m_rgStyles.RemoveAt(i);
                 m_htStyleRules.Remove(style.Name);
                 return;
             }
         }
     }
 }
        /// -----------------------------------------------------------------------------------
        /// <summary>
        /// Set the StyleWs property for the given style, creating an override for the font
        /// for each element in fontOverrides.
        /// </summary>
        /// <param name="styleName">Name of the style whose properties are to be set</param>
        /// <param name="fontOverrides">List of FontOverride's</param>
        /// -----------------------------------------------------------------------------------
        public void OverrideFontsForWritingSystems(string styleName, List <FontOverride> fontOverrides)
        {
            TestStyle    style = FindStyle(styleName);
            ITsPropsBldr propsBldr;

            if (style.Rules != null)
            {
                propsBldr = style.Rules.GetBldr();
            }
            else
            {
                propsBldr = TsPropsBldrClass.Create();
            }

            string propsAsString = String.Empty;

            //Byte[] buffer = new Byte[8 * fontOverrides.Count];
            //int i = 0;
            foreach (FontOverride aFontOverride in fontOverrides)
            {
                // First two characters are the lower and upper words of the writing system ID
                propsAsString += Convert.ToChar(aFontOverride.writingSystem & 0xffff);
                propsAsString += Convert.ToChar(aFontOverride.writingSystem >> 16);
                // Next character is length of font family name (We aren't overriding this)
                propsAsString += Convert.ToChar(0);
                // Next character is the count of overridden properties (always 1)
                propsAsString += Convert.ToChar(1);
                propsAsString += Convert.ToChar((Int16)FwTextPropType.ktptFontSize);
                propsAsString += Convert.ToChar((Int16)FwTextPropVar.ktpvMilliPoint);
                propsAsString += Convert.ToChar((aFontOverride.fontSize * 1000) & 0xffff);
                propsAsString += Convert.ToChar((aFontOverride.fontSize * 1000) >> 16);
//				buffer[i++] = (byte)(aFontOverride.writingSystem & 0xffff);
//				buffer[i++] = (byte)(aFontOverride.writingSystem >> 16);
//				buffer[i++] = 0; // Length of font family name (We aren't overriding this)
//				buffer[i++] = 1; // count of overridden properties
//				buffer[i++] = (byte)FwTextPropType.ktptFontSize;
//				buffer[i++] = (byte)FwTextPropVar.ktpvMilliPoint;
//				buffer[i++] = (byte)(aFontOverride.fontSize & 0xffff);
//				buffer[i++] = (byte)(aFontOverride.fontSize >> 16);
            }
            //string propsAsString = Convert.ToString(ToBase64String(buffer);
            propsBldr.SetStrPropValue((int)FwTextStringProp.kstpWsStyle, propsAsString);
            PutStyle(styleName, string.Empty, style.Hvo, style.BasedOnStyle,
                     style.NextStyle, style.Type, style.IsBuiltIn, true, propsBldr.GetTextProps());
        }
Exemple #11
0
            public RealTest CreateRealTestFrom(RawTest rawTest)
            {
                var test = new RealTest(rawTest.Title, rawTest.Headers, userCache);

                // title is one of: (1) Class.Name (2) cache entry=> (3) cache entry=>Adapter.Class.Name
                Type targetType = AddInstructionsFromTitle(test, rawTest.Title);

                testStyle = DetermineTestType(targetType, rawTest.Headers);
                if (IsOutputTest)
                {
                    ManageActualRowEnumeration(test, targetType);
                }

                AddAutoExecutionWhereApplicable(rawTest, targetType);

                // instruction to repeat over every row of data
                IInstructionParent repeatOverRows = AddRepeatOverRows(test, rawTest.DataRows);

                // instructions repeated for each row of data
                AddRepeatedInstructions(repeatOverRows, rawTest, targetType);

                return test;
            }
Exemple #12
0
 public override TestStyle Add(TestStyle style) =>
 throw new NotImplementedException();
Exemple #13
0
		/// -----------------------------------------------------------------------------------
		/// <summary>
		/// Store style details in the array.
		/// </summary>
		///
		/// <param name="sName">The style name</param>
		/// <param name="saUsage">The usage information for the style</param>
		/// <param name="hvoStyle">The style to be stored</param>
		/// <param name="hvoBasedOn">What the style is based on</param>
		/// <param name="hvoNext">The next Style</param>
		/// <param name="nType">The Style type</param>
		/// <param name="fBuiltIn">True if predefined style</param>
		/// <param name="fModified">True if user has modified predefined style</param>
		/// <param name="ttp">TextProps, contains the formatting of the style</param>
		/// -----------------------------------------------------------------------------------
		public void PutStyle(string sName, string saUsage, int hvoStyle, int hvoBasedOn,
			int hvoNext, int nType, bool fBuiltIn, bool fModified, ITsTextProps ttp)
		{
			TestStyle style = null; // our local reference

			// Get the matching TestStyle from the List of styles, if it's there
			foreach (TestStyle stStyle in m_rgStyles)
			{
				if (stStyle.Hvo == hvoStyle)
				{
					style = stStyle;
					break;
				}
			}
			// If the hvoStyle is not in the List, this is a new style;
			// create a new TestStyle and insert it into the List of styles
			if (style == null)
			{
				style = new TestStyle();
				style.Hvo = hvoStyle;
				m_rgStyles.Add(style);
			}

			// Save the style properties in the fdocache's style object
			style.Name = sName;
			style.BasedOnStyle = hvoBasedOn;
			style.NextStyle = hvoNext;
			style.Type = nType;
			style.IsBuiltIn = fBuiltIn;
			style.IsModified = fModified;
			style.Rules = ttp;

			m_htStyleRules[sName] = ttp;
		}