Esempio n. 1
0
        public void BuildCmFilter2()
        {
            // Setup test values
            Cache.LangProject.PeopleOA = Cache.ServiceLocator.GetInstance <ICmPossibilityListFactory>().Create();
            ICmPossibility person1 = Cache.ServiceLocator.GetInstance <ICmPersonFactory>().Create();

            Cache.LangProject.PeopleOA.PossibilitiesOS.Add(person1);
            person1.ForeColor = 5;
            person1.BackColor = 10;

            // Setup filter
            IFdoOwningCollection <ICmFilter> filtersCol = Cache.LangProject.FiltersOC;
            ICmFilter filter = Cache.ServiceLocator.GetInstance <ICmFilterFactory>().Create();

            filtersCol.Add(filter);
            filter.ColumnInfo = CmPossibilityTags.kClassId + "," + CmPossibilityTags.kflidForeColor
                                + "|" + CmPossibilityTags.kClassId + "," + CmPossibilityTags.kflidBackColor;
            ICmRow row = Cache.ServiceLocator.GetInstance <ICmRowFactory>().Create();

            filter.RowsOS.Add(row);
            ICmCell cell1 = Cache.ServiceLocator.GetInstance <ICmCellFactory>().Create();

            row.CellsOS.Add(cell1);
            cell1.Contents = makeString("= 5");
            ICmCell cell2 = Cache.ServiceLocator.GetInstance <ICmCellFactory>().Create();

            row.CellsOS.Add(cell2);
            cell2.Contents = makeString("= 10");

            // Check the result
            filter.InitCriteria();
            Assert.IsTrue(filter.MatchesCriteria(person1.Hvo));
        }
Esempio n. 2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Create a new style on the specified style list.
        /// </summary>
        /// <param name="styleList">The style list to add the style to</param>
        /// <param name="name">style name</param>
        /// <param name="context">style context</param>
        /// <param name="structure">style structure</param>
        /// <param name="function">style function</param>
        /// <param name="isCharStyle">true if character style, otherwise false</param>
        /// <param name="userLevel">User level</param>
        /// <param name="isBuiltIn">true if style is a bult-in style</param>
        /// ------------------------------------------------------------------------------------
        public IStStyle AddStyle(IFdoOwningCollection <IStStyle> styleList, string name,
                                 ContextValues context, StructureValues structure, FunctionValues function,
                                 bool isCharStyle, int userLevel, bool isBuiltIn)
        {
            IStStyle style = Cache.ServiceLocator.GetInstance <IStStyleFactory>().Create();

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

            style.Rules     = bldr.GetTextProps();
            style.IsBuiltIn = isBuiltIn;
            return(style);
        }
Esempio n. 3
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Save the in-memory mapping lists for the given mapping set
		/// </summary>
		/// <param name="mappingsOC">The owning collection of ScrMarkerMapping objects in the
		/// database</param>
		/// <param name="mappingInfoList">The in-memory list of ImportMappingInfo objects</param>
		/// ------------------------------------------------------------------------------------
		private void SaveMappings(IFdoOwningCollection<IScrMarkerMapping> mappingsOC, ScrMappingList mappingInfoList)
		{
			UndoableUnitOfWorkHelper.DoUsingNewOrCurrentUOW("Save mappings", "Save mappings",
				m_cache.ServiceLocator.GetInstance<IActionHandler>(), () =>
			{
				mappingsOC.Clear();
				foreach (ImportMappingInfo info in mappingInfoList)
				{
					IScrMarkerMapping mapping = Services.GetInstance<IScrMarkerMappingFactory>().Create();
					mappingsOC.Add(mapping);
					// The "Default Paragraph Characters" style is not a real style. So, we save it as
					// as separate target type. We want to set the style now for the in-memory info.
					if (info.StyleName == StyleUtils.DefaultParaCharsStyleName)
						info.MappingTarget = MappingTargetType.DefaultParaChars;
					else if (info.Style == null || info.Style.Name != info.StyleName)
						info.SetStyle(m_cache.LangProject.TranslatedScriptureOA.FindStyle(info.StyleName));
					((ScrMarkerMapping)mapping).InitFromImportMappingInfo(info);
				}
			});
		}
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Creates 2 fake HF sets for use in testing
        /// </summary>
        /// <returns>the created publication</returns>
        /// ------------------------------------------------------------------------------------
        private IPublication CreateFakeHFSets()
        {
            // create a publication
            IPublication pub = Cache.ServiceLocator.GetInstance <IPublicationFactory>().Create();

            Cache.LanguageProject.LexDbOA.PublicationsOC.Add(pub);
            IPubDivision pubDiv = Cache.ServiceLocator.GetInstance <IPubDivisionFactory>().Create();

            pub.DivisionsOS.Add(pubDiv);

            // create the current HF set for the publication
            pubDiv.HFSetOA = Cache.ServiceLocator.GetInstance <IPubHFSetFactory>().Create();
            IPubHeaderFactory phFactory = Cache.ServiceLocator.GetInstance <IPubHeaderFactory>();

            pubDiv.HFSetOA.DefaultHeaderOA = phFactory.Create();
            pubDiv.HFSetOA.DefaultFooterOA = phFactory.Create();
            pubDiv.HFSetOA.FirstHeaderOA   = phFactory.Create();
            pubDiv.HFSetOA.FirstFooterOA   = phFactory.Create();
            pubDiv.HFSetOA.EvenHeaderOA    = phFactory.Create();
            pubDiv.HFSetOA.EvenFooterOA    = phFactory.Create();
            pubDiv.HFSetOA.Name            = "Test HF Set of Matthew printed in Tabaluga";

            // create a dummy HF set
            int           userWs = Cache.WritingSystemFactory.UserWs;
            ITsStrFactory tsf    = Cache.TsStrFactory;
            IPubHFSet     hfset  = Cache.ServiceLocator.GetInstance <IPubHFSetFactory>().Create();

            m_hfSets.Add(hfset);
            hfset.Name            = "Test HF Set created today";
            hfset.Description     = tsf.MakeString("This is a test HF set", userWs);
            hfset.DefaultHeaderOA = phFactory.Create();
            hfset.DefaultFooterOA = phFactory.Create();
            hfset.EvenHeaderOA    = phFactory.Create();
            hfset.EvenFooterOA    = phFactory.Create();
            hfset.FirstFooterOA   = phFactory.Create();
            hfset.FirstHeaderOA   = phFactory.Create();
            hfset.DefaultFooterOA.OutsideAlignedText = tsf.MakeString("outside text", userWs);
            hfset.DefaultFooterOA.CenteredText       = tsf.MakeString("Song of songs", userWs);
            hfset.EvenHeaderOA.CenteredText          = tsf.MakeString("Song even pages", userWs);
            hfset.EvenHeaderOA.InsideAlignedText     = tsf.MakeString("Inside text", userWs);
            hfset.FirstFooterOA.InsideAlignedText    = tsf.MakeString("Inside text", userWs);

            // create another dummy HF set
            IPubHFSet hfset2 = Cache.ServiceLocator.GetInstance <IPubHFSetFactory>().Create();

            m_hfSets.Add(hfset2);
            hfset2.Name            = "Test HF Set of Matthew printed in Tabaluga";
            hfset2.Description     = tsf.MakeString("This is another test HF set", userWs);
            hfset2.DefaultHeaderOA = phFactory.Create();
            hfset2.DefaultFooterOA = phFactory.Create();
            hfset2.EvenHeaderOA    = phFactory.Create();
            hfset2.EvenFooterOA    = phFactory.Create();
            hfset2.FirstFooterOA   = phFactory.Create();
            hfset2.FirstHeaderOA   = phFactory.Create();
            hfset2.DefaultHeaderOA.OutsideAlignedText =
                TsStringUtils.CreateOrcFromGuid(HeaderFooterVc.PageNumberGuid,
                                                FwObjDataTypes.kodtContextString, Cache.DefaultUserWs);
            hfset2.DefaultFooterOA.CenteredText    = tsf.MakeString("Matthew", userWs);
            hfset2.EvenFooterOA.CenteredText       = tsf.MakeString("From Reference", userWs);
            hfset2.EvenHeaderOA.InsideAlignedText  = tsf.MakeString("nothing", userWs);
            hfset2.FirstFooterOA.InsideAlignedText = tsf.MakeString("Inside text", userWs);

            return(pub);
        }
Esempio n. 5
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style on the specified style list.
		/// </summary>
		/// <param name="styleList">The style list to add the style to</param>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <param name="userLevel">User level</param>
		/// <param name="isBuiltin">True for a builtin style, otherwise, false.</param>
		/// <returns>The new created (and properly owned style.</returns>
		/// ------------------------------------------------------------------------------------
		public IStStyle Create(IFdoOwningCollection<IStStyle> styleList, string name,
			ContextValues context, StructureValues structure, FunctionValues function,
			bool isCharStyle, int userLevel, bool isBuiltin)
		{
			var retval = new StStyle();
			styleList.Add(retval);
			retval.Name = name;
			retval.Context = context;
			retval.Structure = structure;
			retval.Function = function;
			retval.Type = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
			retval.UserLevel = userLevel;
			retval.IsBuiltIn = isBuiltin;

			return retval;
		}
Esempio n. 6
0
		/// <summary>
		/// Make a slot which can be identified as the specified type.
		/// For this to be true, the slot must have an msa, owned by a LexEntry, which owns a form, which has
		/// the required type.
		/// </summary>
		IMoInflAffixSlot MakeSlot(IFdoServiceLocator services, IFdoOwningCollection<IMoInflAffixSlot> dest, Guid slotType)
		{
			var entry = services.GetInstance<ILexEntryFactory>().Create();
			var form = services.GetInstance<IMoAffixAllomorphFactory>().Create();
			entry.LexemeFormOA = form;
			form.MorphTypeRA = services.GetInstance<IMoMorphTypeRepository>().GetObject(slotType);
			var msa = services.GetInstance<IMoInflAffMsaFactory>().Create();
			entry.MorphoSyntaxAnalysesOC.Add(msa);
			var slot = services.GetInstance<IMoInflAffixSlotFactory>().Create();
			dest.Add(slot);
			msa.SlotsRC.Add(slot);
			// slot.Affixes.Add(msa); does not add it!
			return slot;
		}
Esempio n. 7
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a new style on the specified style list.
		/// </summary>
		/// <param name="styleList">The style list to add the style to</param>
		/// <param name="name">style name</param>
		/// <param name="context">style context</param>
		/// <param name="structure">style structure</param>
		/// <param name="function">style function</param>
		/// <param name="isCharStyle">true if character style, otherwise false</param>
		/// <param name="userLevel">User level</param>
		/// <param name="isBuiltIn">true if style is a bult-in style</param>
		/// ------------------------------------------------------------------------------------
		public IStStyle AddStyle(IFdoOwningCollection<IStStyle> styleList, string name,
			ContextValues context, StructureValues structure, FunctionValues function,
			bool isCharStyle, int userLevel, bool isBuiltIn)
		{
			IStStyle style = Cache.ServiceLocator.GetInstance<IStStyleFactory>().Create();
			styleList.Add(style);
			style.Name = name;
			style.Context = context;
			style.Structure = structure;
			style.Function = function;
			style.Type = (isCharStyle ? StyleType.kstCharacter : StyleType.kstParagraph);
			style.UserLevel = userLevel;
			ITsPropsBldr bldr = TsPropsBldrClass.Create();
			style.Rules = bldr.GetTextProps();
			style.IsBuiltIn = isBuiltIn;
			return style;
		}