Esempio n. 1
0
        public void WsSpecificOverrides_FontFamily()
        {
            byte[] buffer = new byte[] {
                0x34, 0x12, 0x00, 0x00,     // WS
                0x09, 0x00,                 // FF length
                (byte)'F', 0,
                (byte)'o', 0,
                (byte)'n', 0,
                (byte)'t', 0,
                (byte)'a', 0,
                (byte)'s', 0,
                (byte)'t', 0,
                (byte)'i', 0,
                (byte)'c', 0,

                0x01, 0x00,                 // Count of int props

                0x06, 0x00,                 // First int prop: type
                0x01, 0x00,                 // Variant
                0xe0, 0x2e, 0x00, 0x00,     // value
            };

            DummyStyleInfo entry = new DummyStyleInfo(Cache);

            List <FontOverrideInfo> overrideInfo = entry.CallProcessWsSpecificOverrides(buffer);

            Assert.AreEqual(1, overrideInfo.Count);
            Assert.AreEqual(0x1234, overrideInfo[0].m_ws);
            Assert.AreEqual("Fontastic", overrideInfo[0].m_fontFamily);
            Assert.AreEqual(0, overrideInfo[0].m_stringProps.Count);
            Assert.AreEqual(1, overrideInfo[0].m_intProps.Count);
            Assert.AreEqual(6, overrideInfo[0].m_intProps[0].m_textPropType);
            Assert.AreEqual(1, overrideInfo[0].m_intProps[0].m_variant);
            Assert.AreEqual(0x2ee0, overrideInfo[0].m_intProps[0].m_value);
        }
Esempio n. 2
0
        public void SetBasedOnStyleAndInheritValues_WsOverrideInChildInheritsParentValues()
        {
            // Font family override
            byte[] buffer = new byte[] {
                0xC1, 0x87, 0x8B, 0x3B,     // WS for english (little endian)
                0x09, 0x00,                 // FF length
                (byte)'F', 0,
                (byte)'o', 0,
                (byte)'n', 0,
                (byte)'t', 0,
                (byte)'a', 0,
                (byte)'s', 0,
                (byte)'t', 0,
                (byte)'i', 0,
                (byte)'c', 0,

                0x01, 0x00,                 // Count of int props

                0x06, 0x00,                 // First int prop: type
                0x01, 0x00,                 // Variant
                0xe0, 0x2e, 0x00, 0x00,     // value
            };

            ITsPropsBldr props;

            var mainTitleStyle = AddTestStyle("Title Main", ContextValues.Title,
                                              StructureValues.Body, FunctionValues.Prose, false, Cache.LangProject.StylesOC);
            var inheritFromMain = AddTestStyle("Inherit Title", ContextValues.Title, StructureValues.Body,
                                               FunctionValues.Prose, false, Cache.LangProject.StylesOC);

            inheritFromMain.BasedOnRA = mainTitleStyle;
            props = mainTitleStyle.Rules.GetBldr();
            // set the font property in the mainTitleStyle
            props.SetStrPropValue((int)FwTextPropType.ktptWsStyle, DummyStyleInfo.MakeStringFromBuffer(buffer));
            mainTitleStyle.Rules = props.GetTextProps();

            var entry      = new DummyStyleInfo(mainTitleStyle);
            var childEntry = new DummyStyleInfo(inheritFromMain);
            var styleInfos = new FwStyleSheet.StyleInfoCollection();

            styleInfos.Add(entry);
            styleInfos.Add(childEntry);
            // SUT
            childEntry.SetBasedOnStyleAndInheritValues(styleInfos);
            Assert.AreEqual(childEntry.BasedOnStyle, entry,
                            "The child style entry in the StyleInfoCollection was not based on the parent entry");
            var fontInfoOverrides = entry.FontInfoForWs(Cache.DefaultAnalWs);

            Assert.True(fontInfoOverrides.m_fontName.IsExplicit, "The fontName was not set properly in the parent entry");
            Assert.AreEqual(fontInfoOverrides.FontName.Value, "Fontastic",
                            "The fontName was not set properly in the parent entry");
            var childOverrides = childEntry.FontInfoForWs(Cache.DefaultAnalWs);

            Assert.True(childOverrides.m_fontName.IsInherited,
                        "The child entry in the StyleInfoCollection did not inherit the fontName properly");
            Assert.AreEqual(childOverrides.FontName.Value, "Fontastic",
                            "The child entry in the StyleInfoCollection did not inherit the fontName properly");
        }
Esempio n. 3
0
        public void WsSpecificOverrides_TwoWs()
        {
            CheckDisposed();

            byte[] buffer = new byte[] {
                0x34, 0x12, 0x00, 0x00,     // WS
                0x00, 0x00,                 // FF length
                0x03, 0x00,                 // Count of int props

                0x06, 0x00,                 // First int prop: type
                0x01, 0x00,                 // Variant
                0xe0, 0x2e, 0x00, 0x00,     // value

                0x08, 0x00,                 // Second int prop: type
                0x00, 0x00,                 // Variant
                0xff, 0xff, 0x00, 0x00,     // value

                0x09, 0x00,                 // Third int prop: type
                0x00, 0x00,                 // Variant
                0x00, 0x00, 0x00, 0x00,     // value

                // Second writing system
                0x35, 0x12, 0x00, 0x00,     // WS
                0x00, 0x00,                 // FF length
                0x01, 0x00,                 // Count of int props

                0x08, 0x00,                 // First int prop: type
                0x00, 0x00,                 // Variant
                0xee, 0xee, 0x00, 0x00,     // value
            };

            DummyStyleInfo entry = new DummyStyleInfo(Cache);

            List <FontOverrideInfo> overrideInfo = entry.CallProcessWsSpecificOverrides(buffer);

            Assert.AreEqual(2, overrideInfo.Count);
            Assert.AreEqual(0x1234, overrideInfo[0].m_ws);
            Assert.AreEqual(0, overrideInfo[0].m_fontFamily.Length);
            Assert.AreEqual(0, overrideInfo[0].m_stringProps.Count);
            Assert.AreEqual(3, overrideInfo[0].m_intProps.Count);
            Assert.AreEqual(6, overrideInfo[0].m_intProps[0].m_textPropType);
            Assert.AreEqual(1, overrideInfo[0].m_intProps[0].m_variant);
            Assert.AreEqual(0x2ee0, overrideInfo[0].m_intProps[0].m_value);
            Assert.AreEqual(8, overrideInfo[0].m_intProps[1].m_textPropType);
            Assert.AreEqual(0, overrideInfo[0].m_intProps[1].m_variant);
            Assert.AreEqual(0xffff, overrideInfo[0].m_intProps[1].m_value);
            Assert.AreEqual(9, overrideInfo[0].m_intProps[2].m_textPropType);
            Assert.AreEqual(0, overrideInfo[0].m_intProps[2].m_variant);
            Assert.AreEqual(0, overrideInfo[0].m_intProps[2].m_value);

            Assert.AreEqual(0x1235, overrideInfo[1].m_ws);
            Assert.AreEqual(0, overrideInfo[1].m_fontFamily.Length);
            Assert.AreEqual(0, overrideInfo[1].m_stringProps.Count);
            Assert.AreEqual(1, overrideInfo[1].m_intProps.Count);
            Assert.AreEqual(8, overrideInfo[1].m_intProps[0].m_textPropType);
            Assert.AreEqual(0, overrideInfo[1].m_intProps[0].m_variant);
            Assert.AreEqual(0xeeee, overrideInfo[1].m_intProps[0].m_value);
        }
Esempio n. 4
0
        public void ConstructBasedOnStyle()
        {
            CheckDisposed();

            ITsPropsBldr props;

            IStStyle mainTitleStyle = AddTestStyle("Title Main", ContextValues.Title,
                                                   StructureValues.Body, FunctionValues.Prose, false, Cache.LangProject.StylesOC);

            props = mainTitleStyle.Rules.GetBldr();
            props.SetIntPropValues((int)FwTextPropType.ktptBold,
                                   (int)FwTextPropVar.ktpvDefault, 1);
            props.SetIntPropValues((int)FwTextPropType.ktptAlign,
                                   (int)FwTextPropVar.ktpvDefault,
                                   (int)FwTextAlign.ktalCenter);
            props.SetIntPropValues((int)FwTextPropType.ktptFontSize,
                                   (int)FwTextPropVar.ktpvMilliPoint, 20000);
            props.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Arial");
            mainTitleStyle.Rules = props.GetTextProps();

            DummyStyleInfo entry = new DummyStyleInfo(mainTitleStyle);

            Assert.AreEqual("Title Main", entry.Name);
            // Was: Assert.AreEqual(mainTitleStyle.Usage.UserDefaultWritingSystem, entry.Usage);
            // Since nothing in our test has initialized mainTitleStyle.Usage, it used to be null, like
            // entry.Usage. A change to the implementation of UserDefaultWritingSystem causes it to always
            // return something.
            Assert.AreEqual(mainTitleStyle.Usage.RawUserDefaultWritingSystem, entry.Usage);
            Assert.IsTrue(entry.IsParagraphStyle);
            Assert.AreEqual(FwTextAlign.ktalCenter, entry.Alignment);
            FontInfo fontInfo = entry.FontInfoForWs(-1);

            Assert.IsNotNull(fontInfo);
            Assert.IsTrue(fontInfo.m_bold.Value);
            Assert.AreEqual(20000, fontInfo.m_fontSize.Value);
            Assert.AreEqual("Arial", (string)fontInfo.m_fontName.Value);
            Assert.AreEqual(ContextValues.Title, entry.Context);
            Assert.AreEqual(StructureValues.Body, entry.Structure);
            Assert.AreEqual(FunctionValues.Prose, entry.Function);

            // Check that everything else is inherited
            Assert.IsTrue(fontInfo.m_backColor.IsInherited);
            Assert.IsTrue(fontInfo.m_fontColor.IsInherited);
            Assert.IsTrue(fontInfo.m_italic.IsInherited);
            Assert.IsTrue(fontInfo.m_superSub.IsInherited);
            Assert.IsTrue(fontInfo.m_underline.IsInherited);
            Assert.IsTrue(fontInfo.m_underlineColor.IsInherited);
            Assert.IsTrue(fontInfo.m_features.IsInherited);
            Assert.IsTrue(entry.InheritableLineSpacing.IsInherited);
            Assert.IsTrue(entry.InheritableSpaceBefore.IsInherited);
            Assert.IsTrue(entry.InheritableFirstLineIndent.IsInherited);
            Assert.IsTrue(entry.InheritableLeadingIndent.IsInherited);
            Assert.IsTrue(entry.InheritableTrailingIndent.IsInherited);
            Assert.IsTrue(entry.InheritableBorder.IsInherited);
            Assert.IsTrue(entry.InheritableBorderColor.IsInherited);
        }
Esempio n. 5
0
        public void WsSpecificOverrides_OneWs()
        {
            byte[] buffer = new byte[] {
                0xC1, 0x87, 0x8B, 0x3B,     // WS
                0x00, 0x00,                 // FF length
                0x03, 0x00,                 // Count of int props

                0x06, 0x00,                 // First int prop: type
                0x01, 0x00,                 // Variant
                0xe0, 0x2e, 0x00, 0x00,     // value

                0x08, 0x00,                 // Second int prop: type
                0x00, 0x00,                 // Variant
                0xff, 0xff, 0x00, 0x00,     // value

                0x09, 0x00,                 // Third int prop: type
                0x00, 0x00,                 // Variant
                0x00, 0x00, 0x00, 0x00,     // value
            };

            DummyStyleInfo entry = new DummyStyleInfo(Cache);

            List <FontOverrideInfo> overrideInfo = entry.CallProcessWsSpecificOverrides(buffer);

            Assert.AreEqual(1, overrideInfo.Count);
            Assert.AreEqual(999000001, overrideInfo[0].m_ws);
            Assert.AreEqual(0, overrideInfo[0].m_fontFamily.Length);
            Assert.AreEqual(0, overrideInfo[0].m_stringProps.Count);
            Assert.AreEqual(3, overrideInfo[0].m_intProps.Count);
            Assert.AreEqual(6, overrideInfo[0].m_intProps[0].m_textPropType);
            Assert.AreEqual(1, overrideInfo[0].m_intProps[0].m_variant);
            Assert.AreEqual(0x2ee0, overrideInfo[0].m_intProps[0].m_value);
            Assert.AreEqual(8, overrideInfo[0].m_intProps[1].m_textPropType);
            Assert.AreEqual(0, overrideInfo[0].m_intProps[1].m_variant);
            Assert.AreEqual(0xffff, overrideInfo[0].m_intProps[1].m_value);
            Assert.AreEqual(9, overrideInfo[0].m_intProps[2].m_textPropType);
            Assert.AreEqual(0, overrideInfo[0].m_intProps[2].m_variant);
            Assert.AreEqual(0, overrideInfo[0].m_intProps[2].m_value);
        }
Esempio n. 6
0
        public void CreateCopy()
        {
            IStStyle testStyle = AddTestStyle("Title Main", ContextValues.Title,
                                              StructureValues.Body, FunctionValues.Prose, false, m_scr.StylesOC);

            BaseStyleInfo  basedOnInfo = new BaseStyleInfo();
            DummyStyleInfo origInfo    = new DummyStyleInfo();

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

            BaseStyleInfo newInfo = new BaseStyleInfo(origInfo, "new");

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

            Assert.AreEqual(null, newInfo.RealStyle, "a copy of a style should not have a DB style backing it");
            Assert.AreEqual(false, newInfo.IsBuiltIn, "Copies of styles should not be considered built in");
        }
Esempio n. 7
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);
		}
Esempio n. 8
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);
        }
Esempio n. 9
0
		public void WsSpecificOverrides_FontFamily()
		{
			byte[] buffer = new byte[] {
				0x34, 0x12, 0x00, 0x00, // WS
				0x09, 0x00, // FF length
				(byte)'F', 0,
				(byte)'o', 0,
				(byte)'n', 0,
				(byte)'t', 0,
				(byte)'a', 0,
				(byte)'s', 0,
				(byte)'t', 0,
				(byte)'i', 0,
				(byte)'c', 0,

				0x01, 0x00, // Count of int props

				0x06, 0x00, // First int prop: type
				0x01, 0x00, // Variant
				0xe0, 0x2e, 0x00, 0x00, // value
			};

			DummyStyleInfo entry = new DummyStyleInfo(Cache);

			List<FontOverrideInfo> overrideInfo = entry.CallProcessWsSpecificOverrides(buffer);

			Assert.AreEqual(1, overrideInfo.Count);
			Assert.AreEqual(0x1234, overrideInfo[0].m_ws);
			Assert.AreEqual("Fontastic", overrideInfo[0].m_fontFamily);
			Assert.AreEqual(0, overrideInfo[0].m_stringProps.Count);
			Assert.AreEqual(1, overrideInfo[0].m_intProps.Count);
			Assert.AreEqual(6, overrideInfo[0].m_intProps[0].m_textPropType);
			Assert.AreEqual(1, overrideInfo[0].m_intProps[0].m_variant);
			Assert.AreEqual(0x2ee0, overrideInfo[0].m_intProps[0].m_value);
		}
Esempio n. 10
0
		public void WsSpecificOverrides_TwoWs()
		{
			byte[] buffer = new byte[] {
				0x34, 0x12, 0x00, 0x00, // WS
				0x00, 0x00, // FF length
				0x03, 0x00, // Count of int props

				0x06, 0x00, // First int prop: type
				0x01, 0x00, // Variant
				0xe0, 0x2e, 0x00, 0x00, // value

				0x08, 0x00, // Second int prop: type
				0x00, 0x00, // Variant
				0xff, 0xff, 0x00, 0x00, // value

				0x09, 0x00, // Third int prop: type
				0x00, 0x00, // Variant
				0x00, 0x00, 0x00, 0x00, // value

				// Second writing system
				0x35, 0x12, 0x00, 0x00, // WS
				0x00, 0x00, // FF length
				0x01, 0x00, // Count of int props

				0x08, 0x00, // First int prop: type
				0x00, 0x00, // Variant
				0xee, 0xee, 0x00, 0x00, // value
			};

			DummyStyleInfo entry = new DummyStyleInfo(Cache);

			List<FontOverrideInfo> overrideInfo = entry.CallProcessWsSpecificOverrides(buffer);

			Assert.AreEqual(2, overrideInfo.Count);
			Assert.AreEqual(0x1234, overrideInfo[0].m_ws);
			Assert.AreEqual(0, overrideInfo[0].m_fontFamily.Length);
			Assert.AreEqual(0, overrideInfo[0].m_stringProps.Count);
			Assert.AreEqual(3, overrideInfo[0].m_intProps.Count);
			Assert.AreEqual(6, overrideInfo[0].m_intProps[0].m_textPropType);
			Assert.AreEqual(1, overrideInfo[0].m_intProps[0].m_variant);
			Assert.AreEqual(0x2ee0, overrideInfo[0].m_intProps[0].m_value);
			Assert.AreEqual(8, overrideInfo[0].m_intProps[1].m_textPropType);
			Assert.AreEqual(0, overrideInfo[0].m_intProps[1].m_variant);
			Assert.AreEqual(0xffff, overrideInfo[0].m_intProps[1].m_value);
			Assert.AreEqual(9, overrideInfo[0].m_intProps[2].m_textPropType);
			Assert.AreEqual(0, overrideInfo[0].m_intProps[2].m_variant);
			Assert.AreEqual(0, overrideInfo[0].m_intProps[2].m_value);

			Assert.AreEqual(0x1235, overrideInfo[1].m_ws);
			Assert.AreEqual(0, overrideInfo[1].m_fontFamily.Length);
			Assert.AreEqual(0, overrideInfo[1].m_stringProps.Count);
			Assert.AreEqual(1, overrideInfo[1].m_intProps.Count);
			Assert.AreEqual(8, overrideInfo[1].m_intProps[0].m_textPropType);
			Assert.AreEqual(0, overrideInfo[1].m_intProps[0].m_variant);
			Assert.AreEqual(0xeeee, overrideInfo[1].m_intProps[0].m_value);
		}
Esempio n. 11
0
		public void ConstructBasedOnStyle()
		{
			ITsPropsBldr props;

			IStStyle mainTitleStyle = AddTestStyle("Title Main", ContextValues.Title,
				StructureValues.Body, FunctionValues.Prose, false, Cache.LangProject.StylesOC);
			props = mainTitleStyle.Rules.GetBldr();
			props.SetIntPropValues((int)FwTextPropType.ktptBold,
				(int)FwTextPropVar.ktpvDefault, 1);
			props.SetIntPropValues((int)FwTextPropType.ktptAlign,
				(int)FwTextPropVar.ktpvDefault,
				(int)FwTextAlign.ktalCenter);
			props.SetIntPropValues((int)FwTextPropType.ktptFontSize,
				(int)FwTextPropVar.ktpvMilliPoint, 20000);
			props.SetStrPropValue((int)FwTextPropType.ktptFontFamily, "Arial");
			mainTitleStyle.Rules = props.GetTextProps();

			DummyStyleInfo entry = new DummyStyleInfo(mainTitleStyle);
			Assert.AreEqual("Title Main", entry.Name);
			// Was: Assert.AreEqual(mainTitleStyle.Usage.UserDefaultWritingSystem, entry.Usage);
			// Since nothing in our test has initialized mainTitleStyle.Usage, it used to be null, like
			// entry.Usage. A change to the implementation of UserDefaultWritingSystem causes it to always
			// return something.
			Assert.AreEqual(mainTitleStyle.Usage.RawUserDefaultWritingSystem.Text, entry.Usage);
			Assert.IsTrue(entry.IsParagraphStyle);
			Assert.AreEqual(FwTextAlign.ktalCenter, entry.Alignment);
			FontInfo fontInfo = entry.FontInfoForWs(-1);
			Assert.IsNotNull(fontInfo);
			Assert.IsTrue(fontInfo.m_bold.Value);
			Assert.AreEqual(20000, fontInfo.m_fontSize.Value);
			Assert.AreEqual("Arial", (string)fontInfo.m_fontName.Value);
			Assert.AreEqual(ContextValues.Title, entry.Context);
			Assert.AreEqual(StructureValues.Body, entry.Structure);
			Assert.AreEqual(FunctionValues.Prose, entry.Function);

			// Check that everything else is inherited
			Assert.IsTrue(fontInfo.m_backColor.IsInherited);
			Assert.IsTrue(fontInfo.m_fontColor.IsInherited);
			Assert.IsTrue(fontInfo.m_italic.IsInherited);
			Assert.IsTrue(fontInfo.m_superSub.IsInherited);
			Assert.IsTrue(fontInfo.m_underline.IsInherited);
			Assert.IsTrue(fontInfo.m_underlineColor.IsInherited);
			Assert.IsTrue(fontInfo.m_features.IsInherited);
			Assert.IsTrue(entry.InheritableLineSpacing.IsInherited);
			Assert.IsTrue(entry.InheritableSpaceBefore.IsInherited);
			Assert.IsTrue(entry.InheritableFirstLineIndent.IsInherited);
			Assert.IsTrue(entry.InheritableLeadingIndent.IsInherited);
			Assert.IsTrue(entry.InheritableTrailingIndent.IsInherited);
			Assert.IsTrue(entry.InheritableBorder.IsInherited);
			Assert.IsTrue(entry.InheritableBorderColor.IsInherited);
		}
Esempio n. 12
0
		public void CreateCopy()
		{
			IStStyle testStyle = AddTestStyle("Title Main", ContextValues.Title,
				StructureValues.Body, FunctionValues.Prose, false, m_scr.StylesOC);

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

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

			Assert.AreEqual(null, newInfo.RealStyle, "a copy of a style should not have a DB style backing it");
			Assert.AreEqual(false, newInfo.IsBuiltIn, "Copies of styles should not be considered built in");
		}