示例#1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FwApplyStyleDlg"/> class.
		/// </summary>
		/// <param name="rootSite">The root site.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="hvoStylesOwner">The hvo of the object which owns the style.</param>
		/// <param name="stylesTag">The "flid" in which the styles are owned.</param>
		/// <param name="normalStyleName">Name of the normal style.</param>
		/// <param name="customUserLevel">The custom user level.</param>
		/// <param name="paraStyleName">Name of the currently selected paragraph style.</param>
		/// <param name="charStyleName">Name of the currently selected character style.</param>
		/// <param name="hvoRootObject">The hvo of the root object in the current view.</param>
		/// <param name="app">The application.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public FwApplyStyleDlg(IVwRootSite rootSite, FdoCache cache, int hvoStylesOwner,
			int stylesTag, string normalStyleName, int customUserLevel, string paraStyleName,
			string charStyleName, int hvoRootObject, IApp app,
			IHelpTopicProvider helpTopicProvider)
		{
			m_rootSite = rootSite;
			InitializeComponent();
			m_customUserLevel = customUserLevel;
			m_helpTopicProvider = helpTopicProvider;
			m_paraStyleName = paraStyleName;
			m_charStyleName = charStyleName;

			// Cache is null in tests
			if (cache == null)
				return;

			m_cboTypes.SelectedIndex = 1; // All Styles

			// Load the style information
			m_styleTable = new StyleInfoTable(normalStyleName,
				cache.ServiceLocator.WritingSystemManager);
			m_styleSheet = new FwStyleSheet();
			m_styleSheet.Init(cache, hvoStylesOwner, stylesTag);
			m_styleListHelper = new StyleListBoxHelper(m_lstStyles);
			m_styleListHelper.ShowInternalStyles = false;
		}
示例#2
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="T:FwApplyStyleDlg"/> class.
        /// </summary>
        /// <param name="rootSite">The root site.</param>
        /// <param name="cache">The cache.</param>
        /// <param name="hvoStylesOwner">The hvo of the object which owns the style.</param>
        /// <param name="stylesTag">The "flid" in which the styles are owned.</param>
        /// <param name="normalStyleName">Name of the normal style.</param>
        /// <param name="customUserLevel">The custom user level.</param>
        /// <param name="paraStyleName">Name of the currently selected paragraph style.</param>
        /// <param name="charStyleName">Name of the currently selected character style.</param>
        /// <param name="hvoRootObject">The hvo of the root object in the current view.</param>
        /// <param name="app">The application.</param>
        /// <param name="helpTopicProvider">The help topic provider.</param>
        /// ------------------------------------------------------------------------------------
        public FwApplyStyleDlg(IVwRootSite rootSite, FdoCache cache, int hvoStylesOwner,
                               int stylesTag, string normalStyleName, int customUserLevel, string paraStyleName,
                               string charStyleName, int hvoRootObject, IApp app,
                               IHelpTopicProvider helpTopicProvider)
        {
            m_rootSite = rootSite;
            InitializeComponent();
            m_customUserLevel   = customUserLevel;
            m_helpTopicProvider = helpTopicProvider;
            m_paraStyleName     = paraStyleName;
            m_charStyleName     = charStyleName;

            // Cache is null in tests
            if (cache == null)
            {
                return;
            }

            m_cboTypes.SelectedIndex = 1;             // All Styles

            // Load the style information
            m_styleTable = new StyleInfoTable(normalStyleName,
                                              cache.ServiceLocator.WritingSystemManager);
            m_styleSheet = new FwStyleSheet();
            m_styleSheet.Init(cache, hvoStylesOwner, stylesTag);
            m_styleListHelper = new StyleListBoxHelper(m_lstStyles);
            m_styleListHelper.ShowInternalStyles = false;
        }
示例#3
0
		public void Setup()
		{
			m_infoTable = new StyleInfoTable("Normal", null);
			BaseStyleInfo styleInfo = new BaseStyleInfo();
			m_infoTable.Add("TestStyle", styleInfo);
			m_infoTable.ConnectStyles();
		}
        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);
        }
        public void Setup()
        {
            m_infoTable = new StyleInfoTable("Normal", null);
            BaseStyleInfo styleInfo = new BaseStyleInfo();

            m_infoTable.Add("TestStyle", styleInfo);
            m_infoTable.ConnectStyles();
        }
示例#6
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Install the control.
        /// </summary>
        /// <param name="dockHost">The control that hosts the browser</param>
        /// <param name="cache">The cache (needed in case we have to create the English LDS file
        /// on the fly)</param>
        /// <param name="normalStyle">The normal style (needed in case we have to create the
        /// English LDS file on the fly)</param>
        /// <returns>
        ///     <c>true</c> if the browser was installed successfully; <c>false</c>
        /// otherwise.
        /// </returns>
        /// ------------------------------------------------------------------------------------
        public bool Install(Control dockHost, FdoCache cache, IStStyle normalStyle)
        {
            while (true)
            {
                try
                {
                    RegistrationInfo.AllowP6RegistrationCode = true;
                    RegistrationInfo.AllowAccessToResources();
                    string paratextProjectDir = ScrImportP6Project.ProjectDir;

                    if (!String.IsNullOrEmpty(paratextProjectDir))
                    {
                        string englishLdsPathname = Path.Combine(paratextProjectDir, "English.lds");
                        if (!File.Exists(englishLdsPathname))
                        {
                            ParatextLdsFileAccessor ldsAccessor     = new ParatextLdsFileAccessor(cache);
                            UsfmStyEntry            normalUsfmStyle = new UsfmStyEntry();
                            StyleInfoTable          styleTable      = new StyleInfoTable(normalStyle.Name,
                                                                                         cache.LanguageWritingSystemFactoryAccessor);
                            normalUsfmStyle.SetPropertiesBasedOnStyle(normalStyle);
                            styleTable.Add(normalStyle.Name, normalUsfmStyle);
                            styleTable.ConnectStyles();
                            ldsAccessor.WriteParatextLdsFile(englishLdsPathname,
                                                             cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en"), normalUsfmStyle);
                        }
                    }
                    ScrTextCollection.Initialize();
                    break;
                }
                catch (Exception e)
                {
                    try
                    {
                        ReflectionHelper.SetField(typeof(ScrTextCollection), "initialized", false);
                    }
                    catch (Exception reflectionHelperException)
                    {
                        throw new ContinuableErrorException("Paratext resource browser failed to initialize." +
                                                            Environment.NewLine + reflectionHelperException.Message, e);
                    }
                    if (MessageBox.Show(dockHost.FindForm(), String.Format(
                                            Properties.Resources.kstidCannotDisplayResourcePane,
                                            Application.ProductName, e.Message), Application.ProductName,
                                        MessageBoxButtons.RetryCancel, MessageBoxIcon.Error,
                                        MessageBoxDefaultButton.Button2) != DialogResult.Retry)
                    {
                        return(false);
                    }
                }
            }
            m_toolStrip.Text = "USFM Resource Browser";
            m_extender       = new DockExtender(dockHost);
            dockHost.Controls.Add(this);
            m_floaty = m_extender.Attach(this, m_toolStrip, true);
            this.SendToBack();
            return(true);
        }
        public void UpdateParatextLdsFile_GeneralSectionMissing()
        {
            if (File.Exists("test.lds"))
            {
                File.Delete("test.lds");
            }

            int             wsHvo  = Cache.DefaultVernWs;
            LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo);

            vernWs.Name.UserDefaultWritingSystem = "French";

            DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
            StyleInfoTable    styleTable  = new StyleInfoTable("Normal",
                                                               Cache.LanguageWritingSystemFactoryAccessor);

            styleTable.Add("Normal", normalEntry);
            normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
            normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

            string ldsContentsOrig =
                "[OtherStuff]";

            DummyFileWriter writer = new DummyFileWriter();

            writer.Open("test.lds");
            ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);

            ReflectionHelper.CallMethod(ldsAccessor, "UpdateLdsContents",
                                        ldsContentsOrig, normalEntry, Cache.DefaultVernWs, writer);

            // Verify the .lds file
            string[] expectedLdsContents =
            {
                "[OtherStuff]",
                //Environment.NewLine +
                "[General]",
                "codepage=65001",
                "font=Wingdings",
                "size=14",
                "name=French",
                "RTL=F"
            };

            writer.VerifyOutput(expectedLdsContents);
        }
        public void SaveToDB_CopyOfStyleBasedOnNormal()
        {
            StyleInfoTable styleTable   = new StyleInfoTable("Normal", Cache.ServiceLocator.WritingSystemManager);
            var            styleFactory = Cache.ServiceLocator.GetInstance <IStStyleFactory>();
            var            normalStyle  = styleFactory.Create();

            Cache.LanguageProject.StylesOC.Add(normalStyle);
            normalStyle.Name      = "Normal";
            normalStyle.Context   = ContextValues.Internal;
            normalStyle.Function  = FunctionValues.Prose;
            normalStyle.Structure = StructureValues.Undefined;
            StyleInfo normal = new StyleInfo(normalStyle);

            styleTable.Add("Normal", normal);

            var realStyle = styleFactory.Create();

            Cache.LanguageProject.StylesOC.Add(realStyle);
            realStyle.Name      = "Paragraph";
            realStyle.Context   = ContextValues.Text;
            realStyle.Function  = FunctionValues.Prose;
            realStyle.Structure = StructureValues.Body;
            realStyle.BasedOnRA = normalStyle;
            StyleInfo styleToCopyFrom = new StyleInfo(realStyle);

            styleTable.Add("Paragraph", styleToCopyFrom);

            StyleInfo testInfo = new StyleInfo(styleToCopyFrom, "Copy of Paragraph");

            styleTable.Add("Copy of Paragraph", testInfo);
            styleTable.ConnectStyles();

            // simulate a save to the DB for the test style.
            var style = styleFactory.Create();

            Cache.LanguageProject.StylesOC.Add(style);
            testInfo.SaveToDB(style, false, false);

            Assert.AreEqual(ContextValues.Text, testInfo.Context);
            Assert.AreEqual(StructureValues.Body, testInfo.Structure);
            Assert.AreEqual(FunctionValues.Prose, testInfo.Function);
            Assert.AreEqual(ContextValues.Text, style.Context);
            Assert.AreEqual(StructureValues.Body, style.Structure);
            Assert.AreEqual(FunctionValues.Prose, style.Function);
        }
        public void WriteParatextLdsFile()
        {
            if (File.Exists("test.lds"))
            {
                File.Delete("test.lds");
            }

            int             wsHvo  = Cache.DefaultVernWs;
            LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo);

            vernWs.Name.UserDefaultWritingSystem = "French";

            DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
            StyleInfoTable    styleTable  = new StyleInfoTable("Normal",
                                                               Cache.LanguageWritingSystemFactoryAccessor);

            styleTable.Add("Normal", normalEntry);
            normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
            normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

            ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
            DummyFileWriter         actualLds   = new DummyFileWriter();

            ReflectionHelper.CallMethod(ldsAccessor, "WriteParatextLdsFile", "test.lds",
                                        Cache.DefaultVernWs, normalEntry, actualLds);

            // Verify the .lds file
            string[] expectedLds =
            {
                "[General]",
                "codepage=65001",
                "RTL=F",
                "font=Wingdings",
                "name=French",
                "size=14",
                string.Empty,
                "[Checking]",
                string.Empty,
                "[Characters]",
                string.Empty,
                "[Punctuation]"
            };

            actualLds.VerifyOutput(expectedLds);
        }
        public void WriteParatextLdsFile_BT()
        {
            if (File.Exists("test.lds"))
            {
                File.Delete("test.lds");
            }

            int            wsUrduBT = InMemoryFdoCache.s_wsHvos.Ur;
            IWritingSystem btWs     = Cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsUrduBT);
            string         btWsName = btWs.get_UiName(Cache.DefaultUserWs);

            DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
            StyleInfoTable    styleTable  = new StyleInfoTable("Normal",
                                                               Cache.LanguageWritingSystemFactoryAccessor);

            styleTable.Add("Normal", normalEntry);
            normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
            normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

            DummyFileWriter         fileWriterLDS = new DummyFileWriter();
            ParatextLdsFileAccessor ldsAccessor   = new ParatextLdsFileAccessor(Cache);

            ReflectionHelper.CallMethod(ldsAccessor, "WriteParatextLdsFile", "test.lds",
                                        wsUrduBT, normalEntry, fileWriterLDS);

            // Verify the .lds file
            string[] expectedLds =
            {
                "[General]",
                "codepage=65001",
                "RTL=T",
                "font=Wingdings",
                "name=" + btWs.get_UiName(Cache.DefaultUserWs),
                "size=14",
                string.Empty,
                "[Checking]",
                string.Empty,
                "[Characters]",
                string.Empty,
                "[Punctuation]"
            };

            fileWriterLDS.VerifyOutput(expectedLds);
        }
		public void WriteParatextLdsFile()
		{
			if (File.Exists("test.lds"))
				File.Delete("test.lds");

			int wsHvo = Cache.DefaultVernWs;
			LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo);
			vernWs.Name.UserDefaultWritingSystem = "French";

			DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
			StyleInfoTable styleTable = new StyleInfoTable("Normal",
				Cache.LanguageWritingSystemFactoryAccessor);
			styleTable.Add("Normal", normalEntry);
			normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
			normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			DummyFileWriter actualLds = new DummyFileWriter();
			ReflectionHelper.CallMethod(ldsAccessor, "WriteParatextLdsFile", "test.lds",
				Cache.DefaultVernWs, normalEntry, actualLds);

			// Verify the .lds file
			string[] expectedLds =
			{
				"[General]",
				"codepage=65001",
				"RTL=F",
				"font=Wingdings",
				"name=French",
				"size=14",
				string.Empty,
				"[Checking]",
				string.Empty,
				"[Characters]",
				string.Empty,
				"[Punctuation]"
			};

			actualLds.VerifyOutput(expectedLds);
		}
示例#12
0
		public void SaveToDB_CopyOfStyleBasedOnNormal()
		{
			StyleInfoTable styleTable = new StyleInfoTable("Normal", Cache.ServiceLocator.WritingSystemManager);
			var styleFactory = Cache.ServiceLocator.GetInstance<IStStyleFactory>();
			var normalStyle = styleFactory.Create();
			Cache.LanguageProject.StylesOC.Add(normalStyle);
			normalStyle.Name = "Normal";
			normalStyle.Context = ContextValues.Internal;
			normalStyle.Function = FunctionValues.Prose;
			normalStyle.Structure = StructureValues.Undefined;
			StyleInfo normal = new StyleInfo(normalStyle);
			styleTable.Add("Normal", normal);

			var realStyle = styleFactory.Create();
			Cache.LanguageProject.StylesOC.Add(realStyle);
			realStyle.Name = "Paragraph";
			realStyle.Context = ContextValues.Text;
			realStyle.Function = FunctionValues.Prose;
			realStyle.Structure = StructureValues.Body;
			realStyle.BasedOnRA = normalStyle;
			StyleInfo styleToCopyFrom = new StyleInfo(realStyle);
			styleTable.Add("Paragraph", styleToCopyFrom);

			StyleInfo testInfo = new StyleInfo(styleToCopyFrom, "Copy of Paragraph");
			styleTable.Add("Copy of Paragraph", testInfo);
			styleTable.ConnectStyles();

			// simulate a save to the DB for the test style.
			var style = styleFactory.Create();
			Cache.LanguageProject.StylesOC.Add(style);
			testInfo.SaveToDB(style, false, false);

			Assert.AreEqual(ContextValues.Text, testInfo.Context);
			Assert.AreEqual(StructureValues.Body, testInfo.Structure);
			Assert.AreEqual(FunctionValues.Prose, testInfo.Function);
			Assert.AreEqual(ContextValues.Text, style.Context);
			Assert.AreEqual(StructureValues.Body, style.Structure);
			Assert.AreEqual(FunctionValues.Prose, style.Function);
		}
示例#13
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the styles.
		/// </summary>
		/// <param name="styleTable">The style table.</param>
		/// <param name="pseudoStyles">The pseudo styles.</param>
		/// ------------------------------------------------------------------------------------
		public void AddStyles(StyleInfoTable styleTable, string[] pseudoStyles)
		{
			Debug.Assert(styleTable != null);
			BuildStyleItemList(styleTable.Count, styleTable.Values, pseudoStyles);
		}
示例#14
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Install the control.
		/// </summary>
		/// <param name="dockHost">The control that hosts the browser</param>
		/// <param name="cache">The cache (needed in case we have to create the English LDS file
		/// on the fly)</param>
		/// <param name="normalStyle">The normal style (needed in case we have to create the
		/// English LDS file on the fly)</param>
		/// <returns>
		/// 	<c>true</c> if the browser was installed successfully; <c>false</c>
		/// otherwise.
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public bool Install(Control dockHost, FdoCache cache, IStStyle normalStyle)
		{
			while (true)
			{
				try
				{
					RegistrationInfo.AllowP6RegistrationCode = true;
					RegistrationInfo.AllowAccessToResources();
					string paratextProjectDir = ScrImportP6Project.ProjectDir;

					if (!String.IsNullOrEmpty(paratextProjectDir))
					{
						string englishLdsPathname = Path.Combine(paratextProjectDir, "English.lds");
						if (!File.Exists(englishLdsPathname))
						{
							ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(cache);
							UsfmStyEntry normalUsfmStyle = new UsfmStyEntry();
							StyleInfoTable styleTable = new StyleInfoTable(normalStyle.Name,
								cache.LanguageWritingSystemFactoryAccessor);
							normalUsfmStyle.SetPropertiesBasedOnStyle(normalStyle);
							styleTable.Add(normalStyle.Name, normalUsfmStyle);
							styleTable.ConnectStyles();
							ldsAccessor.WriteParatextLdsFile(englishLdsPathname,
								cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en"), normalUsfmStyle);
						}
					}
					ScrTextCollection.Initialize();
					break;
				}
				catch (Exception e)
				{
					try
					{
						ReflectionHelper.SetField(typeof(ScrTextCollection), "initialized", false);
					}
					catch (Exception reflectionHelperException)
					{
						throw new ContinuableErrorException("Paratext resource browser failed to initialize." +
							Environment.NewLine + reflectionHelperException.Message, e);
					}
					if (MessageBox.Show(dockHost.FindForm(), String.Format(
						Properties.Resources.kstidCannotDisplayResourcePane,
						Application.ProductName, e.Message), Application.ProductName,
						MessageBoxButtons.RetryCancel, MessageBoxIcon.Error,
						MessageBoxDefaultButton.Button2) != DialogResult.Retry)
					{
						return false;
					}
				}
			}
			m_toolStrip.Text = "USFM Resource Browser";
			m_extender = new DockExtender(dockHost);
			dockHost.Controls.Add(this);
			m_floaty = m_extender.Attach(this, m_toolStrip, true);
			this.SendToBack();
			return true;
		}
示例#15
0
		public void ConnectStyles()
		{
			IStStyle normal = AddTestStyle("Normal", ContextValues.Internal, StructureValues.Undefined, FunctionValues.Prose, false);
			IStStyle normalParaStyle = AddTestStyle("Paragraph", ContextValues.Text, StructureValues.Body, FunctionValues.Prose, false);
			IStStyle sectionHead = AddTestStyle("Section Head", ContextValues.Text, StructureValues.Heading, FunctionValues.Prose, false);
			IStStyle verseNumberStyle = AddTestStyle("Verse Number", ContextValues.Text, StructureValues.Body, FunctionValues.Verse, true);
			IStStyle mainTitleStyle = AddTestStyle("Title Main", ContextValues.Title, StructureValues.Body, FunctionValues.Prose, false);
			IStStyle footnoteParaStyle = AddTestStyle("Note General Paragraph", ContextValues.Note, StructureValues.Undefined, FunctionValues.Prose, false);
			IStStyle footnoteMarkerStyle = AddTestStyle("Note Marker", ContextValues.Internal, StructureValues.Undefined, FunctionValues.Prose, true);

			StyleInfoTable table = new StyleInfoTable(string.Empty,
				Cache.ServiceLocator.WritingSystemManager);
			ITsPropsBldr props;

			props = normal.Rules.GetBldr();
			props.SetIntPropValues((int)FwTextPropType.ktptFontSize,
				(int)FwTextPropVar.ktpvMilliPoint, 20000);
			props.SetIntPropValues((int)FwTextPropType.ktptLineHeight,
				(int)FwTextPropVar.ktpvMilliPoint, 16000);
			props.SetIntPropValues((int)FwTextPropType.ktptOffset,
				(int)FwTextPropVar.ktpvMilliPoint, 10000);
			normal.Rules = props.GetTextProps();
			table.Add("Normal", new DummyStyleInfo(normal));

			props = normalParaStyle.Rules.GetBldr();
			props.SetIntPropValues((int)FwTextPropType.ktptBorderLeading,
				(int)FwTextPropVar.ktpvMilliPoint, 1000);
			props.SetIntPropValues((int)FwTextPropType.ktptBorderTop,
				(int)FwTextPropVar.ktpvMilliPoint, 2000);
			props.SetIntPropValues((int)FwTextPropType.ktptBorderTrailing,
				(int)FwTextPropVar.ktpvMilliPoint, 3000);
			props.SetIntPropValues((int)FwTextPropType.ktptBorderBottom,
				(int)FwTextPropVar.ktpvMilliPoint, 4000);
			props.SetIntPropValues((int)FwTextPropType.ktptBorderColor,
				(int)FwTextPropVar.ktpvDefault,
				(int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Thistle)));
			normalParaStyle.Rules = props.GetTextProps();
			normalParaStyle.BasedOnRA = normal;
			normalParaStyle.NextRA = normalParaStyle;
			table.Add("Paragraph", new DummyStyleInfo(normalParaStyle));

			props = footnoteParaStyle.Rules.GetBldr();
			footnoteParaStyle.BasedOnRA = normalParaStyle;
			footnoteParaStyle.NextRA = null;
			table.Add("Note General Paragraph", new DummyStyleInfo(footnoteParaStyle));

			props = sectionHead.Rules.GetBldr();
			props.SetIntPropValues((int)FwTextPropType.ktptItalic,
				(int)FwTextPropVar.ktpvEnum,
				(int)FwTextToggleVal.kttvOff);
			props.SetIntPropValues((int)FwTextPropType.ktptBackColor,
				(int)FwTextPropVar.ktpvDefault,
				(int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Aquamarine)));
			props.SetStrPropValue((int)FwTextPropType.ktptFontFamily, StyleServices.DefaultFont);
			sectionHead.Rules = props.GetTextProps();
			sectionHead.BasedOnRA = normal;
			sectionHead.NextRA = normalParaStyle;
			DummyStyleInfo sectionInfo = new DummyStyleInfo(sectionHead);
			int wsEn = Cache.WritingSystemFactory.GetWsFromStr("en");
			sectionInfo.FontInfoForWs(wsEn).m_fontName.ExplicitValue = "Arial";
			table.Add("Section Head", sectionInfo);

			props = mainTitleStyle.Rules.GetBldr();
			props.SetIntPropValues((int)FwTextPropType.ktptBold,
				(int)FwTextPropVar.ktpvEnum,
				(int)FwTextToggleVal.kttvForceOn);
			props.SetIntPropValues((int)FwTextPropType.ktptAlign,
				(int)FwTextPropVar.ktpvDefault, (int)FwTextAlign.ktalCenter);
			props.SetIntPropValues((int)FwTextPropType.ktptFontSize,
				(int)FwTextPropVar.ktpvMilliPoint, 16000);
			props.SetIntPropValues((int)FwTextPropType.ktptFirstIndent,
				(int)FwTextPropVar.ktpvMilliPoint, 0);
			mainTitleStyle.Rules = props.GetTextProps();
			mainTitleStyle.BasedOnRA = sectionHead;
			mainTitleStyle.NextRA = mainTitleStyle;
			table.Add("Title Main", new DummyStyleInfo(mainTitleStyle));

			props = verseNumberStyle.Rules.GetBldr();
			props.SetIntPropValues((int)FwTextPropType.ktptBold,
				(int)FwTextPropVar.ktpvDefault,
				(int)FwTextToggleVal.kttvForceOn);
			props.SetIntPropValues((int)FwTextPropType.ktptItalic,
				(int)FwTextPropVar.ktpvDefault,
				(int)FwTextToggleVal.kttvForceOn);
			props.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
				(int)FwTextPropVar.ktpvEnum,
				(int)FwSuperscriptVal.kssvSuper);
			props.SetIntPropValues((int)FwTextPropType.ktptUnderline,
				(int)FwTextPropVar.ktpvEnum,
				(int)FwUnderlineType.kuntDouble);
			props.SetIntPropValues((int)FwTextPropType.ktptUnderColor,
				(int)FwTextPropVar.ktpvDefault,
				(int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.SteelBlue)));
			props.SetIntPropValues((int)FwTextPropType.ktptForeColor,
				(int)FwTextPropVar.ktpvDefault,
				(int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Tomato)));
			props.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Courier");
			verseNumberStyle.Rules = props.GetTextProps();
			verseNumberStyle.BasedOnRA = null;
			verseNumberStyle.NextRA = null;
			table.Add("Verse Number", new DummyStyleInfo(verseNumberStyle));

			footnoteMarkerStyle.BasedOnRA = verseNumberStyle;
			footnoteMarkerStyle.NextRA = null;
			table.Add("Note Marker", new DummyStyleInfo(footnoteMarkerStyle));

			table.ConnectStyles();

			// Check "Paragraph" style
			//		Explicit properties
			DummyStyleInfo entry = (DummyStyleInfo)table["Paragraph"];
			Assert.AreEqual("Paragraph", entry.Name);
			Assert.IsTrue(entry.IsParagraphStyle);
			Assert.AreEqual(table["Normal"].StyleNumber, entry.BasedOnStyleNumber);
			Assert.AreEqual(entry.StyleNumber, entry.NextStyleNumber);
			Assert.AreEqual(1000, entry.BorderLeading);
			Assert.AreEqual(2000, entry.BorderTop);
			Assert.AreEqual(3000, entry.BorderTrailing);
			Assert.AreEqual(4000, entry.BorderBottom);
			Assert.AreEqual((Color.FromKnownColor(KnownColor.Thistle)).ToArgb(), entry.BorderColor.ToArgb());
			//		Inherited properties
			FontInfo fontInfo = entry.FontInfoForWs(-1);
			Assert.IsNotNull(fontInfo);
			Assert.IsFalse(entry.ExplicitRightToLeftStyle);
			Assert.IsFalse(fontInfo.m_italic.Value);
			Assert.IsFalse(fontInfo.m_bold.Value);
			Assert.AreEqual(20000, fontInfo.m_fontSize.Value);
			Assert.AreEqual(10000, fontInfo.m_offset.Value);
			Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value);
			Assert.IsTrue(fontInfo.m_underlineColor.IsInherited);
			Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value);
			Assert.IsTrue(fontInfo.m_features.IsInherited);
			Assert.AreEqual(null, fontInfo.m_features.Value);
			Assert.IsTrue(fontInfo.m_backColor.IsInherited);
			Assert.AreEqual(Color.Empty, fontInfo.m_backColor.Value);
			Assert.IsTrue(fontInfo.m_fontColor.IsInherited);
			Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value);
			Assert.AreEqual("<default font>", fontInfo.m_fontName.Value);
			Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value);
			Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment);
			Assert.AreEqual(0, entry.FirstLineIndent);
			Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight);
			Assert.AreEqual(0, entry.LeadingIndent);
			Assert.AreEqual(0, entry.TrailingIndent);
			Assert.AreEqual(0, entry.SpaceAfter);
			Assert.AreEqual(0, entry.SpaceBefore);

			// Check Normal Footnote Paragraph style
			//		Explicit properties
			entry = (DummyStyleInfo)table["Note General Paragraph"];
			Assert.AreEqual("Note General Paragraph", entry.Name);
			Assert.IsTrue(entry.IsParagraphStyle);
			Assert.AreEqual(table["Paragraph"].StyleNumber, entry.BasedOnStyleNumber);
			Assert.AreEqual("Note General Paragraph", entry.NextStyle.Name);
			//		Inherited properties
			fontInfo = entry.FontInfoForWs(-1);
			Assert.IsNotNull(fontInfo);
			Assert.IsFalse(entry.ExplicitRightToLeftStyle);
			Assert.IsFalse(fontInfo.m_italic.Value);
			Assert.IsFalse(fontInfo.m_bold.Value);
			Assert.AreEqual(20000, fontInfo.m_fontSize.Value);
			Assert.AreEqual(10000, fontInfo.m_offset.Value);
			Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value);
			Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value);
			Assert.IsNull(fontInfo.m_features.Value);
			Assert.AreEqual(Color.Empty, fontInfo.m_backColor.Value);
			Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value);
			Assert.AreEqual("<default font>", fontInfo.m_fontName.Value);
			Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value);
			Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment);
			Assert.AreEqual(0, entry.FirstLineIndent);
			Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight);
			Assert.AreEqual(0, entry.LeadingIndent);
			Assert.AreEqual(0, entry.TrailingIndent);
			Assert.AreEqual(0, entry.SpaceAfter);
			Assert.AreEqual(0, entry.SpaceBefore);
			Assert.AreEqual(1000, entry.BorderLeading);
			Assert.AreEqual(2000, entry.BorderTop);
			Assert.AreEqual(3000, entry.BorderTrailing);
			Assert.AreEqual(4000, entry.BorderBottom);
			Assert.AreEqual((Color.FromKnownColor(KnownColor.Thistle)).ToArgb(), entry.BorderColor.ToArgb());

			// Check Title Main style
			//		Explicit properties
			entry = (DummyStyleInfo)table["Title Main"];
			Assert.AreEqual("Title Main", entry.Name);
			Assert.IsTrue(entry.IsParagraphStyle);
			Assert.AreEqual(FwTextAlign.ktalCenter, entry.Alignment);
			Assert.AreEqual(0, entry.FirstLineIndent);
			fontInfo = entry.FontInfoForWs(-1);
			Assert.IsNotNull(fontInfo);
			Assert.IsTrue(fontInfo.m_bold.Value);
			Assert.AreEqual(16000, fontInfo.m_fontSize.Value);
			Assert.AreEqual(table["Section Head"].StyleNumber, entry.BasedOnStyleNumber);
			Assert.AreEqual(entry.StyleNumber, entry.NextStyleNumber);
			//		Inherited properties
			Assert.IsFalse(entry.ExplicitRightToLeftStyle);
			Assert.IsFalse(fontInfo.m_italic.Value);
			Assert.AreEqual(10000, fontInfo.m_offset.Value);
			Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value);
			Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value);
			Assert.IsNull(fontInfo.m_features.Value);
			Assert.AreEqual((Color.FromKnownColor(KnownColor.Aquamarine)).ToArgb(), fontInfo.m_backColor.Value.ToArgb());
			Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value);
			Assert.AreEqual("<default font>", fontInfo.m_fontName.Value);
			Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight);
			Assert.AreEqual(0, entry.LeadingIndent);
			Assert.AreEqual(0, entry.TrailingIndent);
			Assert.AreEqual(0, entry.SpaceAfter);
			Assert.AreEqual(0, entry.SpaceBefore);
			Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value);
			fontInfo = entry.FontInfoForWs(wsEn);
			Assert.AreEqual("Arial", fontInfo.m_fontName.Value);


			// Check Section Head style
			//		Explicit properties
			entry = (DummyStyleInfo)table["Section Head"];
			Assert.AreEqual("Section Head", entry.Name);
			Assert.IsTrue(entry.IsParagraphStyle);
			fontInfo = entry.FontInfoForWs(-1);
			Assert.IsNotNull(fontInfo);
			Assert.IsFalse(fontInfo.m_italic.Value);
			Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value);
			Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value);
			Assert.IsNull(fontInfo.m_features.Value);
			Assert.AreEqual((Color.FromKnownColor(KnownColor.Aquamarine)).ToArgb(), fontInfo.m_backColor.Value.ToArgb());
			Assert.AreEqual("<default font>", fontInfo.m_fontName.Value);
			Assert.AreEqual(table["Normal"].StyleNumber, entry.BasedOnStyleNumber);
			Assert.AreEqual(table["Paragraph"].StyleNumber, entry.NextStyleNumber);
			//		Inherited properties
			Assert.IsFalse(entry.ExplicitRightToLeftStyle);
			Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment);
			Assert.AreEqual(0, entry.FirstLineIndent);
			Assert.IsFalse(fontInfo.m_bold.Value);
			Assert.AreEqual(20000, fontInfo.m_fontSize.Value);
			Assert.AreEqual(10000, fontInfo.m_offset.Value);
			Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value);
			Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight);
			Assert.AreEqual(0, entry.LeadingIndent);
			Assert.AreEqual(0, entry.TrailingIndent);
			Assert.AreEqual(0, entry.SpaceAfter);
			Assert.AreEqual(0, entry.SpaceBefore);
			Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value);

			// Check Verse Number style
			//		Explicit properties
			entry = (DummyStyleInfo)table["Verse Number"];
			Assert.AreEqual("Verse Number", entry.Name);
			Assert.IsFalse(entry.IsParagraphStyle);
			fontInfo = entry.FontInfoForWs(-1);
			Assert.IsNotNull(fontInfo);
			Assert.IsTrue(fontInfo.m_bold.Value);
			Assert.IsTrue(fontInfo.m_italic.Value);
			Assert.AreEqual(FwSuperscriptVal.kssvSuper, fontInfo.m_superSub.Value);
			Assert.AreEqual(FwUnderlineType.kuntDouble, fontInfo.m_underline.Value);
			Assert.AreEqual((Color.FromKnownColor(KnownColor.SteelBlue)).ToArgb(), fontInfo.m_underlineColor.Value.ToArgb());
			Assert.AreEqual((Color.FromKnownColor(KnownColor.Tomato)).ToArgb(), fontInfo.m_fontColor.Value.ToArgb());
			Assert.AreEqual("Courier", fontInfo.m_fontName.Value);
			Assert.AreEqual(0, entry.BasedOnStyleNumber);
			//		Inherited properties
			Assert.IsTrue(fontInfo.m_fontSize.IsInherited);
			Assert.IsTrue(fontInfo.m_offset.IsInherited);

			// Check Footnote Marker style
			//		Explicit properties
			entry = (DummyStyleInfo)table["Note Marker"];
			Assert.AreEqual("Note Marker", entry.Name);
			Assert.IsFalse(entry.IsParagraphStyle);
			Assert.AreEqual(table["Verse Number"].StyleNumber, entry.BasedOnStyleNumber);
			//		Inherited properties
			fontInfo = entry.FontInfoForWs(-1);
			Assert.IsNotNull(fontInfo);
			Assert.IsTrue(fontInfo.m_bold.Value);
			Assert.IsTrue(fontInfo.m_italic.Value);
			Assert.AreEqual(FwSuperscriptVal.kssvSuper, fontInfo.m_superSub.Value);
			Assert.AreEqual(FwUnderlineType.kuntDouble, fontInfo.m_underline.Value);
			Assert.AreEqual((Color.FromKnownColor(KnownColor.SteelBlue)).ToArgb(), fontInfo.m_underlineColor.Value.ToArgb());
			Assert.AreEqual((Color.FromKnownColor(KnownColor.Tomato)).ToArgb(), fontInfo.m_fontColor.Value.ToArgb());
			Assert.AreEqual("Courier", fontInfo.m_fontName.Value);
			//		Inherited properties
			Assert.IsTrue(fontInfo.m_fontSize.IsInherited);
			Assert.IsTrue(fontInfo.m_offset.IsInherited);
		}
示例#16
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the styles.
 /// </summary>
 /// <param name="styleTable">The style table.</param>
 /// <param name="pseudoStyles">The pseudo styles.</param>
 /// ------------------------------------------------------------------------------------
 public void AddStyles(StyleInfoTable styleTable, string[] pseudoStyles)
 {
     Debug.Assert(styleTable != null);
     BuildStyleItemList(styleTable.Count, styleTable.Values, pseudoStyles);
 }
示例#17
0
        public void ConnectStyles()
        {
            IStStyle normal              = AddTestStyle("Normal", ContextValues.Internal, StructureValues.Undefined, FunctionValues.Prose, false);
            IStStyle normalParaStyle     = AddTestStyle("Paragraph", ContextValues.Text, StructureValues.Body, FunctionValues.Prose, false);
            IStStyle sectionHead         = AddTestStyle("Section Head", ContextValues.Text, StructureValues.Heading, FunctionValues.Prose, false);
            IStStyle verseNumberStyle    = AddTestStyle("Verse Number", ContextValues.Text, StructureValues.Body, FunctionValues.Verse, true);
            IStStyle mainTitleStyle      = AddTestStyle("Title Main", ContextValues.Title, StructureValues.Body, FunctionValues.Prose, false);
            IStStyle footnoteParaStyle   = AddTestStyle("Note General Paragraph", ContextValues.Note, StructureValues.Undefined, FunctionValues.Prose, false);
            IStStyle footnoteMarkerStyle = AddTestStyle("Note Marker", ContextValues.Internal, StructureValues.Undefined, FunctionValues.Prose, true);

            StyleInfoTable table = new StyleInfoTable(string.Empty,
                                                      Cache.ServiceLocator.WritingSystemManager);
            ITsPropsBldr props;

            props = normal.Rules.GetBldr();
            props.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                   (int)FwTextPropVar.ktpvMilliPoint, 20000);
            props.SetIntPropValues((int)FwTextPropType.ktptLineHeight,
                                   (int)FwTextPropVar.ktpvMilliPoint, 16000);
            props.SetIntPropValues((int)FwTextPropType.ktptOffset,
                                   (int)FwTextPropVar.ktpvMilliPoint, 10000);
            normal.Rules = props.GetTextProps();
            table.Add("Normal", new DummyStyleInfo(normal));

            props = normalParaStyle.Rules.GetBldr();
            props.SetIntPropValues((int)FwTextPropType.ktptBorderLeading,
                                   (int)FwTextPropVar.ktpvMilliPoint, 1000);
            props.SetIntPropValues((int)FwTextPropType.ktptBorderTop,
                                   (int)FwTextPropVar.ktpvMilliPoint, 2000);
            props.SetIntPropValues((int)FwTextPropType.ktptBorderTrailing,
                                   (int)FwTextPropVar.ktpvMilliPoint, 3000);
            props.SetIntPropValues((int)FwTextPropType.ktptBorderBottom,
                                   (int)FwTextPropVar.ktpvMilliPoint, 4000);
            props.SetIntPropValues((int)FwTextPropType.ktptBorderColor,
                                   (int)FwTextPropVar.ktpvDefault,
                                   (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Thistle)));
            normalParaStyle.Rules     = props.GetTextProps();
            normalParaStyle.BasedOnRA = normal;
            normalParaStyle.NextRA    = normalParaStyle;
            table.Add("Paragraph", new DummyStyleInfo(normalParaStyle));

            props = footnoteParaStyle.Rules.GetBldr();
            footnoteParaStyle.BasedOnRA = normalParaStyle;
            footnoteParaStyle.NextRA    = null;
            table.Add("Note General Paragraph", new DummyStyleInfo(footnoteParaStyle));

            props = sectionHead.Rules.GetBldr();
            props.SetIntPropValues((int)FwTextPropType.ktptItalic,
                                   (int)FwTextPropVar.ktpvEnum,
                                   (int)FwTextToggleVal.kttvOff);
            props.SetIntPropValues((int)FwTextPropType.ktptBackColor,
                                   (int)FwTextPropVar.ktpvDefault,
                                   (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Aquamarine)));
            props.SetStrPropValue((int)FwTextPropType.ktptFontFamily, StyleServices.DefaultFont);
            sectionHead.Rules     = props.GetTextProps();
            sectionHead.BasedOnRA = normal;
            sectionHead.NextRA    = normalParaStyle;
            DummyStyleInfo sectionInfo = new DummyStyleInfo(sectionHead);
            int            wsEn        = Cache.WritingSystemFactory.GetWsFromStr("en");

            sectionInfo.FontInfoForWs(wsEn).m_fontName.ExplicitValue = "Arial";
            table.Add("Section Head", sectionInfo);

            props = mainTitleStyle.Rules.GetBldr();
            props.SetIntPropValues((int)FwTextPropType.ktptBold,
                                   (int)FwTextPropVar.ktpvEnum,
                                   (int)FwTextToggleVal.kttvForceOn);
            props.SetIntPropValues((int)FwTextPropType.ktptAlign,
                                   (int)FwTextPropVar.ktpvDefault, (int)FwTextAlign.ktalCenter);
            props.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                   (int)FwTextPropVar.ktpvMilliPoint, 16000);
            props.SetIntPropValues((int)FwTextPropType.ktptFirstIndent,
                                   (int)FwTextPropVar.ktpvMilliPoint, 0);
            mainTitleStyle.Rules     = props.GetTextProps();
            mainTitleStyle.BasedOnRA = sectionHead;
            mainTitleStyle.NextRA    = mainTitleStyle;
            table.Add("Title Main", new DummyStyleInfo(mainTitleStyle));

            props = verseNumberStyle.Rules.GetBldr();
            props.SetIntPropValues((int)FwTextPropType.ktptBold,
                                   (int)FwTextPropVar.ktpvDefault,
                                   (int)FwTextToggleVal.kttvForceOn);
            props.SetIntPropValues((int)FwTextPropType.ktptItalic,
                                   (int)FwTextPropVar.ktpvDefault,
                                   (int)FwTextToggleVal.kttvForceOn);
            props.SetIntPropValues((int)FwTextPropType.ktptSuperscript,
                                   (int)FwTextPropVar.ktpvEnum,
                                   (int)FwSuperscriptVal.kssvSuper);
            props.SetIntPropValues((int)FwTextPropType.ktptUnderline,
                                   (int)FwTextPropVar.ktpvEnum,
                                   (int)FwUnderlineType.kuntDouble);
            props.SetIntPropValues((int)FwTextPropType.ktptUnderColor,
                                   (int)FwTextPropVar.ktpvDefault,
                                   (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.SteelBlue)));
            props.SetIntPropValues((int)FwTextPropType.ktptForeColor,
                                   (int)FwTextPropVar.ktpvDefault,
                                   (int)ColorUtil.ConvertColorToBGR(Color.FromKnownColor(KnownColor.Tomato)));
            props.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Courier");
            verseNumberStyle.Rules     = props.GetTextProps();
            verseNumberStyle.BasedOnRA = null;
            verseNumberStyle.NextRA    = null;
            table.Add("Verse Number", new DummyStyleInfo(verseNumberStyle));

            footnoteMarkerStyle.BasedOnRA = verseNumberStyle;
            footnoteMarkerStyle.NextRA    = null;
            table.Add("Note Marker", new DummyStyleInfo(footnoteMarkerStyle));

            table.ConnectStyles();

            // Check "Paragraph" style
            //		Explicit properties
            DummyStyleInfo entry = (DummyStyleInfo)table["Paragraph"];

            Assert.AreEqual("Paragraph", entry.Name);
            Assert.IsTrue(entry.IsParagraphStyle);
            Assert.AreEqual(table["Normal"].StyleNumber, entry.BasedOnStyleNumber);
            Assert.AreEqual(entry.StyleNumber, entry.NextStyleNumber);
            Assert.AreEqual(1000, entry.BorderLeading);
            Assert.AreEqual(2000, entry.BorderTop);
            Assert.AreEqual(3000, entry.BorderTrailing);
            Assert.AreEqual(4000, entry.BorderBottom);
            Assert.AreEqual((Color.FromKnownColor(KnownColor.Thistle)).ToArgb(), entry.BorderColor.ToArgb());
            //		Inherited properties
            FontInfo fontInfo = entry.FontInfoForWs(-1);

            Assert.IsNotNull(fontInfo);
            Assert.IsFalse(entry.ExplicitRightToLeftStyle);
            Assert.IsFalse(fontInfo.m_italic.Value);
            Assert.IsFalse(fontInfo.m_bold.Value);
            Assert.AreEqual(20000, fontInfo.m_fontSize.Value);
            Assert.AreEqual(10000, fontInfo.m_offset.Value);
            Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value);
            Assert.IsTrue(fontInfo.m_underlineColor.IsInherited);
            Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value);
            Assert.IsTrue(fontInfo.m_features.IsInherited);
            Assert.AreEqual(null, fontInfo.m_features.Value);
            Assert.IsTrue(fontInfo.m_backColor.IsInherited);
            Assert.AreEqual(Color.Empty, fontInfo.m_backColor.Value);
            Assert.IsTrue(fontInfo.m_fontColor.IsInherited);
            Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value);
            Assert.AreEqual("<default font>", fontInfo.m_fontName.Value);
            Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value);
            Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment);
            Assert.AreEqual(0, entry.FirstLineIndent);
            Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight);
            Assert.AreEqual(0, entry.LeadingIndent);
            Assert.AreEqual(0, entry.TrailingIndent);
            Assert.AreEqual(0, entry.SpaceAfter);
            Assert.AreEqual(0, entry.SpaceBefore);

            // Check Normal Footnote Paragraph style
            //		Explicit properties
            entry = (DummyStyleInfo)table["Note General Paragraph"];
            Assert.AreEqual("Note General Paragraph", entry.Name);
            Assert.IsTrue(entry.IsParagraphStyle);
            Assert.AreEqual(table["Paragraph"].StyleNumber, entry.BasedOnStyleNumber);
            Assert.AreEqual("Note General Paragraph", entry.NextStyle.Name);
            //		Inherited properties
            fontInfo = entry.FontInfoForWs(-1);
            Assert.IsNotNull(fontInfo);
            Assert.IsFalse(entry.ExplicitRightToLeftStyle);
            Assert.IsFalse(fontInfo.m_italic.Value);
            Assert.IsFalse(fontInfo.m_bold.Value);
            Assert.AreEqual(20000, fontInfo.m_fontSize.Value);
            Assert.AreEqual(10000, fontInfo.m_offset.Value);
            Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value);
            Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value);
            Assert.IsNull(fontInfo.m_features.Value);
            Assert.AreEqual(Color.Empty, fontInfo.m_backColor.Value);
            Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value);
            Assert.AreEqual("<default font>", fontInfo.m_fontName.Value);
            Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value);
            Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment);
            Assert.AreEqual(0, entry.FirstLineIndent);
            Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight);
            Assert.AreEqual(0, entry.LeadingIndent);
            Assert.AreEqual(0, entry.TrailingIndent);
            Assert.AreEqual(0, entry.SpaceAfter);
            Assert.AreEqual(0, entry.SpaceBefore);
            Assert.AreEqual(1000, entry.BorderLeading);
            Assert.AreEqual(2000, entry.BorderTop);
            Assert.AreEqual(3000, entry.BorderTrailing);
            Assert.AreEqual(4000, entry.BorderBottom);
            Assert.AreEqual((Color.FromKnownColor(KnownColor.Thistle)).ToArgb(), entry.BorderColor.ToArgb());

            // Check Title Main style
            //		Explicit properties
            entry = (DummyStyleInfo)table["Title Main"];
            Assert.AreEqual("Title Main", entry.Name);
            Assert.IsTrue(entry.IsParagraphStyle);
            Assert.AreEqual(FwTextAlign.ktalCenter, entry.Alignment);
            Assert.AreEqual(0, entry.FirstLineIndent);
            fontInfo = entry.FontInfoForWs(-1);
            Assert.IsNotNull(fontInfo);
            Assert.IsTrue(fontInfo.m_bold.Value);
            Assert.AreEqual(16000, fontInfo.m_fontSize.Value);
            Assert.AreEqual(table["Section Head"].StyleNumber, entry.BasedOnStyleNumber);
            Assert.AreEqual(entry.StyleNumber, entry.NextStyleNumber);
            //		Inherited properties
            Assert.IsFalse(entry.ExplicitRightToLeftStyle);
            Assert.IsFalse(fontInfo.m_italic.Value);
            Assert.AreEqual(10000, fontInfo.m_offset.Value);
            Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value);
            Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value);
            Assert.IsNull(fontInfo.m_features.Value);
            Assert.AreEqual((Color.FromKnownColor(KnownColor.Aquamarine)).ToArgb(), fontInfo.m_backColor.Value.ToArgb());
            Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value);
            Assert.AreEqual("<default font>", fontInfo.m_fontName.Value);
            Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight);
            Assert.AreEqual(0, entry.LeadingIndent);
            Assert.AreEqual(0, entry.TrailingIndent);
            Assert.AreEqual(0, entry.SpaceAfter);
            Assert.AreEqual(0, entry.SpaceBefore);
            Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value);
            fontInfo = entry.FontInfoForWs(wsEn);
            Assert.AreEqual("Arial", fontInfo.m_fontName.Value);


            // Check Section Head style
            //		Explicit properties
            entry = (DummyStyleInfo)table["Section Head"];
            Assert.AreEqual("Section Head", entry.Name);
            Assert.IsTrue(entry.IsParagraphStyle);
            fontInfo = entry.FontInfoForWs(-1);
            Assert.IsNotNull(fontInfo);
            Assert.IsFalse(fontInfo.m_italic.Value);
            Assert.AreEqual(FwUnderlineType.kuntNone, fontInfo.m_underline.Value);
            Assert.AreEqual(Color.Black, fontInfo.m_underlineColor.Value);
            Assert.IsNull(fontInfo.m_features.Value);
            Assert.AreEqual((Color.FromKnownColor(KnownColor.Aquamarine)).ToArgb(), fontInfo.m_backColor.Value.ToArgb());
            Assert.AreEqual("<default font>", fontInfo.m_fontName.Value);
            Assert.AreEqual(table["Normal"].StyleNumber, entry.BasedOnStyleNumber);
            Assert.AreEqual(table["Paragraph"].StyleNumber, entry.NextStyleNumber);
            //		Inherited properties
            Assert.IsFalse(entry.ExplicitRightToLeftStyle);
            Assert.AreEqual(FwTextAlign.ktalLeading, entry.Alignment);
            Assert.AreEqual(0, entry.FirstLineIndent);
            Assert.IsFalse(fontInfo.m_bold.Value);
            Assert.AreEqual(20000, fontInfo.m_fontSize.Value);
            Assert.AreEqual(10000, fontInfo.m_offset.Value);
            Assert.AreEqual(Color.Black, fontInfo.m_fontColor.Value);
            Assert.AreEqual(16000, entry.LineSpacing.m_lineHeight);
            Assert.AreEqual(0, entry.LeadingIndent);
            Assert.AreEqual(0, entry.TrailingIndent);
            Assert.AreEqual(0, entry.SpaceAfter);
            Assert.AreEqual(0, entry.SpaceBefore);
            Assert.AreEqual(FwSuperscriptVal.kssvOff, fontInfo.m_superSub.Value);

            // Check Verse Number style
            //		Explicit properties
            entry = (DummyStyleInfo)table["Verse Number"];
            Assert.AreEqual("Verse Number", entry.Name);
            Assert.IsFalse(entry.IsParagraphStyle);
            fontInfo = entry.FontInfoForWs(-1);
            Assert.IsNotNull(fontInfo);
            Assert.IsTrue(fontInfo.m_bold.Value);
            Assert.IsTrue(fontInfo.m_italic.Value);
            Assert.AreEqual(FwSuperscriptVal.kssvSuper, fontInfo.m_superSub.Value);
            Assert.AreEqual(FwUnderlineType.kuntDouble, fontInfo.m_underline.Value);
            Assert.AreEqual((Color.FromKnownColor(KnownColor.SteelBlue)).ToArgb(), fontInfo.m_underlineColor.Value.ToArgb());
            Assert.AreEqual((Color.FromKnownColor(KnownColor.Tomato)).ToArgb(), fontInfo.m_fontColor.Value.ToArgb());
            Assert.AreEqual("Courier", fontInfo.m_fontName.Value);
            Assert.AreEqual(0, entry.BasedOnStyleNumber);
            //		Inherited properties
            Assert.IsTrue(fontInfo.m_fontSize.IsInherited);
            Assert.IsTrue(fontInfo.m_offset.IsInherited);

            // Check Footnote Marker style
            //		Explicit properties
            entry = (DummyStyleInfo)table["Note Marker"];
            Assert.AreEqual("Note Marker", entry.Name);
            Assert.IsFalse(entry.IsParagraphStyle);
            Assert.AreEqual(table["Verse Number"].StyleNumber, entry.BasedOnStyleNumber);
            //		Inherited properties
            fontInfo = entry.FontInfoForWs(-1);
            Assert.IsNotNull(fontInfo);
            Assert.IsTrue(fontInfo.m_bold.Value);
            Assert.IsTrue(fontInfo.m_italic.Value);
            Assert.AreEqual(FwSuperscriptVal.kssvSuper, fontInfo.m_superSub.Value);
            Assert.AreEqual(FwUnderlineType.kuntDouble, fontInfo.m_underline.Value);
            Assert.AreEqual((Color.FromKnownColor(KnownColor.SteelBlue)).ToArgb(), fontInfo.m_underlineColor.Value.ToArgb());
            Assert.AreEqual((Color.FromKnownColor(KnownColor.Tomato)).ToArgb(), fontInfo.m_fontColor.Value.ToArgb());
            Assert.AreEqual("Courier", fontInfo.m_fontName.Value);
            //		Inherited properties
            Assert.IsTrue(fontInfo.m_fontSize.IsInherited);
            Assert.IsTrue(fontInfo.m_offset.IsInherited);
        }
		public void WriteParatextLdsFile_BT()
		{
			if (File.Exists("test.lds"))
				File.Delete("test.lds");

			int wsUrduBT = InMemoryFdoCache.s_wsHvos.Ur;
			IWritingSystem btWs = Cache.LanguageWritingSystemFactoryAccessor.get_EngineOrNull(wsUrduBT);
			string btWsName = btWs.get_UiName(Cache.DefaultUserWs);

			DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
			StyleInfoTable styleTable = new StyleInfoTable("Normal",
				Cache.LanguageWritingSystemFactoryAccessor);
			styleTable.Add("Normal", normalEntry);
			normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
			normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

			DummyFileWriter fileWriterLDS = new DummyFileWriter();
			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			ReflectionHelper.CallMethod(ldsAccessor, "WriteParatextLdsFile", "test.lds",
				wsUrduBT, normalEntry, fileWriterLDS);

			// Verify the .lds file
			string[] expectedLds =
			{
				"[General]",
				"codepage=65001",
				"RTL=T",
				"font=Wingdings",
				"name=" + btWs.get_UiName(Cache.DefaultUserWs),
				"size=14",
				string.Empty,
				"[Checking]",
				string.Empty,
				"[Characters]",
				string.Empty,
				"[Punctuation]"
			};

			fileWriterLDS.VerifyOutput(expectedLds);
		}
示例#19
0
		private void ReadStyles(IVwStylesheet vss)
		{
			string normalStyleName = vss.GetDefaultBasedOnStyleName();
			m_styleTable = new StyleInfoTable(normalStyleName,
				m_cache.ServiceLocator.WritingSystemManager);
			int cStyles = vss.CStyles;
			for (int i = 0; i < cStyles; ++i)
			{
				int hvo = vss.get_NthStyle(i);
				var sty = m_cache.ServiceLocator.GetInstance<IStStyleRepository>().GetObject(hvo);
				// CSS does not implement the kind of inheritance our styles use. To get the style
				// definitions we want in the CSS, we must create these styles using the 'net effect' of
				// each style and all the ones it is based on. Happily the VwStyleSheet knows exactly
				// how to do this.
				var props = vss.GetStyleRgch(sty.Name.Length, sty.Name);
				var exportStyleInfo = new ExportStyleInfo(sty, props);
				m_styleTable.Add(GetValidCssClassName(sty.Name), exportStyleInfo);
			}
		}
		public void UpdateParatextLdsFile_UpdateFontAndSizeAndAddRTL()
		{
			if (File.Exists("test.lds"))
				File.Delete("test.lds");

			int wsHvo = Cache.DefaultVernWs;
			LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo);
			vernWs.Name.UserDefaultWritingSystem = "French";

			DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
			StyleInfoTable styleTable = new StyleInfoTable("Normal",
				Cache.LanguageWritingSystemFactoryAccessor);
			styleTable.Add("Normal", normalEntry);
			normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
			normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

			string ldsContentsOrig =
				"[General]" + Environment.NewLine +
				"codepage=65001" + Environment.NewLine +
				"DialogFontsize=0" + Environment.NewLine +
				"LowerCaseLetters=" + Environment.NewLine +
				"NoCaseLetters=" + Environment.NewLine +
				"UpperCaseLetters=" + Environment.NewLine +
				"errors=" + Environment.NewLine +
				"font=Arial" + Environment.NewLine +
				"name=French" + Environment.NewLine +
				"separator=" + Environment.NewLine +
				"size=32" + Environment.NewLine +
				Environment.NewLine +
				"[Checking]" + Environment.NewLine +
				Environment.NewLine +
				"[Characters]" + Environment.NewLine +
				Environment.NewLine +
				"[Punctuation]" + Environment.NewLine +
				"diacritics=" + Environment.NewLine +
				"medial=";

			DummyFileWriter writer = new DummyFileWriter();
			writer.Open("test.lds");
			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			ReflectionHelper.CallMethod(ldsAccessor, "UpdateLdsContents",
				ldsContentsOrig, normalEntry, Cache.DefaultVernWs, writer);

			// Verify the .lds file
			string[] expectedLdsContents =
			{
				"[General]",
				"codepage=65001",
				"DialogFontsize=0",
				"LowerCaseLetters=",
				"NoCaseLetters=",
				"UpperCaseLetters=",
				"errors=",
				"font=Wingdings",
				"name=French",
				"separator=",
				"size=14",
				"RTL=F",
				//Environment.NewLine, string.Empty
				"[Checking]",
				//Environment.NewLine, string.Empty
				"[Characters]",
				//Environment.NewLine, string.Empty
				"[Punctuation]",
				"diacritics=",
				"medial="
			};
		   ((DummyFileWriter)writer).VerifyOutput(expectedLdsContents);
		}
        public void UpdateParatextLdsFile_UpdateFontAndSizeAndAddRTL()
        {
            if (File.Exists("test.lds"))
            {
                File.Delete("test.lds");
            }

            int             wsHvo  = Cache.DefaultVernWs;
            LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo);

            vernWs.Name.UserDefaultWritingSystem = "French";

            DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
            StyleInfoTable    styleTable  = new StyleInfoTable("Normal",
                                                               Cache.LanguageWritingSystemFactoryAccessor);

            styleTable.Add("Normal", normalEntry);
            normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
            normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

            string ldsContentsOrig =
                "[General]" + Environment.NewLine +
                "codepage=65001" + Environment.NewLine +
                "DialogFontsize=0" + Environment.NewLine +
                "LowerCaseLetters=" + Environment.NewLine +
                "NoCaseLetters=" + Environment.NewLine +
                "UpperCaseLetters=" + Environment.NewLine +
                "errors=" + Environment.NewLine +
                "font=Arial" + Environment.NewLine +
                "name=French" + Environment.NewLine +
                "separator=" + Environment.NewLine +
                "size=32" + Environment.NewLine +
                Environment.NewLine +
                "[Checking]" + Environment.NewLine +
                Environment.NewLine +
                "[Characters]" + Environment.NewLine +
                Environment.NewLine +
                "[Punctuation]" + Environment.NewLine +
                "diacritics=" + Environment.NewLine +
                "medial=";

            DummyFileWriter writer = new DummyFileWriter();

            writer.Open("test.lds");
            ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);

            ReflectionHelper.CallMethod(ldsAccessor, "UpdateLdsContents",
                                        ldsContentsOrig, normalEntry, Cache.DefaultVernWs, writer);

            // Verify the .lds file
            string[] expectedLdsContents =
            {
                "[General]",
                "codepage=65001",
                "DialogFontsize=0",
                "LowerCaseLetters=",
                "NoCaseLetters=",
                "UpperCaseLetters=",
                "errors=",
                "font=Wingdings",
                "name=French",
                "separator=",
                "size=14",
                "RTL=F",
                //Environment.NewLine, string.Empty
                "[Checking]",
                //Environment.NewLine, string.Empty
                "[Characters]",
                //Environment.NewLine, string.Empty
                "[Punctuation]",
                "diacritics=",
                "medial="
            };
            ((DummyFileWriter)writer).VerifyOutput(expectedLdsContents);
        }
		public void UpdateParatextLdsFile_GeneralSectionMissing()
		{
			if (File.Exists("test.lds"))
				File.Delete("test.lds");

			int wsHvo = Cache.DefaultVernWs;
			LgWritingSystem vernWs = new LgWritingSystem(Cache, wsHvo);
			vernWs.Name.UserDefaultWritingSystem = "French";

			DummyUsfmStyEntry normalEntry = new DummyUsfmStyEntry();
			StyleInfoTable styleTable = new StyleInfoTable("Normal",
				Cache.LanguageWritingSystemFactoryAccessor);
			styleTable.Add("Normal", normalEntry);
			normalEntry.DefaultFontInfo.m_fontSize.ExplicitValue = 14000;
			normalEntry.DefaultFontInfo.m_fontName.ExplicitValue = "Wingdings";

			string ldsContentsOrig =
				"[OtherStuff]";

			DummyFileWriter writer = new DummyFileWriter();
			writer.Open("test.lds");
			ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
			ReflectionHelper.CallMethod(ldsAccessor, "UpdateLdsContents",
				ldsContentsOrig, normalEntry, Cache.DefaultVernWs, writer);

			// Verify the .lds file
			string[] expectedLdsContents =
			{
				"[OtherStuff]",
				//Environment.NewLine +
				"[General]",
				"codepage=65001",
				"font=Wingdings",
				"size=14",
				"name=French",
				"RTL=F"
			};

			writer.VerifyOutput(expectedLdsContents);
		}
示例#23
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FwStylesDlg"/> class.
		/// </summary>
		/// <param name="rootSite">The root site.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="styleSheet">The style sheet.</param>
		/// <param name="defaultRightToLeft">Indicates whether current context (typically the
		/// default direction of the view from which this dialog is invoked) is right to left.</param>
		/// <param name="showBiDiLabels">Indicates whether to show labels that are meaningful
		/// for both left-to-right and right-to-left. If <c>defaultRightToLeft</c> is set to
		/// <c>true</c> the passed-in value for this parameter will be ignored and the display
		/// will automatically be BiDi enabled. If this value is false, then simple "Left" and
		/// "Right" labels will be used in the display, rather than "Leading" and "Trailing".</param>
		/// <param name="normalStyleName">Name of the normal style.</param>
		/// <param name="customUserLevel">The custom user level.</param>
		/// <param name="userMeasurementType">User's prefered measurement units.</param>
		/// <param name="paraStyleName">Name of the currently selected paragraph style.</param>
		/// <param name="charStyleName">Name of the currently selected character style.</param>
		/// <param name="hvoRootObject">The hvo of the root object in the current view.</param>
		/// <param name="app">The application.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		protected void Init(IVwRootSite rootSite, FdoCache cache, FwStyleSheet styleSheet,
			bool defaultRightToLeft, bool showBiDiLabels, string normalStyleName,
			int customUserLevel, MsrSysType userMeasurementType, string paraStyleName,
			string charStyleName, int hvoRootObject, IApp app, IHelpTopicProvider helpTopicProvider)
		{
			CheckDisposed();

			m_rootSite = rootSite;
			m_cache = cache;
			m_customUserLevel = customUserLevel;
			m_hvoRootObject = hvoRootObject;
			m_app = app;
			showBiDiLabels |= defaultRightToLeft;
			m_fShowBidiLabels = showBiDiLabels;
			m_userMeasurementType = userMeasurementType;
			m_helpTopicProvider = helpTopicProvider;

			// Cache is null in tests
			if (cache == null)
				return;

			m_cboTypes.SelectedIndex = 1; // All Styles

			// Load the style information
			m_styleTable = new StyleInfoTable(normalStyleName,
				cache.LanguageWritingSystemFactoryAccessor);
			m_styleSheet = styleSheet;
			FillStyleTable(m_styleSheet);
			m_normalStyleInfo = (StyleInfo)m_styleTable[normalStyleName];
			Debug.Assert(m_normalStyleInfo != null);
			m_styleListHelper = new StyleListBoxHelper(m_lstStyles);
			m_styleListHelper.AddStyles(m_styleTable, null);
			m_styleListHelper.ShowInternalStyles = true;
			m_styleListHelper.StyleChosen += new StyleChosenHandler(m_styleListHelper_StyleChosen);
			m_styleListHelper.Refresh();

			// Mark the current styles
			m_styleListHelper.MarkCurrentStyle(paraStyleName);
			m_styleListHelper.MarkCurrentStyle(charStyleName);

			// General tab
			m_generalTab.StyleListHelper = m_styleListHelper;
			m_generalTab.StyleTable = m_styleTable;
			m_generalTab.ShowBiDiLabels = showBiDiLabels;
			m_generalTab.UserMeasurementType = m_userMeasurementType;
			m_generalTab.RenamedStyles = m_renamedStyles;

			// Load the font information
			m_fontTab.WritingSystemFactory = cache.LanguageWritingSystemFactoryAccessor;
			m_fontTab.FillFontInfo(cache);

			// Disable the background color on the paragraph tab.
			m_paragraphTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_paragraphTab.ShowBiDiLabels = showBiDiLabels;
			m_paragraphTab.MeasureType = userMeasurementType;

			m_bulletsTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_bulletsTab.StyleSheet = m_styleSheet;

			m_borderTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_borderTab.ShowBiDiLabels = showBiDiLabels;

			// Select the current paragraph style in the list (or fall back to Normal)
			if (!string.IsNullOrEmpty(paraStyleName))
				m_styleListHelper.SelectedStyleName = paraStyleName;
			else
				m_styleListHelper.SelectedStyleName = normalStyleName;
			m_styleListHelper_StyleChosen(null, m_styleListHelper.SelectedStyle);

			// Default is not to show the style type selection combo.
			if (!DesignMode)
				AllowSelectStyleTypes = false;
		}
示例#24
0
		private void EnsureEnglishLdsExists()
		{
			string paratextProjectDir = ParatextHelper.ProjectsDirectory;

			if (!String.IsNullOrEmpty(paratextProjectDir))
			{
				string englishLdsPathname = Path.Combine(paratextProjectDir, "English.lds");
				if (!File.Exists(englishLdsPathname))
				{
					IStStyle normalStyle = m_StyleSheet.FindStyle(ScrStyleNames.Normal);
					ParatextLdsFileAccessor ldsAccessor = new ParatextLdsFileAccessor(Cache);
					UsfmStyEntry normalUsfmStyle = new UsfmStyEntry();
					StyleInfoTable styleTable = new StyleInfoTable(normalStyle.Name,
						Cache.ServiceLocator.WritingSystemManager);
					normalUsfmStyle.SetPropertiesBasedOnStyle(normalStyle);
					styleTable.Add(normalStyle.Name, normalUsfmStyle);
					styleTable.ConnectStyles();
					ldsAccessor.WriteParatextLdsFile(englishLdsPathname,
						Cache.LanguageWritingSystemFactoryAccessor.GetWsFromStr("en"), normalUsfmStyle);
					// We pass the directory (rather than passing no arguments, and letting the paratext dll figure
					// it out) because the figuring out goes wrong on Linux, where both programs are simulating
					// the registry.
					ScrTextCollection.Initialize(ParatextHelper.ProjectsDirectory, false);
				}
			}
		}
示例#25
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="T:FwStylesDlg"/> class. This version
		/// can be used by C# clients. There is no need for the client to call Init if this
		/// constructor is used.
		/// </summary>
		/// <param name="rootSite">The root site.</param>
		/// <param name="cache">The cache.</param>
		/// <param name="styleSheet">The style sheet.</param>
		/// <param name="defaultRightToLeft">Indicates whether current context (typically the
		/// default direction of the view from which this dialog is invoked) is right to left.</param>
		/// <param name="showBiDiLabels">Indicates whether to show labels that are meaningful
		/// for both left-to-right and right-to-left. If <c>defaultRightToLeft</c> is set to
		/// <c>true</c> the passed-in value for this parameter will be ignored and the display
		/// will automatically be BiDi enabled. If this value is false, then simple "Left" and
		/// "Right" labels will be used in the display, rather than "Leading" and "Trailing".</param>
		/// <param name="normalStyleName">Name of the normal style.</param>
		/// <param name="customUserLevel">The custom user level.</param>
		/// <param name="userMeasurementType">User's prefered measurement units.</param>
		/// <param name="paraStyleName">Name of the currently selected paragraph style.</param>
		/// <param name="charStyleName">Name of the currently selected character style.</param>
		/// <param name="hvoRootObject">The hvo of the root object in the current view.</param>
		/// <param name="app">The application.</param>
		/// <param name="helpTopicProvider">The help topic provider.</param>
		/// ------------------------------------------------------------------------------------
		public FwStylesDlg(IVwRootSite rootSite, FdoCache cache, FwStyleSheet styleSheet,
			bool defaultRightToLeft, bool showBiDiLabels, string normalStyleName,
			int customUserLevel, MsrSysType userMeasurementType, string paraStyleName,
			string charStyleName, int hvoRootObject, IApp app, IHelpTopicProvider helpTopicProvider)
			: this()
		{
			m_rootSite = rootSite;
			m_cache = cache;
			m_customUserLevel = customUserLevel;
			m_hvoRootObject = hvoRootObject;
			m_app = app;
			showBiDiLabels |= defaultRightToLeft;
			m_userMeasurementType = userMeasurementType;
			m_helpTopicProvider = helpTopicProvider;

			// Cache is null in tests
			if (cache == null)
				return;

			m_cboTypes.SelectedIndex = 1; // All Styles

			// Load the style information
			m_styleTable = new StyleInfoTable(normalStyleName,
				cache.ServiceLocator.WritingSystemManager);
			m_styleSheet = styleSheet;
			FillStyleTable(m_styleSheet);
			m_normalStyleInfo = (StyleInfo)m_styleTable[normalStyleName];
			Debug.Assert(m_normalStyleInfo != null);
			m_styleListHelper = new StyleListBoxHelper(m_lstStyles);
			m_styleListHelper.AddStyles(m_styleTable, null);
			m_styleListHelper.ShowInternalStyles = true;
			m_styleListHelper.StyleChosen += new StyleChosenHandler(m_styleListHelper_StyleChosen);
			m_styleListHelper.Refresh();

			// Mark the current styles
			m_styleListHelper.MarkCurrentStyle(paraStyleName);
			m_styleListHelper.MarkCurrentStyle(charStyleName);

			// General tab
			m_generalTab.Application = m_app;
			m_generalTab.StyleListHelper = m_styleListHelper;
			m_generalTab.StyleTable = m_styleTable;
			m_generalTab.ShowBiDiLabels = showBiDiLabels;
			m_generalTab.UserMeasurementType = m_userMeasurementType;
			m_generalTab.RenamedStyles = m_renamedStyles;

			// Load the font information
			m_fontTab.WritingSystemFactory = cache.WritingSystemFactory;
			m_fontTab.FillFontInfo(cache);

			// Disable the background color on the paragraph tab.
			m_paragraphTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_paragraphTab.ShowBiDiLabels = showBiDiLabels;
			m_paragraphTab.MeasureType = userMeasurementType;

			m_bulletsTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_bulletsTab.StyleSheet = m_styleSheet;

			m_borderTab.DefaultTextDirectionRtoL = defaultRightToLeft;
			m_borderTab.ShowBiDiLabels = showBiDiLabels;

			// Select the current paragraph style in the list (or fall back to Normal)
			CurrentStyle = (!string.IsNullOrEmpty(paraStyleName)) ? paraStyleName : normalStyleName;
		}
示例#26
0
		private void ReadStyles(IVwStylesheet vss)
		{
			string normalStyleName = vss.GetDefaultBasedOnStyleName();
			m_styleTable = new StyleInfoTable(normalStyleName,
				m_cache.LanguageWritingSystemFactoryAccessor);
			int cStyles = vss.CStyles;
			for (int i = 0; i < cStyles; ++i)
			{
				int hvo = vss.get_NthStyle(i);
				IStStyle sty = StStyle.CreateFromDBObject(m_cache, hvo);
				m_styleTable.Add(sty.Name, new ExportStyleInfo(sty));
			}
		}